# milonigada09/supply-chain-forecasting-deep-learning architecture

> Architecture diagram of the GitHub repository milonigada09/supply-chain-forecasting-deep-learning, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/milonigada09/supply-chain-forecasting-deep-learning
- Repository: https://github.com/milonigada09/supply-chain-forecasting-deep-learning

## Overview

##### Project Type and Purpose
- Type: A data-science/ML pipeline for time-series sales forecasting.
- Purpose: Ingest historical sales and inventory data, engineer features, train and compare multiple ML and DL models (Linear Regressor, XGBoost, CNN, LSTM, CNN+LSTM, GRU, Transformer), select the best model, and produce future-sales forecasts.

##### Main Components
a. Data Ingestion & Storage
- Historical sales data, inventory data (could be CSV/Parquet files or a database).
b. Data Preprocessing & Feature Engineering
- Cleaning, normalization, windowing, creation of lag features, train-test split.
c. Model-Training Modules
- Seven parallel subcomponents:
- Linear Regressor
- XGBoost
- CNN
- LSTM
- CNN+LSTM
- GRU
- Transformer (see Transformer.py)
- Each takes preprocessed data and outputs a trained model file (.h5 for DL models).
d. Model Evaluation & Comparison
- Compute error metrics (RMSE, MAE) on validation/test sets.
- Compare models to choose best (XGBoost and CNN+LSTM are highlighted).
e. Model Persistence
- Save the chosen model (and optionally all models) to disk (CNN_MODEL.h5, etc.).
f. Forecasting Interface
- Notebook or script that loads saved model, runs inference for next-day forecasts.
g. (Optional) Deployment / Service Layer

##### Architectural Patterns / Principles
- Pipeline pattern: clear, linear dataflow from ingestion to deployment.
- Modularity: Each model training is its own interchangeable component.
- Parallel training: six DL/ML models can be trained simultaneously.
- Separation of concerns: distinct stages for preprocessing, modeling, and evaluation.

- Linear Regressor
- XGBoost
- CNN
- LSTM
- CNN+LSTM
- GRU
- Transformer

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Data Source
    Data["Historical Sales & Inventory Data"]:::data

    %% Preprocessing
    Preprocess["Data Preprocessing & Feature Engineering"]:::preprocess

    %% Modeling Layer
    subgraph "Modeling Layer"
        direction TB
        LinearReg["Linear Regressor Trainer"]:::model
        XGBoost["XGBoost Trainer"]:::model
        CNN["CNN Trainer"]:::model
        LSTM["LSTM Trainer"]:::model
        CNNLSTM["CNN+LSTM Trainer"]:::model
        GRU["GRU Trainer"]:::model
        Transformer["Transformer Trainer"]:::model
    end

    %% Evaluation & Comparison
    Eval["Model Evaluation & Comparison"]:::eval

    %% Model Persistence
    Persistence["Persist Selected Model"]:::storage

    %% Forecasting Interface
    Forecast["Forecasting Interface / API"]:::interface

    %% README
    README["Project README / Overview"]:::external

    %% Data Flow
    Data -->|“Raw Data”| Preprocess
    Preprocess -->|“Preprocessed Data”| LinearReg
    Preprocess --> XGBoost
    Preprocess --> CNN
    Preprocess --> LSTM
    Preprocess --> CNNLSTM
    Preprocess --> GRU
    Preprocess --> Transformer
    LinearReg -->|“Trained Model”| Eval
    XGBoost --> Eval
    CNN --> Eval
    LSTM --> Eval
    CNNLSTM --> Eval
    GRU --> Eval
    Transformer --> Eval
    Eval -->|“Best Model”| Persistence
    Persistence -->|“Persisted Model”| Forecast

    %% Click Events
    click Preprocess "https://github.com/milonigada09/supply-chain-forecasting-deep-learning/blob/main/Sales Demand Forecast.ipynb"
    click LinearReg "https://github.com/milonigada09/supply-chain-forecasting-deep-learning/blob/main/Sales Demand Forecast.ipynb"
    click XGBoost "https://github.com/milonigada09/supply-chain-forecasting-deep-learning/blob/main/Sales Demand Forecast.ipynb"
    click CNN "https://github.com/milonigada09/supply-chain-forecasting-deep-learning/blob/main/Sales Demand Forecast.ipynb"
    click LSTM "https://github.com/milonigada09/supply-chain-forecasting-deep-learning/blob/main/Sales Demand Forecast.ipynb"
    click CNNLSTM "https://github.com/milonigada09/supply-chain-forecasting-deep-learning/blob/main/Sales Demand Forecast.ipynb"
    click GRU "https://github.com/milonigada09/supply-chain-forecasting-deep-learning/blob/main/Sales Demand Forecast.ipynb"
    click Transformer "https://github.com/milonigada09/supply-chain-forecasting-deep-learning/blob/main/Transformer.py"
    click Persistence "https://github.com/milonigada09/supply-chain-forecasting-deep-learning/blob/main/CNN_MODEL.h5"
    click CNN "https://github.com/milonigada09/supply-chain-forecasting-deep-learning/blob/main/CNN_MODEL.h5"
    click LSTM "https://github.com/milonigada09/supply-chain-forecasting-deep-learning/blob/main/LSTM_MODEL.h5"
    click CNNLSTM "https://github.com/milonigada09/supply-chain-forecasting-deep-learning/blob/main/CNN-LSTM_MODEL.h5"
    click GRU "https://github.com/milonigada09/supply-chain-forecasting-deep-learning/blob/main/GRU_MODEL.h5"
    click Eval "https://github.com/milonigada09/supply-chain-forecasting-deep-learning/blob/main/Sales Demand Forecast.ipynb"
    click Forecast "https://github.com/milonigada09/supply-chain-forecasting-deep-learning/blob/main/Sales Demand Forecast.ipynb"
    click README "https://github.com/milonigada09/supply-chain-forecasting-deep-learning/blob/main/README.md"

    %% Styles
    classDef data fill:#AED6F1,stroke:#21618C,color:#1B2631
    classDef preprocess fill:#ABEBC6,stroke:#1D8348,color:#1B2631
    classDef model fill:#F5CBA7,stroke:#A04000,color:#1B2631
    classDef eval fill:#D7BDE2,stroke:#6C3483,color:#1B2631
    classDef storage fill:#F1948A,stroke:#C0392B,color:#1B2631
    classDef interface fill:#76D7C4,stroke:#117A65,color:#1B2631
    classDef external fill:#F9E79F,stroke:#B7950B,color:#1B2631
```
