# hoaihue04/rfm-kmeans-clustering architecture

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

- Interactive diagram: https://gitdiagram.com/hoaihue04/rfm-kmeans-clustering
- Repository: https://github.com/hoaihue04/rfm-kmeans-clustering

## Overview

This repository documents an Online Retail customer-segmentation workflow: a Python notebook cleans transactions, calculates RFM features and clusters customers; PostgreSQL transforms staging data into a star-schema warehouse; and a Power BI report presents business and segment insights. The README also describes campaign recommendations and seasonal/product analysis. The graph reflects documented relationships only; source excerpts were unavailable, so artifact-level details beyond the README and filenames are omitted.

Main entry points: [`rfm_kmeans_clustering.ipynb`](https://github.com/hoaihue04/rfm-kmeans-clustering/blob/main/rfm_kmeans_clustering.ipynb) (RFM and K-Means), [`sql/01_create_dw_tables.sql`](https://github.com/hoaihue04/rfm-kmeans-clustering/blob/main/sql/01_create_dw_tables.sql) (Create DW Tables), [`sql/02_load_dw_from_staging.sql`](https://github.com/hoaihue04/rfm-kmeans-clustering/blob/main/sql/02_load_dw_from_staging.sql) (Load Warehouse)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_analysis["Customer Analysis"]
  node_notebook["RFM and K-Means"]
  node_model["K-Means Model"]
end

subgraph group_warehouse["Data Warehouse"]
  node_schema_sql["Create DW Tables"]
  node_load_sql["Load Warehouse"]
  node_validate_sql["Validate Data<br/>[03_validate.sql]"]
  node_postgres[("PostgreSQL Staging and DW")]
end

subgraph group_bi["Business Intelligence"]
  node_powerbi["Power BI Dashboard"]
end

node_retail_data["Online Retail II"]
node_business_user(("Business User"))

node_retail_data -->|"provides transactions"| node_notebook
node_notebook -->|"writes staging"| node_postgres
node_schema_sql -->|"creates tables"| node_postgres
node_load_sql -->|"loads star schema"| node_postgres
node_postgres -->|"imports data"| node_powerbi
node_powerbi -->|"shows insights"| node_business_user

click node_notebook "https://github.com/hoaihue04/rfm-kmeans-clustering/blob/main/rfm_kmeans_clustering.ipynb"
click node_model "https://github.com/hoaihue04/rfm-kmeans-clustering/blob/main/models/kmeans_rfm_k4-20111210.joblib"
click node_schema_sql "https://github.com/hoaihue04/rfm-kmeans-clustering/blob/main/sql/01_create_dw_tables.sql"
click node_load_sql "https://github.com/hoaihue04/rfm-kmeans-clustering/blob/main/sql/02_load_dw_from_staging.sql"
click node_validate_sql "https://github.com/hoaihue04/rfm-kmeans-clustering/blob/main/sql/03_validate.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_notebook,node_model,node_business_user toneBlue
class node_schema_sql,node_load_sql,node_validate_sql,node_postgres toneAmber
class node_powerbi toneMint
class node_retail_data toneIndigo
```

## Components

### Customer Analysis

- [RFM and K-Means](https://github.com/hoaihue04/rfm-kmeans-clustering/blob/main/rfm_kmeans_clustering.ipynb): `rfm_kmeans_clustering.ipynb`
- [K-Means Model](https://github.com/hoaihue04/rfm-kmeans-clustering/blob/main/models/kmeans_rfm_k4-20111210.joblib): `models/kmeans_rfm_k4-20111210.joblib`

### Data Warehouse

- [Create DW Tables](https://github.com/hoaihue04/rfm-kmeans-clustering/blob/main/sql/01_create_dw_tables.sql): `sql/01_create_dw_tables.sql`
- [Load Warehouse](https://github.com/hoaihue04/rfm-kmeans-clustering/blob/main/sql/02_load_dw_from_staging.sql): `sql/02_load_dw_from_staging.sql`
- [Validate Data](https://github.com/hoaihue04/rfm-kmeans-clustering/blob/main/sql/03_validate.sql): `sql/03_validate.sql`
- **PostgreSQL Staging and DW**

### Business Intelligence

- **Power BI Dashboard**

### Other components

- **Online Retail II**
- **Business User**

## Connections

- Online Retail II → RFM and K-Means: provides transactions (evidence: `README.md`)
- RFM and K-Means → PostgreSQL Staging and DW: writes staging (evidence: `README.md`)
- Create DW Tables → PostgreSQL Staging and DW: creates tables (evidence: `README.md`)
- Load Warehouse → PostgreSQL Staging and DW: loads star schema (evidence: `README.md`)
- PostgreSQL Staging and DW → Power BI Dashboard: imports data (evidence: `README.md`)
- Power BI Dashboard → Business User: shows insights (evidence: `README.md`)
