How vigneshssuvarna/agrishield works
AgriShield is a crop-disease diagnosis and agronomic decision-support web app. A farmer submits a leaf photo through the detection screen; the frontend orchestrator calls the image API and can optionally submit sensor readings. The backend returns image predictions or, for sensor diagnoses, combines model inference with agronomic rules, optional SHAP attribution, and Markdown reporting. Results and a searchable disease library present the advice. Training and diagnostics scripts are omitted; the README documents their existence, but this map focuses on runtime product behavior. Some backend calls are supported by README statements because their source excerpts are incomplete.
Main entry points: main.py FastAPI endpoints · App.jsx App workflow · Results.jsx Diagnosis results · llm_client.py Report formatting
Components 20
Web experience
- App workflow
frontend/src/App.jsx - Detection form
frontend/src/pages/Detection.jsx - API client
frontend/src/services/api.js - Diagnosis results
frontend/src/pages/Results.jsx - Markdown report view
frontend/src/components/MarkdownReport.jsx - Truth table view
frontend/src/components/TruthTableCard.jsx - Disease library
frontend/src/pages/DiseaseInfo.jsx - Disease content
frontend/src/data/diseases.js
API and diagnosis
- FastAPI endpoints
backend/main.py - Request and response schemas
backend/schemas.py - Sensor inference
backend/ml_engine/predict.py - Image diagnosis
backend/main.py
Agronomic reasoning
- Agronomic rules
backend/xai_rules/truth_table.py - SHAP attribution
backend/shap_explainer.py - Report formatting
backend/llm_formatter/llm_client.py - Report templates
backend/llm_formatter/prompt_templates.py
Model development
- Ensemble prediction
backend/ml_engine/ensemble/predict.py - Ensemble contracts
backend/ml_engine/ensemble/common.py
Other components
- Farmer
- OpenAI-compatible LLM
Connections 21
- Farmer → App workflow: uses
README.md - App workflow → Detection form: shows
frontend/src/App.jsx - App workflow → API client: checks health
frontend/src/App.jsx - App workflow → API client: requests diagnosis
frontend/src/App.jsx - App workflow → Diagnosis results: shows results
frontend/src/App.jsx - App workflow → Disease library: shows library
frontend/src/App.jsx - Detection form → App workflow: submits inputs
README.md - API client → FastAPI endpoints: calls endpoints
README.md - FastAPI endpoints → Request and response schemas: validates payloads
README.md - FastAPI endpoints → Image diagnosis: classifies image
backend/main.py - FastAPI endpoints → Sensor inference: runs inference
backend/main.py - FastAPI endpoints → Agronomic rules: evaluates rules
README.md - FastAPI endpoints → SHAP attribution: computes drivers
README.md - FastAPI endpoints → Report formatting: formats report
README.md - Report formatting → Report templates: builds messages
backend/llm_formatter/llm_client.py - Report formatting → OpenAI-compatible LLM: requests synthesis
backend/llm_formatter/llm_client.py - FastAPI endpoints → Diagnosis results: returns diagnosis
README.md - Diagnosis results → Markdown report view: renders report
README.md - Diagnosis results → Truth table view: renders matrix
README.md - Disease library → Disease content: displays entries
README.md - Ensemble prediction → Ensemble contracts: uses contracts
backend/ml_engine/ensemble/predict.py