# mahamoodmajin183-ui/enterprise-sales-profit-intelligence-platform architecture

> Architecture diagram of the GitHub repository mahamoodmajin183-ui/enterprise-sales-profit-intelligence-platform, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mahamoodmajin183-ui/enterprise-sales-profit-intelligence-platform
- Repository: https://github.com/mahamoodmajin183-ui/enterprise-sales-profit-intelligence-platform

## Overview

This is a local-first retail sales and profit intelligence platform. Its main workflow ingests order and return records, profiles and cleans them into an analytical dataset, builds a DuckDB warehouse, then serves KPI, trend, category, regional, discount, customer, and anomaly analysis through SQL and Python analytics. The Streamlit dashboard presents filtered metrics and visualizations, while an independent validator compares Python calculations with warehouse results. The graph follows documented pipeline links and indexed imports; unsampled SQL and dashboard internals are represented at subsystem level.

Main entry points: [`data/processed/retail_sales_clean.parquet`](https://github.com/mahamoodmajin183-ui/enterprise-sales-profit-intelligence-platform/blob/main/data/processed/retail_sales_clean.parquet) (Clean Sales Dataset), [`app/dashboard.py`](https://github.com/mahamoodmajin183-ui/enterprise-sales-profit-intelligence-platform/blob/main/app/dashboard.py) (Executive Dashboard), [`src/duckdb_manager.py`](https://github.com/mahamoodmajin183-ui/enterprise-sales-profit-intelligence-platform/blob/main/src/duckdb_manager.py) (DuckDB Warehouse), [`src/data_loader.py`](https://github.com/mahamoodmajin183-ui/enterprise-sales-profit-intelligence-platform/blob/main/src/data_loader.py) (Data Loader)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingest["Ingestion and Quality"]
  node_raw_orders["Order Records"]
  node_raw_returns["Returns Records"]
  node_loader["Data Loader<br/>[data_loader.py]"]
  node_profiler["Data Profiler<br/>[data_profiler.py]"]
  node_cleaner["Data Cleaner<br/>[data_cleaner.py]"]
  node_clean_data["Clean Sales Dataset"]
  node_quality_reports["Quality Reports"]
end

subgraph group_warehouse["Warehouse and Analytics"]
  node_config["Paths and Thresholds<br/>[config.py]"]
  node_warehouse_manager[("DuckDB Warehouse<br/>[duckdb_manager.py]")]
  node_warehouse_file[("Sales Warehouse")]
  node_sql_suite["SQL Analytics Suite<br/>[01_kpi_summary.sql]"]
end

subgraph group_insight["Business Insights"]
  node_metrics["Python Metrics<br/>[metrics_engine.py]"]
  node_anomalies["Loss Anomaly Detection"]
  node_reconciliation["SQL-Python Reconciliation"]
end

subgraph group_interface["Dashboard"]
  node_dashboard["Executive Dashboard<br/>[dashboard.py]"]
  node_charts["Plotly Charts<br/>[charts.py]"]
  node_powerbi["Power BI Model<br/>[powerbi_guide.md]"]
end

node_analyst(("Business Analyst"))

node_raw_orders -->|"loads"| node_loader
node_raw_returns -->|"loads"| node_loader
node_loader -->|"profiles"| node_profiler
node_loader -->|"supplies records"| node_cleaner
node_profiler -->|"writes profile"| node_quality_reports
node_cleaner -->|"writes dataset"| node_clean_data
node_cleaner -->|"writes validation"| node_quality_reports
node_clean_data -->|"loads Parquet"| node_warehouse_manager
node_warehouse_manager -->|"creates tables"| node_warehouse_file
node_warehouse_manager -->|"serves queries"| node_sql_suite
node_clean_data -->|"calculates from"| node_metrics
node_clean_data -->|"detects losses"| node_anomalies
node_metrics -->|"compares results"| node_reconciliation
node_warehouse_manager -->|"queries warehouse"| node_reconciliation
node_analyst -->|"uses"| node_dashboard
node_dashboard -->|"calls metrics"| node_metrics
node_dashboard -->|"calls detector"| node_anomalies
node_dashboard -->|"queries data"| node_warehouse_manager
node_dashboard -->|"renders charts"| node_charts
node_clean_data -->|"supports model"| node_powerbi

click node_raw_orders "https://github.com/mahamoodmajin183-ui/enterprise-sales-profit-intelligence-platform/blob/main/data/raw/superstore_orders.csv"
click node_raw_returns "https://github.com/mahamoodmajin183-ui/enterprise-sales-profit-intelligence-platform/blob/main/data/raw/superstore_returns.csv"
click node_loader "https://github.com/mahamoodmajin183-ui/enterprise-sales-profit-intelligence-platform/blob/main/src/data_loader.py"
click node_profiler "https://github.com/mahamoodmajin183-ui/enterprise-sales-profit-intelligence-platform/blob/main/src/data_profiler.py"
click node_cleaner "https://github.com/mahamoodmajin183-ui/enterprise-sales-profit-intelligence-platform/blob/main/src/data_cleaner.py"
click node_clean_data "https://github.com/mahamoodmajin183-ui/enterprise-sales-profit-intelligence-platform/blob/main/data/processed/retail_sales_clean.parquet"
click node_quality_reports "https://github.com/mahamoodmajin183-ui/enterprise-sales-profit-intelligence-platform/blob/main/data/quality_reports/validation_summary.json"
click node_config "https://github.com/mahamoodmajin183-ui/enterprise-sales-profit-intelligence-platform/blob/main/src/config.py"
click node_warehouse_manager "https://github.com/mahamoodmajin183-ui/enterprise-sales-profit-intelligence-platform/blob/main/src/duckdb_manager.py"
click node_warehouse_file "https://github.com/mahamoodmajin183-ui/enterprise-sales-profit-intelligence-platform/blob/main/database/sales_warehouse.duckdb"
click node_sql_suite "https://github.com/mahamoodmajin183-ui/enterprise-sales-profit-intelligence-platform/blob/main/sql/01_kpi_summary.sql"
click node_metrics "https://github.com/mahamoodmajin183-ui/enterprise-sales-profit-intelligence-platform/blob/main/src/metrics_engine.py"
click node_anomalies "https://github.com/mahamoodmajin183-ui/enterprise-sales-profit-intelligence-platform/blob/main/src/anomaly_detector.py"
click node_reconciliation "https://github.com/mahamoodmajin183-ui/enterprise-sales-profit-intelligence-platform/blob/main/src/reconciliation_validator.py"
click node_dashboard "https://github.com/mahamoodmajin183-ui/enterprise-sales-profit-intelligence-platform/blob/main/app/dashboard.py"
click node_charts "https://github.com/mahamoodmajin183-ui/enterprise-sales-profit-intelligence-platform/blob/main/app/components/charts.py"
click node_powerbi "https://github.com/mahamoodmajin183-ui/enterprise-sales-profit-intelligence-platform/blob/main/docs/powerbi_guide.md"

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_orders,node_raw_returns,node_loader,node_profiler,node_cleaner,node_clean_data,node_quality_reports toneBlue
class node_config,node_warehouse_manager,node_warehouse_file,node_sql_suite toneAmber
class node_metrics,node_anomalies,node_reconciliation toneMint
class node_dashboard,node_charts,node_powerbi toneRose
class node_analyst toneIndigo
```

## Components

### Ingestion and Quality

- [Order Records](https://github.com/mahamoodmajin183-ui/enterprise-sales-profit-intelligence-platform/blob/main/data/raw/superstore_orders.csv): `data/raw/superstore_orders.csv`
- [Returns Records](https://github.com/mahamoodmajin183-ui/enterprise-sales-profit-intelligence-platform/blob/main/data/raw/superstore_returns.csv): `data/raw/superstore_returns.csv`
- [Data Loader](https://github.com/mahamoodmajin183-ui/enterprise-sales-profit-intelligence-platform/blob/main/src/data_loader.py): `src/data_loader.py`
- [Data Profiler](https://github.com/mahamoodmajin183-ui/enterprise-sales-profit-intelligence-platform/blob/main/src/data_profiler.py): `src/data_profiler.py`
- [Data Cleaner](https://github.com/mahamoodmajin183-ui/enterprise-sales-profit-intelligence-platform/blob/main/src/data_cleaner.py): `src/data_cleaner.py`
- [Clean Sales Dataset](https://github.com/mahamoodmajin183-ui/enterprise-sales-profit-intelligence-platform/blob/main/data/processed/retail_sales_clean.parquet): `data/processed/retail_sales_clean.parquet`
- [Quality Reports](https://github.com/mahamoodmajin183-ui/enterprise-sales-profit-intelligence-platform/blob/main/data/quality_reports/validation_summary.json): `data/quality_reports/validation_summary.json`

### Warehouse and Analytics

- [Paths and Thresholds](https://github.com/mahamoodmajin183-ui/enterprise-sales-profit-intelligence-platform/blob/main/src/config.py): `src/config.py`
- [DuckDB Warehouse](https://github.com/mahamoodmajin183-ui/enterprise-sales-profit-intelligence-platform/blob/main/src/duckdb_manager.py): `src/duckdb_manager.py`
- [Sales Warehouse](https://github.com/mahamoodmajin183-ui/enterprise-sales-profit-intelligence-platform/blob/main/database/sales_warehouse.duckdb): `database/sales_warehouse.duckdb`
- [SQL Analytics Suite](https://github.com/mahamoodmajin183-ui/enterprise-sales-profit-intelligence-platform/blob/main/sql/01_kpi_summary.sql): `sql/01_kpi_summary.sql`

### Business Insights

- [Python Metrics](https://github.com/mahamoodmajin183-ui/enterprise-sales-profit-intelligence-platform/blob/main/src/metrics_engine.py): `src/metrics_engine.py`
- [Loss Anomaly Detection](https://github.com/mahamoodmajin183-ui/enterprise-sales-profit-intelligence-platform/blob/main/src/anomaly_detector.py): `src/anomaly_detector.py`
- [SQL-Python Reconciliation](https://github.com/mahamoodmajin183-ui/enterprise-sales-profit-intelligence-platform/blob/main/src/reconciliation_validator.py): `src/reconciliation_validator.py`

### Dashboard

- [Executive Dashboard](https://github.com/mahamoodmajin183-ui/enterprise-sales-profit-intelligence-platform/blob/main/app/dashboard.py): `app/dashboard.py`
- [Plotly Charts](https://github.com/mahamoodmajin183-ui/enterprise-sales-profit-intelligence-platform/blob/main/app/components/charts.py): `app/components/charts.py`
- [Power BI Model](https://github.com/mahamoodmajin183-ui/enterprise-sales-profit-intelligence-platform/blob/main/docs/powerbi_guide.md): `docs/powerbi_guide.md`

### Other components

- **Business Analyst**

## Connections

- Order Records → Data Loader: loads (evidence: `README.md`)
- Returns Records → Data Loader: loads (evidence: `README.md`)
- Data Loader → Data Profiler: profiles (evidence: `README.md`)
- Data Loader → Data Cleaner: supplies records (evidence: `README.md`)
- Data Profiler → Quality Reports: writes profile (evidence: `src/data_profiler.py`)
- Data Cleaner → Clean Sales Dataset: writes dataset (evidence: `README.md`)
- Data Cleaner → Quality Reports: writes validation (evidence: `README.md`)
- Clean Sales Dataset → DuckDB Warehouse: loads Parquet (evidence: `src/duckdb_manager.py`)
- DuckDB Warehouse → Sales Warehouse: creates tables (evidence: `README.md`)
- DuckDB Warehouse → SQL Analytics Suite: serves queries (evidence: `README.md`)
- Clean Sales Dataset → Python Metrics: calculates from (evidence: `README.md`)
- Clean Sales Dataset → Loss Anomaly Detection: detects losses (evidence: `README.md`)
- Python Metrics → SQL-Python Reconciliation: compares results (evidence: `src/reconciliation_validator.py`)
- DuckDB Warehouse → SQL-Python Reconciliation: queries warehouse (evidence: `src/reconciliation_validator.py`)
- Business Analyst → Executive Dashboard: uses (evidence: `README.md`)
- Executive Dashboard → Python Metrics: calls metrics (evidence: `app/dashboard.py`)
- Executive Dashboard → Loss Anomaly Detection: calls detector (evidence: `app/dashboard.py`)
- Executive Dashboard → DuckDB Warehouse: queries data (evidence: `app/dashboard.py`)
- Executive Dashboard → Plotly Charts: renders charts (evidence: `app/dashboard.py`)
- Clean Sales Dataset → Power BI Model: supports model (evidence: `README.md`)
