# ajays0708/customer-segmentation-mysql architecture

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

- Interactive diagram: https://gitdiagram.com/ajays0708/customer-segmentation-mysql
- Repository: https://github.com/ajays0708/customer-segmentation-mysql

## Overview

This repository is a MySQL-based customer analytics project. Its main workflow loads order data into a database, computes customer metrics, derives spend-percentile loyalty tiers, and produces enriched and summarized segmentation outputs. The README also documents value-based segments, RFM and monthly/category analyses, and indexing. No SQL excerpts were provided, so the relationships below rely on README statements; the tree does not contain the separately documented analysis.sql or segmentation.sql files.

Main entry points: [`Customer-Segmentation-MySQL/schema.sql`](https://github.com/ajays0708/customer-segmentation-mysql/blob/main/Customer-Segmentation-MySQL/schema.sql) (E-commerce orders), [`Customer-Segmentation-MySQL/queries.sql`](https://github.com/ajays0708/customer-segmentation-mysql/blob/main/Customer-Segmentation-MySQL/queries.sql) (Customer metrics), [`Customer-Segmentation-MySQL/dataset/ecommerce_orders.csv`](https://github.com/ajays0708/customer-segmentation-mysql/blob/main/Customer-Segmentation-MySQL/dataset/ecommerce_orders.csv) (Order datasets), [`Customer-Segmentation-MySQL/customer_segment.csv`](https://github.com/ajays0708/customer-segmentation-mysql/blob/main/Customer-Segmentation-MySQL/customer_segment.csv) (Segment export)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Data and schema"]
  node_orderdata["Order datasets"]
  node_schema["Database schema<br/>[schema.sql]"]
  node_orders[("E-commerce orders<br/>[schema.sql]")]
end

subgraph group_segmentation["Customer segmentation"]
  node_metrics["Customer metrics<br/>[queries.sql]"]
  node_value["Value segments<br/>[queries.sql]"]
  node_tiers["Loyalty tiers<br/>[queries.sql]"]
  node_enriched["Enriched orders<br/>[queries.sql]"]
  node_final["Final segments<br/>[queries.sql]"]
end

subgraph group_analytics["Business analytics"]
  node_summary["Tier performance<br/>[queries.sql]"]
  node_otheranalytics["Additional analytics<br/>[queries.sql]"]
end

subgraph group_delivery["Results and performance"]
  node_indexes["Query indexes<br/>[schema.sql]"]
  node_export["Segment export"]
end

node_analyst(("Analyst"))
node_mysql[("MySQL")]

node_analyst -->|"runs SQL"| node_mysql
node_schema -->|"defines table"| node_orders
node_orderdata -->|"imports into"| node_orders
node_orders -->|"aggregates"| node_metrics
node_metrics -->|"compares labels"| node_value
node_metrics -->|"derives tiers"| node_tiers
node_orders -->|"joins tiers"| node_enriched
node_tiers -->|"adds loyalty tier"| node_enriched
node_enriched -->|"forms output"| node_final
node_final -->|"summarizes tiers"| node_summary
node_orders -->|"analyzes trends"| node_otheranalytics
node_schema -->|"creates indexes"| node_indexes
node_final -->|"exports results"| node_export

click node_orderdata "https://github.com/ajays0708/customer-segmentation-mysql/blob/main/Customer-Segmentation-MySQL/dataset/ecommerce_orders.csv"
click node_schema "https://github.com/ajays0708/customer-segmentation-mysql/blob/main/Customer-Segmentation-MySQL/schema.sql"
click node_orders "https://github.com/ajays0708/customer-segmentation-mysql/blob/main/Customer-Segmentation-MySQL/schema.sql"
click node_metrics "https://github.com/ajays0708/customer-segmentation-mysql/blob/main/Customer-Segmentation-MySQL/queries.sql"
click node_value "https://github.com/ajays0708/customer-segmentation-mysql/blob/main/Customer-Segmentation-MySQL/queries.sql"
click node_tiers "https://github.com/ajays0708/customer-segmentation-mysql/blob/main/Customer-Segmentation-MySQL/queries.sql"
click node_enriched "https://github.com/ajays0708/customer-segmentation-mysql/blob/main/Customer-Segmentation-MySQL/queries.sql"
click node_final "https://github.com/ajays0708/customer-segmentation-mysql/blob/main/Customer-Segmentation-MySQL/queries.sql"
click node_summary "https://github.com/ajays0708/customer-segmentation-mysql/blob/main/Customer-Segmentation-MySQL/queries.sql"
click node_otheranalytics "https://github.com/ajays0708/customer-segmentation-mysql/blob/main/Customer-Segmentation-MySQL/queries.sql"
click node_indexes "https://github.com/ajays0708/customer-segmentation-mysql/blob/main/Customer-Segmentation-MySQL/schema.sql"
click node_export "https://github.com/ajays0708/customer-segmentation-mysql/blob/main/Customer-Segmentation-MySQL/customer_segment.csv"

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_orderdata,node_schema,node_orders toneBlue
class node_metrics,node_value,node_tiers,node_enriched,node_final,node_mysql toneAmber
class node_summary,node_otheranalytics toneMint
class node_indexes,node_export toneRose
class node_analyst toneIndigo
```

## Components

### Data and schema

- [Order datasets](https://github.com/ajays0708/customer-segmentation-mysql/blob/main/Customer-Segmentation-MySQL/dataset/ecommerce_orders.csv): `Customer-Segmentation-MySQL/dataset/ecommerce_orders.csv`
- [Database schema](https://github.com/ajays0708/customer-segmentation-mysql/blob/main/Customer-Segmentation-MySQL/schema.sql): `Customer-Segmentation-MySQL/schema.sql`
- [E-commerce orders](https://github.com/ajays0708/customer-segmentation-mysql/blob/main/Customer-Segmentation-MySQL/schema.sql): `Customer-Segmentation-MySQL/schema.sql`

### Customer segmentation

- [Customer metrics](https://github.com/ajays0708/customer-segmentation-mysql/blob/main/Customer-Segmentation-MySQL/queries.sql): `Customer-Segmentation-MySQL/queries.sql`
- [Value segments](https://github.com/ajays0708/customer-segmentation-mysql/blob/main/Customer-Segmentation-MySQL/queries.sql): `Customer-Segmentation-MySQL/queries.sql`
- [Loyalty tiers](https://github.com/ajays0708/customer-segmentation-mysql/blob/main/Customer-Segmentation-MySQL/queries.sql): `Customer-Segmentation-MySQL/queries.sql`
- [Enriched orders](https://github.com/ajays0708/customer-segmentation-mysql/blob/main/Customer-Segmentation-MySQL/queries.sql): `Customer-Segmentation-MySQL/queries.sql`
- [Final segments](https://github.com/ajays0708/customer-segmentation-mysql/blob/main/Customer-Segmentation-MySQL/queries.sql): `Customer-Segmentation-MySQL/queries.sql`

### Business analytics

- [Tier performance](https://github.com/ajays0708/customer-segmentation-mysql/blob/main/Customer-Segmentation-MySQL/queries.sql): `Customer-Segmentation-MySQL/queries.sql`
- [Additional analytics](https://github.com/ajays0708/customer-segmentation-mysql/blob/main/Customer-Segmentation-MySQL/queries.sql): `Customer-Segmentation-MySQL/queries.sql`

### Results and performance

- [Query indexes](https://github.com/ajays0708/customer-segmentation-mysql/blob/main/Customer-Segmentation-MySQL/schema.sql): `Customer-Segmentation-MySQL/schema.sql`
- [Segment export](https://github.com/ajays0708/customer-segmentation-mysql/blob/main/Customer-Segmentation-MySQL/customer_segment.csv): `Customer-Segmentation-MySQL/customer_segment.csv`

### Other components

- **Analyst**
- **MySQL**

## Connections

- Analyst → MySQL: runs SQL (evidence: `README.md`)
- Database schema → E-commerce orders: defines table (evidence: `README.md`)
- Order datasets → E-commerce orders: imports into (evidence: `README.md`)
- E-commerce orders → Customer metrics: aggregates (evidence: `README.md`)
- Customer metrics → Value segments: compares labels (evidence: `README.md`)
- Customer metrics → Loyalty tiers: derives tiers (evidence: `README.md`)
- E-commerce orders → Enriched orders: joins tiers (evidence: `README.md`)
- Loyalty tiers → Enriched orders: adds loyalty tier (evidence: `README.md`)
- Enriched orders → Final segments: forms output (evidence: `README.md`)
- Final segments → Tier performance: summarizes tiers (evidence: `README.md`)
- E-commerce orders → Additional analytics: analyzes trends (evidence: `README.md`)
- Database schema → Query indexes: creates indexes (evidence: `README.md`)
- Final segments → Segment export: exports results (evidence: `README.md`)
