# rhythem2005/sih-crop-yield- architecture

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

- Interactive diagram: https://gitdiagram.com/rhythem2005/sih-crop-yield-
- Repository: https://github.com/rhythem2005/sih-crop-yield-

## Overview

AgroAI is a farmer-focused agricultural decision platform with crop-yield prediction as its main workflow: farmers enter soil, crop, and location data; weather is incorporated; the backend returns yield estimates and recommendations for the results view and report. Separate product branches support leaf-image diagnosis, farming chat, insurance and claims, and farmer-to-buyer produce trading. The README documents backend model and API integrations; sampled frontend excerpts show routing, weather lookup, image submission, and result rendering. Several feature implementations were not sampled, so their internal links are left out.

Main entry points: [`client/src/App.jsx`](https://github.com/rhythem2005/sih-crop-yield-/blob/main/client/src/App.jsx) (Web app routes), [`server/app.py`](https://github.com/rhythem2005/sih-crop-yield-/blob/main/server/app.py) (FastAPI endpoints), [`client/src/components/InputData.jsx`](https://github.com/rhythem2005/sih-crop-yield-/blob/main/client/src/components/InputData.jsx) (Farm data entry), [`client/src/pages/ResultPage.jsx`](https://github.com/rhythem2005/sih-crop-yield-/blob/main/client/src/pages/ResultPage.jsx) (Yield results)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_g_entry["App and access"]
  node_app["Web app routes<br/>[App.jsx]"]
  node_auth["Auth context<br/>[AuthContext.jsx]"]
end

subgraph group_g_yield["Yield analysis"]
  node_yield_input["Farm data entry<br/>[InputData.jsx]"]
  node_weather_client["Weather lookup<br/>[weatherAPi.js]"]
  node_backend["FastAPI endpoints<br/>[app.py]"]
  node_weather_service["OpenWeather API"]
  node_yield_model["XGBoost model"]
  node_yield_result["Yield results<br/>[ResultPage.jsx]"]
  node_economic["Economic analysis"]
  node_report["PDF report"]
end

subgraph group_g_diagnosis["Plant diagnosis"]
  node_photo_upload["Leaf image upload<br/>[PhotoUpload.jsx]"]
  node_photo_result["Diagnosis results<br/>[PhotoResult.jsx]"]
end

subgraph group_g_market["Produce marketplace"]
  node_market_route["Marketplace role selection<br/>[ChooseRole.jsx]"]
  node_farmer_dashboard["Farmer dashboard"]
  node_product_listing["Crop listings<br/>[AddNewProduct.jsx]"]
  node_buyer_dashboard["Buyer dashboard<br/>[BuyerDashboard.jsx]"]
  node_marketplace["Produce browsing<br/>[Bmarketplace.jsx]"]
end

subgraph group_g_advice["Advice and protection"]
  node_chat["Kisan Mitra chat<br/>[ChatBot.jsx]"]
  node_gemini["Gemini AI"]
  node_insurance["Insurance recommendations"]
  node_claims["Insurance claims<br/>[ClaimSection.jsx]"]
end

node_farmer(("Farmer"))
node_buyer(("Buyer"))

node_farmer -->|"uses"| node_app
node_buyer -->|"uses"| node_app
node_app -->|"routes to"| node_yield_input
node_app -->|"routes to"| node_photo_upload
node_app -->|"routes to"| node_photo_result
node_app -->|"renders"| node_chat
node_app -->|"provides context"| node_auth
node_yield_input -->|"fetches weather"| node_weather_client
node_weather_client -->|"requests conditions"| node_weather_service
node_yield_input -->|"submits prediction"| node_backend
node_backend -->|"fetches weather"| node_weather_service
node_backend -->|"runs prediction"| node_yield_model
node_backend -->|"returns prediction"| node_yield_result
node_yield_result -->|"renders"| node_economic
node_yield_result -->|"renders"| node_report
node_photo_upload -->|"submits image"| node_backend
node_backend -.->|"returns diagnosis"| node_photo_result
node_chat -.->|"sends messages"| node_backend
node_backend -->|"queries"| node_gemini
node_app -->|"routes to"| node_market_route
node_app -->|"routes to"| node_farmer_dashboard
node_app -->|"routes to"| node_buyer_dashboard
node_app -->|"routes to"| node_product_listing
node_app -->|"routes to"| node_marketplace
node_farmer -.->|"requests advice"| node_insurance
node_farmer -.->|"submits claim"| node_claims

click node_app "https://github.com/rhythem2005/sih-crop-yield-/blob/main/client/src/App.jsx"
click node_auth "https://github.com/rhythem2005/sih-crop-yield-/blob/main/client/src/contexts/AuthContext.jsx"
click node_yield_input "https://github.com/rhythem2005/sih-crop-yield-/blob/main/client/src/components/InputData.jsx"
click node_weather_client "https://github.com/rhythem2005/sih-crop-yield-/blob/main/client/src/utils/weatherAPi.js"
click node_backend "https://github.com/rhythem2005/sih-crop-yield-/blob/main/server/app.py"
click node_yield_result "https://github.com/rhythem2005/sih-crop-yield-/blob/main/client/src/pages/ResultPage.jsx"
click node_economic "https://github.com/rhythem2005/sih-crop-yield-/blob/main/client/src/components/EconomicAnalysis.jsx"
click node_report "https://github.com/rhythem2005/sih-crop-yield-/blob/main/client/src/components/ReportGenerator.jsx"
click node_photo_upload "https://github.com/rhythem2005/sih-crop-yield-/blob/main/client/src/pages/PhotoUpload.jsx"
click node_photo_result "https://github.com/rhythem2005/sih-crop-yield-/blob/main/client/src/pages/PhotoResult.jsx"
click node_chat "https://github.com/rhythem2005/sih-crop-yield-/blob/main/client/src/components/ChatBot.jsx"
click node_insurance "https://github.com/rhythem2005/sih-crop-yield-/blob/main/client/src/components/InsuranceRecommendations.jsx"
click node_claims "https://github.com/rhythem2005/sih-crop-yield-/blob/main/client/src/components/ClaimSection.jsx"
click node_market_route "https://github.com/rhythem2005/sih-crop-yield-/blob/main/client/src/components/ChooseRole.jsx"
click node_farmer_dashboard "https://github.com/rhythem2005/sih-crop-yield-/blob/main/client/src/components/FarmerDashboard.jsx"
click node_product_listing "https://github.com/rhythem2005/sih-crop-yield-/blob/main/client/src/components/AddNewProduct.jsx"
click node_buyer_dashboard "https://github.com/rhythem2005/sih-crop-yield-/blob/main/client/src/components/BuyerDashboard.jsx"
click node_marketplace "https://github.com/rhythem2005/sih-crop-yield-/blob/main/client/src/components/Bmarketplace.jsx"

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_app,node_auth toneBlue
class node_yield_input,node_weather_client,node_backend,node_weather_service,node_yield_model,node_yield_result,node_economic,node_report toneAmber
class node_photo_upload,node_photo_result toneMint
class node_market_route,node_farmer_dashboard,node_product_listing,node_buyer_dashboard,node_marketplace toneRose
class node_chat,node_gemini,node_insurance,node_claims,node_farmer,node_buyer toneIndigo
```

## Components

### App and access

- [Web app routes](https://github.com/rhythem2005/sih-crop-yield-/blob/main/client/src/App.jsx): `client/src/App.jsx`
- [Auth context](https://github.com/rhythem2005/sih-crop-yield-/blob/main/client/src/contexts/AuthContext.jsx): `client/src/contexts/AuthContext.jsx`

### Yield analysis

- [Farm data entry](https://github.com/rhythem2005/sih-crop-yield-/blob/main/client/src/components/InputData.jsx): `client/src/components/InputData.jsx`
- [Weather lookup](https://github.com/rhythem2005/sih-crop-yield-/blob/main/client/src/utils/weatherAPi.js): `client/src/utils/weatherAPi.js`
- [FastAPI endpoints](https://github.com/rhythem2005/sih-crop-yield-/blob/main/server/app.py): `server/app.py`
- **OpenWeather API**
- **XGBoost model**
- [Yield results](https://github.com/rhythem2005/sih-crop-yield-/blob/main/client/src/pages/ResultPage.jsx): `client/src/pages/ResultPage.jsx`
- [Economic analysis](https://github.com/rhythem2005/sih-crop-yield-/blob/main/client/src/components/EconomicAnalysis.jsx): `client/src/components/EconomicAnalysis.jsx`
- [PDF report](https://github.com/rhythem2005/sih-crop-yield-/blob/main/client/src/components/ReportGenerator.jsx): `client/src/components/ReportGenerator.jsx`

### Plant diagnosis

- [Leaf image upload](https://github.com/rhythem2005/sih-crop-yield-/blob/main/client/src/pages/PhotoUpload.jsx): `client/src/pages/PhotoUpload.jsx`
- [Diagnosis results](https://github.com/rhythem2005/sih-crop-yield-/blob/main/client/src/pages/PhotoResult.jsx): `client/src/pages/PhotoResult.jsx`

### Produce marketplace

- [Marketplace role selection](https://github.com/rhythem2005/sih-crop-yield-/blob/main/client/src/components/ChooseRole.jsx): `client/src/components/ChooseRole.jsx`
- [Farmer dashboard](https://github.com/rhythem2005/sih-crop-yield-/blob/main/client/src/components/FarmerDashboard.jsx): `client/src/components/FarmerDashboard.jsx`
- [Crop listings](https://github.com/rhythem2005/sih-crop-yield-/blob/main/client/src/components/AddNewProduct.jsx): `client/src/components/AddNewProduct.jsx`
- [Buyer dashboard](https://github.com/rhythem2005/sih-crop-yield-/blob/main/client/src/components/BuyerDashboard.jsx): `client/src/components/BuyerDashboard.jsx`
- [Produce browsing](https://github.com/rhythem2005/sih-crop-yield-/blob/main/client/src/components/Bmarketplace.jsx): `client/src/components/Bmarketplace.jsx`

### Advice and protection

- [Kisan Mitra chat](https://github.com/rhythem2005/sih-crop-yield-/blob/main/client/src/components/ChatBot.jsx): `client/src/components/ChatBot.jsx`
- **Gemini AI**
- [Insurance recommendations](https://github.com/rhythem2005/sih-crop-yield-/blob/main/client/src/components/InsuranceRecommendations.jsx): `client/src/components/InsuranceRecommendations.jsx`
- [Insurance claims](https://github.com/rhythem2005/sih-crop-yield-/blob/main/client/src/components/ClaimSection.jsx): `client/src/components/ClaimSection.jsx`

### Other components

- **Farmer**
- **Buyer**

## Connections

- Farmer → Web app routes: uses (evidence: `README.md`)
- Buyer → Web app routes: uses (evidence: `README.md`)
- Web app routes → Farm data entry: routes to (evidence: `client/src/App.jsx`)
- Web app routes → Leaf image upload: routes to (evidence: `client/src/App.jsx`)
- Web app routes → Diagnosis results: routes to (evidence: `client/src/App.jsx`)
- Web app routes → Kisan Mitra chat: renders (evidence: `client/src/App.jsx`)
- Web app routes → Auth context: provides context (evidence: `client/src/App.jsx`)
- Farm data entry → Weather lookup: fetches weather (evidence: `client/src/components/InputData.jsx`)
- Weather lookup → OpenWeather API: requests conditions (evidence: `client/src/utils/weatherAPi.js`)
- Farm data entry → FastAPI endpoints: submits prediction (evidence: `README.md`)
- FastAPI endpoints → OpenWeather API: fetches weather (evidence: `README.md`)
- FastAPI endpoints → XGBoost model: runs prediction (evidence: `README.md`)
- FastAPI endpoints → Yield results: returns prediction (evidence: `README.md`)
- Yield results → Economic analysis: renders (evidence: `client/src/pages/ResultPage.jsx`)
- Yield results → PDF report: renders (evidence: `client/src/pages/ResultPage.jsx`)
- Leaf image upload → FastAPI endpoints: submits image (evidence: `client/src/pages/PhotoUpload.jsx`)
- FastAPI endpoints → Diagnosis results: returns diagnosis (evidence: `README.md`)
- Kisan Mitra chat → FastAPI endpoints: sends messages (evidence: `README.md`)
- FastAPI endpoints → Gemini AI: queries (evidence: `README.md`)
- Web app routes → Marketplace role selection: routes to (evidence: `client/src/App.jsx`)
- Web app routes → Farmer dashboard: routes to (evidence: `client/src/App.jsx`)
- Web app routes → Buyer dashboard: routes to (evidence: `client/src/App.jsx`)
- Web app routes → Crop listings: routes to (evidence: `client/src/App.jsx`)
- Web app routes → Produce browsing: routes to (evidence: `client/src/App.jsx`)
- Farmer → Insurance recommendations: requests advice (evidence: `README.md`)
- Farmer → Insurance claims: submits claim (evidence: `README.md`)
