# rusirudananga/ml_cw architecture

> Architecture diagram of the GitHub repository rusirudananga/ml_cw, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rusirudananga/ml_cw
- Repository: https://github.com/rusirudananga/ml_cw

## Overview

This repository is a supermarket sales and quantity forecasting application, with a Streamlit interface as its user-facing runtime. Users select a prediction page, provide a date, department and store, and request a quantity or net-sales forecast; the app loads a saved XGBoost model and displays predictions. The documented offline workflow covers data preparation, EDA, model development and saving. Notebook internals and some app wiring were not sampled, so those relationships are shown only where documented.

Main entry points: [`pipelines/run_pipeline.ipynb`](https://github.com/rusirudananga/ml_cw/blob/main/pipelines/run_pipeline.ipynb) (Pipeline orchestration), [`index.py`](https://github.com/rusirudananga/ml_cw/blob/main/index.py) (Streamlit app), [`src/utils/transformation_util.ipynb`](https://github.com/rusirudananga/ml_cw/blob/main/src/utils/transformation_util.ipynb) (Feature preparation), [`src/models/qty_pred_wdepartment_model_final.ipynb`](https://github.com/rusirudananga/ml_cw/blob/main/src/models/qty_pred_wdepartment_model_final.ipynb) (Quantity training)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Prediction runtime"]
  node_app["Streamlit app<br/>[index.py]"]
  node_quantity["Quantity model<br/>[xgb_model_qty.pkl]"]
  node_sales["Sales model"]
end

subgraph group_data["Data preparation"]
  node_training_data["Training data<br/>[training_data.csv]"]
  node_test_data["Test data<br/>[test_data.csv]"]
  node_preparation["Feature preparation"]
  node_eda["Exploratory analysis<br/>[eda.ipynb]"]
end

subgraph group_modeling["Model development"]
  node_pipeline["Pipeline orchestration<br/>[run_pipeline.ipynb]"]
  node_quantity_training["Quantity training"]
  node_sales_training["Sales training"]
end

node_user(("Store user"))

node_user -->|"enters inputs"| node_app
node_app -->|"loads model"| node_quantity
node_app -->|"loads model"| node_sales
node_app -->|"shows forecast"| node_user
node_pipeline -.->|"runs EDA"| node_eda
node_pipeline -.->|"prepares data"| node_preparation
node_pipeline -.->|"builds models"| node_quantity_training
node_pipeline -.->|"builds models"| node_sales_training
node_training_data -.->|"prepares records"| node_preparation
node_test_data -.->|"prepares records"| node_preparation
node_quantity_training -.->|"saves model"| node_quantity
node_sales_training -.->|"saves model"| node_sales

click node_app "https://github.com/rusirudananga/ml_cw/blob/main/index.py"
click node_quantity "https://github.com/rusirudananga/ml_cw/blob/main/src/models/xgb_model_qty.pkl"
click node_sales "https://github.com/rusirudananga/ml_cw/blob/main/src/models/xgb_model_sales.pkl"
click node_training_data "https://github.com/rusirudananga/ml_cw/blob/main/data/training_data.csv"
click node_test_data "https://github.com/rusirudananga/ml_cw/blob/main/data/test_data.csv"
click node_preparation "https://github.com/rusirudananga/ml_cw/blob/main/src/utils/transformation_util.ipynb"
click node_eda "https://github.com/rusirudananga/ml_cw/blob/main/analysis/eda.ipynb"
click node_pipeline "https://github.com/rusirudananga/ml_cw/blob/main/pipelines/run_pipeline.ipynb"
click node_quantity_training "https://github.com/rusirudananga/ml_cw/blob/main/src/models/qty_pred_wdepartment_model_final.ipynb"
click node_sales_training "https://github.com/rusirudananga/ml_cw/blob/main/src/models/sales_pred_wdepartment_model_final.ipynb"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app,node_quantity,node_sales,node_user toneBlue
class node_training_data,node_test_data,node_preparation,node_eda toneAmber
class node_pipeline,node_quantity_training,node_sales_training toneMint
```

## Components

### Prediction runtime

- [Streamlit app](https://github.com/rusirudananga/ml_cw/blob/main/index.py): `index.py`
- [Quantity model](https://github.com/rusirudananga/ml_cw/blob/main/src/models/xgb_model_qty.pkl): `src/models/xgb_model_qty.pkl`
- [Sales model](https://github.com/rusirudananga/ml_cw/blob/main/src/models/xgb_model_sales.pkl): `src/models/xgb_model_sales.pkl`

### Data preparation

- [Training data](https://github.com/rusirudananga/ml_cw/blob/main/data/training_data.csv): `data/training_data.csv`
- [Test data](https://github.com/rusirudananga/ml_cw/blob/main/data/test_data.csv): `data/test_data.csv`
- [Feature preparation](https://github.com/rusirudananga/ml_cw/blob/main/src/utils/transformation_util.ipynb): `src/utils/transformation_util.ipynb`
- [Exploratory analysis](https://github.com/rusirudananga/ml_cw/blob/main/analysis/eda.ipynb): `analysis/eda.ipynb`

### Model development

- [Pipeline orchestration](https://github.com/rusirudananga/ml_cw/blob/main/pipelines/run_pipeline.ipynb): `pipelines/run_pipeline.ipynb`
- [Quantity training](https://github.com/rusirudananga/ml_cw/blob/main/src/models/qty_pred_wdepartment_model_final.ipynb): `src/models/qty_pred_wdepartment_model_final.ipynb`
- [Sales training](https://github.com/rusirudananga/ml_cw/blob/main/src/models/sales_pred_wdepartment_model_final.ipynb): `src/models/sales_pred_wdepartment_model_final.ipynb`

### Other components

- **Store user**

## Connections

- Store user → Streamlit app: enters inputs (evidence: `README.md`)
- Streamlit app → Quantity model: loads model (evidence: `index.py`)
- Streamlit app → Sales model: loads model (evidence: `index.py`)
- Streamlit app → Store user: shows forecast (evidence: `index.py`)
- Pipeline orchestration → Exploratory analysis: runs EDA (evidence: `README.md`)
- Pipeline orchestration → Feature preparation: prepares data (evidence: `README.md`)
- Pipeline orchestration → Quantity training: builds models (evidence: `README.md`)
- Pipeline orchestration → Sales training: builds models (evidence: `README.md`)
- Training data → Feature preparation: prepares records (evidence: `README.md`)
- Test data → Feature preparation: prepares records (evidence: `README.md`)
- Quantity training → Quantity model: saves model (evidence: `README.md`)
- Sales training → Sales model: saves model (evidence: `README.md`)
