How suraj-juluri/smart-crop-detection works
1. Repository shape
- This is a single Flask-based application with one Python entrypoint (run.py) and no separate backend/frontend services.
- The repo is centered around two packaged AI artifacts: keras_model.h5 for disease classification and labels.txt for mapping model outputs to human-readable classes.
2. Primary runtime boundary
- The server is the main application boundary: it receives browser requests, renders pages, processes form/image submissions, and returns results.
- There is no visible database or message queue, so the app appears to be mostly stateless and request-driven.
3. UI layer
- The frontend is described as HTML/CSS/JavaScript, likely served through Flask templates and static assets.
- The UI supports multiple workflows: image upload, symptom selection, crop recommendation form inputs, roadmap viewing, nearby shop lookup, and language switching.
4. Disease detection pipeline
- User uploads a crop image.
- The backend preprocesses the image using PIL/NumPy, runs it through the Keras/TensorFlow model, then converts the predicted class index into a label via labels.txt.
- The result includes disease name, confidence, and treatment/product guidance.
5. Symptom-based detection path
- There is a second diagnostic path that does not depend on the model.
- Users choose symptoms manually, and the backend uses rule-based mapping to infer a likely disease and present the same treatment-oriented output.
6. Crop recommendation subsystem
- Separate from disease diagnosis, the app contains a rule-based recommendation engine.
- Inputs include soil type, weather conditions, location, budget, and water source.
- The output is a suggested crop set, so this subsystem behaves more like decision logic than ML inference.
7. Crop roadmap content
- The roadmap feature is a guidance module that returns a stage-wise farming plan.
- It covers sowing, fertilization, irrigation, and harvest timing, implying mostly curated domain knowledge embedded in app logic or templates.
8. Nearby shops / map integration
- The “nearby shops” feature integrates with Google Maps.
- This is the only clearly external service in the architecture, used to help users locate fertilizer or farm-product shops.
9. Language support
- English and Telugu are supported at the UI/content layer.
- This likely affects templates and text resources rather than the inference pipeline itself.
10. Deployment and hosting
- vercel.json indicates the app is intended to be deployable in a Vercel-style environment, even though the core app is Flask/Python.
- That suggests an adapter or serverless hosting configuration around the Flask entrypoint, but the application logic remains backend-centric.
11. Data flow summary
- Inputs enter through browser forms and image uploads.
- The backend either runs model inference or applies rule-based logic.
- Results are rendered back to the user as treatment guidance, crop recommendations, roadmap steps, or map links.
12. Architectural takeaway
- This is best diagrammed as a monolithic smart-farming assistant with four main internal modules: disease detection, symptom rules, crop recommendation, and farming guidance.
- The only external dependency that materially changes the architecture is Google Maps; the rest of the intelligence is packaged in code and model artifacts within the repo.
Main entry points: run.py Flask app · vercel.json Vercel config · keras_model.h5 Keras model · labels.txt Class labels
Components 14
Flask application
Browser-facing request handling and domain logic
- Flask app · Main request boundary for uploads, forms, rendering, and results
run.py - Upload flow · Handles crop image submission from the browser
run.py - Preprocess · Converts uploaded images into model-ready tensors
run.py - Disease model · Runs crop image classification against the bundled Keras model
run.py - Symptom rules · Maps selected symptoms to a likely disease without ML inference
run.py - Crop advice · Suggests crops from soil, weather, location, budget, and water inputs
run.py - Roadmap · Returns stage-wise farming guidance from sowing to harvest
run.py - Language support · Switches user-facing content between English and Telugu
run.py - Nearby shops · Links users to nearby fertilizer or farm-product shops
run.py - Treatment output · Combines disease name, confidence, and treatment or product guidance
run.py
Packaged AI assets
Model and label artifacts bundled with the repo
- Keras model · Bundled disease-classification network used by the inference path
keras_model.h5 - Class labels · Maps model output indices to readable disease classes
labels.txt
Deployment
Hosting and runtime packaging
- Python deps · Runtime library set for Flask, ML, and image processing
requirements.txt - Vercel config · Serverless hosting and entrypoint wiring for deployment
vercel.json
Connections 17
- Flask app → Upload flow: routes · Receives image upload requests
- Flask app → Symptom rules: routes · Handles symptom-based diagnosis
- Flask app → Crop advice: routes · Handles crop recommendation requests
- Flask app → Roadmap: routes · Serves farming roadmap guidance
- Flask app → Nearby shops: routes · Serves nearby shop lookup
- Flask app → Language support: switches · Selects English or Telugu content
- Upload flow → Preprocess: feeds · Prepares the uploaded image for inference
- Preprocess → Disease model: inputs · Passes model-ready image data
- Disease model → Keras model: loads · Uses the bundled Keras model
- Disease model → Class labels: decodes · Translates predicted class index to disease name
- Disease model → Treatment output: returns · Produces diagnosis and guidance output
- Symptom rules → Treatment output: returns · Produces rule-based diagnosis and guidance output
- Crop advice → Treatment output: returns · Produces crop recommendation response
- Roadmap → Treatment output: returns · Produces stage-wise farming plan
- Nearby shops → Treatment output: returns · Produces map links or shop lookup results
- Flask app → Python deps: depends on · Requires Flask and supporting libraries
- Vercel config → Flask app: hosts · Deploys the Flask entrypoint in a Vercel-style environment