# divanshusingh-ds/customer-churn-ml architecture

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

- Interactive diagram: https://gitdiagram.com/divanshusingh-ds/customer-churn-ml
- Repository: https://github.com/divanshusingh-ds/customer-churn-ml

## Overview

ChurnGuard AI is a Streamlit application for turning customer attributes into churn predictions, risk levels, and retention guidance. The documented workflow also covers data analysis, preprocessing, model comparison and tuning, evaluation, and explainability. In the available source, app.py contains the interface, prediction logic, and model/artifact handling; README documents the broader analysis workflow, but its referenced notebook is absent from the tree. Some detailed analysis-stage connections therefore remain undocumented here.

Main entry points: [`app.py`](https://github.com/divanshusingh-ds/customer-churn-ml/blob/main/app.py) (Streamlit Interface), [`models/churn_model.pkl`](https://github.com/divanshusingh-ds/customer-churn-ml/blob/main/models/churn_model.pkl) (Trained Model), [`models/model_comparison.csv`](https://github.com/divanshusingh-ds/customer-churn-ml/blob/main/models/model_comparison.csv) (Model Comparison), [`models/feature_importance.csv`](https://github.com/divanshusingh-ds/customer-churn-ml/blob/main/models/feature_importance.csv) (Feature Importance)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_analysis["Data and Modeling"]
  node_prep["Data Preparation"]
  node_exploration["Churn Analysis"]
  node_modeling["Model Training"]
  node_evaluation["Model Evaluation"]
  node_explainability["Feature Explainability"]
end

subgraph group_runtime["Prediction App"]
  node_app["Streamlit Interface<br/>[app.py]"]
  node_prediction["Risk Prediction<br/>[app.py]"]
  node_retention["Retention Guidance<br/>[app.py]"]
end

subgraph group_insights["Evaluation and Insights"]
end

subgraph group_assets["Data and Model Assets"]
  node_source_data[("Customer Dataset")]
  node_model[("Trained Model<br/>[churn_model.pkl]")]
  node_comparison["Model Comparison"]
  node_confusion["Confusion Matrix"]
  node_roc["ROC Curve Data<br/>[roc_curve.csv]"]
  node_importance["Feature Importance"]
end

node_customer(("Business User"))

node_customer -->|"enters profile"| node_app
node_app -->|"submits profile"| node_prediction
node_prediction -->|"loads and predicts"| node_model
node_prediction -->|"classifies risk"| node_retention
node_source_data -->|"provides records"| node_prep
node_prep -->|"prepares for analysis"| node_exploration
node_exploration -->|"informs features"| node_modeling
node_modeling -->|"evaluated by"| node_evaluation
node_evaluation -->|"records comparison"| node_comparison
node_modeling -->|"saves model"| node_model
node_modeling -->|"supports analysis"| node_explainability
node_explainability -->|"generates importance"| node_importance
node_app -->|"reads results"| node_confusion
node_app -->|"reads curve data"| node_roc
node_app -->|"reads importance"| node_importance
node_app -->|"shows comparison"| node_comparison
node_retention -->|"supports action"| node_customer

click node_source_data "https://github.com/divanshusingh-ds/customer-churn-ml/blob/main/data/Telco-Customer-Churn.csv"
click node_app "https://github.com/divanshusingh-ds/customer-churn-ml/blob/main/app.py"
click node_prediction "https://github.com/divanshusingh-ds/customer-churn-ml/blob/main/app.py"
click node_retention "https://github.com/divanshusingh-ds/customer-churn-ml/blob/main/app.py"
click node_model "https://github.com/divanshusingh-ds/customer-churn-ml/blob/main/models/churn_model.pkl"
click node_comparison "https://github.com/divanshusingh-ds/customer-churn-ml/blob/main/models/model_comparison.csv"
click node_confusion "https://github.com/divanshusingh-ds/customer-churn-ml/blob/main/models/confusion_matrix.json"
click node_roc "https://github.com/divanshusingh-ds/customer-churn-ml/blob/main/models/roc_curve.csv"
click node_importance "https://github.com/divanshusingh-ds/customer-churn-ml/blob/main/models/feature_importance.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_prep,node_exploration,node_modeling,node_evaluation,node_explainability,node_customer toneBlue
class node_app,node_prediction,node_retention toneAmber
class node_source_data,node_model,node_comparison,node_confusion,node_roc,node_importance toneRose
```

## Components

### Data and Modeling

- **Data Preparation**
- **Churn Analysis**
- **Model Training**
- **Model Evaluation**
- **Feature Explainability**

### Prediction App

- [Streamlit Interface](https://github.com/divanshusingh-ds/customer-churn-ml/blob/main/app.py): `app.py`
- [Risk Prediction](https://github.com/divanshusingh-ds/customer-churn-ml/blob/main/app.py): `app.py`
- [Retention Guidance](https://github.com/divanshusingh-ds/customer-churn-ml/blob/main/app.py): `app.py`

### Data and Model Assets

- [Customer Dataset](https://github.com/divanshusingh-ds/customer-churn-ml/blob/main/data/Telco-Customer-Churn.csv): `data/Telco-Customer-Churn.csv`
- [Trained Model](https://github.com/divanshusingh-ds/customer-churn-ml/blob/main/models/churn_model.pkl): `models/churn_model.pkl`
- [Model Comparison](https://github.com/divanshusingh-ds/customer-churn-ml/blob/main/models/model_comparison.csv): `models/model_comparison.csv`
- [Confusion Matrix](https://github.com/divanshusingh-ds/customer-churn-ml/blob/main/models/confusion_matrix.json): `models/confusion_matrix.json`
- [ROC Curve Data](https://github.com/divanshusingh-ds/customer-churn-ml/blob/main/models/roc_curve.csv): `models/roc_curve.csv`
- [Feature Importance](https://github.com/divanshusingh-ds/customer-churn-ml/blob/main/models/feature_importance.csv): `models/feature_importance.csv`

### Other components

- **Business User**

## Connections

- Business User → Streamlit Interface: enters profile (evidence: `README.md`)
- Streamlit Interface → Risk Prediction: submits profile (evidence: `app.py`)
- Risk Prediction → Trained Model: loads and predicts (evidence: `app.py`)
- Risk Prediction → Retention Guidance: classifies risk (evidence: `README.md`)
- Customer Dataset → Data Preparation: provides records (evidence: `README.md`)
- Data Preparation → Churn Analysis: prepares for analysis (evidence: `README.md`)
- Churn Analysis → Model Training: informs features (evidence: `README.md`)
- Model Training → Model Evaluation: evaluated by (evidence: `README.md`)
- Model Evaluation → Model Comparison: records comparison (evidence: `README.md`)
- Model Training → Trained Model: saves model (evidence: `README.md`)
- Model Training → Feature Explainability: supports analysis (evidence: `README.md`)
- Feature Explainability → Feature Importance: generates importance (evidence: `README.md`)
- Streamlit Interface → Confusion Matrix: reads results (evidence: `app.py`)
- Streamlit Interface → ROC Curve Data: reads curve data (evidence: `app.py`)
- Streamlit Interface → Feature Importance: reads importance (evidence: `app.py`)
- Streamlit Interface → Model Comparison: shows comparison (evidence: `README.md`)
- Retention Guidance → Business User: supports action (evidence: `README.md`)
