# ujjwals653/crop-advisory architecture

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

- Interactive diagram: https://gitdiagram.com/ujjwals653/crop-advisory
- Repository: https://github.com/ujjwals653/crop-advisory

## Overview

Smart Agriculture is a farm and crop management PWA with monitoring, weather alerts, crop advice, and irrigation scheduling. A farmer manages farms and crops, records observations or sensor readings, then requests advice; the backend evaluates crop, sensor, weather, and agronomic-rule data, stores advisories and irrigation events, and presents them for review and action. Weather refresh and notifications are additional capabilities. Edges are limited to relationships shown in excerpts, the source index, or README; UI-to-endpoint calls are not mapped where their implementation was not shown.

Main entry points: [`backend/models.py`](https://github.com/ujjwals653/crop-advisory/blob/main/backend/models.py) (Domain records), [`backend/app.py`](https://github.com/ujjwals653/crop-advisory/blob/main/backend/app.py) (Flask application), [`frontend/src/App.jsx`](https://github.com/ujjwals653/crop-advisory/blob/main/frontend/src/App.jsx) (App routes), [`backend/services/advisory_engine.py`](https://github.com/ujjwals653/crop-advisory/blob/main/backend/services/advisory_engine.py) (Advisory engine)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Farmer PWA"]
  node_app["App routes<br/>[App.jsx]"]
  node_monitor["Crop monitoring<br/>[CropMonitor.jsx]"]
  node_advice_ui["Crop advice<br/>[CropAdvice.jsx]"]
  node_irrigation_ui["Irrigation<br/>[Irrigation.jsx]"]
  node_weather_ui["Weather<br/>[Weather.jsx]"]
  node_notifications_ui["Notifications<br/>[Notifications.jsx]"]
  node_settings_ui["Notification settings"]
  node_api_client["API client<br/>[api.js]"]
  node_auth["Authentication state<br/>[auth.jsx]"]
end

subgraph group_api["Backend API"]
  node_api_app["Flask application<br/>[app.py]"]
  node_auth_routes["Authentication routes<br/>[auth.py]"]
  node_farm_routes["Farm routes<br/>[farms.py]"]
  node_monitor_routes["Monitoring routes<br/>[monitoring.py]"]
  node_weather_routes["Weather routes<br/>[weather.py]"]
  node_advice_routes["Advisory routes<br/>[advisory.py]"]
  node_irrigation_routes["Irrigation routes<br/>[irrigation.py]"]
  node_notification_routes["Notification routes<br/>[notifications.py]"]
end

subgraph group_domain["Agriculture Services"]
  node_engine["Advisory engine<br/>[advisory_engine.py]"]
  node_rules["Agronomic rules<br/>[seed_rules.py]"]
  node_irrigation_service["Irrigation service<br/>[irrigation.py]"]
  node_weather_service["Weather service<br/>[weather.py]"]
  node_alerts["Alert evaluation<br/>[alerts.py]"]
  node_settings["System settings"]
  node_notifications["Notification dispatcher<br/>[notifications.py]"]
end

subgraph group_platform["Persistence and Delivery"]
  node_models["Domain records<br/>[models.py]"]
  node_database[("MySQL database")]
end

node_farmer(("Farmer"))
node_open_meteo["Open-Meteo"]

node_farmer -->|"uses"| node_app
node_app -->|"routes to"| node_monitor
node_app -->|"routes to"| node_advice_ui
node_app -->|"routes to"| node_irrigation_ui
node_app -->|"routes to"| node_weather_ui
node_app -->|"routes to"| node_notifications_ui
node_app -->|"routes to"| node_settings_ui
node_auth -->|"calls"| node_api_client
node_api_app -->|"registers"| node_auth_routes
node_api_app -->|"registers"| node_farm_routes
node_api_app -->|"registers"| node_monitor_routes
node_api_app -->|"registers"| node_weather_routes
node_api_app -->|"registers"| node_advice_routes
node_api_app -->|"registers"| node_irrigation_routes
node_api_app -->|"registers"| node_notification_routes
node_advice_routes -->|"calls"| node_engine
node_advice_routes -->|"reads and writes"| node_models
node_monitor_routes -->|"reads and writes"| node_models
node_farm_routes -->|"reads and writes"| node_models
node_auth_routes -->|"reads and writes"| node_models
node_weather_routes -->|"calls"| node_weather_service
node_irrigation_routes -->|"calls"| node_irrigation_service
node_irrigation_routes -->|"reads and writes"| node_models
node_notification_routes -->|"reads and writes"| node_models
node_engine -->|"uses weather"| node_weather_service
node_engine -->|"updates schedule"| node_irrigation_service
node_engine -->|"dispatches"| node_notifications
node_alerts -->|"notifies"| node_notifications
node_weather_service -->|"evaluates forecasts"| node_alerts
node_weather_service -->|"fetches forecast"| node_open_meteo
node_engine -->|"reads thresholds"| node_settings
node_alerts -->|"reads thresholds"| node_settings
node_weather_service -->|"reads refresh interval"| node_settings
node_notifications -->|"stores notifications"| node_models
node_models -.->|"persists records"| node_database
node_rules -->|"seeds rules"| node_models

click node_app "https://github.com/ujjwals653/crop-advisory/blob/main/frontend/src/App.jsx"
click node_monitor "https://github.com/ujjwals653/crop-advisory/blob/main/frontend/src/pages/CropMonitor.jsx"
click node_advice_ui "https://github.com/ujjwals653/crop-advisory/blob/main/frontend/src/pages/CropAdvice.jsx"
click node_irrigation_ui "https://github.com/ujjwals653/crop-advisory/blob/main/frontend/src/pages/Irrigation.jsx"
click node_weather_ui "https://github.com/ujjwals653/crop-advisory/blob/main/frontend/src/pages/Weather.jsx"
click node_notifications_ui "https://github.com/ujjwals653/crop-advisory/blob/main/frontend/src/pages/Notifications.jsx"
click node_settings_ui "https://github.com/ujjwals653/crop-advisory/blob/main/frontend/src/pages/NotificationSettings.jsx"
click node_api_client "https://github.com/ujjwals653/crop-advisory/blob/main/frontend/src/lib/api.js"
click node_auth "https://github.com/ujjwals653/crop-advisory/blob/main/frontend/src/lib/auth.jsx"
click node_api_app "https://github.com/ujjwals653/crop-advisory/blob/main/backend/app.py"
click node_auth_routes "https://github.com/ujjwals653/crop-advisory/blob/main/backend/routes/auth.py"
click node_farm_routes "https://github.com/ujjwals653/crop-advisory/blob/main/backend/routes/farms.py"
click node_monitor_routes "https://github.com/ujjwals653/crop-advisory/blob/main/backend/routes/monitoring.py"
click node_weather_routes "https://github.com/ujjwals653/crop-advisory/blob/main/backend/routes/weather.py"
click node_advice_routes "https://github.com/ujjwals653/crop-advisory/blob/main/backend/routes/advisory.py"
click node_irrigation_routes "https://github.com/ujjwals653/crop-advisory/blob/main/backend/routes/irrigation.py"
click node_notification_routes "https://github.com/ujjwals653/crop-advisory/blob/main/backend/routes/notifications.py"
click node_engine "https://github.com/ujjwals653/crop-advisory/blob/main/backend/services/advisory_engine.py"
click node_rules "https://github.com/ujjwals653/crop-advisory/blob/main/backend/seed_rules.py"
click node_irrigation_service "https://github.com/ujjwals653/crop-advisory/blob/main/backend/services/irrigation.py"
click node_weather_service "https://github.com/ujjwals653/crop-advisory/blob/main/backend/services/weather.py"
click node_alerts "https://github.com/ujjwals653/crop-advisory/blob/main/backend/services/alerts.py"
click node_settings "https://github.com/ujjwals653/crop-advisory/blob/main/backend/settings_service.py"
click node_notifications "https://github.com/ujjwals653/crop-advisory/blob/main/backend/services/notifications.py"
click node_models "https://github.com/ujjwals653/crop-advisory/blob/main/backend/models.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_app,node_monitor,node_advice_ui,node_irrigation_ui,node_weather_ui,node_notifications_ui,node_settings_ui,node_api_client,node_auth toneBlue
class node_api_app,node_auth_routes,node_farm_routes,node_monitor_routes,node_weather_routes,node_advice_routes,node_irrigation_routes,node_notification_routes toneAmber
class node_engine,node_rules,node_irrigation_service,node_weather_service,node_alerts,node_settings,node_notifications toneMint
class node_models,node_database toneRose
class node_farmer,node_open_meteo toneIndigo
```

## Components

### Farmer PWA

- [App routes](https://github.com/ujjwals653/crop-advisory/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Crop monitoring](https://github.com/ujjwals653/crop-advisory/blob/main/frontend/src/pages/CropMonitor.jsx): `frontend/src/pages/CropMonitor.jsx`
- [Crop advice](https://github.com/ujjwals653/crop-advisory/blob/main/frontend/src/pages/CropAdvice.jsx): `frontend/src/pages/CropAdvice.jsx`
- [Irrigation](https://github.com/ujjwals653/crop-advisory/blob/main/frontend/src/pages/Irrigation.jsx): `frontend/src/pages/Irrigation.jsx`
- [Weather](https://github.com/ujjwals653/crop-advisory/blob/main/frontend/src/pages/Weather.jsx): `frontend/src/pages/Weather.jsx`
- [Notifications](https://github.com/ujjwals653/crop-advisory/blob/main/frontend/src/pages/Notifications.jsx): `frontend/src/pages/Notifications.jsx`
- [Notification settings](https://github.com/ujjwals653/crop-advisory/blob/main/frontend/src/pages/NotificationSettings.jsx): `frontend/src/pages/NotificationSettings.jsx`
- [API client](https://github.com/ujjwals653/crop-advisory/blob/main/frontend/src/lib/api.js): `frontend/src/lib/api.js`
- [Authentication state](https://github.com/ujjwals653/crop-advisory/blob/main/frontend/src/lib/auth.jsx): `frontend/src/lib/auth.jsx`

### Backend API

- [Flask application](https://github.com/ujjwals653/crop-advisory/blob/main/backend/app.py): `backend/app.py`
- [Authentication routes](https://github.com/ujjwals653/crop-advisory/blob/main/backend/routes/auth.py): `backend/routes/auth.py`
- [Farm routes](https://github.com/ujjwals653/crop-advisory/blob/main/backend/routes/farms.py): `backend/routes/farms.py`
- [Monitoring routes](https://github.com/ujjwals653/crop-advisory/blob/main/backend/routes/monitoring.py): `backend/routes/monitoring.py`
- [Weather routes](https://github.com/ujjwals653/crop-advisory/blob/main/backend/routes/weather.py): `backend/routes/weather.py`
- [Advisory routes](https://github.com/ujjwals653/crop-advisory/blob/main/backend/routes/advisory.py): `backend/routes/advisory.py`
- [Irrigation routes](https://github.com/ujjwals653/crop-advisory/blob/main/backend/routes/irrigation.py): `backend/routes/irrigation.py`
- [Notification routes](https://github.com/ujjwals653/crop-advisory/blob/main/backend/routes/notifications.py): `backend/routes/notifications.py`

### Agriculture Services

- [Advisory engine](https://github.com/ujjwals653/crop-advisory/blob/main/backend/services/advisory_engine.py): `backend/services/advisory_engine.py`
- [Agronomic rules](https://github.com/ujjwals653/crop-advisory/blob/main/backend/seed_rules.py): `backend/seed_rules.py`
- [Irrigation service](https://github.com/ujjwals653/crop-advisory/blob/main/backend/services/irrigation.py): `backend/services/irrigation.py`
- [Weather service](https://github.com/ujjwals653/crop-advisory/blob/main/backend/services/weather.py): `backend/services/weather.py`
- [Alert evaluation](https://github.com/ujjwals653/crop-advisory/blob/main/backend/services/alerts.py): `backend/services/alerts.py`
- [System settings](https://github.com/ujjwals653/crop-advisory/blob/main/backend/settings_service.py): `backend/settings_service.py`
- [Notification dispatcher](https://github.com/ujjwals653/crop-advisory/blob/main/backend/services/notifications.py): `backend/services/notifications.py`

### Persistence and Delivery

- [Domain records](https://github.com/ujjwals653/crop-advisory/blob/main/backend/models.py): `backend/models.py`
- **MySQL database**

### Other components

- **Farmer**
- **Open-Meteo**

## Connections

- Farmer → App routes: uses (evidence: `README.md`)
- App routes → Crop monitoring: routes to (evidence: `frontend/src/App.jsx`)
- App routes → Crop advice: routes to (evidence: `frontend/src/App.jsx`)
- App routes → Irrigation: routes to (evidence: `frontend/src/App.jsx`)
- App routes → Weather: routes to (evidence: `frontend/src/App.jsx`)
- App routes → Notifications: routes to (evidence: `frontend/src/App.jsx`)
- App routes → Notification settings: routes to (evidence: `frontend/src/App.jsx`)
- Authentication state → API client: calls (evidence: `frontend/src/lib/auth.jsx`)
- Flask application → Authentication routes: registers (evidence: `backend/app.py`)
- Flask application → Farm routes: registers (evidence: `backend/app.py`)
- Flask application → Monitoring routes: registers (evidence: `backend/app.py`)
- Flask application → Weather routes: registers (evidence: `backend/app.py`)
- Flask application → Advisory routes: registers (evidence: `backend/app.py`)
- Flask application → Irrigation routes: registers (evidence: `backend/app.py`)
- Flask application → Notification routes: registers (evidence: `backend/app.py`)
- Advisory routes → Advisory engine: calls (evidence: `backend/routes/advisory.py`)
- Advisory routes → Domain records: reads and writes (evidence: `backend/routes/advisory.py`)
- Monitoring routes → Domain records: reads and writes (evidence: `backend/routes/monitoring.py`)
- Farm routes → Domain records: reads and writes (evidence: `backend/routes/farms.py`)
- Authentication routes → Domain records: reads and writes (evidence: `backend/routes/auth.py`)
- Weather routes → Weather service: calls (evidence: `backend/routes/weather.py`)
- Irrigation routes → Irrigation service: calls (evidence: `backend/routes/irrigation.py`)
- Irrigation routes → Domain records: reads and writes (evidence: `backend/routes/irrigation.py`)
- Notification routes → Domain records: reads and writes (evidence: `backend/routes/notifications.py`)
- Advisory engine → Weather service: uses weather (evidence: `backend/services/advisory_engine.py`)
- Advisory engine → Irrigation service: updates schedule (evidence: `backend/services/advisory_engine.py`)
- Advisory engine → Notification dispatcher: dispatches (evidence: `backend/services/advisory_engine.py`)
- Alert evaluation → Notification dispatcher: notifies (evidence: `backend/services/alerts.py`)
- Weather service → Alert evaluation: evaluates forecasts (evidence: `backend/services/weather.py`)
- Weather service → Open-Meteo: fetches forecast (evidence: `backend/services/weather.py`)
- Advisory engine → System settings: reads thresholds (evidence: `backend/services/advisory_engine.py`)
- Alert evaluation → System settings: reads thresholds (evidence: `backend/services/alerts.py`)
- Weather service → System settings: reads refresh interval (evidence: `backend/services/weather.py`)
- Notification dispatcher → Domain records: stores notifications (evidence: `backend/services/notifications.py`)
- Domain records → MySQL database: persists records (evidence: `README.md`)
- Agronomic rules → Domain records: seeds rules (evidence: `backend/seed_rules.py`)
