How anushkagupta12/smart-agriculture-system works
CP-SAS is a Flask-backed smart-agriculture dashboard for plant-disease detection, sensor monitoring and irrigation control. The main user workflow is submitting a leaf image through the dashboard, receiving a model prediction enriched with disease remedies and sensor context, and viewing the result. In parallel, ESP32 readings feed sensor history and automatic irrigation logic; dashboard controls can also change irrigation mode or state. The backend is largely concentrated in app.py. Some routes and dashboard sections are documented but not shown in the excerpts, so those links rely on README evidence.
Main entry points: app.py REST endpoints · dashboard.js Dashboard interactions · data SQLite data store · index.html Web dashboard
Components 18
Dashboard
- Web dashboard
templates/index.html - Dashboard interactions
static/js/dashboard.js
Flask API
- REST endpoints
app.py - System status
app.py
Plant diagnosis
- Leaf image upload
app.py - Disease classifier
app.py - Remedy lookup
app.py - Disease knowledge base
data/remedies.json - AI recommendation
app.py - Model class metadata
model/class_names.json
Sensors and irrigation
- Sensor ingestion
app.py - Sensor history and stats
app.py - Irrigation control
app.py - Irrigation event log
app.py
Agricultural data
- SQLite data store
data
Other components
- Farm operator
- ESP32 device
- Gemini service
Connections 26
- Farm operator → Web dashboard: uses
README.md - Web dashboard → Dashboard interactions: loads
README.md - Dashboard interactions → REST endpoints: requests API
static/js/dashboard.js - Farm operator → Dashboard interactions: submits image
README.md - REST endpoints → Leaf image upload: routes prediction
README.md - Leaf image upload → Disease classifier: invokes inference
app.py - Disease classifier → Model class metadata: loads classes
app.py - Leaf image upload → Remedy lookup: looks up result
app.py - Remedy lookup → Disease knowledge base: reads remedies
app.py - Leaf image upload → AI recommendation: requests advice
app.py - AI recommendation → Gemini service: requests recommendation
- ESP32 device → Sensor ingestion: sends readings
README.md - REST endpoints → Sensor ingestion: routes readings
README.md - Sensor ingestion → SQLite data store: writes readings
app.py - Sensor history and stats → SQLite data store: queries readings
app.py - REST endpoints → Sensor history and stats: serves history
README.md - Sensor ingestion → Irrigation control: applies auto rules
app.py - Irrigation control → Irrigation event log: records changes
app.py - Irrigation event log → SQLite data store: writes events
app.py - Irrigation control → SQLite data store: stores state
app.py - REST endpoints → Irrigation control: routes commands
README.md - REST endpoints → System status: serves health
README.md - System status → SQLite data store: reports database
app.py - Dashboard interactions → Sensor history and stats: loads charts
static/js/dashboard.js - Dashboard interactions → Irrigation control: sends controls
static/js/dashboard.js - Dashboard interactions → System status: checks health
static/js/dashboard.js