# bhattkaushal/timelytics architecture

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

- Interactive diagram: https://gitdiagram.com/bhattkaushal/timelytics
- Repository: https://github.com/bhattkaushal/timelytics

## Overview

1. **What this repository is**
   Timelytics is a small, end-to-end machine learning project for forecasting Order-to-Delivery (OTD) time. The repo is centered on a **Streamlit** application for interactive prediction, backed by a **pretrained ensemble model** stored as `voting_model.pkl`.

2. **Primary runtime boundary**
   The main user-facing boundary is `streamlitApp.py`. At runtime, this file serves as the app entrypoint, loads the trained model artifact, accepts order-related inputs from the user, and returns an OTD forecast. The rest of the repository mainly supports that inference path.

3. **Training vs inference split**
   The project clearly separates **offline model development** from **online prediction**:
   - `Order to Delivery (OTD) Time Forecasting.ipynb` appears to be the training/experimentation notebook.
   - `voting_model.pkl` is the serialized output of that work.
   This means model training is not part of the deployed app flow; the app consumes a frozen artifact.

4. **Model architecture**
   The README states the predictor is an **ensemble/voting model** built from three ML algorithms: **XGBoost, Random Forest, and SVM**. The ensemble is the core decision layer of the system, combining multiple learners to produce the final OTD estimate.

5. **Data layer**
   The repository includes the raw Olist ecommerce datasets in `data/`, such as:
   - orders
   - order items
   - order payments
   - order reviews
   - customers
   - products
   - sellers
   - category translation  
   These tables form the source layer for feature construction and model training. The zipped dataset file is also kept under `data/`, indicating the project expects local preprocessing rather than a managed data service.

6. **Feature engineering and joins**
   Because the source data is split across multiple relational tables, the training notebook likely performs the main data integration work: joining orders with customers, products, sellers, payments, and reviews, then deriving delivery-time-related features. That preprocessing boundary is important in the architecture because the app itself probably depends on the same input schema/feature format as the notebook produced.

7. **Application flow**
   The inference flow is likely:
   user input in Streamlit → feature preparation inside `streamlitApp.py` → load `voting_model.pkl` → generate OTD prediction → display result.  
   No backend service, API layer, or database is present, so the app is a self-contained local ML interface.

8. **Supporting UI and deployment config**
   The `.streamlit/config.toml` file customizes the Streamlit runtime, including a dark theme and disabled usage statistics. The `assets/` folder contains at least one schema image used in documentation, not runtime logic. These pieces support usability and presentation but do not change the core ML architecture.

9. **Environment and dependency boundary**
   `requirements.txt` and `packages.txt` define the Python and system-level dependencies needed for the notebook and Streamlit app. The presence of `.devcontainer/` suggests the repo is also set up for containerized development, which helps reproduce the same runtime environment across machines.

10. **Overall system picture**
   Architecturally, this is a **single-machine ML application** with three layers:
   - **data preparation/training** in the notebook,
   - **model artifact storage** in `voting_model.pkl`,
   - **interactive inference** in `streamlitApp.py`.  
   There are no signs of microservices, external databases, or cloud-hosted inference endpoints; the repo is built around local execution of a packaged model over local CSV data.

Main entry points: [`streamlitApp.py`](https://github.com/bhattkaushal/timelytics/blob/main/streamlitApp.py) (App entry), [`requirements.txt`](https://github.com/bhattkaushal/timelytics/blob/main/requirements.txt) (Dependencies), [`.devcontainer/devcontainer.json`](https://github.com/bhattkaushal/timelytics/blob/main/.devcontainer/devcontainer.json) (Dev container), [`Order to Delivery (OTD) Time Forecasting.ipynb`](https://github.com/bhattkaushal/timelytics/blob/HEAD/Order%20to%20Delivery%20(OTD)%20Time%20Forecasting.ipynb) (Training notebook)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Streamlit App"]
  node_streamlit_app["App entry<br/>streamlit runtime<br/>[streamlitApp.py]"]
  node_input_form["Input form<br/>ui input"]
  node_feature_prep["Feature prep<br/>inference prep"]
  node_model_loader["Model load<br/>artifact loader"]
  node_forecast_view["Forecast output<br/>result view"]
end

subgraph group_train["Training"]
  node_otd_notebook["Training notebook<br/>offline notebook"]
  node_join_features["Join features<br/>data integration"]
  node_ensemble_train["Ensemble train<br/>model training"]
  node_voting_model["Voting model<br/>serialized artifact<br/>[voting_model.pkl]"]
end

subgraph group_data["Data"]
  node_orders_csv["Orders data<br/>source table"]
  node_customers_csv["Customers data<br/>source table"]
  node_commerce_csvs["Commerce tables<br/>source tables"]
  node_category_map["Category map<br/>lookup table"]
end

subgraph group_env["Environment"]
  node_streamlit_cfg["Streamlit config<br/>runtime config<br/>[config.toml]"]
  node_deps["Dependencies<br/>package specs<br/>[requirements.txt]"]
  node_devcontainer["Dev container<br/>dev environment<br/>[devcontainer.json]"]
end

node_streamlit_app -->|"renders"| node_input_form
node_input_form -->|"submits"| node_feature_prep
node_feature_prep -->|"feeds"| node_model_loader
node_model_loader -->|"predicts"| node_forecast_view
node_otd_notebook -->|"builds"| node_join_features
node_join_features -->|"trains"| node_ensemble_train
node_ensemble_train -->|"exports"| node_voting_model
node_orders_csv -->|"input"| node_join_features
node_customers_csv -->|"input"| node_join_features
node_commerce_csvs -->|"input"| node_join_features
node_category_map -->|"input"| node_join_features
node_voting_model -->|"loads"| node_model_loader
node_streamlit_cfg -.->|"configures"| node_streamlit_app
node_deps -.->|"supports"| node_streamlit_app
node_deps -.->|"supports"| node_otd_notebook
node_devcontainer -.->|"provisions"| node_deps
node_devcontainer -.->|"provisions"| node_streamlit_app

click node_streamlit_app "https://github.com/bhattkaushal/timelytics/blob/main/streamlitApp.py"
click node_otd_notebook "https://github.com/bhattkaushal/timelytics/blob/main/Order to Delivery (OTD) Time Forecasting.ipynb"
click node_voting_model "https://github.com/bhattkaushal/timelytics/blob/main/voting_model.pkl"
click node_orders_csv "https://github.com/bhattkaushal/timelytics/blob/main/data/olist_orders_dataset.csv"
click node_customers_csv "https://github.com/bhattkaushal/timelytics/blob/main/data/olist_customers_dataset.csv"
click node_category_map "https://github.com/bhattkaushal/timelytics/blob/main/data/product_category_name_translation.csv"
click node_streamlit_cfg "https://github.com/bhattkaushal/timelytics/blob/main/.streamlit/config.toml"
click node_deps "https://github.com/bhattkaushal/timelytics/blob/main/requirements.txt"
click node_devcontainer "https://github.com/bhattkaushal/timelytics/blob/main/.devcontainer/devcontainer.json"

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_streamlit_app,node_input_form,node_feature_prep,node_model_loader,node_forecast_view toneBlue
class node_otd_notebook,node_join_features,node_ensemble_train,node_voting_model toneAmber
class node_orders_csv,node_customers_csv,node_commerce_csvs,node_category_map toneMint
class node_streamlit_cfg,node_deps,node_devcontainer toneRose
```

## Components

### Streamlit App

Interactive OTD prediction interface and inference flow

- [App entry](https://github.com/bhattkaushal/timelytics/blob/main/streamlitApp.py): streamlit runtime · User-facing Streamlit entrypoint for order-to-delivery forecasting · `streamlitApp.py`
- **Input form**: ui input · Collects order-related values from the user
- **Feature prep**: inference prep · Converts submitted order data into model-ready features
- **Model load**: artifact loader · Loads the serialized voting ensemble for prediction
- **Forecast output**: result view · Displays the predicted OTD time back to the user

### Training

Offline notebook workflow that builds the ensemble model

- [Training notebook](https://github.com/bhattkaushal/timelytics/blob/HEAD/Order%20to%20Delivery%20(OTD)%20Time%20Forecasting.ipynb): offline notebook · Experimentation and model development for OTD forecasting · `Order to Delivery (OTD) Time Forecasting.ipynb`
- **Join features**: data integration · Combines order, customer, product, payment, seller, and review tables
- **Ensemble train**: model training · Fits the voting ensemble from multiple learners
- [Voting model](https://github.com/bhattkaushal/timelytics/blob/main/voting_model.pkl): serialized artifact · Frozen pretrained ensemble consumed by the app · `voting_model.pkl`

### Data

Local Olist source tables used for feature building and training

- [Orders data](https://github.com/bhattkaushal/timelytics/blob/main/data/olist_orders_dataset.csv): source table · Core order records used for feature construction · `data/olist_orders_dataset.csv`
- [Customers data](https://github.com/bhattkaushal/timelytics/blob/main/data/olist_customers_dataset.csv): source table · Customer dimension table used in joins · `data/olist_customers_dataset.csv`
- **Commerce tables**: source tables · Order items, payments, reviews, products, and sellers tables
- [Category map](https://github.com/bhattkaushal/timelytics/blob/main/data/product_category_name_translation.csv): lookup table · Translation table for product category names · `data/product_category_name_translation.csv`

### Environment

Runtime and development configuration

- [Streamlit config](https://github.com/bhattkaushal/timelytics/blob/main/.streamlit/config.toml): runtime config · Theme and Streamlit runtime settings · `.streamlit/config.toml`
- [Dependencies](https://github.com/bhattkaushal/timelytics/blob/main/requirements.txt): package specs · Python and system dependency manifests · `requirements.txt`
- [Dev container](https://github.com/bhattkaushal/timelytics/blob/main/.devcontainer/devcontainer.json): dev environment · Containerized development setup · `.devcontainer/devcontainer.json`

## Connections

- App entry → Input form: renders · Starts the interactive order input flow
- Input form → Feature prep: submits · Collected order values are transformed into features
- Feature prep → Model load: feeds · Prepared features are passed to the pretrained model
- Model load → Forecast output: predicts · Model inference produces the forecast shown in the UI
- Training notebook → Join features: builds · Notebook assembles training features from relational source data
- Join features → Ensemble train: trains · Feature set is used to fit the ensemble learners
- Ensemble train → Voting model: exports · Training outputs the serialized voting artifact
- Orders data → Join features: input · Order records are a primary training source
- Customers data → Join features: input · Customer records are joined during feature engineering
- Commerce tables → Join features: input · Item, payment, review, product, and seller tables feed the join
- Category map → Join features: input · Category translation is used in preprocessing
- Voting model → Model load: loads · Streamlit inference consumes the saved ensemble artifact
- Streamlit config → App entry: configures · Applies Streamlit runtime and theme settings
- Dependencies → App entry: supports · Python dependencies required by the app
- Dependencies → Training notebook: supports · Notebook execution depends on the same package set
- Dev container → Dependencies: provisions · Containerized environment helps reproduce dependencies
- Dev container → App entry: provisions · Development container supports local app execution
