# krishgarg344/crop_monitoring_sih architecture

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

- Interactive diagram: https://gitdiagram.com/krishgarg344/crop_monitoring_sih
- Repository: https://github.com/krishgarg344/crop_monitoring_sih

## Overview

CropVision is a satellite-based crop-health monitor. Its main user workflow is selecting a farm in the Streamlit dashboard, loading processed vegetation-index rasters, normalizing and stacking them, running patch-wise CNN inference, and viewing health maps and summaries. The advanced dashboard also presents simulated soil metrics and estimates pest risk from crop stress and simulated weather. A separate Flask API currently predicts on a random dummy patch, rather than on uploaded satellite imagery. Notebook and data-preparation details are documented but not sampled, so those relationships are not expanded.

Main entry points: [`dashboard_1.py`](https://github.com/krishgarg344/crop_monitoring_sih/blob/main/dashboard_1.py) (Multi-tab dashboard), [`dashboard.py`](https://github.com/krishgarg344/crop_monitoring_sih/blob/main/dashboard.py) (Basic dashboard), [`model/crop_health_model.keras`](https://github.com/krishgarg344/crop_monitoring_sih/blob/main/model/crop_health_model.keras) (Crop health CNN), [`app.py`](https://github.com/krishgarg344/crop_monitoring_sih/blob/main/app.py) (Flask test API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_dashboard["Farm dashboard"]
  node_advanced_ui["Multi-tab dashboard<br/>[dashboard_1.py]"]
  node_basic_ui["Basic dashboard<br/>[dashboard.py]"]
  node_rasters["Processed indices"]
end

subgraph group_inference["Model inference"]
  node_index_stack["Index normalization<br/>[dashboard_1.py]"]
  node_patch_inference["Patch prediction<br/>[dashboard_1.py]"]
  node_cnn_model["Crop health CNN"]
  node_health_map["Health map<br/>[dashboard_1.py]"]
end

subgraph group_insights["Farm insights"]
  node_health_stats["Health distribution<br/>[dashboard_1.py]"]
  node_soil_metrics["Simulated soil<br/>[dashboard_1.py]"]
  node_pest_assessment["Pest risk rules<br/>[dashboard_1.py]"]
  node_farm_summary["Farm summary<br/>[dashboard_1.py]"]
end

subgraph group_api["Test API"]
  node_flask_api["Flask test API<br/>[app.py]"]
  node_api_model["Crop health CNN"]
end

node_farmer(("Farm user"))
node_api_user(("API caller"))

node_farmer -->|"selects farm"| node_advanced_ui
node_advanced_ui -->|"reads indices"| node_rasters
node_advanced_ui -->|"loads model"| node_cnn_model
node_advanced_ui -->|"normalizes indices"| node_index_stack
node_index_stack -->|"provides stack"| node_patch_inference
node_advanced_ui -->|"requests map"| node_patch_inference
node_patch_inference -->|"predicts patches"| node_cnn_model
node_patch_inference -->|"reconstructs map"| node_health_map
node_advanced_ui -->|"calculates percentages"| node_health_stats
node_health_map -->|"counts classes"| node_health_stats
node_advanced_ui -->|"generates metrics"| node_soil_metrics
node_advanced_ui -->|"assesses risk"| node_pest_assessment
node_health_stats -->|"supplies stress"| node_pest_assessment
node_advanced_ui -->|"renders summary"| node_farm_summary
node_health_stats -->|"supplies percentages"| node_farm_summary
node_farmer -->|"selects farm"| node_basic_ui
node_basic_ui -->|"reads indices"| node_rasters
node_basic_ui -->|"loads model"| node_cnn_model
node_basic_ui -->|"normalizes indices"| node_index_stack
node_basic_ui -->|"requests map"| node_patch_inference
node_patch_inference -->|"returns map"| node_basic_ui
node_api_user -.->|"requests prediction"| node_flask_api
node_flask_api -->|"loads and predicts"| node_api_model

click node_advanced_ui "https://github.com/krishgarg344/crop_monitoring_sih/blob/main/dashboard_1.py"
click node_basic_ui "https://github.com/krishgarg344/crop_monitoring_sih/blob/main/dashboard.py"
click node_rasters "https://github.com/krishgarg344/crop_monitoring_sih/tree/main/data/processed"
click node_index_stack "https://github.com/krishgarg344/crop_monitoring_sih/blob/main/dashboard_1.py"
click node_patch_inference "https://github.com/krishgarg344/crop_monitoring_sih/blob/main/dashboard_1.py"
click node_cnn_model "https://github.com/krishgarg344/crop_monitoring_sih/blob/main/model/crop_health_model.keras"
click node_health_map "https://github.com/krishgarg344/crop_monitoring_sih/blob/main/dashboard_1.py"
click node_health_stats "https://github.com/krishgarg344/crop_monitoring_sih/blob/main/dashboard_1.py"
click node_soil_metrics "https://github.com/krishgarg344/crop_monitoring_sih/blob/main/dashboard_1.py"
click node_pest_assessment "https://github.com/krishgarg344/crop_monitoring_sih/blob/main/dashboard_1.py"
click node_farm_summary "https://github.com/krishgarg344/crop_monitoring_sih/blob/main/dashboard_1.py"
click node_flask_api "https://github.com/krishgarg344/crop_monitoring_sih/blob/main/app.py"
click node_api_model "https://github.com/krishgarg344/crop_monitoring_sih/blob/main/model/crop_health_model.keras"

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_advanced_ui,node_basic_ui,node_rasters,node_farmer toneBlue
class node_index_stack,node_patch_inference,node_cnn_model,node_health_map toneAmber
class node_health_stats,node_soil_metrics,node_pest_assessment,node_farm_summary,node_api_user toneMint
class node_flask_api,node_api_model toneRose
```

## Components

### Farm dashboard

- [Multi-tab dashboard](https://github.com/krishgarg344/crop_monitoring_sih/blob/main/dashboard_1.py): `dashboard_1.py`
- [Basic dashboard](https://github.com/krishgarg344/crop_monitoring_sih/blob/main/dashboard.py): `dashboard.py`
- [Processed indices](https://github.com/krishgarg344/crop_monitoring_sih/tree/main/data/processed): `data/processed`

### Model inference

- [Index normalization](https://github.com/krishgarg344/crop_monitoring_sih/blob/main/dashboard_1.py): `dashboard_1.py`
- [Patch prediction](https://github.com/krishgarg344/crop_monitoring_sih/blob/main/dashboard_1.py): `dashboard_1.py`
- [Crop health CNN](https://github.com/krishgarg344/crop_monitoring_sih/blob/main/model/crop_health_model.keras): `model/crop_health_model.keras`
- [Health map](https://github.com/krishgarg344/crop_monitoring_sih/blob/main/dashboard_1.py): `dashboard_1.py`

### Farm insights

- [Health distribution](https://github.com/krishgarg344/crop_monitoring_sih/blob/main/dashboard_1.py): `dashboard_1.py`
- [Simulated soil](https://github.com/krishgarg344/crop_monitoring_sih/blob/main/dashboard_1.py): `dashboard_1.py`
- [Pest risk rules](https://github.com/krishgarg344/crop_monitoring_sih/blob/main/dashboard_1.py): `dashboard_1.py`
- [Farm summary](https://github.com/krishgarg344/crop_monitoring_sih/blob/main/dashboard_1.py): `dashboard_1.py`

### Test API

- [Flask test API](https://github.com/krishgarg344/crop_monitoring_sih/blob/main/app.py): `app.py`
- [Crop health CNN](https://github.com/krishgarg344/crop_monitoring_sih/blob/main/model/crop_health_model.keras): `model/crop_health_model.keras`

### Other components

- **Farm user**
- **API caller**

## Connections

- Farm user → Multi-tab dashboard: selects farm (evidence: `Readme.md`)
- Multi-tab dashboard → Processed indices: reads indices (evidence: `dashboard_1.py`)
- Multi-tab dashboard → Crop health CNN: loads model (evidence: `dashboard_1.py`)
- Multi-tab dashboard → Index normalization: normalizes indices (evidence: `dashboard_1.py`)
- Index normalization → Patch prediction: provides stack (evidence: `dashboard_1.py`)
- Multi-tab dashboard → Patch prediction: requests map (evidence: `dashboard_1.py`)
- Patch prediction → Crop health CNN: predicts patches (evidence: `dashboard_1.py`)
- Patch prediction → Health map: reconstructs map (evidence: `dashboard_1.py`)
- Multi-tab dashboard → Health distribution: calculates percentages (evidence: `dashboard_1.py`)
- Health map → Health distribution: counts classes (evidence: `dashboard_1.py`)
- Multi-tab dashboard → Simulated soil: generates metrics (evidence: `dashboard_1.py`)
- Multi-tab dashboard → Pest risk rules: assesses risk (evidence: `dashboard_1.py`)
- Health distribution → Pest risk rules: supplies stress (evidence: `dashboard_1.py`)
- Multi-tab dashboard → Farm summary: renders summary (evidence: `dashboard_1.py`)
- Health distribution → Farm summary: supplies percentages (evidence: `dashboard_1.py`)
- Farm user → Basic dashboard: selects farm (evidence: `dashboard.py`)
- Basic dashboard → Processed indices: reads indices (evidence: `dashboard.py`)
- Basic dashboard → Crop health CNN: loads model (evidence: `dashboard.py`)
- Basic dashboard → Index normalization: normalizes indices (evidence: `dashboard.py`)
- Basic dashboard → Patch prediction: requests map (evidence: `dashboard.py`)
- Patch prediction → Basic dashboard: returns map (evidence: `dashboard.py`)
- API caller → Flask test API: requests prediction (evidence: `app.py`)
- Flask test API → Crop health CNN: loads and predicts (evidence: `app.py`)
