# kumarpranavv/yieldwise architecture

> Architecture diagram of the GitHub repository kumarpranavv/yieldwise, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-08-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kumarpranavv/yieldwise
- Repository: https://github.com/kumarpranavv/yieldwise

## Overview

##### Project type and purpose
- YieldWise is an end-to-end data-science application with a Python/Streamlit web UI.
- Its goal is to forecast Remaining Safe Storage Days (RSSD) for grain using a Gradient Boosting Regressor, provide what-if analyses, and display rich visualizations on a Streamlit dashboard.

##### File structure
- Top-level directories/files:
- data/ (train.csv, test.csv) → raw datasets
- models/ (grain_predictor_pipeline.joblib) → persisted ML pipeline
- output/ (metrics.json) → evaluation results
- src/ → all core scripts:
– data_preprocessing.py
– model_utils.py
– train.py (batch training pipeline)
– evaluate.py (standalone evaluation & plots)
– predict.py (inference logic)
- main.py → Streamlit application entrypoint
- requirements.txt, .gitignore
- Architectural pattern: a clear separation between batch pipelines (data prep, train, evaluate) and real-time/inference (Streamlit front end invoking predict).

##### Pulling in README insights
- Tech stack: Python 3.12, Pandas/NumPy, Scikit-learn, Streamlit, Plotly/Matplotlib/Seaborn
- Full DS lifecycle: synthetic data gen, feature engineering, train, eval, deploy as interactive tool.

a. Main components:
1. Data Storage
– raw CSV files in data/
2. Batch Pipeline
– Data Preprocessing (src/data_preprocessing.py)
– Model Training & Serialization (src/train.py + model_utils.py → models/)
– Model Evaluation (src/evaluate.py → output/metrics.json & evaluation plots)
3. Inference & Serving
– Inference Engine (src/predict.py loads joblib pipeline)
– Streamlit Web App (main.py)
4. Visualization Libraries
– Plotly/Matplotlib/Seaborn used by evaluate.py & Streamlit UI
5. External Dependencies
– Scikit-learn, Pandas, NumPy
b. Relationships & data flow:
- Raw data → Data Preprocessing → Features
- Features → Model Training → Trained Pipeline (.joblib)
- Trained Pipeline → Model Evaluation → metrics.json & plots
- Trained Pipeline + User Input → Predict → Streamlit UI
- Streamlit UI → Visualization Components → Browser
c. Architectural patterns & principles:
- Separation of concerns: batch vs interactive
- Pipeline modularity: each script addresses a single phase
- File-based artifact storage for reproducibility
d. Key technologies/frameworks:
- Streamlit (UI & app server)
- scikit-learn Pipeline (model + preprocessing)
- Plotly/Matplotlib/Seaborn (charts)
- joblib (model persistence)

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Batch Pipeline"
        Preprocess["Data Preprocessing\n(src/data_preprocessing.py)"]:::batch
        TrainScript["Model Training\n(src/train.py)"]:::batch
        ModelUtils["Training Utilities\n(src/model_utils.py)"]:::batch
        Evaluate["Model Evaluation\n(src/evaluate.py)"]:::batch
    end

    subgraph "Storage"
        TrainCSV["train.csv"]:::storage
        TestCSV["test.csv"]:::storage
        ModelArtifact["grain_predictor_pipeline.joblib"]:::storage
        MetricsOutput["metrics.json"]:::storage
    end

    subgraph "Real-Time Inference & UI"
        Predict["Inference Engine\n(src/predict.py)"]:::inference
        UI["Streamlit App\n(main.py)"]:::inference
        Browser["Browser"]:::external
    end

    Requirements["requirements.txt"]:::external

    TrainCSV -->|"raw CSVs"| Preprocess
    TestCSV --> Preprocess
    Preprocess -->|"features"| TrainScript
    ModelUtils -.-> TrainScript
    TrainScript -->|"model.joblib"| ModelArtifact
    ModelArtifact --> Evaluate
    Evaluate -->|"metrics & plots"| MetricsOutput
    ModelArtifact --> Predict
    Predict -->|"predictions"| UI
    UI -->|"render visualizations"| Browser
    Requirements -.-> Preprocess

    click TrainCSV "https://github.com/kumarpranavv/yieldwise/blob/main/data/train.csv"
    click TestCSV "https://github.com/kumarpranavv/yieldwise/blob/main/data/test.csv"
    click Preprocess "https://github.com/kumarpranavv/yieldwise/blob/main/src/data_preprocessing.py"
    click TrainScript "https://github.com/kumarpranavv/yieldwise/blob/main/src/train.py"
    click ModelUtils "https://github.com/kumarpranavv/yieldwise/blob/main/src/model_utils.py"
    click ModelArtifact "https://github.com/kumarpranavv/yieldwise/blob/main/models/grain_predictor_pipeline.joblib"
    click Evaluate "https://github.com/kumarpranavv/yieldwise/blob/main/src/evaluate.py"
    click MetricsOutput "https://github.com/kumarpranavv/yieldwise/blob/main/output/metrics.json"
    click Predict "https://github.com/kumarpranavv/yieldwise/blob/main/src/predict.py"
    click UI "https://github.com/kumarpranavv/yieldwise/blob/main/main.py"
    click Requirements "https://github.com/kumarpranavv/yieldwise/blob/main/requirements.txt"

    classDef batch fill:#ADD8E6,stroke:#000,stroke-width:1px;
    classDef storage fill:#FFA500,stroke:#000,stroke-width:1px;
    classDef inference fill:#90EE90,stroke:#000,stroke-width:1px;
    classDef external fill:#D3D3D3,stroke:#000,stroke-width:1px;
```
