# vaibhav2824/retail-revenue-rescue architecture

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

- Interactive diagram: https://gitdiagram.com/vaibhav2824/retail-revenue-rescue
- Repository: https://github.com/vaibhav2824/retail-revenue-rescue

## Overview

Retail Revenue Rescue is a retail analytics and consulting product: raw sales data is landed, cleaned with rejected rows retained for audit, transformed into business-facing gold tables, and used for churn-risk scoring and reporting. Users explore findings in Power BI or ask questions through a guarded natural-language-to-SQL assistant. The sampled notebooks show the Databricks implementation; the README documents Power BI and workflow capabilities not represented by sampled source. Local pipeline details are also sampled. External platform and dashboard links rely on README documentation.

Main entry points: [`assistant/core.py`](https://github.com/vaibhav2824/retail-revenue-rescue/blob/main/assistant/core.py) (Assistant orchestration), [`retail/transforms.py`](https://github.com/vaibhav2824/retail-revenue-rescue/blob/main/retail/transforms.py) (Data transforms), [`notebooks/03_gold.py`](https://github.com/vaibhav2824/retail-revenue-rescue/blob/main/notebooks/03_gold.py) (Gold business tables), [`notebooks/02_silver.py`](https://github.com/vaibhav2824/retail-revenue-rescue/blob/main/notebooks/02_silver.py) (Silver transactions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_lakehouse["Lakehouse pipeline"]
  node_raw_volume[("Raw volume<br/>[01_bronze.py]")]
  node_bronze[("Bronze transactions<br/>[01_bronze.py]")]
  node_silver[("Silver transactions<br/>[02_silver.py]")]
  node_quarantine[("Silver quarantine<br/>[02_silver.py]")]
  node_transforms["Data transforms<br/>[transforms.py]"]
  node_table_writer["Delta table writer<br/>[tables.py]"]
end

subgraph group_analytics["Customer analytics"]
  node_gold[("Gold business tables<br/>[03_gold.py]")]
  node_churn_snapshot["Churn snapshots<br/>[transforms.py]"]
  node_churn_model["Churn model<br/>[churn.py]"]
  node_risk_scores[("Churn risk scores<br/>[04_churn_model.py]")]
  node_mlflow["MLflow tracking"]
end

subgraph group_assistant["Data assistant"]
  node_assistant_ui["Question interface<br/>[app.py]"]
  node_assistant_core["Assistant orchestration<br/>[core.py]"]
  node_sql_guard["Read-only SQL guard<br/>[core.py]"]
  node_query_runner["Gold query runner<br/>[core.py]"]
  node_answer["Answer and results<br/>[core.py]"]
end

subgraph group_reporting["Business reporting"]
  node_powerbi["Power BI dashboard"]
end

node_uci["Retail extract"]
node_databricks["Databricks platform"]
node_business_user(("Business user"))
node_groq["Groq language model"]

node_uci -->|"uploaded to"| node_raw_volume
node_raw_volume -->|"read and persisted"| node_bronze
node_bronze -->|"written by"| node_table_writer
node_bronze -->|"rows labeled"| node_transforms
node_transforms -->|"clean rows"| node_silver
node_transforms -->|"rejected rows"| node_quarantine
node_silver -->|"persisted by"| node_table_writer
node_silver -->|"aggregated by"| node_transforms
node_transforms -->|"business aggregates"| node_gold
node_gold -->|"persisted by"| node_table_writer
node_silver -->|"snapshot features"| node_churn_snapshot
node_churn_snapshot -->|"training data"| node_churn_model
node_churn_model -->|"logs model and metrics"| node_mlflow
node_churn_model -->|"scores customers"| node_risk_scores
node_risk_scores -->|"persisted by"| node_table_writer
node_databricks -.->|"hosts"| node_raw_volume
node_gold -->|"feeds dashboard"| node_powerbi
node_business_user -.->|"explores findings"| node_powerbi
node_business_user -->|"asks question"| node_assistant_ui
node_assistant_ui -->|"calls ask"| node_assistant_core
node_assistant_core -->|"generates SQL and prose"| node_groq
node_assistant_core -->|"checks generated SQL"| node_sql_guard
node_sql_guard -->|"permits safe query"| node_query_runner
node_query_runner -->|"reads gold tables"| node_gold
node_query_runner -->|"returns query data"| node_assistant_core
node_assistant_core -->|"returns answer and SQL"| node_answer
node_gold -->|"feeds assistant"| node_assistant_core

click node_raw_volume "https://github.com/vaibhav2824/retail-revenue-rescue/blob/main/notebooks/01_bronze.py"
click node_bronze "https://github.com/vaibhav2824/retail-revenue-rescue/blob/main/notebooks/01_bronze.py"
click node_silver "https://github.com/vaibhav2824/retail-revenue-rescue/blob/main/notebooks/02_silver.py"
click node_quarantine "https://github.com/vaibhav2824/retail-revenue-rescue/blob/main/notebooks/02_silver.py"
click node_transforms "https://github.com/vaibhav2824/retail-revenue-rescue/blob/main/retail/transforms.py"
click node_table_writer "https://github.com/vaibhav2824/retail-revenue-rescue/blob/main/retail/tables.py"
click node_gold "https://github.com/vaibhav2824/retail-revenue-rescue/blob/main/notebooks/03_gold.py"
click node_churn_snapshot "https://github.com/vaibhav2824/retail-revenue-rescue/blob/main/retail/transforms.py"
click node_churn_model "https://github.com/vaibhav2824/retail-revenue-rescue/blob/main/retail/churn.py"
click node_risk_scores "https://github.com/vaibhav2824/retail-revenue-rescue/blob/main/notebooks/04_churn_model.py"
click node_powerbi "https://github.com/vaibhav2824/retail-revenue-rescue/tree/main/powerbi"
click node_assistant_ui "https://github.com/vaibhav2824/retail-revenue-rescue/blob/main/assistant/app.py"
click node_assistant_core "https://github.com/vaibhav2824/retail-revenue-rescue/blob/main/assistant/core.py"
click node_sql_guard "https://github.com/vaibhav2824/retail-revenue-rescue/blob/main/assistant/core.py"
click node_query_runner "https://github.com/vaibhav2824/retail-revenue-rescue/blob/main/assistant/core.py"
click node_answer "https://github.com/vaibhav2824/retail-revenue-rescue/blob/main/assistant/core.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_raw_volume,node_bronze,node_silver,node_quarantine,node_transforms,node_table_writer,node_business_user toneBlue
class node_gold,node_churn_snapshot,node_churn_model,node_risk_scores,node_mlflow toneAmber
class node_assistant_ui,node_assistant_core,node_sql_guard,node_query_runner,node_answer toneMint
class node_powerbi toneRose
class node_uci,node_databricks,node_groq toneIndigo
```

## Components

### Lakehouse pipeline

- [Raw volume](https://github.com/vaibhav2824/retail-revenue-rescue/blob/main/notebooks/01_bronze.py): `notebooks/01_bronze.py`
- [Bronze transactions](https://github.com/vaibhav2824/retail-revenue-rescue/blob/main/notebooks/01_bronze.py): `notebooks/01_bronze.py`
- [Silver transactions](https://github.com/vaibhav2824/retail-revenue-rescue/blob/main/notebooks/02_silver.py): `notebooks/02_silver.py`
- [Silver quarantine](https://github.com/vaibhav2824/retail-revenue-rescue/blob/main/notebooks/02_silver.py): `notebooks/02_silver.py`
- [Data transforms](https://github.com/vaibhav2824/retail-revenue-rescue/blob/main/retail/transforms.py): `retail/transforms.py`
- [Delta table writer](https://github.com/vaibhav2824/retail-revenue-rescue/blob/main/retail/tables.py): `retail/tables.py`

### Customer analytics

- [Gold business tables](https://github.com/vaibhav2824/retail-revenue-rescue/blob/main/notebooks/03_gold.py): `notebooks/03_gold.py`
- [Churn snapshots](https://github.com/vaibhav2824/retail-revenue-rescue/blob/main/retail/transforms.py): `retail/transforms.py`
- [Churn model](https://github.com/vaibhav2824/retail-revenue-rescue/blob/main/retail/churn.py): `retail/churn.py`
- [Churn risk scores](https://github.com/vaibhav2824/retail-revenue-rescue/blob/main/notebooks/04_churn_model.py): `notebooks/04_churn_model.py`
- **MLflow tracking**

### Data assistant

- [Question interface](https://github.com/vaibhav2824/retail-revenue-rescue/blob/main/assistant/app.py): `assistant/app.py`
- [Assistant orchestration](https://github.com/vaibhav2824/retail-revenue-rescue/blob/main/assistant/core.py): `assistant/core.py`
- [Read-only SQL guard](https://github.com/vaibhav2824/retail-revenue-rescue/blob/main/assistant/core.py): `assistant/core.py`
- [Gold query runner](https://github.com/vaibhav2824/retail-revenue-rescue/blob/main/assistant/core.py): `assistant/core.py`
- [Answer and results](https://github.com/vaibhav2824/retail-revenue-rescue/blob/main/assistant/core.py): `assistant/core.py`

### Business reporting

- [Power BI dashboard](https://github.com/vaibhav2824/retail-revenue-rescue/tree/main/powerbi): `powerbi`

### Other components

- **Retail extract**
- **Databricks platform**
- **Business user**
- **Groq language model**

## Connections

- Retail extract → Raw volume: uploaded to (evidence: `README.md`)
- Raw volume → Bronze transactions: read and persisted (evidence: `notebooks/01_bronze.py`)
- Bronze transactions → Delta table writer: written by (evidence: `notebooks/01_bronze.py`)
- Bronze transactions → Data transforms: rows labeled
- Data transforms → Silver transactions: clean rows (evidence: `notebooks/02_silver.py`)
- Data transforms → Silver quarantine: rejected rows (evidence: `notebooks/02_silver.py`)
- Silver transactions → Delta table writer: persisted by (evidence: `notebooks/02_silver.py`)
- Silver transactions → Data transforms: aggregated by (evidence: `notebooks/02_silver.py`)
- Data transforms → Gold business tables: business aggregates (evidence: `notebooks/03_gold.py`)
- Gold business tables → Delta table writer: persisted by (evidence: `notebooks/03_gold.py`)
- Silver transactions → Churn snapshots: snapshot features (evidence: `notebooks/02_silver.py`)
- Churn snapshots → Churn model: training data (evidence: `notebooks/04_churn_model.py`)
- Churn model → MLflow tracking: logs model and metrics
- Churn model → Churn risk scores: scores customers (evidence: `notebooks/04_churn_model.py`)
- Churn risk scores → Delta table writer: persisted by (evidence: `notebooks/04_churn_model.py`)
- Databricks platform → Raw volume: hosts (evidence: `README.md`)
- Gold business tables → Power BI dashboard: feeds dashboard (evidence: `README.md`)
- Business user → Power BI dashboard: explores findings (evidence: `README.md`)
- Business user → Question interface: asks question (evidence: `assistant/app.py`)
- Question interface → Assistant orchestration: calls ask (evidence: `assistant/app.py`)
- Assistant orchestration → Groq language model: generates SQL and prose (evidence: `assistant/core.py`)
- Assistant orchestration → Read-only SQL guard: checks generated SQL (evidence: `assistant/core.py`)
- Read-only SQL guard → Gold query runner: permits safe query (evidence: `assistant/core.py`)
- Gold query runner → Gold business tables: reads gold tables (evidence: `assistant/core.py`)
- Gold query runner → Assistant orchestration: returns query data (evidence: `assistant/core.py`)
- Assistant orchestration → Answer and results: returns answer and SQL (evidence: `assistant/core.py`)
- Gold business tables → Assistant orchestration: feeds assistant (evidence: `README.md`)
