How sarthakgarg1204/cropgenie works
Step 1: Identify the Project Type and Purpose
• CropGenie is a single-page, ML-powered web application built with Streamlit.
• Purpose: provide crop and fertilizer recommendations using a trained Decision Tree model and a lookup dataset.
Step 2: Analyze the File Structure
Top-level files:
• app.py – Streamlit app entry point (UI + controller logic)
• crop_model.pkl – Serialized Decision Tree Classifier
• crop_scaler.sav – Serialized StandardScaler for feature normalization
• Fertilizer Prediction.csv – CSV lookup table for fertilizer recommendations
• requirements.txt – Python dependencies
• README.md, LICENSE, .gitignore
Step 3: Pull Insights from README
• Frontend: Streamlit
• ML Model: scikit-learn Decision Tree
• Data handling: pandas, numpy
• Deployment: Streamlit Cloud or local
a. Main Components
1. User Browser
2. Streamlit Server (app.py)
• UI Layer (sidebar, tabs, input widgets)
• Controller Layer (handles user inputs, orchestrates calls)
3. ML Inference Layer
• Feature Scaler (crop_scaler.sav)
• Decision Tree Model (crop_model.pkl)
4. Data Lookup Layer
• Fertilizer Prediction CSV
5. Optional Persistence/Logging (could be a file or external database, not present today)
6. Deployment Infrastructure
• Localhost or Streamlit Cloud
b. Relationships & Data Flow
1. User enters soil/crop parameters in the browser →
2. Streamlit Server captures inputs →
3. Controller sends raw inputs to the Scaler →
4. Scaled features feed the Decision Tree →
5. Controller retrieves fertilizer info from the CSV lookup →
6. Combined recommendation pushed back to the UI →
7. Results rendered in the browser
c. Architectural Patterns & Principles
• Layered Monolith: clear separation of UI, business logic, ML inference, and data lookup.
• Single Responsibility: app.py orchestrates but model/scaler/data are external resources.
• Configuration-as-Code: dependencies in requirements.txt, models as artifacts.
d. Key Technologies & Frameworks
• Streamlit: UI framework
• scikit-learn: model + scaler
• pandas/numpy: data ingestion & manipulation
• CSV file: static dataset
• Streamlit Cloud / local server: hosting
• “Frontend vs. Backend” even though both run in the same Python process.
• CSV lookup as a distinct “Data Source” component.
• Deployment target (Streamlit Cloud).
Step 6: Diagramming Guidelines
• Use clear, consistent labels:
• “User Browser”
• “Streamlit App (UI + Controller)”
• “Feature Scaler”
• “Decision Tree Model”
• “Fertilizer Lookup CSV”
• “Streamlit Cloud / Localhost”
• Inputs → UI → Controller → Scaler → Model → Controller → UI → Browser
• Controller → CSV → Controller
• UI components (e.g., blue rectangles)
• Processing/inference (e.g., green rounded rectangles)
Step 7: Final Notes
• Be as granular as needed: you could even split the Controller into “Input Validation,” “Model Invocation,” and “Result Formatting.”
• Don’t over-engineer—capture all moving parts: UI widgets, model artifacts, data lookup, and hosting.