🤖 Machine Learning Yield Prediction
Extra Trees Regression model trained on global crop data
Predicts yield (hg/ha) based on region, crop type, rainfall, temperature, and pesticide usage
AI-generated natural language explanations of predictions
Text-to-speech output for accessibility
Upload crop leaf images for instant AI-powered classification
Identifies diseases with confidence scores
Provides treatment recommendations
Maintains detection history per farm
Real-time telemetry: temperature, humidity, soil moisture, pH, rainfall, light
Live auto-refreshing data (10s intervals)
Interactive time-series charts (Recharts)
Supports multiple farms with sensor history
Historical vs predicted yield comparison
Temperature vs soil moisture correlation analysis
Per-farm statistical averages
Beautiful gradient charts and data visualizations
🌍 Multi-Language Support (i18n)
9 languages : English, हिंदी, বাংলা, ଓଡ଼ିଆ, اردو, Français, Español, தமிழ், తెలుగు
Instant language switching from Settings page
All pages fully translated (Dashboard, Farms, Prediction, Disease, Sensors, Analytics)
Create, view, and manage multiple farms
Track location (lat/long), area, and primary crop
GPS coordinates for weather and map integrations
👤 User Profile & Authentication
JWT-based authentication (register/login)
Editable profile with persistent save to database
Role-based user system (Farmer, Agricultural Officer, Admin)
Dark/Light theme toggle
Glassmorphism design with animated gradients
Responsive layout with mobile support
Framer Motion animations throughout
Modern landing page with feature showcase
Technology
Purpose
React 19
UI framework
TypeScript 6
Type safety
Vite 8
Build tool & dev server
TailwindCSS 3
Utility-first styling
Framer Motion
Animations
React Router 7
Client-side routing
TanStack React Query
Server state management
Recharts
Data visualization
React Hook Form + Zod
Form validation
react-i18next
Internationalization
Leaflet
Maps (installed)
Axios
HTTP client
Radix UI
Accessible headless components
Technology
Purpose
FastAPI
Async Python web framework
SQLAlchemy 2
Async ORM
Alembic
Database migrations
PostgreSQL
Database (via Supabase)
AsyncPG
Async PostgreSQL driver
scikit-learn
ML model (Extra Trees)
Pandas / NumPy
Data processing
Joblib
Model serialization
python-jose
JWT token handling
Passlib + Bcrypt
Password hashing
Pydantic v2
Data validation
Loguru
Structured logging
Python 3.10+
Node.js 18+ & npm
PostgreSQL database (or a free Supabase project)
git clone https://github.com/sheikhwasimuddin/AgriSense.git
cd AgriSense
cd backend
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Configure environment
cp .env.example .env
# Edit .env with your database credentials (see Environment Variables below)
# Run database migrations
alembic upgrade head
# Seed sample data (optional)
python seed_db.py
# Start the server
uvicorn main:app --reload --port 8000
cd frontend
# Install dependencies
npm install
# Start development server
npm run dev
The app will be available at http://localhost:5173
Create a .env file in the backend/ directory:
# Database (Supabase PostgreSQL)
SUPABASE_URL = https://your-project-ref.supabase.co
SUPABASE_ANON_KEY = your-anon-key
DATABASE_URL = postgresql+asyncpg://postgres:password@db.your-project-ref.supabase.co:5432/postgres
# Authentication
JWT_SECRET_KEY = your_jwt_secret_key
ALGORITHM = HS256
ACCESS_TOKEN_EXPIRE_MINUTES = 30
AgriSense/
├── backend/
│ ├── api/ # FastAPI route handlers
│ │ ├── auth.py # Authentication (register, login, profile)
│ │ ├── farms.py # Farm CRUD operations
│ │ ├── prediction.py # ML yield prediction endpoint
│ │ ├── disease.py # Disease detection endpoint
│ │ ├── sensors.py # IoT sensor data endpoints
│ │ └── analytics.py # Analytics aggregation
│ ├── core/
│ │ ├── config.py # Pydantic settings
│ │ ├── database.py # Async SQLAlchemy engine
│ │ ├── logger.py # Loguru configuration
│ │ └── security.py # JWT & password utilities
│ ├── db/
│ │ ├── models.py # SQLAlchemy ORM models
│ │ ├── schemas.py # Pydantic request/response schemas
│ │ ├── crud.py # Database operations
│ │ └── migrations/ # Alembic migration scripts
│ ├── ml/
│ │ ├── predictor.py # ML model loading & inference
│ │ ├── pipeline.pkl # Trained Extra Trees pipeline
│ │ └── best_model.pkl # Best model checkpoint
│ ├── main.py # FastAPI app entry point
│ ├── seed_db.py # Database seeder
│ ├── requirements.txt
│ └── .env.example
│
├── frontend/
│ ├── src/
│ │ ├── components/
│ │ │ ├── layout/
│ │ │ │ ├── Sidebar.tsx # Navigation sidebar
│ │ │ │ ├── Navbar.tsx # Top navigation bar
│ │ │ │ └── MainLayout.tsx # App shell layout
│ │ │ ├── ui/ # Radix UI components (shadcn/ui)
│ │ │ └── theme-provider.tsx # Dark/Light theme context
│ │ ├── pages/
│ │ │ ├── Home.tsx # Public landing page
│ │ │ ├── Login.tsx # Authentication - login
│ │ │ ├── Register.tsx # Authentication - register
│ │ │ ├── Dashboard.tsx # Main dashboard
│ │ │ ├── Farms.tsx # Farm management
│ │ │ ├── Prediction.tsx # ML yield prediction
│ │ │ ├── Disease.tsx # Disease detection
│ │ │ ├── Sensors.tsx # IoT sensor dashboard
│ │ │ ├── Analytics.tsx # Charts & analytics
│ │ │ ├── Profile.tsx # User profile editor
│ │ │ └── Settings.tsx # App settings & language
│ │ ├── services/ # API client functions
│ │ ├── context/ # React context providers
│ │ ├── locales/ # Translation files (9 languages)
│ │ ├── types/ # TypeScript interfaces
│ │ ├── i18n.ts # i18n configuration
│ │ ├── App.tsx # Router & providers
│ │ └── main.tsx # Entry point
│ ├── package.json
│ └── vite.config.ts
│
└── README.md
Method
Endpoint
Description
POST
/api/v1/auth/register
Register a new user
POST
/api/v1/auth/login
Login (returns JWT token)
GET
/api/v1/auth/profile
Get current user profile
PUT
/api/v1/auth/profile
Update user profile
Method
Endpoint
Description
GET
/api/v1/farms/
List all user farms
POST
/api/v1/farms/
Create a new farm
DELETE
/api/v1/farms/{id}
Delete a farm
Method
Endpoint
Description
POST
/api/v1/predict/yield
Predict crop yield
GET
/api/v1/predict/history/{farm_id}
Get prediction history
Method
Endpoint
Description
POST
/api/v1/disease/predict
Detect disease from image
GET
/api/v1/disease/history/{farm_id}
Get detection history
Method
Endpoint
Description
GET
/api/v1/sensors/latest/{farm_id}
Latest sensor readings
GET
/api/v1/sensors/history/{farm_id}
Sensor data history
Method
Endpoint
Description
GET
/api/v1/analytics/summary/{farm_id}
Farm analytics summary
Method
Endpoint
Description
GET
/health
API health check
📖 Interactive API docs available at http://localhost:8000/docs (Swagger UI)
erDiagram
USERS {
uuid id PK
string full_name
string email UK
string phone
string city
int age
float food_stock
string role
string hashed_password
datetime created_at
}
FARMS {
int id PK
uuid user_id FK
string farm_name
string location
float latitude
float longitude
float area
string crop
}
SENSOR_DATA {
int id PK
int farm_id FK
float temperature
float humidity
float soil_moisture
float soil_ph
float rainfall
float light_intensity
datetime timestamp
}
YIELD_PREDICTIONS {
int id PK
int farm_id FK
string crop
int year
float rainfall
float temperature
float pesticides
float predicted_yield
datetime created_at
}
DISEASE_PREDICTIONS {
int id PK
int farm_id FK
string image_url
string disease
float confidence
string recommendation
datetime created_at
}
USERS ||--o{ FARMS : owns
FARMS ||--o{ SENSOR_DATA : has
FARMS ||--o{ YIELD_PREDICTIONS : has
FARMS ||--o{ DISEASE_PREDICTIONS : has
Loading
Language
Code
Status
🇬🇧 English
en
✅ Complete
🇮🇳 हिंदी (Hindi)
hi
✅ Complete
🇮🇳 বাংলা (Bengali)
bn
✅ Complete
🇮🇳 ଓଡ଼ିଆ (Odia)
or
✅ Complete
🇵🇰 اردو (Urdu)
ur
✅ Complete
🇫🇷 Français (French)
fr
✅ Complete
🇪🇸 Español (Spanish)
es
✅ Complete
🇮🇳 தமிழ் (Tamil)
ta
✅ Complete
🇮🇳 తెలుగు (Telugu)
te
✅ Complete
Property
Value
Algorithm
Extra Trees Regressor
Training Data
Global crop yield dataset (FAO)
Input Features
Region, Crop, Year, Rainfall, Temperature, Pesticides
Output
Predicted Yield (hg/ha)
Pipeline
Label Encoding + Extra Trees (scikit-learn)
Serialization
Joblib (.pkl)
# Backend
cd backend
python -m pytest tests/
# Frontend
cd frontend
npm run lint
npm run build # TypeScript type-check + production build
cd backend
# Create a new migration after model changes
alembic revision --autogenerate -m " Description of change"
# Apply migrations
alembic upgrade head
# Rollback one step
alembic downgrade -1
Contributions are welcome! Here's how:
Fork the repository
Create your feature branch (git checkout -b feature/amazing-feature)
Commit your changes (git commit -m 'feat: add amazing feature')
Push to the branch (git push origin feature/amazing-feature)
Open a Pull Request
This project is licensed under the MIT License — see the LICENSE file for details.
Sheikh Wasimuddin
⭐ Star this repo if you find it useful!
Built with ❤️ for farmers, by engineers.