# bitsbybhargav/customer-transaction-analytics- architecture

> Architecture diagram of the GitHub repository bitsbybhargav/customer-transaction-analytics-, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-05-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/bitsbybhargav/customer-transaction-analytics-
- Repository: https://github.com/bitsbybhargav/customer-transaction-analytics-

## Overview

1. **What this repo is**
   - This is a **customer transaction analytics / BI project**, not an application service.
   - The main deliverable is an analytics workflow: **SQL for KPI and segmentation logic**, **Python for exploratory analysis**, and a **Power BI model** for reporting.

2. **Primary data layer**
   - The repository includes five sanitized CSV exports that form the core relational dataset:
     - `customers_export.csv`
     - `orders_export.csv`
     - `order_items_export.csv`
     - `payments_export.csv`
     - `products_export.csv`
   - These files represent the base fact/dimension tables used across the SQL, notebook, and Power BI artifacts.

3. **SQL analytics subsystem**
   - The SQL work is split across multiple root-level files:
     - `CTA_Analytics_Suite.sql`
     - `CTA_queries.sql`
     - `Business_Intelligence_Queries.sql`
     - `foundationalqueries.sql`
     - `Technical_Evaluation_Suite.sql`
     - `RetailSales Practice Queries.sql`
   - Architecturally, these appear to represent **progressive query sets**: foundational extraction, intermediate aggregations, and advanced analytical queries.
   - The README indicates the final suite covers **RFM segmentation, payment leakage analysis, retention/cohort analysis, YoY growth, and AOV benchmarks**.

4. **Analytical boundaries in SQL**
   - The SQL layer is the main business logic engine.
   - It likely performs:
     - multi-table joins across customers/orders/items/payments/products
     - time-based aggregations
     - window-function-based ranking and segmentation
     - customer value classification
     - failed/pending payment reconciliation
   - This is the layer where business definitions are encoded and reused for downstream reporting.

5. **Python EDA layer**
   - `analysis.ipynb` is the exploratory analysis and visualization notebook.
   - According to the README, it recreates the 5-table schema in pandas and generates charts for:
     - monthly revenue trend
     - payment gateway success/failure comparison
     - city-wise transaction distribution
   - This is a read/transform/visualize layer, not the source of truth for core business rules.

6. **Export and connection utilities**
   - `test_connection.py` suggests a small utility for validating database connectivity before extraction.
   - `export_data.py` likely pulls data from the source database into the CSV exports.
   - Together, these form the ingestion boundary between the operational data source and the repository’s offline analytics artifacts.

7. **BI / dashboard layer**
   - `Model_VIew_CTA.pbix` is the Power BI semantic/reporting artifact.
   - It likely consumes the exported tables and/or modeled relationships to create interactive dashboards.
   - `dashboard images/` contains static visual outputs, probably screenshots or presentation assets derived from the PBIX/reporting layer.

8. **End-to-end data flow**
   - The implied flow is:
     - source database → `test_connection.py` validation
     - source database → `export_data.py` → CSV extracts
     - CSV extracts → SQL analysis suites
     - CSV extracts → `analysis.ipynb` for EDA
     - CSV extracts/modelled tables → `Model_VIew_CTA.pbix` for dashboards
   - So the repo is organized around **one dataset feeding three consumption paths**: SQL intelligence, notebook exploration, and BI reporting.

9. **Important architectural emphasis**
   - The project is logic-heavy and analytics-centric: the “application” is the **business interpretation of transactions**.
   - The core outputs are not APIs or services, but:
     - customer segments
     - leakage/recovery estimates
     - retention metrics
     - revenue trend analysis
     - gateway performance insights

10. **Repo structure note**
   - The README describes a more folderized layout, but the actual tree is flattened at the repo root.
   - For diagramming, it’s still best to treat the repo as three layers:
     - **data extraction/export**
     - **SQL analytics engine**
     - **Python/Power BI presentation and exploration**

Main entry points: [`export_data.py`](https://github.com/bitsbybhargav/customer-transaction-analytics-/blob/main/export_data.py) (Export Data), [`foundationalqueries.sql`](https://github.com/bitsbybhargav/customer-transaction-analytics-/blob/main/foundationalqueries.sql) (Foundations), [`Model_VIew_CTA.pbix`](https://github.com/bitsbybhargav/customer-transaction-analytics-/blob/main/Model_VIew_CTA.pbix) (Power BI), [`analysis.ipynb`](https://github.com/bitsbybhargav/customer-transaction-analytics-/blob/main/analysis.ipynb) (EDA Notebook)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingestion["Ingestion"]
  node_test_connection["Test Conn<br/>db check<br/>[test_connection.py]"]
  node_export_data["Export Data<br/>extract tool<br/>[export_data.py]"]
end

subgraph group_analytics["Analytics"]
  node_customers_export["Customers<br/>csv table"]
  node_orders_export["Orders<br/>csv fact<br/>[orders_export.csv]"]
  node_order_items_export["Order Items<br/>csv fact"]
  node_payments_export["Payments<br/>csv fact"]
  node_products_export["Products<br/>csv dimension"]
  node_foundationalqueries["Foundations<br/>sql base"]
  node_cta_queries["CTA Queries<br/>sql intermediate<br/>[CTA_queries.sql]"]
  node_cta_analytics_suite["Analytics Suite<br/>sql advanced"]
  node_technical_evaluation_suite["Eval Suite<br/>sql advanced"]
  node_business_intelligence_queries["BI Queries<br/>sql reporting"]
  node_retailsales_practice_queries["Practice SQL<br/>sql practice"]
  node_analysis_notebook["EDA Notebook<br/>python notebook<br/>[analysis.ipynb]"]
end

subgraph group_reporting["Reporting"]
  node_powerbi_model["Power BI<br/>bi model"]
  node_dashboard_images["Dashboards<br/>visual assets"]
end

node_test_connection -->|"validate"| node_export_data
node_export_data -->|"writes"| node_customers_export
node_export_data -->|"writes"| node_orders_export
node_export_data -->|"writes"| node_order_items_export
node_export_data -->|"writes"| node_payments_export
node_export_data -->|"writes"| node_products_export
node_customers_export -->|"feeds"| node_foundationalqueries
node_orders_export -->|"feeds"| node_foundationalqueries
node_order_items_export -->|"feeds"| node_foundationalqueries
node_payments_export -->|"feeds"| node_foundationalqueries
node_products_export -->|"feeds"| node_foundationalqueries
node_foundationalqueries -->|"builds"| node_cta_queries
node_cta_queries -->|"extends"| node_cta_analytics_suite
node_cta_analytics_suite -->|"informs"| node_technical_evaluation_suite
node_cta_analytics_suite -->|"reused by"| node_business_intelligence_queries
node_business_intelligence_queries -->|"complements"| node_retailsales_practice_queries
node_customers_export -->|"loads"| node_analysis_notebook
node_orders_export -->|"loads"| node_analysis_notebook
node_order_items_export -->|"loads"| node_analysis_notebook
node_payments_export -->|"loads"| node_analysis_notebook
node_products_export -->|"loads"| node_analysis_notebook
node_customers_export -->|"models"| node_powerbi_model
node_orders_export -->|"models"| node_powerbi_model
node_order_items_export -->|"models"| node_powerbi_model
node_payments_export -->|"models"| node_powerbi_model
node_products_export -->|"models"| node_powerbi_model
node_powerbi_model -->|"renders"| node_dashboard_images

click node_test_connection "https://github.com/bitsbybhargav/customer-transaction-analytics-/blob/main/test_connection.py"
click node_export_data "https://github.com/bitsbybhargav/customer-transaction-analytics-/blob/main/export_data.py"
click node_customers_export "https://github.com/bitsbybhargav/customer-transaction-analytics-/blob/main/customers_export.csv"
click node_orders_export "https://github.com/bitsbybhargav/customer-transaction-analytics-/blob/main/orders_export.csv"
click node_order_items_export "https://github.com/bitsbybhargav/customer-transaction-analytics-/blob/main/order_items_export.csv"
click node_payments_export "https://github.com/bitsbybhargav/customer-transaction-analytics-/blob/main/payments_export.csv"
click node_products_export "https://github.com/bitsbybhargav/customer-transaction-analytics-/blob/main/products_export.csv"
click node_foundationalqueries "https://github.com/bitsbybhargav/customer-transaction-analytics-/blob/main/foundationalqueries.sql"
click node_cta_queries "https://github.com/bitsbybhargav/customer-transaction-analytics-/blob/main/CTA_queries.sql"
click node_cta_analytics_suite "https://github.com/bitsbybhargav/customer-transaction-analytics-/blob/main/CTA_Analytics_Suite.sql"
click node_technical_evaluation_suite "https://github.com/bitsbybhargav/customer-transaction-analytics-/blob/main/Technical_Evaluation_Suite.sql"
click node_business_intelligence_queries "https://github.com/bitsbybhargav/customer-transaction-analytics-/blob/main/Business_Intelligence_Queries.sql"
click node_retailsales_practice_queries "https://github.com/bitsbybhargav/customer-transaction-analytics-/blob/main/RetailSales Practice Queries.sql"
click node_analysis_notebook "https://github.com/bitsbybhargav/customer-transaction-analytics-/blob/main/analysis.ipynb"
click node_powerbi_model "https://github.com/bitsbybhargav/customer-transaction-analytics-/blob/main/Model_VIew_CTA.pbix"
click node_dashboard_images "https://github.com/bitsbybhargav/customer-transaction-analytics-/tree/main/dashboard images"

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_test_connection,node_export_data toneBlue
class node_customers_export,node_orders_export,node_order_items_export,node_payments_export,node_products_export,node_foundationalqueries,node_cta_queries,node_cta_analytics_suite,node_technical_evaluation_suite,node_business_intelligence_queries,node_retailsales_practice_queries,node_analysis_notebook toneAmber
class node_powerbi_model,node_dashboard_images toneMint
```

## Components

### Ingestion

Database validation and CSV export utilities.

- [Test Conn](https://github.com/bitsbybhargav/customer-transaction-analytics-/blob/main/test_connection.py): db check · Validates source database access before extraction. · `test_connection.py`
- [Export Data](https://github.com/bitsbybhargav/customer-transaction-analytics-/blob/main/export_data.py): extract tool · Pulls source data into flat CSV exports. · `export_data.py`

### Analytics

SQL logic and notebook exploration over the exported customer transaction data.

- [Customers](https://github.com/bitsbybhargav/customer-transaction-analytics-/blob/main/customers_export.csv): csv table · Customer dimension export. · `customers_export.csv`
- [Orders](https://github.com/bitsbybhargav/customer-transaction-analytics-/blob/main/orders_export.csv): csv fact · Order transaction export. · `orders_export.csv`
- [Order Items](https://github.com/bitsbybhargav/customer-transaction-analytics-/blob/main/order_items_export.csv): csv fact · Line-item level order export. · `order_items_export.csv`
- [Payments](https://github.com/bitsbybhargav/customer-transaction-analytics-/blob/main/payments_export.csv): csv fact · Payment transaction export. · `payments_export.csv`
- [Products](https://github.com/bitsbybhargav/customer-transaction-analytics-/blob/main/products_export.csv): csv dimension · Product catalog export. · `products_export.csv`
- [Foundations](https://github.com/bitsbybhargav/customer-transaction-analytics-/blob/main/foundationalqueries.sql): sql base · Core extraction and baseline query logic. · `foundationalqueries.sql`
- [CTA Queries](https://github.com/bitsbybhargav/customer-transaction-analytics-/blob/main/CTA_queries.sql): sql intermediate · Intermediate analytical queries and joins. · `CTA_queries.sql`
- [Analytics Suite](https://github.com/bitsbybhargav/customer-transaction-analytics-/blob/main/CTA_Analytics_Suite.sql): sql advanced · Main KPI, segmentation, and cohort logic. · `CTA_Analytics_Suite.sql`
- [Eval Suite](https://github.com/bitsbybhargav/customer-transaction-analytics-/blob/main/Technical_Evaluation_Suite.sql): sql advanced · Technical evaluation and deeper analytical checks. · `Technical_Evaluation_Suite.sql`
- [BI Queries](https://github.com/bitsbybhargav/customer-transaction-analytics-/blob/main/Business_Intelligence_Queries.sql): sql reporting · Business intelligence query set for reporting metrics. · `Business_Intelligence_Queries.sql`
- [Practice SQL](https://github.com/bitsbybhargav/customer-transaction-analytics-/blob/HEAD/RetailSales%20Practice%20Queries.sql): sql practice · Practice-oriented retail sales analysis queries. · `RetailSales Practice Queries.sql`
- [EDA Notebook](https://github.com/bitsbybhargav/customer-transaction-analytics-/blob/main/analysis.ipynb): python notebook · Pandas exploration and visualization of the transaction dataset. · `analysis.ipynb`

### Reporting

Power BI model and derived dashboard visuals.

- [Power BI](https://github.com/bitsbybhargav/customer-transaction-analytics-/blob/main/Model_VIew_CTA.pbix): bi model · Semantic model and interactive reporting artifact. · `Model_VIew_CTA.pbix`
- [Dashboards](https://github.com/bitsbybhargav/customer-transaction-analytics-/tree/HEAD/dashboard%20images): visual assets · Static dashboard screenshots or presentation images. · `dashboard images`

## Connections

- Test Conn → Export Data: validate · Connection check precedes extraction.
- Export Data → Customers: writes · Exports customer data to CSV.
- Export Data → Orders: writes · Exports order data to CSV.
- Export Data → Order Items: writes · Exports line-item data to CSV.
- Export Data → Payments: writes · Exports payment data to CSV.
- Export Data → Products: writes · Exports product data to CSV.
- Customers → Foundations: feeds · Customer records support base SQL analysis.
- Orders → Foundations: feeds · Order records support base SQL analysis.
- Order Items → Foundations: feeds · Item-level records support base SQL analysis.
- Payments → Foundations: feeds · Payment records support base SQL analysis.
- Products → Foundations: feeds · Product records support base SQL analysis.
- Foundations → CTA Queries: builds · Foundational logic is refined into intermediate query sets.
- CTA Queries → Analytics Suite: extends · Intermediate logic rolls into the main analytics suite.
- Analytics Suite → Eval Suite: informs · Core KPI logic supports evaluation-oriented queries.
- Analytics Suite → BI Queries: reused by · Analytical definitions feed BI reporting queries.
- BI Queries → Practice SQL: complements · Reporting logic sits alongside practice-oriented SQL.
- Customers → EDA Notebook: loads · Notebook reconstructs the customer table in pandas.
- Orders → EDA Notebook: loads · Notebook reconstructs the order table in pandas.
- Order Items → EDA Notebook: loads · Notebook reconstructs the line-item table in pandas.
- Payments → EDA Notebook: loads · Notebook reconstructs the payment table in pandas.
- Products → EDA Notebook: loads · Notebook reconstructs the product table in pandas.
- Customers → Power BI: models · Customer data is consumed by the BI model.
- Orders → Power BI: models · Order data is consumed by the BI model.
- Order Items → Power BI: models · Item-level data is consumed by the BI model.
- Payments → Power BI: models · Payment data is consumed by the BI model.
- Products → Power BI: models · Product data is consumed by the BI model.
- Power BI → Dashboards: renders · PBIX produces dashboard visuals and screenshots.
