# shivamshinde123/battery-features-predictions architecture

> Architecture diagram of the GitHub repository shivamshinde123/battery-features-predictions, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-09-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/shivamshinde123/battery-features-predictions
- Repository: https://github.com/shivamshinde123/battery-features-predictions

## Overview

##### Main Components
a. Data Storage & Versioning
- Raw data (“Data/” directory, managed by DVC and remote storage)
- Processed datasets in DVC cache (".dvc/")
b. Pipeline Orchestration
- DVC pipeline (dvc.yaml, dvc.lock, params.yaml)
- Steps: loader → validation → preprocessing → model training → evaluation
c. Core ML Modules (src/)
- loader.py (data ingestion)
- validation.py (data sanity checks)
- preprocessing.py (feature engineering)
- model_training_xgboost.py & model_training_nn.py
- utils.py (shared helpers)
d. Experiment Tracking & Logging
- MLflow (mlruns/ directory)
- Logs/ (training logs)
- Metrics/ (JSON metrics files)
e. Model Artifacts
- Models/ (serialized model files)
f. Serving Layer
- src/frontend/webapp.py (Flask/FastAPI app exposing prediction API)
g. Notebooks & Exploratory Analysis
- Notebooks/ (Jupyter notebooks)
h. Continuous Integration
- GitHub Actions CI (".github/workflows/ci.yml")
- pytest tests (src/tests/)

##### Relationships & Data Flow
- Raw Data → DVC fetch → loader → validation → preprocessing → model training → evaluation
- model_training_xgboost & model_training_nn output → Models/
- Evaluator → writes performance metrics → Metrics/ → MLflow logging
- MLflow client in scripts logs parameters & metrics → mlruns/
- Frontend app loads latest model from Models/ to serve predictions
- CI pipeline runs:
- dvc repro (validates pipeline reproducibility)
- pytest src/tests (ensures code correctness)

##### Architectural Patterns & Design Principles
- Pipeline-as-Code: DVC defines a reproducible DAG of data-processing steps
- Modular Codebase: Single-responsibility modules (loader, validation, preprocessing, training)
- MLOps Best Practices: Experiment tracking (MLflow), version control for data (DVC), automated testing
- Separation of Concerns: Data pipeline vs. model serving (frontend)

##### Key Technologies & Frameworks
- Python 3.10
- DVC (pipeline orchestration & data versioning)
- MLflow (experiment tracking)
- XGBoost, PyTorch/Keras (neural nets)
- Flask or FastAPI (webapp)
- pytest (testing)
- GitHub Actions (CI)

##### Details
- Params.yaml as input to both training modules

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Data & Versioning
    subgraph "Data & Versioning"
        RawData["Raw Data (.csv)"]:::dataStore
        DVCRemote["DVC Remote Storage"]:::dataStore
        DVCCache["DVC Cache (.dvc/)"]:::dataStore
    end

    %% DVC Pipeline Configuration
    subgraph "DVC Pipeline Configuration"
        DVCYAML["dvc.yaml"]:::config
        DVCLock["dvc.lock"]:::config
        Params["params.yaml"]:::config
    end

    %% Data Pipeline
    subgraph "Data Pipeline"
        Loader["loader.py"]:::process
        Validation["validation.py"]:::process
        Preprocessing["preprocessing.py"]:::process
        XGBoost["model_training_xgboost.py"]:::process
        NN["model_training_nn.py"]:::process
        Evaluator["Evaluator"]:::process
    end

    %% Experiment Tracking & Artifacts
    subgraph "Experiment Tracking & Artifacts"
        Metrics["Metrics/"]:::tracking
        MLFlow["MLflow (mlruns/)"]:::tracking
        Models["Models/"]:::tracking
    end

    %% Serving Layer
    subgraph "Serving Layer"
        Webapp["webapp.py"]:::serving
    end

    %% Exploratory Analysis
    subgraph "Exploratory Analysis"
        Notebook["battery-state-of-charge-soc-prediction.ipynb"]:::notebook
    end

    %% CI/CD
    subgraph "CI/CD"
        CI[".github/workflows/ci.yml"]:::ci
        Tests["src/tests/"]:::ci
    end

    %% Connections
    RawData --> DVCCache
    RawData --> DVCRemote
    DVCCache --> DVCYAML
    DVCYAML --> Loader
    DVCYAML --> Validation
    DVCYAML --> Preprocessing
    DVCYAML --> XGBoost
    DVCYAML --> NN
    Params --> XGBoost
    Params --> NN
    Loader --> Validation
    Validation --> Preprocessing
    Preprocessing --> XGBoost
    Preprocessing --> NN
    XGBoost --> Evaluator
    NN --> Evaluator
    Evaluator --> Metrics
    Evaluator --> MLFlow
    XGBoost --> Models
    NN --> Models
    Webapp --> Models
    CI --> DVCYAML
    CI --> Tests

    %% Click Events
    click DVCCache "https://github.com/shivamshinde123/battery-features-predictions/tree/main/.dvc/"
    click DVCYAML "https://github.com/shivamshinde123/battery-features-predictions/blob/main/dvc.yaml"
    click DVCLock "https://github.com/shivamshinde123/battery-features-predictions/blob/main/dvc.lock"
    click Params "https://github.com/shivamshinde123/battery-features-predictions/blob/main/params.yaml"
    click Loader "https://github.com/shivamshinde123/battery-features-predictions/blob/main/src/loader.py"
    click Validation "https://github.com/shivamshinde123/battery-features-predictions/blob/main/src/validation.py"
    click Preprocessing "https://github.com/shivamshinde123/battery-features-predictions/blob/main/src/preprocessing.py"
    click XGBoost "https://github.com/shivamshinde123/battery-features-predictions/blob/main/src/model_training_xgboost.py"
    click NN "https://github.com/shivamshinde123/battery-features-predictions/blob/main/src/model_training_nn.py"
    click Metrics "https://github.com/shivamshinde123/battery-features-predictions/tree/main/Metrics/"
    click Models "https://github.com/shivamshinde123/battery-features-predictions/tree/main/Models/"
    click Webapp "https://github.com/shivamshinde123/battery-features-predictions/blob/main/src/frontend/webapp.py"
    click Notebook "https://github.com/shivamshinde123/battery-features-predictions/blob/main/Notebooks/battery-state-of-charge-soc-prediction.ipynb"
    click CI "https://github.com/shivamshinde123/battery-features-predictions/blob/main/.github/workflows/ci.yml"
    click Tests "https://github.com/shivamshinde123/battery-features-predictions/tree/main/src/tests/"

    %% Styles
    classDef dataStore fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef process fill:#90EE90,stroke:#333,stroke-width:1px
    classDef tracking fill:#FFA500,stroke:#333,stroke-width:1px
    classDef serving fill:#DDA0DD,stroke:#333,stroke-width:1px
    classDef ci fill:#D3D3D3,stroke:#333,stroke-width:1px
    classDef config fill:#FFE5B4,stroke:#333,stroke-width:1px
    classDef notebook fill:#E6E6FA,stroke:#333,stroke-width:1px
```
