How ravikant-diwakar/agrisens works
Project Type and Purpose
• This is a full‐stack, AI‐powered Smart Farming Assistant ("AgriSens") that provides farmers with (a) Smart Crop Recommendations, (b) Plant Disease Identification, (c) Fertilizer Recommendations, (d) Real-time Weather Forecasts, and (e) a Smart Farming Guide via a user-friendly web interface.
High‐Level File‐Structure Analysis
• Frontend (AgriSens-web-app): static HTML/CSS/JS pages for Home, Explore, Guide, Weather Forecast, and Developing-Phase.
• Crop Recommendation Service (CROP-RECOMMENDATION): Python webapp.py, several pre-trained .pkl model files, dataset CSV, requirements.txt.
• Plant Disease Identification Service (PLANT-DISEASE-IDENTIFICATION): Python main.py, trained Keras model .keras, settings JSON, Jupyter notebooks, requirements.txt.
• Datasets: raw CSVs for crop & fertilizer recommendations; image dataset referenced but not served live.
• Miscellaneous: SystemArchitecture.md, research paper PDF, license, project‐level README.md.
README Insights
• Confirms a static SPA-style frontend hosted (e.g., Netlify), and backend AI services (likely served via Flask/Streamlit).
• External integrations: real-time weather API.
• No persistent database—data and models load from the file system at runtime.
Main Architectural Components
A. Frontend/UI Layer
• Static pages (HTML/CSS/JS) served from a CDN/Netlify.
• Routes for Crop Rec form, Disease Identification upload, Fertilizer Rec form, Weather page, Guide.
B. API Gateway / Web Server
• One or two Python apps (webapp.py and main.py), each exposing REST endpoints (e.g., /predict_crop, /predict_disease).
• Runs on a server (e.g., AWS EC2, Heroku, Streamlit Cloud).
C. ML Inference Services
1. Crop Recommendation Service
– Loads multiple scikit-learn models (RandomForest.pkl, etc.).
– Accepts JSON payload of soil/climate features → returns best‐fit crop label.
2. Disease Identification Service
– Loads CNN Keras model (trained_plant_disease_model.keras).
– Accepts image upload → returns disease class/confidence.
3. Fertilizer Recommendation
– Could be integrated in webapp.py using CSV‐based lookup or a simple rule engine.
D. External Services
• Weather Forecast Module: HTTP calls to a third‐party Weather API (e.g., OpenWeatherMap) to fetch real‐time temperature, humidity, rainfall.
E. Data & Models Storage
• Model artifact directory on the server.
• CSV files for fertilizer rules and crop rec dataset (used offline for retraining).
F. Optional Logging/Monitoring
• (Not present in code, but recommended) logging service to capture API usage, errors, model latencies.
Component Interactions
1. User in Browser → (HTTP GET) → Static UI
2. User submits soil data → (HTTP POST /predict_crop) → Crop Rec Service → loads model → returns JSON → UI renders crop recommendation.
3. User uploads leaf image → (HTTP POST /predict_disease) → Disease Service → loads CNN → returns JSON → UI displays disease and guide link.
4. UI page for Weather → triggers JS fetch to backend or directly to external Weather API → displays real-time forecast.
5. Fertilizer page → similar flow to crop rec but with fertilizer logic.
6. Smart Farming Guide → static content.
Key Architectural Patterns
• Separation of Concerns: distinct UI, API, and ML layers.
• Microservices‐style: each ML feature (crop rec, disease id, fertilizer) runs in its own module/endpoint.
• Stateless Services: inference endpoints load models once on startup, handle requests independently (no session state).
• Client‐Server: browser UI vs. backend API.