# manikumarreddyalla/retailinsight architecture

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

- Interactive diagram: https://gitdiagram.com/manikumarreddyalla/retailinsight
- Repository: https://github.com/manikumarreddyalla/retailinsight

## Overview

RetailInsight is a retail demand-forecasting platform: users request product forecasts through a Streamlit dashboard, which communicates with a FastAPI backend; the backend resolves product sales history, validates it, and produces forecasts with MATPFN or fallback models. A separate batch-training workflow evaluates models against naive baselines, applies quality gates, and stores artifacts in a registry. The README documents the UI/API capabilities and integrations; backend app and UI source were not sampled, so their detailed runtime wiring is not asserted.

Main entry points: [`backend/app.py`](https://github.com/manikumarreddyalla/retailinsight/blob/main/backend/app.py) (Forecast API), [`backend/evaluation.py`](https://github.com/manikumarreddyalla/retailinsight/blob/main/backend/evaluation.py) (Walk-forward evaluation), [`scripts/train.py`](https://github.com/manikumarreddyalla/retailinsight/blob/main/scripts/train.py) (Batch training), [`backend/model/predictor.py`](https://github.com/manikumarreddyalla/retailinsight/blob/main/backend/model/predictor.py) (Product forecast)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User experience"]
  node_dashboard["Analytics dashboard<br/>[ui.py]"]
  node_api["Forecast API<br/>[app.py]"]
end

subgraph group_forecasting["Forecasting runtime"]
  node_predictor["Product forecast<br/>[predictor.py]"]
  node_sales["Sales history<br/>[sales_dataset.csv]"]
  node_products["Product catalog"]
  node_calendar["Calendar data"]
  node_data_loader["Retail data loader<br/>[utils.py]"]
  node_input_quality["Validation and drift<br/>[validation.py]"]
end

subgraph group_modeling["Modeling and quality"]
  node_matpfn["MATPFN forecaster<br/>[matpfn.py]"]
  node_linear_model["Linear baseline"]
  node_xgb_model["XGBoost forecaster<br/>[xgboost_model.py]"]
  node_neural_model["Neural network model"]
  node_evaluation["Walk-forward evaluation<br/>[evaluation.py]"]
  node_training["Batch training<br/>[train.py]"]
end

subgraph group_operations["Model operations"]
  node_artifact_registry[("Artifact registry<br/>[registry.py]")]
  node_monitoring["Monitoring events<br/>[monitoring.py]"]
  node_event_log[("JSONL event log")]
end

node_user(("Retail user"))

node_user -->|"uses"| node_dashboard
node_dashboard -->|"requests forecasts"| node_api
node_api -.->|"orchestrates inference"| node_predictor
node_predictor -->|"loads history"| node_data_loader
node_data_loader -->|"reads"| node_sales
node_data_loader -->|"reads"| node_products
node_data_loader -->|"reads"| node_calendar
node_predictor -->|"validates and profiles"| node_input_quality
node_predictor -->|"trains and predicts"| node_matpfn
node_api -.->|"validates requests"| node_input_quality
node_training -->|"validates candidates"| node_evaluation
node_training -->|"trains or fine-tunes"| node_matpfn
node_training -->|"registers artifacts"| node_artifact_registry
node_training -->|"records quality"| node_monitoring
node_evaluation -->|"validates sales"| node_input_quality
node_evaluation -->|"trains and forecasts"| node_matpfn
node_evaluation -->|"trains and forecasts"| node_linear_model
node_evaluation -->|"trains and forecasts"| node_xgb_model
node_monitoring -->|"appends events"| node_event_log
node_api -.->|"logs inference"| node_monitoring
node_api -.->|"resolves models"| node_artifact_registry

click node_dashboard "https://github.com/manikumarreddyalla/retailinsight/blob/main/frontend/ui.py"
click node_api "https://github.com/manikumarreddyalla/retailinsight/blob/main/backend/app.py"
click node_predictor "https://github.com/manikumarreddyalla/retailinsight/blob/main/backend/model/predictor.py"
click node_sales "https://github.com/manikumarreddyalla/retailinsight/blob/main/backend/data/sales_dataset.csv"
click node_products "https://github.com/manikumarreddyalla/retailinsight/blob/main/backend/data/products_master.csv"
click node_calendar "https://github.com/manikumarreddyalla/retailinsight/blob/main/backend/data/calendar_dataset.csv"
click node_data_loader "https://github.com/manikumarreddyalla/retailinsight/blob/main/backend/utils.py"
click node_input_quality "https://github.com/manikumarreddyalla/retailinsight/blob/main/backend/validation.py"
click node_matpfn "https://github.com/manikumarreddyalla/retailinsight/blob/main/backend/model/matpfn.py"
click node_linear_model "https://github.com/manikumarreddyalla/retailinsight/blob/main/backend/model/linear_regression_model.py"
click node_xgb_model "https://github.com/manikumarreddyalla/retailinsight/blob/main/backend/model/xgboost_model.py"
click node_neural_model "https://github.com/manikumarreddyalla/retailinsight/blob/main/backend/model/neural_network_model.py"
click node_evaluation "https://github.com/manikumarreddyalla/retailinsight/blob/main/backend/evaluation.py"
click node_training "https://github.com/manikumarreddyalla/retailinsight/blob/main/scripts/train.py"
click node_artifact_registry "https://github.com/manikumarreddyalla/retailinsight/blob/main/backend/registry.py"
click node_monitoring "https://github.com/manikumarreddyalla/retailinsight/blob/main/backend/monitoring.py"
click node_event_log "https://github.com/manikumarreddyalla/retailinsight/blob/main/backend/models/monitoring_events.jsonl"

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_dashboard,node_api,node_user toneBlue
class node_predictor,node_sales,node_products,node_calendar,node_data_loader,node_input_quality toneAmber
class node_matpfn,node_linear_model,node_xgb_model,node_neural_model,node_evaluation,node_training toneMint
class node_artifact_registry,node_monitoring,node_event_log toneRose
```

## Components

### User experience

- [Analytics dashboard](https://github.com/manikumarreddyalla/retailinsight/blob/main/frontend/ui.py): `frontend/ui.py`
- [Forecast API](https://github.com/manikumarreddyalla/retailinsight/blob/main/backend/app.py): `backend/app.py`

### Forecasting runtime

- [Product forecast](https://github.com/manikumarreddyalla/retailinsight/blob/main/backend/model/predictor.py): `backend/model/predictor.py`
- [Sales history](https://github.com/manikumarreddyalla/retailinsight/blob/main/backend/data/sales_dataset.csv): `backend/data/sales_dataset.csv`
- [Product catalog](https://github.com/manikumarreddyalla/retailinsight/blob/main/backend/data/products_master.csv): `backend/data/products_master.csv`
- [Calendar data](https://github.com/manikumarreddyalla/retailinsight/blob/main/backend/data/calendar_dataset.csv): `backend/data/calendar_dataset.csv`
- [Retail data loader](https://github.com/manikumarreddyalla/retailinsight/blob/main/backend/utils.py): `backend/utils.py`
- [Validation and drift](https://github.com/manikumarreddyalla/retailinsight/blob/main/backend/validation.py): `backend/validation.py`

### Modeling and quality

- [MATPFN forecaster](https://github.com/manikumarreddyalla/retailinsight/blob/main/backend/model/matpfn.py): `backend/model/matpfn.py`
- [Linear baseline](https://github.com/manikumarreddyalla/retailinsight/blob/main/backend/model/linear_regression_model.py): `backend/model/linear_regression_model.py`
- [XGBoost forecaster](https://github.com/manikumarreddyalla/retailinsight/blob/main/backend/model/xgboost_model.py): `backend/model/xgboost_model.py`
- [Neural network model](https://github.com/manikumarreddyalla/retailinsight/blob/main/backend/model/neural_network_model.py): `backend/model/neural_network_model.py`
- [Walk-forward evaluation](https://github.com/manikumarreddyalla/retailinsight/blob/main/backend/evaluation.py): `backend/evaluation.py`
- [Batch training](https://github.com/manikumarreddyalla/retailinsight/blob/main/scripts/train.py): `scripts/train.py`

### Model operations

- [Artifact registry](https://github.com/manikumarreddyalla/retailinsight/blob/main/backend/registry.py): `backend/registry.py`
- [Monitoring events](https://github.com/manikumarreddyalla/retailinsight/blob/main/backend/monitoring.py): `backend/monitoring.py`
- [JSONL event log](https://github.com/manikumarreddyalla/retailinsight/blob/main/backend/models/monitoring_events.jsonl): `backend/models/monitoring_events.jsonl`

### Other components

- **Retail user**

## Connections

- Retail user → Analytics dashboard: uses (evidence: `README.md`)
- Analytics dashboard → Forecast API: requests forecasts (evidence: `README.md`)
- Forecast API → Product forecast: orchestrates inference
- Product forecast → Retail data loader: loads history (evidence: `backend/model/predictor.py`)
- Retail data loader → Sales history: reads (evidence: `backend/utils.py`)
- Retail data loader → Product catalog: reads (evidence: `backend/utils.py`)
- Retail data loader → Calendar data: reads (evidence: `backend/utils.py`)
- Product forecast → Validation and drift: validates and profiles (evidence: `backend/model/predictor.py`)
- Product forecast → MATPFN forecaster: trains and predicts (evidence: `backend/model/predictor.py`)
- Forecast API → Validation and drift: validates requests
- Batch training → Walk-forward evaluation: validates candidates (evidence: `scripts/train.py`)
- Batch training → MATPFN forecaster: trains or fine-tunes (evidence: `scripts/train.py`)
- Batch training → Artifact registry: registers artifacts (evidence: `scripts/train.py`)
- Batch training → Monitoring events: records quality (evidence: `scripts/train.py`)
- Walk-forward evaluation → Validation and drift: validates sales (evidence: `backend/evaluation.py`)
- Walk-forward evaluation → MATPFN forecaster: trains and forecasts (evidence: `backend/evaluation.py`)
- Walk-forward evaluation → Linear baseline: trains and forecasts (evidence: `backend/evaluation.py`)
- Walk-forward evaluation → XGBoost forecaster: trains and forecasts (evidence: `backend/evaluation.py`)
- Monitoring events → JSONL event log: appends events (evidence: `backend/monitoring.py`)
- Forecast API → Monitoring events: logs inference
- Forecast API → Artifact registry: resolves models
