# devika1902/inventory-analysis architecture

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

- Interactive diagram: https://gitdiagram.com/devika1902/inventory-analysis
- Repository: https://github.com/devika1902/inventory-analysis

## Overview

This repository is a synthetic retail demand-forecasting and replenishment decision-support demo. Its main workflow generates store/product demand and inventory inputs, builds leakage-aware features, validates and selects a forecasting model, forecasts future demand, and derives constrained reorder recommendations. The pipeline writes CSV results that the Streamlit dashboard reads for interactive scenarios, visualizations, and downloads. BigQuery DDL and a dashboard view support an optional cloud/Looker Studio path. Source excerpts show the Python call chain; SQL loading details are documented rather than implemented here.

Main entry points: [`src/pipeline.py`](https://github.com/devika1902/inventory-analysis/blob/main/src/pipeline.py) (Pipeline runner), [`app.py`](https://github.com/devika1902/inventory-analysis/blob/main/app.py) (CSV data loader), [`src/forecast.py`](https://github.com/devika1902/inventory-analysis/blob/main/src/forecast.py) (Model validation), [`sql/dashboard_views.sql`](https://github.com/devika1902/inventory-analysis/blob/main/sql/dashboard_views.sql) (Inventory dashboard view)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_pipeline["Forecast pipeline"]
  node_pipeline_runner["Pipeline runner<br/>[pipeline.py]"]
  node_synthetic_inputs["Synthetic inputs<br/>[data.py]"]
  node_feature_engineering["Feature engineering<br/>[features.py]"]
  node_model_validation["Model validation<br/>[forecast.py]"]
  node_demand_forecasts["Demand forecasts<br/>[forecast.py]"]
  node_csv_outputs["Forecast and recommendation CSVs<br/>[pipeline.py]"]
end

subgraph group_planning["Inventory planning"]
  node_replenishment["Replenishment optimizer<br/>[inventory.py]"]
end

subgraph group_dashboard["Decision dashboard"]
  node_dashboard_loader["CSV data loader<br/>[app.py]"]
  node_scenario_controls["Scenario controls<br/>[app.py]"]
  node_risk_and_kpis["Risk and KPI views<br/>[app.py]"]
  node_forecast_views["Forecast and metrics views<br/>[app.py]"]
  node_downloads["CSV downloads<br/>[app.py]"]
end

subgraph group_warehouse["Analytics warehouse"]
  node_bigquery_schema["BigQuery table schema<br/>[schema.sql]"]
  node_dashboard_view["Inventory dashboard view"]
end

node_planner(("Retail planner"))
node_bigquery[("Google BigQuery")]
node_looker(("Looker Studio"))

node_planner -->|"runs pipeline"| node_pipeline_runner
node_pipeline_runner -->|"generates data"| node_synthetic_inputs
node_pipeline_runner -->|"builds features"| node_feature_engineering
node_pipeline_runner -->|"evaluates models"| node_model_validation
node_pipeline_runner -->|"fits forecasts"| node_demand_forecasts
node_model_validation -->|"uses features"| node_feature_engineering
node_pipeline_runner -->|"optimizes orders"| node_replenishment
node_pipeline_runner -->|"writes CSVs"| node_csv_outputs
node_planner -->|"opens dashboard"| node_dashboard_loader
node_csv_outputs -->|"loads CSVs"| node_dashboard_loader
node_dashboard_loader -->|"provides data"| node_scenario_controls
node_scenario_controls -->|"recalculates scenario"| node_replenishment
node_dashboard_loader -->|"filters and summarizes"| node_risk_and_kpis
node_dashboard_loader -->|"renders forecasts"| node_forecast_views
node_dashboard_loader -->|"exports data"| node_downloads
node_planner -.->|"loads CSV tables"| node_bigquery
node_bigquery_schema -.->|"defines tables"| node_bigquery
node_dashboard_view -.->|"defines view"| node_bigquery
node_looker -.->|"uses view"| node_dashboard_view

click node_pipeline_runner "https://github.com/devika1902/inventory-analysis/blob/main/src/pipeline.py"
click node_synthetic_inputs "https://github.com/devika1902/inventory-analysis/blob/main/src/data.py"
click node_feature_engineering "https://github.com/devika1902/inventory-analysis/blob/main/src/features.py"
click node_model_validation "https://github.com/devika1902/inventory-analysis/blob/main/src/forecast.py"
click node_demand_forecasts "https://github.com/devika1902/inventory-analysis/blob/main/src/forecast.py"
click node_replenishment "https://github.com/devika1902/inventory-analysis/blob/main/src/inventory.py"
click node_csv_outputs "https://github.com/devika1902/inventory-analysis/blob/main/src/pipeline.py"
click node_dashboard_loader "https://github.com/devika1902/inventory-analysis/blob/main/app.py"
click node_scenario_controls "https://github.com/devika1902/inventory-analysis/blob/main/app.py"
click node_risk_and_kpis "https://github.com/devika1902/inventory-analysis/blob/main/app.py"
click node_forecast_views "https://github.com/devika1902/inventory-analysis/blob/main/app.py"
click node_downloads "https://github.com/devika1902/inventory-analysis/blob/main/app.py"
click node_bigquery_schema "https://github.com/devika1902/inventory-analysis/blob/main/sql/schema.sql"
click node_dashboard_view "https://github.com/devika1902/inventory-analysis/blob/main/sql/dashboard_views.sql"

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_pipeline_runner,node_synthetic_inputs,node_feature_engineering,node_model_validation,node_demand_forecasts,node_csv_outputs toneBlue
class node_replenishment,node_bigquery toneAmber
class node_dashboard_loader,node_scenario_controls,node_risk_and_kpis,node_forecast_views,node_downloads toneMint
class node_bigquery_schema,node_dashboard_view toneRose
class node_planner,node_looker toneIndigo
```

## Components

### Forecast pipeline

- [Pipeline runner](https://github.com/devika1902/inventory-analysis/blob/main/src/pipeline.py): `src/pipeline.py`
- [Synthetic inputs](https://github.com/devika1902/inventory-analysis/blob/main/src/data.py): `src/data.py`
- [Feature engineering](https://github.com/devika1902/inventory-analysis/blob/main/src/features.py): `src/features.py`
- [Model validation](https://github.com/devika1902/inventory-analysis/blob/main/src/forecast.py): `src/forecast.py`
- [Demand forecasts](https://github.com/devika1902/inventory-analysis/blob/main/src/forecast.py): `src/forecast.py`
- [Forecast and recommendation CSVs](https://github.com/devika1902/inventory-analysis/blob/main/src/pipeline.py): `src/pipeline.py`

### Inventory planning

- [Replenishment optimizer](https://github.com/devika1902/inventory-analysis/blob/main/src/inventory.py): `src/inventory.py`

### Decision dashboard

- [CSV data loader](https://github.com/devika1902/inventory-analysis/blob/main/app.py): `app.py`
- [Scenario controls](https://github.com/devika1902/inventory-analysis/blob/main/app.py): `app.py`
- [Risk and KPI views](https://github.com/devika1902/inventory-analysis/blob/main/app.py): `app.py`
- [Forecast and metrics views](https://github.com/devika1902/inventory-analysis/blob/main/app.py): `app.py`
- [CSV downloads](https://github.com/devika1902/inventory-analysis/blob/main/app.py): `app.py`

### Analytics warehouse

- [BigQuery table schema](https://github.com/devika1902/inventory-analysis/blob/main/sql/schema.sql): `sql/schema.sql`
- [Inventory dashboard view](https://github.com/devika1902/inventory-analysis/blob/main/sql/dashboard_views.sql): `sql/dashboard_views.sql`

### Other components

- **Retail planner**
- **Google BigQuery**
- **Looker Studio**

## Connections

- Retail planner → Pipeline runner: runs pipeline (evidence: `README.md`)
- Pipeline runner → Synthetic inputs: generates data (evidence: `src/pipeline.py`)
- Pipeline runner → Feature engineering: builds features (evidence: `src/pipeline.py`)
- Pipeline runner → Model validation: evaluates models (evidence: `src/pipeline.py`)
- Pipeline runner → Demand forecasts: fits forecasts (evidence: `src/pipeline.py`)
- Model validation → Feature engineering: uses features (evidence: `src/forecast.py`)
- Pipeline runner → Replenishment optimizer: optimizes orders (evidence: `src/pipeline.py`)
- Pipeline runner → Forecast and recommendation CSVs: writes CSVs (evidence: `src/pipeline.py`)
- Retail planner → CSV data loader: opens dashboard (evidence: `README.md`)
- Forecast and recommendation CSVs → CSV data loader: loads CSVs (evidence: `app.py`)
- CSV data loader → Scenario controls: provides data (evidence: `app.py`)
- Scenario controls → Replenishment optimizer: recalculates scenario (evidence: `app.py`)
- CSV data loader → Risk and KPI views: filters and summarizes (evidence: `app.py`)
- CSV data loader → Forecast and metrics views: renders forecasts (evidence: `app.py`)
- CSV data loader → CSV downloads: exports data (evidence: `app.py`)
- Retail planner → Google BigQuery: loads CSV tables
- BigQuery table schema → Google BigQuery: defines tables (evidence: `README.md`)
- Inventory dashboard view → Google BigQuery: defines view (evidence: `README.md`)
- Looker Studio → Inventory dashboard view: uses view (evidence: `README.md`)
