AI-powered platform for Indian farmers: crop disease detection, treatment advice, irrigation scheduling & market price alerts.
6 Microservices:
1. API Gateway (FastAPI, port 8000) — Auth, routing, rate limiting
2. Disease Detection (FastAPI + PyTorch, port 8001) — MobileNetV2
3. Treatment Advisory (FastAPI + Kafka consumer) — RAG pipeline
4. Irrigation Service (FastAPI, port 8003) — Weather + crop formulas
5. Mandi Service (FastAPI + Redis, port 8004) — Market prices
6. Notification Service (Kafka consumer) — Central notification hub
Infrastructure:
• Kafka + Zookeeper — async event streaming
• PostgreSQL — persistent storage
• Redis — rate limiting + price caching
• Qdrant — vector database (for RAG)
• Nginx — reverse proxy
• Frontend — single-page HTML app (Node/Express)
- Docker Desktop installed and running
- 8GB RAM recommended (Kafka + multiple services)
- Ports 80, 8000 free
# If downloaded as zip:
unzip agent-kisaan.zip
cd agent-kisaancp .env .env.local
# Edit .env to add real API keys (weather, mandi, SMS)
# Platform works fully in demo mode without real keysdocker compose up -dThat's it! Docker Compose handles startup order automatically via health checks.
- Web App: http://localhost (port 80, via Nginx)
- API Docs: http://localhost:8000/docs
- API Direct: http://localhost:8000/api
- Open http://localhost
- Click "Get Started Free"
- Register with your phone number
- Upload a crop photo → get instant disease diagnosis!
Docker Compose uses health-check-gated startup:
Zookeeper (healthy)
→ Kafka (healthy)
→ PostgreSQL (healthy) + Redis (healthy) + Qdrant (healthy)
→ All 6 Application Services
→ Nginx
No service starts until its dependencies are fully healthy. First startup takes ~3-4 minutes as Kafka initializes.
# Check all services
docker compose ps
# View logs for a specific service
docker compose logs api-gateway -f
docker compose logs disease-detection -f
docker compose logs treatment-advisory -f
# Check individual health endpoints
curl http://localhost:8000/health
curl http://localhost:8000/api/mandi/pricesThe platform uses MobileNetV2 (PyTorch) trained on PlantVillage dataset:
- 38 disease classes across 14 crop types
- Simulation mode: If no trained model file is present, returns realistic demo results
- Production mode: Download PlantVillage-trained weights and place at:
docker volume inspect agent-kisaan_model_data
To use a real trained model:
# Copy model file into Docker volume
docker run --rm -v agent-kisaan_model_data:/models -v $(pwd):/src alpine \
cp /src/mobilenetv2_plant_disease.pth /models/- Upload crop photo (JPEG/PNG/WebP, max 10MB)
- Drag & drop supported
- Binary classifier checks if image is actually a plant
- Returns top-3 predictions with confidence scores
- Async treatment advice via Kafka
- Kafka consumer listens for
disease.detectedevents - Knowledge base: ICAR guidelines, state agriculture department data
- Deduplication: same farmer+crop+disease within 30 min → cached result
- Fallback response when disease not in knowledge base
- Register fields with crop type, soil type, acreage
- Weather-adjusted irrigation calculation (ET0 method)
- Irrigation reminders published to Kafka
- Live prices from Agmarknet API (or demo data if no API key)
- Redis cache with 6-hour TTL
- 3-tier fallback: Live API → Redis cache → PostgreSQL → demo data
- Centralized notification hub via Kafka
- In-app notifications (read/unread tracking)
- SMS ready (configure MSG91 key)
- JWT authentication (24-hour tokens, stateless)
- Redis rate limiting: 10 requests/minute per user (fail-open)
- File upload validation (type + size)
- Nginx SSL termination ready
| Edge Case | Solution |
|---|---|
| Image not a crop | Binary plant classifier, returns clear error |
| Kafka consumer crashes | Manual offset commit (at-least-once delivery) |
| No relevant treatment in KB | Similarity threshold + fallback message with KVK contact |
| Redis is down | Fail-open: allow requests, log warning |
| Duplicate disease detections | 30-minute dedup window per farmer+crop+disease |
| Model file missing | Simulation mode + Docker healthcheck fails gracefully |
| Mandi API is down | 3-tier fallback with staleness warning |
docker compose down # Stop but keep data
docker compose down -v # Stop and delete all data (fresh start)Run individual services:
# API Gateway only
cd api-gateway
pip install -r requirements.txt
uvicorn main:app --reload --port 8000agent-kisaan/
├── docker-compose.yml
├── .env
├── nginx/
│ └── nginx.conf
├── postgres/
│ └── init.sql
├── api-gateway/
│ ├── main.py
│ ├── requirements.txt
│ └── Dockerfile
├── disease-detection/
│ ├── main.py
│ ├── requirements.txt
│ └── Dockerfile
├── treatment-advisory/
│ ├── main.py
│ ├── requirements.txt
│ └── Dockerfile
├── irrigation-service/
│ ├── main.py
│ ├── requirements.txt
│ └── Dockerfile
├── mandi-service/
│ ├── main.py
│ ├── requirements.txt
│ └── Dockerfile
├── notification-service/
│ ├── main.py
│ ├── requirements.txt
│ └── Dockerfile
└── frontend/
├── index.html
├── server.js
├── package.json
└── Dockerfile
For any agricultural queries: 1800-180-1551 (Toll free, 6AM–10PM)