# johnteja20-afk/smart-retail-customer-analytics architecture

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

- Interactive diagram: https://gitdiagram.com/johnteja20-afk/smart-retail-customer-analytics
- Repository: https://github.com/johnteja20-afk/smart-retail-customer-analytics

## Overview

Smart Retail Customer Analytics is a small, script-based ML project with a Gradio prediction interface. Its main user workflow accepts customer attributes, derives an estimated purchase value, and returns repeat-purchase, spending, and segment predictions. The broader workflow creates and cleans synthetic data, explores and engineers features, trains and evaluates classification, regression, and clustering models, and persists model artifacts. The graph preserves documented tuning and analysis capabilities; some connections are documented in the README rather than verified in source excerpts, so those edges are marked dashed.

Main entry points: [`app.py`](https://github.com/johnteja20-afk/smart-retail-customer-analytics/blob/main/app.py) (Gradio Predictions), [`Data/feature_engineered_data.csv`](https://github.com/johnteja20-afk/smart-retail-customer-analytics/blob/main/Data/feature_engineered_data.csv) (Engineered Dataset), [`Data/cleaned_retail_data.csv`](https://github.com/johnteja20-afk/smart-retail-customer-analytics/blob/main/Data/cleaned_retail_data.csv) (Cleaned Dataset), [`save_clustering.py`](https://github.com/johnteja20-afk/smart-retail-customer-analytics/blob/main/save_clustering.py) (Cluster Persistence)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Customer Data"]
  node_dataset_gen["Synthetic Data<br/>[create_dataset.py]"]
  node_raw_data[("Retail Dataset<br/>[retail_data.csv]")]
  node_cleaning["Data Cleaning<br/>[clean_data.py]"]
  node_clean_data[("Cleaned Dataset")]
  node_inspection["Data Inspection<br/>[inspect_data.py]"]
  node_eda["Exploratory Analysis<br/>[eda.py]"]
  node_engineering["Feature Engineering"]
  node_feature_data[("Engineered Dataset")]
  node_clustered_data[("Clustered Dataset")]
end

subgraph group_ml["Modeling"]
  node_classification["Purchase Classifier"]
  node_classification_tuning["Classifier Tuning"]
  node_importance["Feature Importance"]
  node_regression["Spending Regressor"]
  node_regression_tuning["Regressor Tuning<br/>[tune_regression.py]"]
  node_clustering["Customer Clustering"]
  node_cluster_analysis["Cluster Analysis"]
end

subgraph group_artifacts["Model Artifacts"]
  node_cluster_saving["Cluster Persistence<br/>[save_clustering.py]"]
  node_model_saving["Model Persistence<br/>[save_models.py]"]
  node_classifier_file["Classifier Artifact"]
  node_regressor_file["Regressor Artifact"]
  node_kmeans_file["K-Means Artifact<br/>[kmeans_model.pkl]"]
  node_scaler_file["Scaler Artifact<br/>[scaler.pkl]"]
  node_features_file["Cluster Features"]
end

subgraph group_product["Prediction App"]
  node_model_loader["Model Loading<br/>[load_model.py]"]
  node_app["Gradio Predictions<br/>[app.py]"]
end

node_user(("Retail Analyst"))

node_dataset_gen -->|"writes"| node_raw_data
node_cleaning -->|"reads"| node_raw_data
node_cleaning -->|"writes"| node_clean_data
node_inspection -.->|"inspects"| node_clean_data
node_eda -->|"analyzes"| node_clean_data
node_engineering -->|"reads"| node_clean_data
node_engineering -->|"writes"| node_feature_data
node_classification -->|"reads"| node_feature_data
node_classification_tuning -->|"reads"| node_feature_data
node_importance -->|"reads"| node_feature_data
node_regression -->|"reads"| node_feature_data
node_regression_tuning -->|"reads"| node_feature_data
node_clustering -->|"reads"| node_feature_data
node_clustering -->|"writes"| node_clustered_data
node_cluster_analysis -.->|"analyzes"| node_clustered_data
node_model_saving -.->|"saves"| node_classifier_file
node_model_saving -.->|"saves"| node_regressor_file
node_cluster_saving -.->|"saves"| node_kmeans_file
node_cluster_saving -.->|"saves"| node_scaler_file
node_cluster_saving -.->|"saves"| node_features_file
node_user -->|"enters attributes"| node_app
node_app -->|"loads and predicts"| node_classifier_file
node_app -->|"loads and predicts"| node_regressor_file
node_app -->|"loads and predicts"| node_kmeans_file
node_app -->|"loads and scales"| node_scaler_file
node_app -->|"loads features"| node_features_file
node_model_loader -.->|"loads"| node_classifier_file
node_app -->|"returns predictions"| node_user

click node_dataset_gen "https://github.com/johnteja20-afk/smart-retail-customer-analytics/blob/main/create_dataset.py"
click node_raw_data "https://github.com/johnteja20-afk/smart-retail-customer-analytics/blob/main/Data/retail_data.csv"
click node_cleaning "https://github.com/johnteja20-afk/smart-retail-customer-analytics/blob/main/clean_data.py"
click node_clean_data "https://github.com/johnteja20-afk/smart-retail-customer-analytics/blob/main/Data/cleaned_retail_data.csv"
click node_inspection "https://github.com/johnteja20-afk/smart-retail-customer-analytics/blob/main/inspect_data.py"
click node_eda "https://github.com/johnteja20-afk/smart-retail-customer-analytics/blob/main/eda.py"
click node_engineering "https://github.com/johnteja20-afk/smart-retail-customer-analytics/blob/main/feature_engineering.py"
click node_feature_data "https://github.com/johnteja20-afk/smart-retail-customer-analytics/blob/main/Data/feature_engineered_data.csv"
click node_classification "https://github.com/johnteja20-afk/smart-retail-customer-analytics/blob/main/classification_model.py"
click node_classification_tuning "https://github.com/johnteja20-afk/smart-retail-customer-analytics/blob/main/tune_classification.py"
click node_importance "https://github.com/johnteja20-afk/smart-retail-customer-analytics/blob/main/feature_importance.py"
click node_regression "https://github.com/johnteja20-afk/smart-retail-customer-analytics/blob/main/regression_model.py"
click node_regression_tuning "https://github.com/johnteja20-afk/smart-retail-customer-analytics/blob/main/tune_regression.py"
click node_clustering "https://github.com/johnteja20-afk/smart-retail-customer-analytics/blob/main/clustering_model.py"
click node_cluster_analysis "https://github.com/johnteja20-afk/smart-retail-customer-analytics/blob/main/analyze_clusters.py"
click node_cluster_saving "https://github.com/johnteja20-afk/smart-retail-customer-analytics/blob/main/save_clustering.py"
click node_clustered_data "https://github.com/johnteja20-afk/smart-retail-customer-analytics/blob/main/Data/clustered_retail_data.csv"
click node_model_saving "https://github.com/johnteja20-afk/smart-retail-customer-analytics/blob/main/save_models.py"
click node_classifier_file "https://github.com/johnteja20-afk/smart-retail-customer-analytics/blob/main/models/classification_model.pkl"
click node_regressor_file "https://github.com/johnteja20-afk/smart-retail-customer-analytics/blob/main/models/regression_model.pkl"
click node_kmeans_file "https://github.com/johnteja20-afk/smart-retail-customer-analytics/blob/main/models/kmeans_model.pkl"
click node_scaler_file "https://github.com/johnteja20-afk/smart-retail-customer-analytics/blob/main/models/scaler.pkl"
click node_features_file "https://github.com/johnteja20-afk/smart-retail-customer-analytics/blob/main/models/clustering_features.pkl"
click node_model_loader "https://github.com/johnteja20-afk/smart-retail-customer-analytics/blob/main/load_model.py"
click node_app "https://github.com/johnteja20-afk/smart-retail-customer-analytics/blob/main/app.py"

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_dataset_gen,node_raw_data,node_cleaning,node_clean_data,node_inspection,node_eda,node_engineering,node_feature_data,node_clustered_data toneBlue
class node_classification,node_classification_tuning,node_importance,node_regression,node_regression_tuning,node_clustering,node_cluster_analysis toneAmber
class node_cluster_saving,node_model_saving,node_classifier_file,node_regressor_file,node_kmeans_file,node_scaler_file,node_features_file toneMint
class node_model_loader,node_app toneRose
class node_user toneIndigo
```

## Components

### Customer Data

- [Synthetic Data](https://github.com/johnteja20-afk/smart-retail-customer-analytics/blob/main/create_dataset.py): `create_dataset.py`
- [Retail Dataset](https://github.com/johnteja20-afk/smart-retail-customer-analytics/blob/main/Data/retail_data.csv): `Data/retail_data.csv`
- [Data Cleaning](https://github.com/johnteja20-afk/smart-retail-customer-analytics/blob/main/clean_data.py): `clean_data.py`
- [Cleaned Dataset](https://github.com/johnteja20-afk/smart-retail-customer-analytics/blob/main/Data/cleaned_retail_data.csv): `Data/cleaned_retail_data.csv`
- [Data Inspection](https://github.com/johnteja20-afk/smart-retail-customer-analytics/blob/main/inspect_data.py): `inspect_data.py`
- [Exploratory Analysis](https://github.com/johnteja20-afk/smart-retail-customer-analytics/blob/main/eda.py): `eda.py`
- [Feature Engineering](https://github.com/johnteja20-afk/smart-retail-customer-analytics/blob/main/feature_engineering.py): `feature_engineering.py`
- [Engineered Dataset](https://github.com/johnteja20-afk/smart-retail-customer-analytics/blob/main/Data/feature_engineered_data.csv): `Data/feature_engineered_data.csv`
- [Clustered Dataset](https://github.com/johnteja20-afk/smart-retail-customer-analytics/blob/main/Data/clustered_retail_data.csv): `Data/clustered_retail_data.csv`

### Modeling

- [Purchase Classifier](https://github.com/johnteja20-afk/smart-retail-customer-analytics/blob/main/classification_model.py): `classification_model.py`
- [Classifier Tuning](https://github.com/johnteja20-afk/smart-retail-customer-analytics/blob/main/tune_classification.py): `tune_classification.py`
- [Feature Importance](https://github.com/johnteja20-afk/smart-retail-customer-analytics/blob/main/feature_importance.py): `feature_importance.py`
- [Spending Regressor](https://github.com/johnteja20-afk/smart-retail-customer-analytics/blob/main/regression_model.py): `regression_model.py`
- [Regressor Tuning](https://github.com/johnteja20-afk/smart-retail-customer-analytics/blob/main/tune_regression.py): `tune_regression.py`
- [Customer Clustering](https://github.com/johnteja20-afk/smart-retail-customer-analytics/blob/main/clustering_model.py): `clustering_model.py`
- [Cluster Analysis](https://github.com/johnteja20-afk/smart-retail-customer-analytics/blob/main/analyze_clusters.py): `analyze_clusters.py`

### Model Artifacts

- [Cluster Persistence](https://github.com/johnteja20-afk/smart-retail-customer-analytics/blob/main/save_clustering.py): `save_clustering.py`
- [Model Persistence](https://github.com/johnteja20-afk/smart-retail-customer-analytics/blob/main/save_models.py): `save_models.py`
- [Classifier Artifact](https://github.com/johnteja20-afk/smart-retail-customer-analytics/blob/main/models/classification_model.pkl): `models/classification_model.pkl`
- [Regressor Artifact](https://github.com/johnteja20-afk/smart-retail-customer-analytics/blob/main/models/regression_model.pkl): `models/regression_model.pkl`
- [K-Means Artifact](https://github.com/johnteja20-afk/smart-retail-customer-analytics/blob/main/models/kmeans_model.pkl): `models/kmeans_model.pkl`
- [Scaler Artifact](https://github.com/johnteja20-afk/smart-retail-customer-analytics/blob/main/models/scaler.pkl): `models/scaler.pkl`
- [Cluster Features](https://github.com/johnteja20-afk/smart-retail-customer-analytics/blob/main/models/clustering_features.pkl): `models/clustering_features.pkl`

### Prediction App

- [Model Loading](https://github.com/johnteja20-afk/smart-retail-customer-analytics/blob/main/load_model.py): `load_model.py`
- [Gradio Predictions](https://github.com/johnteja20-afk/smart-retail-customer-analytics/blob/main/app.py): `app.py`

### Other components

- **Retail Analyst**

## Connections

- Synthetic Data → Retail Dataset: writes (evidence: `create_dataset.py`)
- Data Cleaning → Retail Dataset: reads (evidence: `clean_data.py`)
- Data Cleaning → Cleaned Dataset: writes (evidence: `clean_data.py`)
- Data Inspection → Cleaned Dataset: inspects (evidence: `README.md`)
- Exploratory Analysis → Cleaned Dataset: analyzes (evidence: `eda.py`)
- Feature Engineering → Cleaned Dataset: reads (evidence: `feature_engineering.py`)
- Feature Engineering → Engineered Dataset: writes (evidence: `feature_engineering.py`)
- Purchase Classifier → Engineered Dataset: reads (evidence: `classification_model.py`)
- Classifier Tuning → Engineered Dataset: reads (evidence: `tune_classification.py`)
- Feature Importance → Engineered Dataset: reads (evidence: `feature_importance.py`)
- Spending Regressor → Engineered Dataset: reads (evidence: `regression_model.py`)
- Regressor Tuning → Engineered Dataset: reads (evidence: `tune_regression.py`)
- Customer Clustering → Engineered Dataset: reads (evidence: `clustering_model.py`)
- Customer Clustering → Clustered Dataset: writes (evidence: `clustering_model.py`)
- Cluster Analysis → Clustered Dataset: analyzes (evidence: `README.md`)
- Model Persistence → Classifier Artifact: saves (evidence: `README.md`)
- Model Persistence → Regressor Artifact: saves (evidence: `README.md`)
- Cluster Persistence → K-Means Artifact: saves (evidence: `README.md`)
- Cluster Persistence → Scaler Artifact: saves (evidence: `README.md`)
- Cluster Persistence → Cluster Features: saves (evidence: `README.md`)
- Retail Analyst → Gradio Predictions: enters attributes (evidence: `app.py`)
- Gradio Predictions → Classifier Artifact: loads and predicts (evidence: `app.py`)
- Gradio Predictions → Regressor Artifact: loads and predicts (evidence: `app.py`)
- Gradio Predictions → K-Means Artifact: loads and predicts (evidence: `app.py`)
- Gradio Predictions → Scaler Artifact: loads and scales (evidence: `app.py`)
- Gradio Predictions → Cluster Features: loads features (evidence: `app.py`)
- Model Loading → Classifier Artifact: loads (evidence: `README.md`)
- Gradio Predictions → Retail Analyst: returns predictions (evidence: `app.py`)
