# parand1khalili/retail-forecast architecture

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

- Interactive diagram: https://gitdiagram.com/parand1khalili/retail-forecast
- Repository: https://github.com/parand1khalili/retail-forecast

## Overview

This is a local RA sales-forecasting application. A user uploads a workbook through the web interface; the service checks readiness, interprets the workbook schema, builds a dataset, and forecasts future periods. Users can also run model backtests and download forecast workbooks. The graph includes documented analysis and reporting capabilities as separate branches. Evidence is limited to the supplied excerpts and source index; unsampled implementation details and some wiring are therefore omitted.

Main entry points: [`forecasting/auto_engine.py`](https://github.com/parand1khalili/retail-forecast/blob/master/forecasting/auto_engine.py) (Automatic forecasts), [`forecasting/app.py`](https://github.com/parand1khalili/retail-forecast/blob/master/forecasting/app.py) (HTTP service), [`forecasting/app_core.py`](https://github.com/parand1khalili/retail-forecast/blob/master/forecasting/app_core.py) (Dataset parsing), [`forecasting/app_ui.html`](https://github.com/parand1khalili/retail-forecast/blob/master/forecasting/app_ui.html) (Web UI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Web interface"]
  node_ui["Web UI<br/>[app_ui.html]"]
  node_server["HTTP service<br/>[app.py]"]
  node_readiness["Runtime checks"]
  node_identity["Runtime identity"]
end

subgraph group_data["Data preparation"]
  node_schema["Schema detection<br/>[schema.py]"]
  node_dataset["Dataset parsing<br/>[app_core.py]"]
end

subgraph group_forecast["Forecasting"]
  node_engine["Automatic forecasts<br/>[auto_engine.py]"]
  node_selection["Selection policies<br/>[selection_core.py]"]
  node_category["Category selection"]
end

subgraph group_evaluation["Evaluation and outputs"]
  node_benchmark_levels["Level comparisons"]
  node_backtest["Backtest models<br/>[backtest.py]"]
  node_light["Light benchmark<br/>[light_benchmark.py]"]
  node_backtest_lab["Backtest audit<br/>[backtest_lab.py]"]
  node_hierarchy_audit["Hierarchy audit"]
  node_actuals["Actuals evaluation"]
  node_export["Full workbook export<br/>[full_export.py]"]
  node_forecast_export["Forecast export<br/>[export_forecast.py]"]
  node_report["Model report"]
end

node_user(("User"))

node_user -->|"uses"| node_ui
node_ui -->|"sends requests"| node_server
node_server -->|"checks readiness"| node_readiness
node_server -->|"loads workbook"| node_dataset
node_dataset -->|"resolves fields"| node_schema
node_server -->|"requests forecasts"| node_engine
node_engine -->|"uses dataset"| node_dataset
node_engine -->|"uses policies"| node_selection
node_engine -->|"selects recipes"| node_category
node_category -->|"uses comparisons"| node_benchmark_levels
node_server -->|"builds workbook"| node_export
node_export -->|"requests forecasts"| node_engine
node_server -->|"serves audit"| node_backtest_lab
node_backtest_lab -->|"uses audit"| node_hierarchy_audit
node_engine -->|"uses benchmarks"| node_backtest
node_engine -->|"uses benchmarks"| node_light
node_hierarchy_audit -->|"evaluates forecasts"| node_engine
node_server -.->|"reports runtime"| node_identity
node_dataset -.->|"evaluated against"| node_actuals
node_engine -->|"provides forecasts"| node_forecast_export
node_engine -->|"provides results"| node_report

click node_ui "https://github.com/parand1khalili/retail-forecast/blob/master/forecasting/app_ui.html"
click node_server "https://github.com/parand1khalili/retail-forecast/blob/master/forecasting/app.py"
click node_readiness "https://github.com/parand1khalili/retail-forecast/blob/master/forecasting/runtime_preflight.py"
click node_schema "https://github.com/parand1khalili/retail-forecast/blob/master/forecasting/schema.py"
click node_dataset "https://github.com/parand1khalili/retail-forecast/blob/master/forecasting/app_core.py"
click node_engine "https://github.com/parand1khalili/retail-forecast/blob/master/forecasting/auto_engine.py"
click node_selection "https://github.com/parand1khalili/retail-forecast/blob/master/forecasting/selection_core.py"
click node_category "https://github.com/parand1khalili/retail-forecast/blob/master/forecasting/category_selection.py"
click node_benchmark_levels "https://github.com/parand1khalili/retail-forecast/blob/master/forecasting/benchmark_levels.py"
click node_backtest "https://github.com/parand1khalili/retail-forecast/blob/master/forecasting/backtest.py"
click node_light "https://github.com/parand1khalili/retail-forecast/blob/master/forecasting/light_benchmark.py"
click node_backtest_lab "https://github.com/parand1khalili/retail-forecast/blob/master/forecasting/backtest_lab.py"
click node_hierarchy_audit "https://github.com/parand1khalili/retail-forecast/blob/master/forecasting/evaluate_hierarchy.py"
click node_actuals "https://github.com/parand1khalili/retail-forecast/blob/master/forecasting/evaluate_actuals.py"
click node_export "https://github.com/parand1khalili/retail-forecast/blob/master/forecasting/full_export.py"
click node_forecast_export "https://github.com/parand1khalili/retail-forecast/blob/master/forecasting/export_forecast.py"
click node_report "https://github.com/parand1khalili/retail-forecast/blob/master/forecasting/write_model_report.py"
click node_identity "https://github.com/parand1khalili/retail-forecast/blob/master/forecasting/runtime_identity.py"

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_ui,node_server,node_readiness,node_identity,node_user toneBlue
class node_schema,node_dataset toneAmber
class node_engine,node_selection,node_category toneMint
class node_benchmark_levels,node_backtest,node_light,node_backtest_lab,node_hierarchy_audit,node_actuals,node_export,node_forecast_export,node_report toneRose
```

## Components

### Web interface

- [Web UI](https://github.com/parand1khalili/retail-forecast/blob/master/forecasting/app_ui.html): `forecasting/app_ui.html`
- [HTTP service](https://github.com/parand1khalili/retail-forecast/blob/master/forecasting/app.py): `forecasting/app.py`
- [Runtime checks](https://github.com/parand1khalili/retail-forecast/blob/master/forecasting/runtime_preflight.py): `forecasting/runtime_preflight.py`
- [Runtime identity](https://github.com/parand1khalili/retail-forecast/blob/master/forecasting/runtime_identity.py): `forecasting/runtime_identity.py`

### Data preparation

- [Schema detection](https://github.com/parand1khalili/retail-forecast/blob/master/forecasting/schema.py): `forecasting/schema.py`
- [Dataset parsing](https://github.com/parand1khalili/retail-forecast/blob/master/forecasting/app_core.py): `forecasting/app_core.py`

### Forecasting

- [Automatic forecasts](https://github.com/parand1khalili/retail-forecast/blob/master/forecasting/auto_engine.py): `forecasting/auto_engine.py`
- [Selection policies](https://github.com/parand1khalili/retail-forecast/blob/master/forecasting/selection_core.py): `forecasting/selection_core.py`
- [Category selection](https://github.com/parand1khalili/retail-forecast/blob/master/forecasting/category_selection.py): `forecasting/category_selection.py`

### Evaluation and outputs

- [Level comparisons](https://github.com/parand1khalili/retail-forecast/blob/master/forecasting/benchmark_levels.py): `forecasting/benchmark_levels.py`
- [Backtest models](https://github.com/parand1khalili/retail-forecast/blob/master/forecasting/backtest.py): `forecasting/backtest.py`
- [Light benchmark](https://github.com/parand1khalili/retail-forecast/blob/master/forecasting/light_benchmark.py): `forecasting/light_benchmark.py`
- [Backtest audit](https://github.com/parand1khalili/retail-forecast/blob/master/forecasting/backtest_lab.py): `forecasting/backtest_lab.py`
- [Hierarchy audit](https://github.com/parand1khalili/retail-forecast/blob/master/forecasting/evaluate_hierarchy.py): `forecasting/evaluate_hierarchy.py`
- [Actuals evaluation](https://github.com/parand1khalili/retail-forecast/blob/master/forecasting/evaluate_actuals.py): `forecasting/evaluate_actuals.py`
- [Full workbook export](https://github.com/parand1khalili/retail-forecast/blob/master/forecasting/full_export.py): `forecasting/full_export.py`
- [Forecast export](https://github.com/parand1khalili/retail-forecast/blob/master/forecasting/export_forecast.py): `forecasting/export_forecast.py`
- [Model report](https://github.com/parand1khalili/retail-forecast/blob/master/forecasting/write_model_report.py): `forecasting/write_model_report.py`

### Other components

- **User**

## Connections

- User → Web UI: uses
- Web UI → HTTP service: sends requests
- HTTP service → Runtime checks: checks readiness (evidence: `forecasting/app.py`)
- HTTP service → Dataset parsing: loads workbook (evidence: `forecasting/app.py`)
- Dataset parsing → Schema detection: resolves fields (evidence: `forecasting/app_core.py`)
- HTTP service → Automatic forecasts: requests forecasts (evidence: `forecasting/app.py`)
- Automatic forecasts → Dataset parsing: uses dataset (evidence: `forecasting/auto_engine.py`)
- Automatic forecasts → Selection policies: uses policies (evidence: `forecasting/auto_engine.py`)
- Automatic forecasts → Category selection: selects recipes (evidence: `forecasting/auto_engine.py`)
- Category selection → Level comparisons: uses comparisons (evidence: `forecasting/category_selection.py`)
- HTTP service → Full workbook export: builds workbook (evidence: `forecasting/app.py`)
- Full workbook export → Automatic forecasts: requests forecasts (evidence: `forecasting/full_export.py`)
- HTTP service → Backtest audit: serves audit (evidence: `forecasting/app.py`)
- Backtest audit → Hierarchy audit: uses audit (evidence: `forecasting/backtest_lab.py`)
- Automatic forecasts → Backtest models: uses benchmarks (evidence: `forecasting/auto_engine.py`)
- Automatic forecasts → Light benchmark: uses benchmarks (evidence: `forecasting/auto_engine.py`)
- Hierarchy audit → Automatic forecasts: evaluates forecasts (evidence: `forecasting/evaluate_hierarchy.py`)
- HTTP service → Runtime identity: reports runtime (evidence: `forecasting/app.py`)
- Dataset parsing → Actuals evaluation: evaluated against
- Automatic forecasts → Forecast export: provides forecasts (evidence: `forecasting/export_forecast.py`)
- Automatic forecasts → Model report: provides results (evidence: `forecasting/write_model_report.py`)
