# ashwin07026/agrivision architecture

> Architecture diagram of the GitHub repository ashwin07026/agrivision, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ashwin07026/agrivision
- Repository: https://github.com/ashwin07026/agrivision

## Overview

AgriVision is a farmer-facing agriculture decision-support platform. Its main workflow is a dashboard where users choose disease detection or historical yield estimation, submit inputs to the FastAPI backend, and view results; market prices and nearby agricultural-supply discovery are additional capabilities. Disease inference includes image validation and LiteRT model loading, while yield inference applies supported-input and year policies. The source excerpts show key routes and model/service calls; some frontend-to-route wiring and marketplace details are supported only by the README or source index.

Main entry points: [`backend/app/main.py`](https://github.com/ashwin07026/agrivision/blob/main/backend/app/main.py) (FastAPI application), [`frontend/src/App.jsx`](https://github.com/ashwin07026/agrivision/blob/main/frontend/src/App.jsx) (Dashboard), [`frontend/src/components/DiseaseCard.jsx`](https://github.com/ashwin07026/agrivision/blob/main/frontend/src/components/DiseaseCard.jsx) (Disease upload), [`backend/app/services/yield_service.py`](https://github.com/ashwin07026/agrivision/blob/main/backend/app/services/yield_service.py) (Yield inference)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Farmer interface"]
  node_dashboard["Dashboard<br/>[App.jsx]"]
  node_language["Language support<br/>[I18nContext.jsx]"]
  node_disease_ui["Disease upload<br/>[DiseaseCard.jsx]"]
  node_disease_result["Disease results<br/>[ResultBox.jsx]"]
  node_care_lookup["Leaf care lookup<br/>[LeafCareLookup.jsx]"]
  node_yield_ui["Yield inputs<br/>[YieldCard.jsx]"]
  node_market_ui["Market prices<br/>[MarketCard.jsx]"]
  node_supply_ui["Supply finder<br/>[SuppliesCard.jsx]"]
  node_nearby_shops["Nearby shops"]
end

subgraph group_disease["Disease analysis"]
  node_api["FastAPI application<br/>[main.py]"]
  node_image_validation["Image validation"]
  node_image_preprocessing["Image preprocessing"]
  node_disease_service["Disease inference<br/>[disease_service.py]"]
  node_model_loader["Model loader<br/>[model_loader.py]"]
  node_lite_model["LiteRT runtime<br/>[lite_model.py]"]
end

subgraph group_yield["Yield estimation"]
  node_yield_service["Yield inference<br/>[yield_service.py]"]
  node_year_policy["Year policy"]
  node_yield_router["Yield route<br/>[yield_router.py]"]
end

subgraph group_market["Market services"]
  node_market_service["Market lookup<br/>[market_service.py]"]
  node_marketplace_api["Marketplace routes<br/>[marketplace.py]"]
  node_shop_provider["Shop provider<br/>[shop_provider.py]"]
  node_data_gov["data.gov.in"]
  node_maps["Google Maps"]
end

node_farmer(("Farmer"))

node_farmer -->|"uses"| node_dashboard
node_dashboard -->|"renders"| node_disease_ui
node_dashboard -->|"renders"| node_yield_ui
node_dashboard -->|"offers"| node_market_ui
node_dashboard -->|"renders"| node_supply_ui
node_dashboard -->|"provides"| node_language
node_disease_ui -->|"shows"| node_disease_result
node_disease_ui -->|"supplies prediction"| node_care_lookup
node_yield_ui -->|"renders results"| node_disease_result
node_supply_ui -->|"renders"| node_nearby_shops
node_dashboard -->|"requests status"| node_api
node_disease_ui -.->|"submits image"| node_api
node_yield_ui -.->|"requests estimate"| node_api
node_market_ui -.->|"requests prices"| node_api
node_api -->|"validates image"| node_image_validation
node_api -->|"resizes image"| node_image_preprocessing
node_api -->|"gets model"| node_model_loader
node_api -->|"gets prices"| node_market_service
node_api -->|"registers routes"| node_marketplace_api
node_api -.->|"registers shops"| node_shop_provider
node_disease_service -->|"gets model"| node_model_loader
node_model_loader -->|"loads runtime"| node_lite_model
node_api -.->|"predicts yield"| node_yield_service
node_yield_router -->|"calls"| node_yield_service
node_yield_service -->|"checks years"| node_year_policy
node_yield_service -->|"gets model"| node_model_loader
node_market_service -->|"queries"| node_data_gov
node_marketplace_api -.->|"serves shop lookup"| node_shop_provider
node_nearby_shops -.->|"opens search"| node_maps

click node_dashboard "https://github.com/ashwin07026/agrivision/blob/main/frontend/src/App.jsx"
click node_language "https://github.com/ashwin07026/agrivision/blob/main/frontend/src/i18n/I18nContext.jsx"
click node_disease_ui "https://github.com/ashwin07026/agrivision/blob/main/frontend/src/components/DiseaseCard.jsx"
click node_disease_result "https://github.com/ashwin07026/agrivision/blob/main/frontend/src/components/ResultBox.jsx"
click node_care_lookup "https://github.com/ashwin07026/agrivision/blob/main/frontend/src/components/LeafCareLookup.jsx"
click node_yield_ui "https://github.com/ashwin07026/agrivision/blob/main/frontend/src/components/YieldCard.jsx"
click node_market_ui "https://github.com/ashwin07026/agrivision/blob/main/frontend/src/components/MarketCard.jsx"
click node_supply_ui "https://github.com/ashwin07026/agrivision/blob/main/frontend/src/components/SuppliesCard.jsx"
click node_nearby_shops "https://github.com/ashwin07026/agrivision/blob/main/frontend/src/components/NearbyShopsCard.jsx"
click node_api "https://github.com/ashwin07026/agrivision/blob/main/backend/app/main.py"
click node_image_validation "https://github.com/ashwin07026/agrivision/blob/main/backend/app/services/image_validation.py"
click node_image_preprocessing "https://github.com/ashwin07026/agrivision/blob/main/backend/app/ml/image_preprocessing.py"
click node_disease_service "https://github.com/ashwin07026/agrivision/blob/main/backend/app/services/disease_service.py"
click node_model_loader "https://github.com/ashwin07026/agrivision/blob/main/backend/app/ml/model_loader.py"
click node_lite_model "https://github.com/ashwin07026/agrivision/blob/main/backend/app/ml/lite_model.py"
click node_yield_service "https://github.com/ashwin07026/agrivision/blob/main/backend/app/services/yield_service.py"
click node_year_policy "https://github.com/ashwin07026/agrivision/blob/main/backend/app/services/yield_year_policy.py"
click node_yield_router "https://github.com/ashwin07026/agrivision/blob/main/backend/app/api/yield_router.py"
click node_market_service "https://github.com/ashwin07026/agrivision/blob/main/backend/app/services/market_service.py"
click node_marketplace_api "https://github.com/ashwin07026/agrivision/blob/main/backend/app/api/marketplace.py"
click node_shop_provider "https://github.com/ashwin07026/agrivision/blob/main/backend/app/services/shop_provider.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_dashboard,node_language,node_disease_ui,node_disease_result,node_care_lookup,node_yield_ui,node_market_ui,node_supply_ui,node_nearby_shops toneBlue
class node_api,node_image_validation,node_image_preprocessing,node_disease_service,node_model_loader,node_lite_model toneAmber
class node_yield_service,node_year_policy,node_yield_router toneMint
class node_market_service,node_marketplace_api,node_shop_provider,node_data_gov,node_maps toneRose
class node_farmer toneIndigo
```

## Components

### Farmer interface

- [Dashboard](https://github.com/ashwin07026/agrivision/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Language support](https://github.com/ashwin07026/agrivision/blob/main/frontend/src/i18n/I18nContext.jsx): `frontend/src/i18n/I18nContext.jsx`
- [Disease upload](https://github.com/ashwin07026/agrivision/blob/main/frontend/src/components/DiseaseCard.jsx): `frontend/src/components/DiseaseCard.jsx`
- [Disease results](https://github.com/ashwin07026/agrivision/blob/main/frontend/src/components/ResultBox.jsx): `frontend/src/components/ResultBox.jsx`
- [Leaf care lookup](https://github.com/ashwin07026/agrivision/blob/main/frontend/src/components/LeafCareLookup.jsx): `frontend/src/components/LeafCareLookup.jsx`
- [Yield inputs](https://github.com/ashwin07026/agrivision/blob/main/frontend/src/components/YieldCard.jsx): `frontend/src/components/YieldCard.jsx`
- [Market prices](https://github.com/ashwin07026/agrivision/blob/main/frontend/src/components/MarketCard.jsx): `frontend/src/components/MarketCard.jsx`
- [Supply finder](https://github.com/ashwin07026/agrivision/blob/main/frontend/src/components/SuppliesCard.jsx): `frontend/src/components/SuppliesCard.jsx`
- [Nearby shops](https://github.com/ashwin07026/agrivision/blob/main/frontend/src/components/NearbyShopsCard.jsx): `frontend/src/components/NearbyShopsCard.jsx`

### Disease analysis

- [FastAPI application](https://github.com/ashwin07026/agrivision/blob/main/backend/app/main.py): `backend/app/main.py`
- [Image validation](https://github.com/ashwin07026/agrivision/blob/main/backend/app/services/image_validation.py): `backend/app/services/image_validation.py`
- [Image preprocessing](https://github.com/ashwin07026/agrivision/blob/main/backend/app/ml/image_preprocessing.py): `backend/app/ml/image_preprocessing.py`
- [Disease inference](https://github.com/ashwin07026/agrivision/blob/main/backend/app/services/disease_service.py): `backend/app/services/disease_service.py`
- [Model loader](https://github.com/ashwin07026/agrivision/blob/main/backend/app/ml/model_loader.py): `backend/app/ml/model_loader.py`
- [LiteRT runtime](https://github.com/ashwin07026/agrivision/blob/main/backend/app/ml/lite_model.py): `backend/app/ml/lite_model.py`

### Yield estimation

- [Yield inference](https://github.com/ashwin07026/agrivision/blob/main/backend/app/services/yield_service.py): `backend/app/services/yield_service.py`
- [Year policy](https://github.com/ashwin07026/agrivision/blob/main/backend/app/services/yield_year_policy.py): `backend/app/services/yield_year_policy.py`
- [Yield route](https://github.com/ashwin07026/agrivision/blob/main/backend/app/api/yield_router.py): `backend/app/api/yield_router.py`

### Market services

- [Market lookup](https://github.com/ashwin07026/agrivision/blob/main/backend/app/services/market_service.py): `backend/app/services/market_service.py`
- [Marketplace routes](https://github.com/ashwin07026/agrivision/blob/main/backend/app/api/marketplace.py): `backend/app/api/marketplace.py`
- [Shop provider](https://github.com/ashwin07026/agrivision/blob/main/backend/app/services/shop_provider.py): `backend/app/services/shop_provider.py`
- **data.gov.in**
- **Google Maps**

### Other components

- **Farmer**

## Connections

- Farmer → Dashboard: uses
- Dashboard → Disease upload: renders (evidence: `frontend/src/App.jsx`)
- Dashboard → Yield inputs: renders (evidence: `frontend/src/App.jsx`)
- Dashboard → Market prices: offers
- Dashboard → Supply finder: renders (evidence: `frontend/src/App.jsx`)
- Dashboard → Language support: provides (evidence: `frontend/src/App.jsx`)
- Disease upload → Disease results: shows (evidence: `frontend/src/components/DiseaseCard.jsx`)
- Disease upload → Leaf care lookup: supplies prediction (evidence: `frontend/src/App.jsx`)
- Yield inputs → Disease results: renders results (evidence: `frontend/src/components/YieldCard.jsx`)
- Supply finder → Nearby shops: renders
- Dashboard → FastAPI application: requests status (evidence: `frontend/src/App.jsx`)
- Disease upload → FastAPI application: submits image
- Yield inputs → FastAPI application: requests estimate
- Market prices → FastAPI application: requests prices
- FastAPI application → Image validation: validates image (evidence: `backend/app/main.py`)
- FastAPI application → Image preprocessing: resizes image (evidence: `backend/app/main.py`)
- FastAPI application → Model loader: gets model (evidence: `backend/app/main.py`)
- FastAPI application → Market lookup: gets prices (evidence: `backend/app/main.py`)
- FastAPI application → Marketplace routes: registers routes (evidence: `backend/app/main.py`)
- FastAPI application → Shop provider: registers shops (evidence: `backend/app/main.py`)
- Disease inference → Model loader: gets model (evidence: `backend/app/services/disease_service.py`)
- Model loader → LiteRT runtime: loads runtime (evidence: `backend/app/ml/model_loader.py`)
- FastAPI application → Yield inference: predicts yield
- Yield route → Yield inference: calls (evidence: `backend/app/api/yield_router.py`)
- Yield inference → Year policy: checks years (evidence: `backend/app/services/yield_service.py`)
- Yield inference → Model loader: gets model (evidence: `backend/app/services/yield_service.py`)
- Market lookup → data.gov.in: queries (evidence: `backend/app/services/market_service.py`)
- Marketplace routes → Shop provider: serves shop lookup
- Nearby shops → Google Maps: opens search
