# avibadola510/crop-recommendation-ai-model architecture

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

- Interactive diagram: https://gitdiagram.com/avibadola510/crop-recommendation-ai-model
- Repository: https://github.com/avibadola510/crop-recommendation-ai-model

## Overview

AgriIntel AI is a Streamlit application that uses location-based live weather and soil nutrient inputs to rank three crop options, then recommends a fertilizer for the highest-ranked crop. Its main flow also presents confidence scores and crop feature importance. The runtime is concentrated in app.py; model artifacts are stored under models/. Weather lookup can fail, in which case the application uses fallback weather values. The README describes crop and fertilizer recommendations based on crop and demographic factors; the sampled implementation represents location through weather lookup.

Main entry points: [`app.py`](https://github.com/avibadola510/crop-recommendation-ai-model/blob/main/app.py) (Prediction flow), [`models`](https://github.com/avibadola510/crop-recommendation-ai-model/tree/main/models) (Model artifacts)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interaction["User interaction"]
  node_streamlit_ui["Streamlit inputs<br/>[app.py]"]
  node_soil_defaults["Soil defaults<br/>[app.py]"]
end

subgraph group_recommendation["Recommendation"]
  node_recommendation_flow["Prediction flow<br/>[app.py]"]
  node_weather_lookup["Weather lookup<br/>[app.py]"]
  node_weather_fallback["Fallback weather<br/>[app.py]"]
  node_model_artifacts["Model artifacts"]
  node_crop_model["Crop model<br/>[app.py]"]
  node_crop_ranking["Top-three ranking<br/>[app.py]"]
  node_fertilizer_model["Fertilizer model<br/>[app.py]"]
end

subgraph group_presentation["Results"]
  node_feature_analysis["Feature importance<br/>[app.py]"]
  node_recommendation_results["Recommendation results<br/>[app.py]"]
end

node_user(("Grower"))
node_weather_service{{"Weather API"}}

node_user -->|"enters inputs"| node_streamlit_ui
node_soil_defaults -->|"supplies defaults"| node_streamlit_ui
node_streamlit_ui -->|"submits prediction"| node_recommendation_flow
node_recommendation_flow -->|"requests weather"| node_weather_lookup
node_weather_lookup -->|"fetches conditions"| node_weather_service
node_weather_lookup -->|"uses on failure"| node_weather_fallback
node_recommendation_flow -->|"loads models"| node_model_artifacts
node_recommendation_flow -->|"predicts probabilities"| node_crop_model
node_crop_model -->|"ranks crops"| node_crop_ranking
node_recommendation_flow -->|"predicts fertilizer"| node_fertilizer_model
node_crop_ranking -->|"provides top crop"| node_fertilizer_model
node_crop_model -->|"provides importances"| node_feature_analysis
node_model_artifacts -->|"provides feature metadata"| node_feature_analysis
node_crop_ranking -->|"displays ranked crops"| node_recommendation_results
node_fertilizer_model -->|"displays recommendation"| node_recommendation_results
node_feature_analysis -->|"renders chart"| node_recommendation_results

click node_streamlit_ui "https://github.com/avibadola510/crop-recommendation-ai-model/blob/main/app.py"
click node_recommendation_flow "https://github.com/avibadola510/crop-recommendation-ai-model/blob/main/app.py"
click node_soil_defaults "https://github.com/avibadola510/crop-recommendation-ai-model/blob/main/app.py"
click node_weather_lookup "https://github.com/avibadola510/crop-recommendation-ai-model/blob/main/app.py"
click node_weather_fallback "https://github.com/avibadola510/crop-recommendation-ai-model/blob/main/app.py"
click node_model_artifacts "https://github.com/avibadola510/crop-recommendation-ai-model/tree/main/models"
click node_crop_model "https://github.com/avibadola510/crop-recommendation-ai-model/blob/main/app.py"
click node_crop_ranking "https://github.com/avibadola510/crop-recommendation-ai-model/blob/main/app.py"
click node_fertilizer_model "https://github.com/avibadola510/crop-recommendation-ai-model/blob/main/app.py"
click node_feature_analysis "https://github.com/avibadola510/crop-recommendation-ai-model/blob/main/app.py"
click node_recommendation_results "https://github.com/avibadola510/crop-recommendation-ai-model/blob/main/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_streamlit_ui,node_soil_defaults toneBlue
class node_recommendation_flow,node_weather_lookup,node_weather_fallback,node_model_artifacts,node_crop_model,node_crop_ranking,node_fertilizer_model toneAmber
class node_feature_analysis,node_recommendation_results,node_weather_service toneMint
class node_user toneIndigo
```

## Components

### User interaction

- [Streamlit inputs](https://github.com/avibadola510/crop-recommendation-ai-model/blob/main/app.py): `app.py`
- [Soil defaults](https://github.com/avibadola510/crop-recommendation-ai-model/blob/main/app.py): `app.py`

### Recommendation

- [Prediction flow](https://github.com/avibadola510/crop-recommendation-ai-model/blob/main/app.py): `app.py`
- [Weather lookup](https://github.com/avibadola510/crop-recommendation-ai-model/blob/main/app.py): `app.py`
- [Fallback weather](https://github.com/avibadola510/crop-recommendation-ai-model/blob/main/app.py): `app.py`
- [Model artifacts](https://github.com/avibadola510/crop-recommendation-ai-model/tree/main/models): `models`
- [Crop model](https://github.com/avibadola510/crop-recommendation-ai-model/blob/main/app.py): `app.py`
- [Top-three ranking](https://github.com/avibadola510/crop-recommendation-ai-model/blob/main/app.py): `app.py`
- [Fertilizer model](https://github.com/avibadola510/crop-recommendation-ai-model/blob/main/app.py): `app.py`

### Results

- [Feature importance](https://github.com/avibadola510/crop-recommendation-ai-model/blob/main/app.py): `app.py`
- [Recommendation results](https://github.com/avibadola510/crop-recommendation-ai-model/blob/main/app.py): `app.py`

### Other components

- **Grower**
- **Weather API**

## Connections

- Grower → Streamlit inputs: enters inputs (evidence: `app.py`)
- Soil defaults → Streamlit inputs: supplies defaults (evidence: `app.py`)
- Streamlit inputs → Prediction flow: submits prediction (evidence: `app.py`)
- Prediction flow → Weather lookup: requests weather (evidence: `app.py`)
- Weather lookup → Weather API: fetches conditions (evidence: `app.py`)
- Weather lookup → Fallback weather: uses on failure (evidence: `app.py`)
- Prediction flow → Model artifacts: loads models (evidence: `app.py`)
- Prediction flow → Crop model: predicts probabilities (evidence: `app.py`)
- Crop model → Top-three ranking: ranks crops (evidence: `app.py`)
- Prediction flow → Fertilizer model: predicts fertilizer (evidence: `app.py`)
- Top-three ranking → Fertilizer model: provides top crop (evidence: `app.py`)
- Crop model → Feature importance: provides importances (evidence: `app.py`)
- Model artifacts → Feature importance: provides feature metadata (evidence: `app.py`)
- Top-three ranking → Recommendation results: displays ranked crops (evidence: `app.py`)
- Fertilizer model → Recommendation results: displays recommendation (evidence: `app.py`)
- Feature importance → Recommendation results: renders chart (evidence: `app.py`)
