How himani9545/agrosolution works
1. Overall shape
- This repository is a Python-based agricultural decision-support web app.
- The system is split into a thin web/UI layer, a set of ML recommendation modules, and bundled training/runtime artifacts used for inference.
2. Primary entrypoint and web app boundary
- UI - Copy/appUi.py is the main application entrypoint.
- It serves the HTML pages in templates/, connects user actions to model predictions, and likely acts as the central router/controller for the site.
3. Presentation layer
- templates/ contains the user-facing pages: home, about, crops, crop info, and three embedded tool pages for crop, fertilizer, and pesticide flows.
- static/ holds the CSS and JavaScript that shape the experience, including animations, image handling, login/signup behavior, and language switching.
4. Multilingual UI support
- static/js/language.js indicates client-side language switching between English and Hindi.
- This is a UI concern rather than a model concern; it changes presentation text without affecting prediction logic.
5. Crop recommendation subsystem
- models/crop.py and models/crop_app.py form the crop recommendation logic.
- The runtime prediction path uses crop_recommendation_model.pkl plus crop_label_encoder.pkl to map environmental inputs into a crop suggestion.
6. Fertilizer recommendation subsystem
- models/fertilizer.py and models/ferti_app.py implement fertilizer guidance.
- It uses fertilizer_recommendation_model.pkl, fertilizer_dosage_model.pkl, and fertilizer_label_encoder.pkl, suggesting both product selection and dosage/amount prediction.
- The supporting datasets live in data/expanded_fertilizer_dataset.csv and data/updated_fertilizer_dataset.csv.
7. Pesticide / pest-disease subsystem
- models/pesticide.py and models/pesticide_app.py handle the pest/pesticide flow.
- This subsystem is more complex: it includes pesticide_model.pkl, a scaler.pkl, and several label encoders (le_crop.pkl, le_pest.pkl, le_disease.pkl, le_pesticide.pkl, le_method.pkl, le_dosage.pkl).
- That indicates a preprocessing step, then classification, then decoding predicted labels into actionable pesticide guidance.
8. Image-based input path
- The README highlights image-based pest detection, and static/js/image.js suggests the UI supports image upload/preview behavior.
- The expected flow is: user supplies an image → app preprocesses it → model predicts pest/disease-related output → encoded labels are converted into a recommendation.
9. Data layer
- The repository includes training/reference datasets in data/, notably Crop_recommendation.csv, fertilizer datasets, and pesticide_recommendation_large.csv.
- users.csv appears both under UI - Copy/data/ and at the project root, which suggests a simple CSV-backed user store rather than a database.
- There is no sign of an external database or cloud storage layer in the repo.
10. Embedded Streamlit experience
- The presence of templates/streamlit_iframe_crop.html, streamlit_iframe_ferti.html, and streamlit_iframe_pesticide.html suggests some tools are exposed through embedded Streamlit views.
- This creates a boundary between the main web UI and the interactive ML widgets, with the UI hosting those tools inside iframes.
11. Model artifact packaging
- The .pkl files under models/ are the deployed inference assets, separate from the source code that wraps them.
- This implies the training pipeline is not part of the runtime app; the app consumes frozen models and encoders only.
12. Functional flow for the whole system
- User visits the UI → selects a service (crop, fertilizer, or pesticide) → submits agronomic parameters or an image → server-side code in appUi.py and the relevant module invokes the serialized model → prediction is rendered back through HTML/Streamlit UI.
- Authentication-like behavior is handled separately through login.js, signup.js, and CSV-based user data.
13. Key architectural boundaries to show in a diagram
- Browser/UI layer: HTML, CSS, JS, image upload, language switching.
- Python web layer: route handling and page rendering.
- ML inference layer: crop/fertilizer/pesticide modules plus model artifacts.
- Data assets layer: CSV datasets and user records.
- Embedded Streamlit layer: iframe-hosted interactive prediction tools.
Main entry points: appUi.py App entry · streamlit_iframe_crop.html Tool frames · pesticide_app.py Pesticide flow · crop.py Crop model
Components 21
Web UI
Browser-facing pages, scripts, and request handling
- App entry · Main web entrypoint and controller for the site
UI - Copy/appUi.py - Pages · User-facing templates for landing and informational pages
UI - Copy/templates/home.html - Tool frames · Embedded pages that host interactive recommendation tools
UI - Copy/templates/streamlit_iframe_crop.html - Support pages · About, crop info, and auxiliary pages used by the site
UI - Copy/templates/about.html - Stylesheets · Site styling for layout, branding, and embedded tool shells
UI - Copy/static/style.css - Language switch · Client-side English/Hindi text switching
UI - Copy/static/js/language.js - Image upload · Image preview and upload behavior for pest/disease flows
UI - Copy/static/js/image.js - Auth scripts · Login and signup interactions backed by simple CSV user data
UI - Copy/static/js/login.js
ML Inference
Recommendation flows and serialized model assets
- Crop flow · Crop recommendation request handling and feature-to-label mapping
UI - Copy/models/crop_app.py - Crop model · Crop recommendation logic used by the runtime app
UI - Copy/models/crop.py - Fertilizer flow · Fertilizer selection and dosage guidance
UI - Copy/models/ferti_app.py - Fertilizer model · Fertilizer recommendation logic and decoded outputs
UI - Copy/models/fertilizer.py - Pesticide flow · Pest and pesticide recommendation pipeline
UI - Copy/models/pesticide_app.py - Pesticide model · Preprocesses inputs and decodes pesticide guidance
UI - Copy/models/pesticide.py - Crop artifacts · Serialized crop classifier and label encoder
UI - Copy/models/crop_recommendation_model.pkl - Fertilizer artifacts · Serialized fertilizer and dosage models plus encoder
UI - Copy/models/fertilizer_recommendation_model.pkl - Pesticide artifacts · Serialized pesticide model, scaler, and label encoders
UI - Copy/models/pesticide_model.pkl
Data Assets
Reference datasets and simple CSV-backed records
- Crop data · Reference dataset for crop recommendation
UI - Copy/data/Crop_recommendation.csv - Fertilizer data · Datasets used to train fertilizer guidance models
UI - Copy/data/updated_fertilizer_dataset.csv - Pesticide data · Reference dataset for pesticide recommendation
UI - Copy/data/pesticide_recommendation_large.csv - Users CSV · Lightweight user record storage used by the auth flow
UI - Copy/users.csv
Connections 24
- App entry → Pages: renders · Serves the main pages and route responses
- App entry → Tool frames: hosts · Embeds interactive recommendation tools in the UI
- App entry → Support pages: renders · Serves support and informational pages
- App entry → Stylesheets: uses · Loads CSS for page layout and embedded shells
- App entry → Language switch: serves · Delivers multilingual UI behavior to the browser
- App entry → Image upload: serves · Supports image-based input interactions
- App entry → Auth scripts: supports · Connects the web app to login and signup behavior
- App entry → Crop flow: routes to · Dispatches crop requests to the crop subsystem
- App entry → Fertilizer flow: routes to · Dispatches fertilizer requests to the fertilizer subsystem
- App entry → Pesticide flow: routes to · Dispatches pest and pesticide requests to the pesticide subsystem
- Auth scripts → Users CSV: reads/writes · Uses CSV-backed user records instead of a database
- Crop flow → Crop model: invokes · Delegates crop recommendation logic to the core wrapper
- Crop model → Crop artifacts: loads · Consumes frozen crop model and label encoder
- Crop model → Crop data: trained from · Uses crop dataset as the reference training source
- Fertilizer flow → Fertilizer model: invokes · Delegates fertilizer recommendation and dosage prediction
- Fertilizer model → Fertilizer artifacts: loads · Consumes fertilizer models and encoders
- Fertilizer model → Fertilizer data: trained from · Uses fertilizer datasets as the reference source
- Pesticide flow → Pesticide model: invokes · Delegates pesticide recommendation logic to the core wrapper
- Pesticide model → Pesticide artifacts: loads · Consumes scaler, model, and label encoders
- Pesticide model → Pesticide data: trained from · Uses pesticide dataset as the reference source
- Image upload → Pesticide flow: feeds input · Supports image-based pest detection workflow
- Tool frames → Crop flow: embeds · Hosts crop tool UI in an iframe
- Tool frames → Fertilizer flow: embeds · Hosts fertilizer tool UI in an iframe
- Tool frames → Pesticide flow: embeds · Hosts pesticide tool UI in an iframe