# 941-abhi/crop_yield_prediction_system architecture

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

- Interactive diagram: https://gitdiagram.com/941-abhi/crop_yield_prediction_system
- Repository: https://github.com/941-abhi/crop_yield_prediction_system

## Overview

AgriXAI is a crop-yield advisory application. Its primary workflow is farmer sign-in, entry of crop and farm conditions, model-based yield prediction, and presentation of yield status, explanatory factors, and recommendations; authenticated users can also view profile statistics. The web application and its prediction logic are concentrated in app.py. The repository also contains a standalone desktop predictor and a model-training script. The graph follows documented capabilities and the supplied excerpts; several implementation details, including exact model-loading and explanation calls in app.py, were not shown.

Main entry points: [`app.py`](https://github.com/941-abhi/crop_yield_prediction_system/blob/main/app.py) (Flask application), [`train_model_no_crop_year.py`](https://github.com/941-abhi/crop_yield_prediction_system/blob/main/train_model_no_crop_year.py) (Model training), [`crop_app.py`](https://github.com/941-abhi/crop_yield_prediction_system/blob/main/crop_app.py) (Desktop predictor), [`model/yield_model.pkl`](https://github.com/941-abhi/crop_yield_prediction_system/blob/main/model/yield_model.pkl) (Yield model)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
  node_webapp["Flask application<br/>[app.py]"]
  node_welcome["Welcome page<br/>[welcome.html]"]
end

subgraph group_identity["Identity and profile"]
  node_loginpage["Login page<br/>[login.html]"]
  node_signuppage["Signup page<br/>[signup.html]"]
  node_profilepage["Profile page<br/>[profile.html]"]
  node_firebase["Firebase Auth"]
end

subgraph group_advisory["Yield advisory"]
  node_predictform["Prediction form<br/>[predict.html]"]
  node_prediction["Prediction logic<br/>[app.py]"]
  node_resultpage["Results page<br/>[result.html]"]
  node_desktop["Desktop predictor<br/>[crop_app.py]"]
end

subgraph group_ml["Model lifecycle"]
  node_model["Yield model<br/>[yield_model.pkl]"]
  node_encoders["Category encoders<br/>[encoders.pkl]"]
  node_targets["Yield reference values<br/>[target_values.pkl]"]
  node_training["Model training"]
  node_dataset["Crop yield data<br/>[crop_yield1.csv]"]
end

node_farmer(("Farmer"))

node_farmer -->|"uses"| node_webapp
node_webapp -->|"shows"| node_welcome
node_webapp -->|"shows"| node_loginpage
node_webapp -->|"shows"| node_signuppage
node_webapp -->|"shows"| node_profilepage
node_webapp -->|"shows"| node_predictform
node_webapp -->|"handles"| node_prediction
node_prediction -->|"shows"| node_resultpage
node_webapp -.->|"authenticates with"| node_firebase
node_prediction -.->|"predicts with"| node_model
node_prediction -.->|"encodes with"| node_encoders
node_prediction -.->|"compares against"| node_targets
node_training -->|"trains from"| node_dataset
node_training -->|"saves"| node_model
node_training -->|"saves"| node_encoders
node_training -->|"saves"| node_targets
node_farmer -->|"uses"| node_desktop
node_desktop -->|"loads"| node_model
node_desktop -->|"loads"| node_encoders
node_desktop -->|"loads"| node_targets

click node_webapp "https://github.com/941-abhi/crop_yield_prediction_system/blob/main/app.py"
click node_welcome "https://github.com/941-abhi/crop_yield_prediction_system/blob/main/templates/welcome.html"
click node_loginpage "https://github.com/941-abhi/crop_yield_prediction_system/blob/main/templates/login.html"
click node_signuppage "https://github.com/941-abhi/crop_yield_prediction_system/blob/main/templates/signup.html"
click node_profilepage "https://github.com/941-abhi/crop_yield_prediction_system/blob/main/templates/profile.html"
click node_predictform "https://github.com/941-abhi/crop_yield_prediction_system/blob/main/templates/predict.html"
click node_prediction "https://github.com/941-abhi/crop_yield_prediction_system/blob/main/app.py"
click node_resultpage "https://github.com/941-abhi/crop_yield_prediction_system/blob/main/templates/result.html"
click node_model "https://github.com/941-abhi/crop_yield_prediction_system/blob/main/model/yield_model.pkl"
click node_encoders "https://github.com/941-abhi/crop_yield_prediction_system/blob/main/model/encoders.pkl"
click node_targets "https://github.com/941-abhi/crop_yield_prediction_system/blob/main/model/target_values.pkl"
click node_training "https://github.com/941-abhi/crop_yield_prediction_system/blob/main/train_model_no_crop_year.py"
click node_dataset "https://github.com/941-abhi/crop_yield_prediction_system/blob/main/crop_yield1.csv"
click node_desktop "https://github.com/941-abhi/crop_yield_prediction_system/blob/main/crop_app.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_webapp,node_welcome toneBlue
class node_loginpage,node_signuppage,node_profilepage,node_firebase toneAmber
class node_predictform,node_prediction,node_resultpage,node_desktop toneMint
class node_model,node_encoders,node_targets,node_training,node_dataset toneRose
class node_farmer toneIndigo
```

## Components

### Web experience

- [Flask application](https://github.com/941-abhi/crop_yield_prediction_system/blob/main/app.py): `app.py`
- [Welcome page](https://github.com/941-abhi/crop_yield_prediction_system/blob/main/templates/welcome.html): `templates/welcome.html`

### Identity and profile

- [Login page](https://github.com/941-abhi/crop_yield_prediction_system/blob/main/templates/login.html): `templates/login.html`
- [Signup page](https://github.com/941-abhi/crop_yield_prediction_system/blob/main/templates/signup.html): `templates/signup.html`
- [Profile page](https://github.com/941-abhi/crop_yield_prediction_system/blob/main/templates/profile.html): `templates/profile.html`
- **Firebase Auth**

### Yield advisory

- [Prediction form](https://github.com/941-abhi/crop_yield_prediction_system/blob/main/templates/predict.html): `templates/predict.html`
- [Prediction logic](https://github.com/941-abhi/crop_yield_prediction_system/blob/main/app.py): `app.py`
- [Results page](https://github.com/941-abhi/crop_yield_prediction_system/blob/main/templates/result.html): `templates/result.html`
- [Desktop predictor](https://github.com/941-abhi/crop_yield_prediction_system/blob/main/crop_app.py): `crop_app.py`

### Model lifecycle

- [Yield model](https://github.com/941-abhi/crop_yield_prediction_system/blob/main/model/yield_model.pkl): `model/yield_model.pkl`
- [Category encoders](https://github.com/941-abhi/crop_yield_prediction_system/blob/main/model/encoders.pkl): `model/encoders.pkl`
- [Yield reference values](https://github.com/941-abhi/crop_yield_prediction_system/blob/main/model/target_values.pkl): `model/target_values.pkl`
- [Model training](https://github.com/941-abhi/crop_yield_prediction_system/blob/main/train_model_no_crop_year.py): `train_model_no_crop_year.py`
- [Crop yield data](https://github.com/941-abhi/crop_yield_prediction_system/blob/main/crop_yield1.csv): `crop_yield1.csv`

### Other components

- **Farmer**

## Connections

- Farmer → Flask application: uses (evidence: `README.md`)
- Flask application → Welcome page: shows (evidence: `README.md`)
- Flask application → Login page: shows (evidence: `README.md`)
- Flask application → Signup page: shows (evidence: `README.md`)
- Flask application → Profile page: shows (evidence: `README.md`)
- Flask application → Prediction form: shows (evidence: `README.md`)
- Flask application → Prediction logic: handles (evidence: `README.md`)
- Prediction logic → Results page: shows (evidence: `README.md`)
- Flask application → Firebase Auth: authenticates with (evidence: `README.md`)
- Prediction logic → Yield model: predicts with (evidence: `README.md`)
- Prediction logic → Category encoders: encodes with (evidence: `README.md`)
- Prediction logic → Yield reference values: compares against (evidence: `README.md`)
- Model training → Crop yield data: trains from (evidence: `train_model_no_crop_year.py`)
- Model training → Yield model: saves (evidence: `train_model_no_crop_year.py`)
- Model training → Category encoders: saves (evidence: `train_model_no_crop_year.py`)
- Model training → Yield reference values: saves (evidence: `train_model_no_crop_year.py`)
- Farmer → Desktop predictor: uses (evidence: `crop_app.py`)
- Desktop predictor → Yield model: loads (evidence: `crop_app.py`)
- Desktop predictor → Category encoders: loads (evidence: `crop_app.py`)
- Desktop predictor → Yield reference values: loads (evidence: `crop_app.py`)
