# am4n-kxn/customer_behavior_analysis architecture

> Architecture diagram of the GitHub repository am4n-kxn/customer_behavior_analysis, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/am4n-kxn/customer_behavior_analysis
- Repository: https://github.com/am4n-kxn/customer_behavior_analysis

## Overview

#### Purpose and entry points
This repository is a customer-shopping analytics pipeline: raw CSV data is cleaned and modeled for PostgreSQL analysis, then presented in an executive Power BI dashboard. The primary artifacts are the source dataset at `customer_shopping_behavior_data.csv`, analysis/ETL notebook at `Customer Analysis.ipynb`, SQL implementation at `customer_behavior_sql_queries.sql`, and BI report at `Customer Behavior Dashboard.pbix`.

#### Raw data boundary
`customer_shopping_behavior_data.csv` is the system’s inbound data boundary. It contains the customer shopping behavior records used by every downstream stage. Data quality, missing-value handling, and schema normalization occur before database loading, separating source-file irregularities from relational analytics.

#### Processing and ETL
`Customer Analysis.ipynb` is the Python-oriented processing entry point, using Pandas and NumPy per the project description. Its role is to inspect, clean, format, and prepare records for transfer to PostgreSQL. SQLAlchemy and Psycopg2 form the application-to-database integration boundary, targeting a local PostgreSQL server managed through pgAdmin 4.

#### Relational analytics layer
`customer_behavior_sql_queries.sql` defines the database-facing analytics layer. It represents the PostgreSQL schema/query boundary used to organize transactional customer behavior data, apply relational structure and indexing, and produce reusable analytical results. PostgreSQL is the durable analytical store between Python ETL and Power BI consumption.

#### Business metrics and dashboarding
`Customer Behavior Dashboard.pbix` is the Power BI Desktop delivery layer. It consumes the prepared analytical data and exposes executive-oriented KPIs, DAX measures, conditional formatting, and interactive slicers. Power BI is the final consumer-facing boundary; dashboard filters should drive metric recalculation within the report rather than alter source data.

#### Primary control and data flow
1. Source records enter from `customer_shopping_behavior_data.csv`.
2. `Customer Analysis.ipynb` performs Python-based profiling, cleaning, missing-value treatment, and schema formatting.
3. Prepared data is loaded through SQLAlchemy/Psycopg2 into local PostgreSQL.
4. `customer_behavior_sql_queries.sql` creates or queries the relational analytical structure.
5. `Customer Behavior Dashboard.pbix` connects to the modeled data and renders filterable KPI and behavioral analysis views.

#### Material runtimes and infrastructure
The pipeline spans a Python notebook runtime, a local PostgreSQL database server, pgAdmin 4 for database administration, and Power BI Desktop for reporting. No deployed application service, API, orchestration platform, or cloud infrastructure is represented in the repository.

Main entry points: [`Customer Behavior Dashboard.pbix`](https://github.com/am4n-kxn/customer_behavior_analysis/blob/HEAD/Customer%20Behavior%20Dashboard.pbix) (Customer behavior dashboard), [`Customer Analysis.ipynb`](https://github.com/am4n-kxn/customer_behavior_analysis/blob/HEAD/Customer%20Analysis.ipynb) (Customer analysis notebook), [`customer_shopping_behavior_data.csv`](https://github.com/am4n-kxn/customer_behavior_analysis/blob/main/customer_shopping_behavior_data.csv) (Shopping behavior CSV), [`customer_behavior_sql_queries.sql`](https://github.com/am4n-kxn/customer_behavior_analysis/blob/main/customer_behavior_sql_queries.sql) (SQL analytics queries)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingest["Data preparation"]
  node_raw_csv["Shopping behavior CSV<br/>raw dataset"]
  node_notebook["Customer analysis notebook<br/>Python ETL"]
  node_cleaning["Cleaning and normalization<br/>ETL stage"]
  node_db_drivers["SQLAlchemy / Psycopg2<br/>database integration"]
end

subgraph group_database["Relational analytics"]
  node_postgres[("Local PostgreSQL<br/>analytical database")]
  node_sql_script["SQL analytics queries<br/>SQL implementation"]
  node_relational_model["Modeled analytics data<br/>relational layer"]
  node_pgadmin["pgAdmin 4<br/>database administration"]
end

subgraph group_reporting["Executive reporting"]
  node_powerbi["Customer behavior dashboard<br/>Power BI report"]
  node_dax_kpis["DAX KPIs and visuals<br/>report model"]
  node_slicers["Interactive slicers<br/>report interaction"]
end

node_raw_csv -->|"input"| node_notebook
node_notebook -->|"profiles and prepares"| node_cleaning
node_cleaning -->|"prepared records"| node_db_drivers
node_db_drivers -->|"loads"| node_postgres
node_sql_script -->|"creates and queries"| node_postgres
node_postgres -->|"organizes"| node_relational_model
node_pgadmin -.->|"administers"| node_postgres
node_postgres -->|"data connection"| node_powerbi
node_relational_model -->|"analytical data"| node_powerbi
node_powerbi -->|"defines"| node_dax_kpis
node_slicers -->|"recalculates"| node_dax_kpis

click node_raw_csv "https://github.com/am4n-kxn/customer_behavior_analysis/blob/main/customer_shopping_behavior_data.csv"
click node_notebook "https://github.com/am4n-kxn/customer_behavior_analysis/blob/main/Customer Analysis.ipynb"
click node_sql_script "https://github.com/am4n-kxn/customer_behavior_analysis/blob/main/customer_behavior_sql_queries.sql"
click node_powerbi "https://github.com/am4n-kxn/customer_behavior_analysis/blob/main/Customer Behavior Dashboard.pbix"

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_csv,node_notebook,node_cleaning,node_db_drivers toneBlue
class node_postgres,node_sql_script,node_relational_model,node_pgadmin toneAmber
class node_powerbi,node_dax_kpis,node_slicers toneMint
```

## Components

### Data preparation

- [Shopping behavior CSV](https://github.com/am4n-kxn/customer_behavior_analysis/blob/main/customer_shopping_behavior_data.csv): raw dataset · Inbound customer shopping records. · `customer_shopping_behavior_data.csv`
- [Customer analysis notebook](https://github.com/am4n-kxn/customer_behavior_analysis/blob/HEAD/Customer%20Analysis.ipynb): Python ETL · Pandas/NumPy processing entry point. · `Customer Analysis.ipynb`
- **Cleaning and normalization**: ETL stage · Profiles records, treats missing values, and formats schema.
- **SQLAlchemy / Psycopg2**: database integration · Loads prepared records into PostgreSQL.

### Relational analytics

- **Local PostgreSQL**: analytical database · Durable relational store between ETL and reporting.
- [SQL analytics queries](https://github.com/am4n-kxn/customer_behavior_analysis/blob/main/customer_behavior_sql_queries.sql): SQL implementation · Defines schema, indexing, and reusable analytics queries. · `customer_behavior_sql_queries.sql`
- **Modeled analytics data**: relational layer · Structured customer behavior data for analysis.
- **pgAdmin 4**: database administration · Administers the local PostgreSQL server.

### Executive reporting

- [Customer behavior dashboard](https://github.com/am4n-kxn/customer_behavior_analysis/blob/HEAD/Customer%20Behavior%20Dashboard.pbix): Power BI report · Executive-facing report delivery artifact. · `Customer Behavior Dashboard.pbix`
- **DAX KPIs and visuals**: report model · Calculates executive metrics and behavioral views.
- **Interactive slicers**: report interaction · Filters report views without changing source data.

## Connections

- Shopping behavior CSV → Customer analysis notebook: input
- Customer analysis notebook → Cleaning and normalization: profiles and prepares
- Cleaning and normalization → SQLAlchemy / Psycopg2: prepared records
- SQLAlchemy / Psycopg2 → Local PostgreSQL: loads
- SQL analytics queries → Local PostgreSQL: creates and queries
- Local PostgreSQL → Modeled analytics data: organizes
- pgAdmin 4 → Local PostgreSQL: administers
- Local PostgreSQL → Customer behavior dashboard: data connection
- Modeled analytics data → Customer behavior dashboard: analytical data
- Customer behavior dashboard → DAX KPIs and visuals: defines
- Interactive slicers → DAX KPIs and visuals: recalculates
