# srividyadasari5/opti-crop architecture

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

- Interactive diagram: https://gitdiagram.com/srividyadasari5/opti-crop
- Repository: https://github.com/srividyadasari5/opti-crop

## Overview

OptiCrop is a Flask web application that recommends a crop from seven soil and weather inputs. A user enters measurements in the browser; the frontend submits them to Flask, which validates and scales them before predicting with a trained classifier and returning a crop recommendation. The training pipeline prepares the CSV dataset, compares classifiers, and saves the winning model and scaler. The README also describes model benchmarking and clustering. Source excerpts show the web and training code; other documented capabilities are retained where their implementation was not sampled.

Main entry points: [`5. Project Development Phase/app.py`](https://github.com/srividyadasari5/opti-crop/blob/main/5.%20Project%20Development%20Phase/app.py) (Flask routes), [`5. Project Development Phase/train.py`](https://github.com/srividyadasari5/opti-crop/blob/main/5.%20Project%20Development%20Phase/train.py) (Training and comparison), [`5. Project Development Phase/static/script.js`](https://github.com/srividyadasari5/opti-crop/blob/main/5.%20Project%20Development%20Phase/static/script.js) (Form interaction), [`5. Project Development Phase/templates/index.html`](https://github.com/srividyadasari5/opti-crop/blob/main/5.%20Project%20Development%20Phase/templates/index.html) (Input form)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Farmer interface"]
  node_form["Input form<br/>[index.html]"]
  node_browser["Form interaction<br/>[script.js]"]
  node_styles["Interface styles<br/>[style.css]"]
  node_recommendation["Crop recommendation<br/>[script.js]"]
end

subgraph group_web["Prediction service"]
  node_flask["Flask routes<br/>[app.py]"]
  node_validation["Input validation<br/>[app.py]"]
end

subgraph group_ml["Model pipeline"]
  node_scaling["Feature scaling<br/>[app.py]"]
  node_classifier["Crop classifier<br/>[app.py]"]
  node_training["Training and comparison<br/>[train.py]"]
  node_clustering["K-Means analysis<br/>[train.py]"]
end

subgraph group_data["Agricultural data"]
  node_dataset[("Crop dataset")]
end

node_farmer(("Farmer"))

node_farmer -->|"enters measurements"| node_form
node_form -->|"submits form"| node_browser
node_browser -->|"POSTs inputs"| node_flask
node_flask -->|"validates inputs"| node_validation
node_flask -->|"scales features"| node_scaling
node_flask -->|"predicts crop"| node_classifier
node_flask -->|"renders page"| node_form
node_browser -->|"displays response"| node_recommendation
node_training -->|"reads data"| node_dataset
node_training -->|"fits clusters"| node_clustering
node_training -->|"selects and saves model"| node_classifier
node_training -->|"saves scaler"| node_scaling

click node_form "https://github.com/srividyadasari5/opti-crop/blob/main/5.%20Project%20Development%20Phase/templates/index.html"
click node_browser "https://github.com/srividyadasari5/opti-crop/blob/main/5.%20Project%20Development%20Phase/static/script.js"
click node_styles "https://github.com/srividyadasari5/opti-crop/blob/main/5.%20Project%20Development%20Phase/static/style.css"
click node_flask "https://github.com/srividyadasari5/opti-crop/blob/main/5.%20Project%20Development%20Phase/app.py"
click node_validation "https://github.com/srividyadasari5/opti-crop/blob/main/5.%20Project%20Development%20Phase/app.py"
click node_scaling "https://github.com/srividyadasari5/opti-crop/blob/main/5.%20Project%20Development%20Phase/app.py"
click node_classifier "https://github.com/srividyadasari5/opti-crop/blob/main/5.%20Project%20Development%20Phase/app.py"
click node_training "https://github.com/srividyadasari5/opti-crop/blob/main/5.%20Project%20Development%20Phase/train.py"
click node_clustering "https://github.com/srividyadasari5/opti-crop/blob/main/5.%20Project%20Development%20Phase/train.py"
click node_dataset "https://github.com/srividyadasari5/opti-crop/blob/main/5.%20Project%20Development%20Phase/data/Crop_recommendation.csv"
click node_recommendation "https://github.com/srividyadasari5/opti-crop/blob/main/5.%20Project%20Development%20Phase/static/script.js"

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_form,node_browser,node_styles,node_recommendation toneBlue
class node_flask,node_validation toneAmber
class node_scaling,node_classifier,node_training,node_clustering toneMint
class node_dataset toneRose
class node_farmer toneIndigo
```

## Components

### Farmer interface

- [Input form](https://github.com/srividyadasari5/opti-crop/blob/main/5.%20Project%20Development%20Phase/templates/index.html): `5. Project Development Phase/templates/index.html`
- [Form interaction](https://github.com/srividyadasari5/opti-crop/blob/main/5.%20Project%20Development%20Phase/static/script.js): `5. Project Development Phase/static/script.js`
- [Interface styles](https://github.com/srividyadasari5/opti-crop/blob/main/5.%20Project%20Development%20Phase/static/style.css): `5. Project Development Phase/static/style.css`
- [Crop recommendation](https://github.com/srividyadasari5/opti-crop/blob/main/5.%20Project%20Development%20Phase/static/script.js): `5. Project Development Phase/static/script.js`

### Prediction service

- [Flask routes](https://github.com/srividyadasari5/opti-crop/blob/main/5.%20Project%20Development%20Phase/app.py): `5. Project Development Phase/app.py`
- [Input validation](https://github.com/srividyadasari5/opti-crop/blob/main/5.%20Project%20Development%20Phase/app.py): `5. Project Development Phase/app.py`

### Model pipeline

- [Feature scaling](https://github.com/srividyadasari5/opti-crop/blob/main/5.%20Project%20Development%20Phase/app.py): `5. Project Development Phase/app.py`
- [Crop classifier](https://github.com/srividyadasari5/opti-crop/blob/main/5.%20Project%20Development%20Phase/app.py): `5. Project Development Phase/app.py`
- [Training and comparison](https://github.com/srividyadasari5/opti-crop/blob/main/5.%20Project%20Development%20Phase/train.py): `5. Project Development Phase/train.py`
- [K-Means analysis](https://github.com/srividyadasari5/opti-crop/blob/main/5.%20Project%20Development%20Phase/train.py): `5. Project Development Phase/train.py`

### Agricultural data

- [Crop dataset](https://github.com/srividyadasari5/opti-crop/blob/main/5.%20Project%20Development%20Phase/data/Crop_recommendation.csv): `5. Project Development Phase/data/Crop_recommendation.csv`

### Other components

- **Farmer**

## Connections

- Farmer → Input form: enters measurements (evidence: `README.md`)
- Input form → Form interaction: submits form (evidence: `5. Project Development Phase/static/script.js`)
- Form interaction → Flask routes: POSTs inputs (evidence: `5. Project Development Phase/static/script.js`)
- Flask routes → Input validation: validates inputs (evidence: `5. Project Development Phase/app.py`)
- Flask routes → Feature scaling: scales features (evidence: `5. Project Development Phase/app.py`)
- Flask routes → Crop classifier: predicts crop (evidence: `5. Project Development Phase/app.py`)
- Flask routes → Input form: renders page (evidence: `5. Project Development Phase/app.py`)
- Form interaction → Crop recommendation: displays response (evidence: `5. Project Development Phase/static/script.js`)
- Training and comparison → Crop dataset: reads data (evidence: `5. Project Development Phase/train.py`)
- Training and comparison → K-Means analysis: fits clusters (evidence: `5. Project Development Phase/train.py`)
- Training and comparison → Crop classifier: selects and saves model (evidence: `5. Project Development Phase/train.py`)
- Training and comparison → Feature scaling: saves scaler (evidence: `5. Project Development Phase/train.py`)
