# yash-sojitra-20/crop-recommendation-system architecture

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

- Interactive diagram: https://gitdiagram.com/yash-sojitra-20/crop-recommendation-system
- Repository: https://github.com/yash-sojitra-20/crop-recommendation-system

## Overview

This is a farmer-facing crop recommendation web app. Farmers enter seven soil and climate values in the React form; the FastAPI endpoint validates the request, gets a nearest-match crop from the CSV-backed recommender, then asks Gemini for a rotation suggestion and Gujarati translations before returning results for display. The UI also provides a home page and a multilingual farmer disease guide. The endpoint and module calls are visible in the sampled source; the frontend-to-backend link is inferred from the matching request path, and no deployment or persistence layer is shown.

Main entry points: [`Frontend/frontend_form/src/App.jsx`](https://github.com/yash-sojitra-20/crop-recommendation-system/blob/main/Frontend/frontend_form/src/App.jsx) (App routes), [`Backend/main.py`](https://github.com/yash-sojitra-20/crop-recommendation-system/blob/main/Backend/main.py) (Prediction endpoint), [`Frontend/frontend_form/src/components/CropInputFrom.jsx`](https://github.com/yash-sojitra-20/crop-recommendation-system/blob/main/Frontend/frontend_form/src/components/CropInputFrom.jsx) (Prediction form), [`Frontend/frontend_form/src/components/Navbar.jsx`](https://github.com/yash-sojitra-20/crop-recommendation-system/blob/main/Frontend/frontend_form/src/components/Navbar.jsx) (Navigation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Farmer interface"]
  node_app_entry["React entry<br/>[main.jsx]"]
  node_app["App routes<br/>[App.jsx]"]
  node_navbar["Navigation<br/>[Navbar.jsx]"]
  node_home["Home page<br/>[Home.jsx]"]
  node_form["Prediction form<br/>[CropInputFrom.jsx]"]
  node_guide["Farmer disease guide<br/>[FarmerGuide.jsx]"]
end

subgraph group_api["Prediction API"]
  node_api_endpoint["Prediction endpoint<br/>[main.py]"]
end

subgraph group_recommendation["Crop recommendation"]
  node_predictor["Constraint and nearest-match predictor<br/>[recommendation.py]"]
  node_crop_data[("Crop dataset")]
end

subgraph group_rotation["Rotation and translation"]
  node_rotation["Rotation and translation<br/>[rotation.py]"]
end

node_farmer(("Farmer"))
node_gemini{{"Gemini API"}}

node_farmer -->|"enters conditions"| node_form
node_app_entry -->|"renders"| node_app
node_app -->|"renders"| node_navbar
node_app -->|"routes to"| node_home
node_app -->|"routes to"| node_form
node_app -->|"routes to"| node_guide
node_navbar -->|"navigates routes"| node_app
node_form -->|"posts prediction"| node_api_endpoint
node_api_endpoint -->|"calls predictor"| node_predictor
node_predictor -->|"reads dataset"| node_crop_data
node_api_endpoint -->|"calls rotation"| node_rotation
node_rotation -->|"requests suggestions"| node_gemini
node_api_endpoint -->|"returns results"| node_form

click node_app_entry "https://github.com/yash-sojitra-20/crop-recommendation-system/blob/main/Frontend/frontend_form/src/main.jsx"
click node_app "https://github.com/yash-sojitra-20/crop-recommendation-system/blob/main/Frontend/frontend_form/src/App.jsx"
click node_navbar "https://github.com/yash-sojitra-20/crop-recommendation-system/blob/main/Frontend/frontend_form/src/components/Navbar.jsx"
click node_home "https://github.com/yash-sojitra-20/crop-recommendation-system/blob/main/Frontend/frontend_form/src/pages/Home.jsx"
click node_form "https://github.com/yash-sojitra-20/crop-recommendation-system/blob/main/Frontend/frontend_form/src/components/CropInputFrom.jsx"
click node_guide "https://github.com/yash-sojitra-20/crop-recommendation-system/blob/main/Frontend/frontend_form/src/pages/FarmerGuide.jsx"
click node_api_endpoint "https://github.com/yash-sojitra-20/crop-recommendation-system/blob/main/Backend/main.py"
click node_predictor "https://github.com/yash-sojitra-20/crop-recommendation-system/blob/main/Backend/crop_recommendation/recommendation.py"
click node_crop_data "https://github.com/yash-sojitra-20/crop-recommendation-system/blob/main/Backend/crop_recommendation/Crop_Recommendation.csv"
click node_rotation "https://github.com/yash-sojitra-20/crop-recommendation-system/blob/main/Backend/crop_rotation/rotation.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_app_entry,node_app,node_navbar,node_home,node_form,node_guide toneBlue
class node_api_endpoint toneAmber
class node_predictor,node_crop_data,node_gemini toneMint
class node_rotation toneRose
class node_farmer toneIndigo
```

## Components

### Farmer interface

- [React entry](https://github.com/yash-sojitra-20/crop-recommendation-system/blob/main/Frontend/frontend_form/src/main.jsx): `Frontend/frontend_form/src/main.jsx`
- [App routes](https://github.com/yash-sojitra-20/crop-recommendation-system/blob/main/Frontend/frontend_form/src/App.jsx): `Frontend/frontend_form/src/App.jsx`
- [Navigation](https://github.com/yash-sojitra-20/crop-recommendation-system/blob/main/Frontend/frontend_form/src/components/Navbar.jsx): `Frontend/frontend_form/src/components/Navbar.jsx`
- [Home page](https://github.com/yash-sojitra-20/crop-recommendation-system/blob/main/Frontend/frontend_form/src/pages/Home.jsx): `Frontend/frontend_form/src/pages/Home.jsx`
- [Prediction form](https://github.com/yash-sojitra-20/crop-recommendation-system/blob/main/Frontend/frontend_form/src/components/CropInputFrom.jsx): `Frontend/frontend_form/src/components/CropInputFrom.jsx`
- [Farmer disease guide](https://github.com/yash-sojitra-20/crop-recommendation-system/blob/main/Frontend/frontend_form/src/pages/FarmerGuide.jsx): `Frontend/frontend_form/src/pages/FarmerGuide.jsx`

### Prediction API

- [Prediction endpoint](https://github.com/yash-sojitra-20/crop-recommendation-system/blob/main/Backend/main.py): `Backend/main.py`

### Crop recommendation

- [Constraint and nearest-match predictor](https://github.com/yash-sojitra-20/crop-recommendation-system/blob/main/Backend/crop_recommendation/recommendation.py): `Backend/crop_recommendation/recommendation.py`
- [Crop dataset](https://github.com/yash-sojitra-20/crop-recommendation-system/blob/main/Backend/crop_recommendation/Crop_Recommendation.csv): `Backend/crop_recommendation/Crop_Recommendation.csv`

### Rotation and translation

- [Rotation and translation](https://github.com/yash-sojitra-20/crop-recommendation-system/blob/main/Backend/crop_rotation/rotation.py): `Backend/crop_rotation/rotation.py`

### Other components

- **Farmer**
- **Gemini API**

## Connections

- Farmer → Prediction form: enters conditions (evidence: `Frontend/frontend_form/src/components/CropInputFrom.jsx`)
- React entry → App routes: renders (evidence: `Frontend/frontend_form/src/main.jsx`)
- App routes → Navigation: renders (evidence: `Frontend/frontend_form/src/App.jsx`)
- App routes → Home page: routes to (evidence: `Frontend/frontend_form/src/App.jsx`)
- App routes → Prediction form: routes to (evidence: `Frontend/frontend_form/src/App.jsx`)
- App routes → Farmer disease guide: routes to (evidence: `Frontend/frontend_form/src/App.jsx`)
- Navigation → App routes: navigates routes (evidence: `Frontend/frontend_form/src/components/Navbar.jsx`)
- Prediction form → Prediction endpoint: posts prediction (evidence: `Frontend/frontend_form/src/components/CropInputFrom.jsx`)
- Prediction endpoint → Constraint and nearest-match predictor: calls predictor (evidence: `Backend/main.py`)
- Constraint and nearest-match predictor → Crop dataset: reads dataset (evidence: `Backend/crop_recommendation/recommendation.py`)
- Prediction endpoint → Rotation and translation: calls rotation (evidence: `Backend/main.py`)
- Rotation and translation → Gemini API: requests suggestions (evidence: `Backend/crop_rotation/rotation.py`)
- Prediction endpoint → Prediction form: returns results (evidence: `Backend/main.py`)
