# arnavvtt/smartagri architecture

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

- Interactive diagram: https://gitdiagram.com/arnavvtt/smartagri
- Repository: https://github.com/arnavvtt/smartagri

## Overview

Smart Agriculture Portal is a Django application for farmers. The main workflow combines account and crop management with location-aware weather, crop advisories, mandi prices, and farm-planning support. Views coordinate requests and domain logic; models hold crop and profile data, while templates present the results. The README documents the external weather and government market-data integrations. Several product areas are documented but their implementation was not fully sampled, so those relationships are shown only where the README supports them.

Main entry points: [`agriapp/views.py`](https://github.com/arnavvtt/smartagri/blob/main/agriapp/views.py) (Request Views), [`agriapp/urls.py`](https://github.com/arnavvtt/smartagri/blob/main/agriapp/urls.py) (App Routes), [`agriapp/models.py`](https://github.com/arnavvtt/smartagri/blob/main/agriapp/models.py) (Farm Records), [`static/js/main.js`](https://github.com/arnavvtt/smartagri/blob/main/static/js/main.js) (Insight Refresh UI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web and Accounts"]
  node_routes["App Routes<br/>[urls.py]"]
  node_views["Request Views<br/>[views.py]"]
  node_templates["Page Templates"]
  node_auth["Authentication<br/>[views.py]"]
  node_browser["Insight Refresh UI<br/>[main.js]"]
end

subgraph group_farm["Farm Management"]
  node_cropforms["Crop Forms<br/>[forms.py]"]
  node_farmdata[("Farm Records<br/>[models.py]")]
  node_sqlite[("SQLite Database<br/>[db.sqlite3]")]
end

subgraph group_insights["Weather Insights"]
  node_weather["Weather Fetch<br/>[views.py]"]
  node_forecast["Forecast Analysis"]
  node_crop_rules["Crop Rules"]
  node_location["City State Map<br/>[city_state_map.py]"]
  node_state_risks["State Risk Advisories<br/>[state_risks.py]"]
  node_farm_utils["Farm Summaries<br/>[utils.py]"]
end

subgraph group_market["Market and Planning"]
  node_mandi["Mandi Prices<br/>[views.py]"]
  node_planner["Farm Planner<br/>[views.py]"]
end

node_farmer(("Farmer"))
node_openweather{{"OpenWeather API"}}
node_apmc{{"Government APMC API"}}

node_farmer -->|"requests pages"| node_routes
node_routes -->|"dispatches"| node_views
node_views -->|"renders pages"| node_templates
node_views -->|"handles login"| node_auth
node_views -->|"uses forms"| node_cropforms
node_views -->|"queries crops"| node_farmdata
node_farmdata -.->|"persists records"| node_sqlite
node_views -->|"gets weather"| node_weather
node_weather -.->|"fetches forecast"| node_openweather
node_views -->|"analyzes forecast"| node_forecast
node_views -->|"uses crop rules"| node_crop_rules
node_views -->|"maps location"| node_location
node_views -->|"gets risk advisories"| node_state_risks
node_views -->|"builds summaries"| node_farm_utils
node_views -->|"serves prices"| node_mandi
node_mandi -->|"fetches prices"| node_apmc
node_views -->|"serves planning"| node_planner
node_browser -->|"refreshes insight"| node_routes

click node_routes "https://github.com/arnavvtt/smartagri/blob/main/agriapp/urls.py"
click node_views "https://github.com/arnavvtt/smartagri/blob/main/agriapp/views.py"
click node_templates "https://github.com/arnavvtt/smartagri/tree/main/templates"
click node_auth "https://github.com/arnavvtt/smartagri/blob/main/agriapp/views.py"
click node_cropforms "https://github.com/arnavvtt/smartagri/blob/main/agriapp/forms.py"
click node_farmdata "https://github.com/arnavvtt/smartagri/blob/main/agriapp/models.py"
click node_weather "https://github.com/arnavvtt/smartagri/blob/main/agriapp/views.py"
click node_forecast "https://github.com/arnavvtt/smartagri/blob/main/agriapp/weather_forecast.py"
click node_crop_rules "https://github.com/arnavvtt/smartagri/blob/main/agriapp/crop_weather_rules.py"
click node_location "https://github.com/arnavvtt/smartagri/blob/main/agriapp/city_state_map.py"
click node_state_risks "https://github.com/arnavvtt/smartagri/blob/main/agriapp/state_risks.py"
click node_farm_utils "https://github.com/arnavvtt/smartagri/blob/main/agriapp/utils.py"
click node_mandi "https://github.com/arnavvtt/smartagri/blob/main/agriapp/views.py"
click node_planner "https://github.com/arnavvtt/smartagri/blob/main/agriapp/views.py"
click node_browser "https://github.com/arnavvtt/smartagri/blob/main/static/js/main.js"
click node_sqlite "https://github.com/arnavvtt/smartagri/blob/main/db.sqlite3"

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_routes,node_views,node_templates,node_auth,node_browser toneBlue
class node_cropforms,node_farmdata,node_sqlite toneAmber
class node_weather,node_forecast,node_crop_rules,node_location,node_state_risks,node_farm_utils,node_openweather,node_apmc toneMint
class node_mandi,node_planner toneRose
class node_farmer toneIndigo
```

## Components

### Web and Accounts

- [App Routes](https://github.com/arnavvtt/smartagri/blob/main/agriapp/urls.py): `agriapp/urls.py`
- [Request Views](https://github.com/arnavvtt/smartagri/blob/main/agriapp/views.py): `agriapp/views.py`
- [Page Templates](https://github.com/arnavvtt/smartagri/tree/main/templates): `templates`
- [Authentication](https://github.com/arnavvtt/smartagri/blob/main/agriapp/views.py): `agriapp/views.py`
- [Insight Refresh UI](https://github.com/arnavvtt/smartagri/blob/main/static/js/main.js): `static/js/main.js`

### Farm Management

- [Crop Forms](https://github.com/arnavvtt/smartagri/blob/main/agriapp/forms.py): `agriapp/forms.py`
- [Farm Records](https://github.com/arnavvtt/smartagri/blob/main/agriapp/models.py): `agriapp/models.py`
- [SQLite Database](https://github.com/arnavvtt/smartagri/blob/main/db.sqlite3): `db.sqlite3`

### Weather Insights

- [Weather Fetch](https://github.com/arnavvtt/smartagri/blob/main/agriapp/views.py): `agriapp/views.py`
- [Forecast Analysis](https://github.com/arnavvtt/smartagri/blob/main/agriapp/weather_forecast.py): `agriapp/weather_forecast.py`
- [Crop Rules](https://github.com/arnavvtt/smartagri/blob/main/agriapp/crop_weather_rules.py): `agriapp/crop_weather_rules.py`
- [City State Map](https://github.com/arnavvtt/smartagri/blob/main/agriapp/city_state_map.py): `agriapp/city_state_map.py`
- [State Risk Advisories](https://github.com/arnavvtt/smartagri/blob/main/agriapp/state_risks.py): `agriapp/state_risks.py`
- [Farm Summaries](https://github.com/arnavvtt/smartagri/blob/main/agriapp/utils.py): `agriapp/utils.py`

### Market and Planning

- [Mandi Prices](https://github.com/arnavvtt/smartagri/blob/main/agriapp/views.py): `agriapp/views.py`
- [Farm Planner](https://github.com/arnavvtt/smartagri/blob/main/agriapp/views.py): `agriapp/views.py`

### Other components

- **Farmer**
- **OpenWeather API**
- **Government APMC API**

## Connections

- Farmer → App Routes: requests pages (evidence: `agriapp/urls.py`)
- App Routes → Request Views: dispatches (evidence: `agriapp/urls.py`)
- Request Views → Page Templates: renders pages (evidence: `agriapp/views.py`)
- Request Views → Authentication: handles login (evidence: `agriapp/views.py`)
- Request Views → Crop Forms: uses forms (evidence: `agriapp/views.py`)
- Request Views → Farm Records: queries crops (evidence: `agriapp/views.py`)
- Farm Records → SQLite Database: persists records (evidence: `README.md`)
- Request Views → Weather Fetch: gets weather (evidence: `agriapp/views.py`)
- Weather Fetch → OpenWeather API: fetches forecast (evidence: `README.md`)
- Request Views → Forecast Analysis: analyzes forecast (evidence: `agriapp/views.py`)
- Request Views → Crop Rules: uses crop rules (evidence: `agriapp/views.py`)
- Request Views → City State Map: maps location (evidence: `agriapp/views.py`)
- Request Views → State Risk Advisories: gets risk advisories (evidence: `agriapp/views.py`)
- Request Views → Farm Summaries: builds summaries (evidence: `agriapp/views.py`)
- Request Views → Mandi Prices: serves prices (evidence: `agriapp/views.py`)
- Mandi Prices → Government APMC API: fetches prices (evidence: `README.md`)
- Request Views → Farm Planner: serves planning (evidence: `README.md`)
- Insight Refresh UI → App Routes: refreshes insight (evidence: `static/js/main.js`)
