How karankarpe22/ai-agriculture-disease-detection-assistant works
Krishi Sahayyak is an agricultural decision-support application. A farmer submits a leaf image or question through the web interface; the FastAPI backend invokes a LangGraph workflow, which can validate and classify images, gather weather, soil, and agronomic evidence, and synthesize bilingual advice. The result is returned to the interface, with speech synthesis available separately. The graph reflects documented workflow stages and sampled service calls; several frontend/API and internal workflow links rely on README documentation because their implementation excerpts were incomplete.
Main entry points: nodes.py Workflow Nodes · main.py FastAPI API · workflow.py StateGraph Workflow · predict.py Disease Prediction
Components 22
User Interface
- Web Interface
frontend/app.js
API & Orchestration
- FastAPI API
backend/main.py - StateGraph Workflow
src/graph/workflow.py - Workflow State
src/graph/state.py - Workflow Nodes
src/graph/nodes.py
Leaf Diagnosis
- Image Quality Check
src/preprocessing/quality_check.py - Disease Prediction
src/prediction/predict.py - MobileNetV3 Model
src/training/model.py - Image Transforms
src/preprocessing/transforms.py
Agronomic Context
- Weather Risk
src/weather/weather_service.py - Weather Providers
- Soil Profile
src/soil/soil_service.py - Soil Records
data/soil/synthetic_soil_records.json - Evidence Retrieval
src/rag/vector_store.py - Agronomy Knowledge
knowledge_base - FAISS Index
models/rag_index.faiss
Advice & Access
- Gemini Guidance
src/gemini/guidance_service.py - Google Gemini
- English-Marathi Localization
src/utils/localization.py - Voice Synthesis
src/utils/voice_service.py - Speech Providers
Other components
- Farmer
Connections 25
- Farmer → Web Interface: submits request
README.md - Web Interface → FastAPI API: calls API
- FastAPI API → StateGraph Workflow: runs workflow
backend/main.py - StateGraph Workflow → Workflow Nodes: dispatches stages
README.md - StateGraph Workflow → Workflow State: shares state
README.md - Workflow Nodes → Image Quality Check: checks image
src/graph/nodes.py - Workflow Nodes → Disease Prediction: requests prediction
src/graph/nodes.py - Disease Prediction → Image Quality Check: checks quality
src/prediction/predict.py - Disease Prediction → Image Transforms: applies transforms
src/prediction/predict.py - Disease Prediction → MobileNetV3 Model: runs inference
src/prediction/predict.py - Workflow Nodes → Weather Risk: fetches weather
src/graph/nodes.py - Weather Risk → Weather Providers: queries providers
src/weather/weather_service.py - Workflow Nodes → Soil Profile: requests profile
src/graph/nodes.py - Soil Profile → Soil Records: loads records
src/soil/soil_service.py - Workflow Nodes → Evidence Retrieval: retrieves evidence
src/graph/nodes.py - Evidence Retrieval → Agronomy Knowledge: grounds retrieval
README.md - Evidence Retrieval → FAISS Index: searches index
README.md - Workflow Nodes → Gemini Guidance: requests synthesis
src/graph/nodes.py - Gemini Guidance → Google Gemini: generates advice
README.md - StateGraph Workflow → English-Marathi Localization: uses translations
src/graph/workflow.py - FastAPI API → Voice Synthesis: generates speech
backend/main.py - Voice Synthesis → Speech Providers: synthesizes audio
README.md - FastAPI API → Web Interface: serves interface
backend/main.py - FastAPI API → Workflow State: formats response
backend/main.py - FastAPI API → Weather Risk: serves weather
backend/main.py