Skip to content

Lucky-939/AgroTech

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🌱 AgroTech β€” Smart Agriculture Platform

Empowering farmers with AI-driven crop predictions and data-backed farming insights.

Python Django Gemini AI HTML5 SCSS JavaScript License: MIT


AgroTech is an intelligent web platform built to modernize Indian agriculture. It combines a Django-powered backend, a curated ML crop predictor, and Google Gemini AI to deliver real-time, natural-language farming advice β€” putting the power of data science directly in the hands of farmers.


πŸ“Œ Table of Contents


✨ Features

Module Description
🌾 Crop Predictor ML-powered engine recommending the best crop based on soil & climate inputs
πŸ€– Gemini AI Advisor Google Gemini API provides natural-language farming tips, fertilizer advice, and pest control guidance
πŸ“Š Smart Datasets Curated agricultural datasets covering soil nutrients, rainfall, temperature, and humidity
πŸ–₯️ Responsive Dashboard Clean, mobile-friendly UI built with HTML5, SCSS, and vanilla JavaScript
βš™οΈ Django Backend Robust server-side logic handling predictions, routing, and data processing
πŸ”’ Secure Architecture Environment-based configuration, Django ORM, and modular app design

πŸ—‚οΈ Project Structure

AgroTech/
β”‚
β”œβ”€β”€ Predictor/             # ML model logic β€” crop prediction engine
β”‚   └── ...                # Saved models (.pkl / .joblib), inference scripts
β”‚
β”œβ”€β”€ backend/               # Django app β€” views, URLs, models, forms
β”‚   └── ...
β”‚
β”œβ”€β”€ datasets/              # Raw & processed agricultural datasets (.csv)
β”‚   └── ...
β”‚
β”œβ”€β”€ static/                # Static assets β€” CSS, SCSS, JavaScript, images
β”‚   β”œβ”€β”€ css/
β”‚   β”œβ”€β”€ js/
β”‚   └── images/
β”‚
β”œβ”€β”€ templates/             # Django HTML templates β€” pages and partials
β”‚   └── ...
β”‚
β”œβ”€β”€ manage.py              # Django management entry point
β”œβ”€β”€ requirements.txt       # Python dependencies
β”œβ”€β”€ .gitignore
└── README.md

πŸ› οΈ Tech Stack

Backend

Frontend

  • HTML5, SCSS / CSS3, JavaScript (ES6+)
  • Django Templating Engine

Data

  • Custom curated CSV datasets (soil nutrients, weather parameters, crop labels)

πŸ€– Google Gemini AI Integration

AgroTech uses the Google Gemini API to provide farmers with intelligent, conversational farming advice β€” going beyond simple predictions.

What Gemini Powers in AgroTech

  • 🌿 Fertilizer Recommendations β€” Based on soil nutrient levels (N, P, K), Gemini suggests organic and chemical fertilizer options in plain language
  • πŸ› Pest & Disease Guidance β€” Farmers can describe symptoms and Gemini returns actionable pest control advice
  • 🌦️ Climate-Aware Tips β€” Seasonal and weather-aware crop care suggestions tailored to local conditions
  • πŸ’¬ Natural Language Interface β€” Farmers interact with the platform conversationally, not just through forms

How It Works

Farmer Input (soil data / question)
        β”‚
        β–Ό
  Django Backend receives request
        β”‚
        β–Ό
  Prompt constructed with farming context
        β”‚
        β–Ό
  Google Gemini API call (gemini-pro model)
        β”‚
        β–Ό
  AI-generated advice returned to UI

Setting Up Your Gemini API Key

  1. Visit https://ai.google.dev/ and sign in with your Google account
  2. Click "Get API Key" β†’ "Create API Key in new project"
  3. Copy the generated key
  4. Add it to your .env file as shown in the Environment Configuration section below

⚠️ Never commit your API key to version control. Always use environment variables.


βš™οΈ Installation

Prerequisites

  • Python 3.10 or higher
  • pip (Python package manager)
  • Git
  • A Google Gemini API key (get one free here)

Step 1 β€” Clone the Repository

git clone https://github.com/Lucky-939/AgroTech.git
cd AgroTech

Step 2 β€” Create a Virtual Environment

# Create virtual environment
python -m venv venv

# Activate on Linux / macOS
source venv/bin/activate

# Activate on Windows
venv\Scripts\activate

Step 3 β€” Install Dependencies

pip install -r requirements.txt

Step 4 β€” Configure Environment Variables

Create a .env file in the project root (see Environment Configuration below).

Step 5 β€” Apply Migrations

python manage.py makemigrations
python manage.py migrate

Step 6 β€” Run the Development Server

python manage.py runserver

Visit: http://127.0.0.1:8000/


πŸ”‘ Environment Configuration

Create a .env file in the root of the project with the following variables:

# Django
SECRET_KEY=your_django_secret_key_here
DEBUG=True
ALLOWED_HOSTS=127.0.0.1,localhost

# Google Gemini AI
GEMINI_API_KEY=your_google_gemini_api_key_here

πŸ’‘ Tip: Generate a Django secret key using:

python -c "from django.core.management.utils import get_random_secret_key; print(get_random_secret_key())"

Make sure .env is listed in your .gitignore β€” never push API keys to GitHub.


πŸš€ Usage

  1. Open your browser and go to http://127.0.0.1:8000/
  2. Enter your field parameters β€” nitrogen (N), phosphorus (P), potassium (K), temperature, humidity, pH, and rainfall
  3. Submit to get an instant ML-based crop recommendation
  4. Ask Gemini β€” use the AI advisor to get fertilizer tips, pest control advice, or farming guidance in natural language
  5. Explore the dashboard to understand why a specific crop is recommended for your local conditions

🌿 How the Predictor Works

User Input (Soil + Climate Parameters)
        β”‚
        β–Ό
  Feature Preprocessing
  (Normalization / Encoding)
        β”‚
        β–Ό
  Trained ML Model
  (Random Forest / Decision Tree)
        β”‚
        β–Ό
  Crop Recommendation Output
  e.g., "Rice", "Wheat", "Cotton"
        β”‚
        β–Ό
  Gemini AI adds natural-language advice
  e.g., "Apply urea fertilizer before sowing..."

The Predictor/ module contains the pre-trained model, label encoders, and the Python inference script. The Django backend calls this module to serve predictions, then passes context to Gemini for enriched AI guidance.


πŸ“ Dataset Schema

The datasets/ folder contains curated agricultural data with the following feature columns:

Column Description Unit
N Nitrogen content in soil mg/kg
P Phosphorus content in soil mg/kg
K Potassium content in soil mg/kg
temperature Average ambient temperature Β°C
humidity Relative humidity %
ph Soil pH value 0–14 scale
rainfall Annual rainfall mm
label Recommended crop (target variable) crop name

🀝 Contributing

Contributions are welcome! Here's how to get started:

# 1. Fork the repository on GitHub

# 2. Clone your fork
git clone https://github.com/YOUR-USERNAME/AgroTech.git

# 3. Create a new feature branch
git checkout -b feature/your-feature-name

# 4. Make your changes and commit
git add .
git commit -m "feat: describe your change here"

# 5. Push to your fork and open a Pull Request
git push origin feature/your-feature-name

Please follow PEP 8 for Python code and include comments where needed.

πŸ› Reporting Issues

Found a bug or have a suggestion? Open an issue with:

  • A clear description of the problem
  • Steps to reproduce it
  • Expected vs. actual behaviour
  • Screenshots if applicable

πŸ“„ License

This project is licensed under the MIT License β€” see the LICENSE file for details.


Made with ❀️ for Indian Farmers β€” Lucky-939

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors