# anujsoni9450/agri-vision-final architecture

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

- Interactive diagram: https://gitdiagram.com/anujsoni9450/agri-vision-final
- Repository: https://github.com/anujsoni9450/agri-vision-final

## Overview

Agri-Vision AI is a Streamlit farmer-support application. Its primary workflow is leaf-image diagnosis, followed by confidence reporting and localized treatment advice, with optional voice playback. Separate pages provide weather-based spraying guidance, farmer support links, market searches, and feedback collection. The README documents the diagnosis model and AI capabilities; the sampled pages show the other page workflows. `main.py` was not sampled, so its internal calls and page-dispatch behavior are not verified.

Main entry points: [`main.py`](https://github.com/anujsoni9450/agri-vision-final/blob/main/main.py) (Diagnosis dashboard), [`pages/1_Farmer_Support.py`](https://github.com/anujsoni9450/agri-vision-final/blob/main/pages/1_Farmer_Support.py) (Farmer support), [`pages/3_Analysis.py`](https://github.com/anujsoni9450/agri-vision-final/blob/main/pages/3_Analysis.py) (Weather spraying analysis), [`pages/4_Market.py`](https://github.com/anujsoni9450/agri-vision-final/blob/main/pages/4_Market.py) (Treatment and store search)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_diagnosis["Crop diagnosis"]
  node_dashboard["Diagnosis dashboard<br/>[main.py]"]
  node_vit_model["Fine-tuned ViT"]
end

subgraph group_advice["Treatment advice"]
  node_openai{{"OpenAI GPT-4o Mini"}}
  node_treatment_advice["Localized treatment advice<br/>[main.py]"]
  node_gtts{{"Google Text-to-Speech"}}
end

subgraph group_farmer_tools["Farmer tools"]
  node_farmer_support["Farmer support"]
  node_maps{{"Google Maps"}}
  node_state_portals{{"State agriculture portals"}}
  node_weather_analysis["Weather spraying analysis<br/>[3_Analysis.py]"]
  node_open_meteo{{"Open-Meteo forecast"}}
  node_market_search["Treatment and store search<br/>[4_Market.py]"]
  node_retailers{{"Online retailers"}}
end

subgraph group_engagement["Feedback and history"]
  node_feedback_form["Feedback form<br/>[2_Feedback.py]"]
  node_feedback_log["Feedback CSV<br/>[feedback_log.csv]"]
  node_scan_history["Scan history display<br/>[3_Analysis.py]"]
  node_history_log["Scan history CSV<br/>[history_log.csv]"]
end

node_farmer(("Farmer"))

node_farmer -->|"runs app"| node_dashboard
node_dashboard -->|"classifies leaves"| node_vit_model
node_dashboard -->|"requests advice"| node_openai
node_dashboard -.->|"presents advice"| node_treatment_advice
node_dashboard -->|"requests speech"| node_gtts
node_farmer_support -->|"links to"| node_maps
node_farmer_support -->|"links to"| node_state_portals
node_weather_analysis -->|"fetches forecast"| node_open_meteo
node_weather_analysis -->|"reads history"| node_history_log
node_market_search -->|"links to products"| node_retailers
node_market_search -->|"searches stores"| node_maps
node_feedback_form -->|"appends feedback"| node_feedback_log

click node_dashboard "https://github.com/anujsoni9450/agri-vision-final/blob/main/main.py"
click node_vit_model "https://github.com/anujsoni9450/agri-vision-final/tree/main/crop_final_model"
click node_treatment_advice "https://github.com/anujsoni9450/agri-vision-final/blob/main/main.py"
click node_farmer_support "https://github.com/anujsoni9450/agri-vision-final/blob/main/pages/1_Farmer_Support.py"
click node_weather_analysis "https://github.com/anujsoni9450/agri-vision-final/blob/main/pages/3_Analysis.py"
click node_market_search "https://github.com/anujsoni9450/agri-vision-final/blob/main/pages/4_Market.py"
click node_feedback_form "https://github.com/anujsoni9450/agri-vision-final/blob/main/pages/2_Feedback.py"
click node_feedback_log "https://github.com/anujsoni9450/agri-vision-final/blob/main/feedback_log.csv"
click node_scan_history "https://github.com/anujsoni9450/agri-vision-final/blob/main/pages/3_Analysis.py"
click node_history_log "https://github.com/anujsoni9450/agri-vision-final/blob/main/history_log.csv"

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_dashboard,node_vit_model toneBlue
class node_openai,node_treatment_advice,node_gtts toneAmber
class node_farmer_support,node_maps,node_state_portals,node_weather_analysis,node_open_meteo,node_market_search,node_retailers toneMint
class node_feedback_form,node_feedback_log,node_scan_history,node_history_log toneRose
class node_farmer toneIndigo
```

## Components

### Crop diagnosis

- [Diagnosis dashboard](https://github.com/anujsoni9450/agri-vision-final/blob/main/main.py): `main.py`
- [Fine-tuned ViT](https://github.com/anujsoni9450/agri-vision-final/tree/main/crop_final_model): `crop_final_model`

### Treatment advice

- **OpenAI GPT-4o Mini**
- [Localized treatment advice](https://github.com/anujsoni9450/agri-vision-final/blob/main/main.py): `main.py`
- **Google Text-to-Speech**

### Farmer tools

- [Farmer support](https://github.com/anujsoni9450/agri-vision-final/blob/main/pages/1_Farmer_Support.py): `pages/1_Farmer_Support.py`
- **Google Maps**
- **State agriculture portals**
- [Weather spraying analysis](https://github.com/anujsoni9450/agri-vision-final/blob/main/pages/3_Analysis.py): `pages/3_Analysis.py`
- **Open-Meteo forecast**
- [Treatment and store search](https://github.com/anujsoni9450/agri-vision-final/blob/main/pages/4_Market.py): `pages/4_Market.py`
- **Online retailers**

### Feedback and history

- [Feedback form](https://github.com/anujsoni9450/agri-vision-final/blob/main/pages/2_Feedback.py): `pages/2_Feedback.py`
- [Feedback CSV](https://github.com/anujsoni9450/agri-vision-final/blob/main/feedback_log.csv): `feedback_log.csv`
- [Scan history display](https://github.com/anujsoni9450/agri-vision-final/blob/main/pages/3_Analysis.py): `pages/3_Analysis.py`
- [Scan history CSV](https://github.com/anujsoni9450/agri-vision-final/blob/main/history_log.csv): `history_log.csv`

### Other components

- **Farmer**

## Connections

- Farmer → Diagnosis dashboard: runs app (evidence: `README.md`)
- Diagnosis dashboard → Fine-tuned ViT: classifies leaves (evidence: `README.md`)
- Diagnosis dashboard → OpenAI GPT-4o Mini: requests advice (evidence: `README.md`)
- Diagnosis dashboard → Localized treatment advice: presents advice
- Diagnosis dashboard → Google Text-to-Speech: requests speech (evidence: `README.md`)
- Farmer support → Google Maps: links to (evidence: `pages/1_Farmer_Support.py`)
- Farmer support → State agriculture portals: links to (evidence: `pages/1_Farmer_Support.py`)
- Weather spraying analysis → Open-Meteo forecast: fetches forecast (evidence: `pages/3_Analysis.py`)
- Weather spraying analysis → Scan history CSV: reads history (evidence: `pages/3_Analysis.py`)
- Treatment and store search → Online retailers: links to products (evidence: `pages/4_Market.py`)
- Treatment and store search → Google Maps: searches stores (evidence: `pages/4_Market.py`)
- Feedback form → Feedback CSV: appends feedback (evidence: `pages/2_Feedback.py`)
