# jamipavankumar5435-oss/crop-yield-prediction architecture

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

- Interactive diagram: https://gitdiagram.com/jamipavankumar5435-oss/crop-yield-prediction
- Repository: https://github.com/jamipavankumar5435-oss/crop-yield-prediction

## Overview

This repository provides crop-yield prediction through two independent user interfaces: a Gradio app and a Streamlit app. Users enter farm, crop, soil, and weather details, select a model, and receive a yield estimate; supported models also produce SHAP feature explanations. Both apps load a shared serialized model package. The source excerpts show the complete prediction workflows, but do not describe how the package was trained or evaluated, so those stages are not represented.

Main entry points: [`app.py`](https://github.com/jamipavankumar5435-oss/crop-yield-prediction/blob/main/app.py) (Yield prediction), [`streamlit_app.py`](https://github.com/jamipavankumar5435-oss/crop-yield-prediction/blob/main/streamlit_app.py) (Streamlit form), [`crop_yield_models.pkl`](https://github.com/jamipavankumar5435-oss/crop-yield-prediction/blob/main/crop_yield_models.pkl) (Serialized models)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["User interfaces"]
  node_gradio["Gradio form<br/>[app.py]"]
  node_streamlit["Streamlit form<br/>[streamlit_app.py]"]
end

subgraph group_inference["Prediction and explanation"]
  node_gradio_prepare["Input preparation<br/>[app.py]"]
  node_gradio_predict["Yield prediction<br/>[app.py]"]
  node_gradio_shap["SHAP explanation<br/>[app.py]"]
  node_streamlit_prepare["Input preparation<br/>[streamlit_app.py]"]
  node_streamlit_predict["Yield prediction<br/>[streamlit_app.py]"]
  node_streamlit_shap["SHAP explanation<br/>[streamlit_app.py]"]
end

subgraph group_assets["Model assets"]
  node_model_package["Serialized models"]
end

node_user(("Farm user"))

node_user -->|"enters details"| node_gradio
node_user -->|"enters details"| node_streamlit
node_gradio -->|"submits inputs"| node_gradio_prepare
node_gradio_prepare -->|"returns features"| node_gradio_predict
node_gradio -->|"calls prediction"| node_gradio_predict
node_gradio_predict -->|"loads models"| node_model_package
node_gradio_predict -->|"explains prediction"| node_gradio_shap
node_gradio_predict -->|"returns result"| node_gradio
node_gradio_shap -->|"returns explanation"| node_gradio
node_streamlit -->|"builds features"| node_streamlit_prepare
node_streamlit -->|"predicts on submit"| node_streamlit_predict
node_streamlit_predict -->|"loads models"| node_model_package
node_streamlit_predict -->|"explains prediction"| node_streamlit_shap
node_streamlit_predict -->|"shows result"| node_streamlit
node_streamlit_shap -->|"shows explanation"| node_streamlit

click node_gradio "https://github.com/jamipavankumar5435-oss/crop-yield-prediction/blob/main/app.py"
click node_streamlit "https://github.com/jamipavankumar5435-oss/crop-yield-prediction/blob/main/streamlit_app.py"
click node_gradio_prepare "https://github.com/jamipavankumar5435-oss/crop-yield-prediction/blob/main/app.py"
click node_gradio_predict "https://github.com/jamipavankumar5435-oss/crop-yield-prediction/blob/main/app.py"
click node_gradio_shap "https://github.com/jamipavankumar5435-oss/crop-yield-prediction/blob/main/app.py"
click node_streamlit_prepare "https://github.com/jamipavankumar5435-oss/crop-yield-prediction/blob/main/streamlit_app.py"
click node_streamlit_predict "https://github.com/jamipavankumar5435-oss/crop-yield-prediction/blob/main/streamlit_app.py"
click node_streamlit_shap "https://github.com/jamipavankumar5435-oss/crop-yield-prediction/blob/main/streamlit_app.py"
click node_model_package "https://github.com/jamipavankumar5435-oss/crop-yield-prediction/blob/main/crop_yield_models.pkl"

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_gradio,node_streamlit,node_user toneBlue
class node_gradio_prepare,node_gradio_predict,node_gradio_shap,node_streamlit_prepare,node_streamlit_predict,node_streamlit_shap toneAmber
class node_model_package toneMint
```

## Components

### User interfaces

- [Gradio form](https://github.com/jamipavankumar5435-oss/crop-yield-prediction/blob/main/app.py): `app.py`
- [Streamlit form](https://github.com/jamipavankumar5435-oss/crop-yield-prediction/blob/main/streamlit_app.py): `streamlit_app.py`

### Prediction and explanation

- [Input preparation](https://github.com/jamipavankumar5435-oss/crop-yield-prediction/blob/main/app.py): `app.py`
- [Yield prediction](https://github.com/jamipavankumar5435-oss/crop-yield-prediction/blob/main/app.py): `app.py`
- [SHAP explanation](https://github.com/jamipavankumar5435-oss/crop-yield-prediction/blob/main/app.py): `app.py`
- [Input preparation](https://github.com/jamipavankumar5435-oss/crop-yield-prediction/blob/main/streamlit_app.py): `streamlit_app.py`
- [Yield prediction](https://github.com/jamipavankumar5435-oss/crop-yield-prediction/blob/main/streamlit_app.py): `streamlit_app.py`
- [SHAP explanation](https://github.com/jamipavankumar5435-oss/crop-yield-prediction/blob/main/streamlit_app.py): `streamlit_app.py`

### Model assets

- [Serialized models](https://github.com/jamipavankumar5435-oss/crop-yield-prediction/blob/main/crop_yield_models.pkl): `crop_yield_models.pkl`

### Other components

- **Farm user**

## Connections

- Farm user → Gradio form: enters details (evidence: `app.py`)
- Farm user → Streamlit form: enters details (evidence: `streamlit_app.py`)
- Gradio form → Input preparation: submits inputs (evidence: `app.py`)
- Input preparation → Yield prediction: returns features (evidence: `app.py`)
- Gradio form → Yield prediction: calls prediction (evidence: `app.py`)
- Yield prediction → Serialized models: loads models (evidence: `app.py`)
- Yield prediction → SHAP explanation: explains prediction (evidence: `app.py`)
- Yield prediction → Gradio form: returns result (evidence: `app.py`)
- SHAP explanation → Gradio form: returns explanation (evidence: `app.py`)
- Streamlit form → Input preparation: builds features (evidence: `streamlit_app.py`)
- Streamlit form → Yield prediction: predicts on submit (evidence: `streamlit_app.py`)
- Yield prediction → Serialized models: loads models (evidence: `streamlit_app.py`)
- Yield prediction → SHAP explanation: explains prediction (evidence: `streamlit_app.py`)
- Yield prediction → Streamlit form: shows result (evidence: `streamlit_app.py`)
- SHAP explanation → Streamlit form: shows explanation (evidence: `streamlit_app.py`)
