How ashwin-r2/croprecomendation works
AgriPredict serves two prediction workflows: crop classification and yield regression. Requests pass through Flask routes, server-side validation, and startup-loaded services/models; yield forecasts additionally use historical regional yields and derive production from predicted yield × area. The broader product also includes model training/evaluation, a metrics page, prediction history, and both web and REST interfaces. Some route and storage wiring is documented rather than excerpted, so those edges cite the README; unsampled internals are not inferred.
Main entry points: web.py Web routes · train_yield_model.py Yield model training · yield_service.py Yield service · train_crop_model.py Crop model training
Components 23
User interfaces
- Forms and results
templates - Model performance page
templates/performance.html - Browser interactions
static/js/app.js
Flask serving
- Web routes
app/routes/web.py - REST API
app/routes/api.py - Input validation
app/validators/input_validator.py - Crop service
app/services/crop_service.py - Yield service
app/services/yield_service.py - History service
app/services/history_service.py - App startup
app/app.py
Prediction models
- Crop prediction
src/models/crop_model.py - Yield prediction
src/models/yield_model.py - Yield history features
src/data/features.py
ML lifecycle
- Crop model training
src/training/train_crop_model.py - Yield model training
src/training/train_yield_model.py - Dataset preprocessing
src/data/preprocessing.py - Model evaluation
src/evaluation/metrics.py - ML paths and settings
src/settings.py
Persisted data
- Crop and yield datasets
data/raw - Saved models and metadata
models - Prediction history
- Historical yields
models/yield_history.csv
Other components
- Farmer / client
Connections 36
- Farmer / client → Web routes: submits forms
README.md - Farmer / client → REST API: sends JSON
README.md - Web routes → Input validation: validates inputs
README.md - Web routes → Crop service: requests crop
README.md - Web routes → Yield service: requests forecast
README.md - REST API → Crop service: requests prediction
README.md - REST API → Yield service: requests prediction
README.md - Crop service → Input validation: validates input
app/services/crop_service.py - Crop service → Crop prediction: predicts with
app/services/crop_service.py - Yield service → Input validation: validates input
app/services/yield_service.py - Yield service → Yield prediction: predicts with
app/services/yield_service.py - Yield prediction → Yield history features: adds history features
src/models/yield_model.py - Yield service → Historical yields: loads history
README.md - Web routes → Forms and results: renders pages
README.md - Browser interactions → Forms and results: supports forms
- Web routes → History service: serves history
README.md - History service → Prediction history: reads and writes
README.md - Web routes → Model performance page: serves metrics page
README.md - App startup → Crop service: creates at startup
app/app.py - App startup → Yield service: creates at startup
app/app.py - App startup → Web routes: registers routes
app/app.py - App startup → REST API: registers routes
app/app.py - Crop model training → Dataset preprocessing: uses pipelines
src/training/train_crop_model.py - Crop model training → Crop prediction: selects classifier
src/training/train_crop_model.py - Crop model training → Model evaluation: computes metrics
src/training/train_crop_model.py - Yield model training → Dataset preprocessing: uses pipelines
src/training/train_yield_model.py - Yield model training → Yield prediction: selects regressor
src/training/train_yield_model.py - Yield model training → Yield history features: builds features
src/training/train_yield_model.py - Yield model training → Model evaluation: computes metrics
src/training/train_yield_model.py - Crop model training → Crop and yield datasets: trains from data
README.md - Yield model training → Crop and yield datasets: trains from data
README.md - Crop model training → Saved models and metadata: saves model results
README.md - Yield model training → Saved models and metadata: saves model results
README.md - ML paths and settings → Crop and yield datasets: configures paths
src/settings.py - ML paths and settings → Saved models and metadata: configures paths
src/settings.py - ML paths and settings → Prediction history: configures path
src/settings.py