AgroSmart is a starter web application for the mini project: "AgroSmart - Smart Crop Advisory and Disease Detection System."
This version implements the milestone modules end-to-end:
- User registration, login, and farmer profile
- Crop recommendation with an ML hook (RandomForest) and fallback logic
- Fertilizer recommendation with history and nutrient status chart
- Leaf disease detection with a CNN/Keras hook (when a model exists) and fallback logic
- REST APIs for crop, fertilizer, and disease flows
- SQLite history storage for predictions and recommendations
- Python 3.13+
- Flask
- SQLite (via SQLAlchemy)
AgroSmart/
├── app.py
├── requirements.txt
├── requirements-ml.txt
├── requirements-dev.txt
├── agrosmart/
│ ├── __init__.py
│ ├── config.py
│ ├── db.py
│ ├── models.py
│ ├── routes.py
│ ├── routes_api.py
│ ├── routes_auth.py
│ ├── routes_services.py
│ ├── services/
│ │ ├── advisory.py
│ │ ├── crop_ml.py
│ │ └── disease.py
│ └── templates/
│ ├── base.html
│ ├── public_home.html
│ ├── dashboard.html
│ ├── auth/
│ └── services/
└── static/
└── styles.css
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
python3 app.pyThen open http://127.0.0.1:5000.
This repo includes a basic render.yaml for a Flask + Gunicorn deploy.
- Push this repo to GitHub.
- In Render, create a new Blueprint from the repo (it will read
render.yaml). - Add environment variables in Render:
DATABASE_URL:- Recommended: use Render Postgres (managed).
- If you insist on MySQL: you must run your own MySQL as a private service and set
DATABASE_URLtomysql://...(the app auto-normalizes tomysql+pymysql://).
- SMTP variables:
SMTP_HOST,SMTP_PORT,SMTP_USER,SMTP_PASS,SMTP_FROM,SMTP_TLS,SMTP_SSL.
Note: For production, use a persistent disk or external storage for uploads/ (otherwise uploaded images may not persist across deploys).
Recommended persistent paths (if you mount a Render Disk at /var/data):
UPLOAD_FOLDER=/var/data/uploadsMODEL_STORE=/var/data/models
By default, members must verify an OTP sent to their email before logging in.
Set SMTP settings (example):
export REQUIRE_EMAIL_OTP=1
export EMAIL_DELIVERY=smtp
export SMTP_HOST="smtp.yourprovider.com"
export SMTP_PORT="587"
export SMTP_USER="your-agrosmart-email@domain.com"
export SMTP_PASS="your-smtp-password-or-app-password"
export SMTP_FROM="AgroSmart <your-agrosmart-email@domain.com>"
export SMTP_TLS=1
export SMTP_SSL=0If you want to disable OTP locally:
export REQUIRE_EMAIL_OTP=0Crop model (RandomForest):
pip install -r requirements-ml.txt
python3 scripts/train_crop_model.py --data data/sample_crop_data.csv --out models/crop_model.joblibDisease model (CNN/Keras, requires TensorFlow installed for your machine):
python3 scripts/train_disease_model.py --data_dir /path/to/leaf_dataset --out models/disease_model.kerasOnce models exist, the web app auto-uses them; otherwise it falls back to safe placeholder logic.
POST /api/crop/predict(JSON)POST /api/fertilizer/recommend(JSON)POST /api/disease/predict(multipart:leaf_image)
All APIs require login (session cookie).
Admin dashboard: /admin/ (requires admin login).
Admin login page: /admin/login
Promote a user to admin:
python3 scripts/make_admin.py --email you@example.comAdmin login details:
- Use the same email/password as the promoted user.
- After login, admin session is stored separately as
admin_user_id.
Set an API key:
export OPENWEATHER_API_KEY="your_key_here"
Then on Crop Recommendation page, click "Auto-fill weather". It uses your Profile location by default.
- Language selector is in the top bar (English/Hindi/Telugu).
- Each module page has Speak/Stop buttons (browser Text-to-Speech via Web Speech API).