# pifarhan/customer-churn-prediction architecture

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

- Interactive diagram: https://gitdiagram.com/pifarhan/customer-churn-prediction
- Repository: https://github.com/pifarhan/customer-churn-prediction

## Overview

This repository is a customer-churn analytics and prediction application. Its user-facing workflow collects a customer profile, applies a saved Random Forest pipeline, and presents churn probability, a business-defined risk band, behavioral indicators, and retention suggestions. A separate notebook documents the data-analysis and model-training lifecycle, while the Streamlit app also presents model performance and feature-importance information. The notebook’s implementation was not sampled, so its stages and links are based on README documentation; the app’s inference and recommendation behavior is visible in the excerpt.

Main entry points: [`app/app.py`](https://github.com/pifarhan/customer-churn-prediction/blob/main/app/app.py) (Streamlit dashboard), [`notebooks/customer_churn_analysis.ipynb`](https://github.com/pifarhan/customer-churn-prediction/blob/main/notebooks/customer_churn_analysis.ipynb) (Data and model workflow), [`models/customer_churn_model.pkl`](https://github.com/pifarhan/customer-churn-prediction/blob/main/models/customer_churn_model.pkl) (Random Forest pipeline), [`data/customer_churn_dataset-testing-master.csv`](https://github.com/pifarhan/customer-churn-prediction/blob/main/data/customer_churn_dataset-testing-master.csv) (Customer data)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_analysis["Analysis and Training"]
  node_dataset[("Customer data")]
  node_analysis_workflow["Data and model workflow"]
end

subgraph group_artifacts["Model Artifacts"]
  node_pipeline["Random Forest pipeline"]
  node_metadata["Feature metadata<br/>[model_metadata.pkl]"]
end

subgraph group_dashboard["Prediction Dashboard"]
  node_dashboard_app["Streamlit dashboard<br/>[app.py]"]
  node_profile_input["Profile input<br/>[app.py]"]
  node_inference["Churn inference<br/>[app.py]"]
  node_performance["Model performance<br/>[app.py]"]
end

subgraph group_decision["Risk and Retention"]
  node_risk_band["Risk classification<br/>[app.py]"]
  node_risk_indicators["Behavioral indicators<br/>[app.py]"]
  node_retention["Retention recommendations<br/>[app.py]"]
  node_drivers["Churn drivers<br/>[app.py]"]
end

node_analyst(("Analyst"))
node_customer(("Customer profile"))

node_analyst -->|"analyzes data"| node_analysis_workflow
node_dataset -->|"analyzed by"| node_analysis_workflow
node_analysis_workflow -->|"trains and saves"| node_pipeline
node_customer -->|"uses"| node_dashboard_app
node_dashboard_app -->|"collects profile"| node_profile_input
node_profile_input -->|"predicts churn"| node_inference
node_dashboard_app -->|"loads for inference"| node_pipeline
node_dashboard_app -->|"uses feature metadata"| node_metadata
node_inference -->|"assigns risk band"| node_risk_band
node_inference -->|"shows indicators"| node_risk_indicators
node_inference -->|"suggests actions"| node_retention
node_dashboard_app -->|"shows feature importance"| node_drivers
node_dashboard_app -->|"shows metrics"| node_performance

click node_dataset "https://github.com/pifarhan/customer-churn-prediction/blob/main/data/customer_churn_dataset-testing-master.csv"
click node_analysis_workflow "https://github.com/pifarhan/customer-churn-prediction/blob/main/notebooks/customer_churn_analysis.ipynb"
click node_pipeline "https://github.com/pifarhan/customer-churn-prediction/blob/main/models/customer_churn_model.pkl"
click node_metadata "https://github.com/pifarhan/customer-churn-prediction/blob/main/models/model_metadata.pkl"
click node_dashboard_app "https://github.com/pifarhan/customer-churn-prediction/blob/main/app/app.py"
click node_profile_input "https://github.com/pifarhan/customer-churn-prediction/blob/main/app/app.py"
click node_inference "https://github.com/pifarhan/customer-churn-prediction/blob/main/app/app.py"
click node_performance "https://github.com/pifarhan/customer-churn-prediction/blob/main/app/app.py"
click node_risk_band "https://github.com/pifarhan/customer-churn-prediction/blob/main/app/app.py"
click node_risk_indicators "https://github.com/pifarhan/customer-churn-prediction/blob/main/app/app.py"
click node_retention "https://github.com/pifarhan/customer-churn-prediction/blob/main/app/app.py"
click node_drivers "https://github.com/pifarhan/customer-churn-prediction/blob/main/app/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,node_analysis_workflow toneBlue
class node_pipeline,node_metadata toneAmber
class node_dashboard_app,node_profile_input,node_inference,node_performance toneMint
class node_risk_band,node_risk_indicators,node_retention,node_drivers toneRose
class node_analyst,node_customer toneIndigo
```

## Components

### Analysis and Training

- [Customer data](https://github.com/pifarhan/customer-churn-prediction/blob/main/data/customer_churn_dataset-testing-master.csv): `data/customer_churn_dataset-testing-master.csv`
- [Data and model workflow](https://github.com/pifarhan/customer-churn-prediction/blob/main/notebooks/customer_churn_analysis.ipynb): `notebooks/customer_churn_analysis.ipynb`

### Model Artifacts

- [Random Forest pipeline](https://github.com/pifarhan/customer-churn-prediction/blob/main/models/customer_churn_model.pkl): `models/customer_churn_model.pkl`
- [Feature metadata](https://github.com/pifarhan/customer-churn-prediction/blob/main/models/model_metadata.pkl): `models/model_metadata.pkl`

### Prediction Dashboard

- [Streamlit dashboard](https://github.com/pifarhan/customer-churn-prediction/blob/main/app/app.py): `app/app.py`
- [Profile input](https://github.com/pifarhan/customer-churn-prediction/blob/main/app/app.py): `app/app.py`
- [Churn inference](https://github.com/pifarhan/customer-churn-prediction/blob/main/app/app.py): `app/app.py`
- [Model performance](https://github.com/pifarhan/customer-churn-prediction/blob/main/app/app.py): `app/app.py`

### Risk and Retention

- [Risk classification](https://github.com/pifarhan/customer-churn-prediction/blob/main/app/app.py): `app/app.py`
- [Behavioral indicators](https://github.com/pifarhan/customer-churn-prediction/blob/main/app/app.py): `app/app.py`
- [Retention recommendations](https://github.com/pifarhan/customer-churn-prediction/blob/main/app/app.py): `app/app.py`
- [Churn drivers](https://github.com/pifarhan/customer-churn-prediction/blob/main/app/app.py): `app/app.py`

### Other components

- **Analyst**
- **Customer profile**

## Connections

- Analyst → Data and model workflow: analyzes data (evidence: `README.md`)
- Customer data → Data and model workflow: analyzed by (evidence: `README.md`)
- Data and model workflow → Random Forest pipeline: trains and saves (evidence: `README.md`)
- Customer profile → Streamlit dashboard: uses (evidence: `README.md`)
- Streamlit dashboard → Profile input: collects profile (evidence: `app/app.py`)
- Profile input → Churn inference: predicts churn (evidence: `app/app.py`)
- Streamlit dashboard → Random Forest pipeline: loads for inference (evidence: `README.md`)
- Streamlit dashboard → Feature metadata: uses feature metadata (evidence: `README.md`)
- Churn inference → Risk classification: assigns risk band (evidence: `app/app.py`)
- Churn inference → Behavioral indicators: shows indicators (evidence: `README.md`)
- Churn inference → Retention recommendations: suggests actions (evidence: `app/app.py`)
- Streamlit dashboard → Churn drivers: shows feature importance (evidence: `README.md`)
- Streamlit dashboard → Model performance: shows metrics (evidence: `README.md`)
