# skarshad1928/telco-churn-api architecture

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

- Interactive diagram: https://gitdiagram.com/skarshad1928/telco-churn-api
- Repository: https://github.com/skarshad1928/telco-churn-api

## Overview

This repository is a telecom churn prediction and retention application. A customer service representative enters a customer profile in the Streamlit portal; it sends the profile to the FastAPI endpoint, which assigns a cluster, scales features, and returns churn probability and risk tier for the portal’s retention guidance. Separately, a Dash dashboard filters the customer dataset and presents churn and value analytics. The README describes training and feature-engineering stages, but the available source does not expose their implementation; the graph focuses on the shipped prediction and analytics paths.

Main entry points: [`app.py`](https://github.com/skarshad1928/telco-churn-api/blob/main/app.py) (Prediction endpoint), [`dashboard.py`](https://github.com/skarshad1928/telco-churn-api/blob/main/dashboard.py) (Retention portal), [`visual.py`](https://github.com/skarshad1928/telco-churn-api/blob/main/visual.py) (Churn analytics), [`kmeans_cluster_model.pkl`](https://github.com/skarshad1928/telco-churn-api/blob/main/kmeans_cluster_model.pkl) (K-Means model)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_prediction["Prediction API"]
  node_api["Prediction endpoint<br/>[app.py]"]
  node_cluster["K-Means model"]
  node_scaler["Feature scaler<br/>[scaler.pkl]"]
  node_churn_model["Churn model"]
end

subgraph group_interfaces["User Interfaces"]
  node_portal["Retention portal<br/>[dashboard.py]"]
  node_guidance["Retention guidance<br/>[dashboard.py]"]
end

subgraph group_analytics["Analytics Data"]
  node_dataset["Telco customer data"]
  node_dashboard["Churn analytics<br/>[visual.py]"]
end

node_csr(("Service representative"))
node_analyst(("Business analyst"))

node_csr -->|"enters profile"| node_portal
node_portal -->|"posts prediction"| node_api
node_api -->|"assigns cluster"| node_cluster
node_api -->|"scales features"| node_scaler
node_api -->|"predicts risk"| node_churn_model
node_api -->|"returns scores"| node_portal
node_portal -->|"shows actions"| node_guidance
node_analyst -->|"filters insights"| node_dashboard
node_dashboard -->|"reads records"| node_dataset

click node_portal "https://github.com/skarshad1928/telco-churn-api/blob/main/dashboard.py"
click node_api "https://github.com/skarshad1928/telco-churn-api/blob/main/app.py"
click node_cluster "https://github.com/skarshad1928/telco-churn-api/blob/main/kmeans_cluster_model.pkl"
click node_scaler "https://github.com/skarshad1928/telco-churn-api/blob/main/scaler.pkl"
click node_churn_model "https://github.com/skarshad1928/telco-churn-api/blob/main/optimal_logistic_reg_model.pkl"
click node_guidance "https://github.com/skarshad1928/telco-churn-api/blob/main/dashboard.py"
click node_dataset "https://github.com/skarshad1928/telco-churn-api/blob/main/Telco_customer_churn.xlsx"
click node_dashboard "https://github.com/skarshad1928/telco-churn-api/blob/main/visual.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_api,node_cluster,node_scaler,node_churn_model toneBlue
class node_portal,node_guidance toneAmber
class node_dataset,node_dashboard toneMint
class node_csr,node_analyst toneIndigo
```

## Components

### Prediction API

- [Prediction endpoint](https://github.com/skarshad1928/telco-churn-api/blob/main/app.py): `app.py`
- [K-Means model](https://github.com/skarshad1928/telco-churn-api/blob/main/kmeans_cluster_model.pkl): `kmeans_cluster_model.pkl`
- [Feature scaler](https://github.com/skarshad1928/telco-churn-api/blob/main/scaler.pkl): `scaler.pkl`
- [Churn model](https://github.com/skarshad1928/telco-churn-api/blob/main/optimal_logistic_reg_model.pkl): `optimal_logistic_reg_model.pkl`

### User Interfaces

- [Retention portal](https://github.com/skarshad1928/telco-churn-api/blob/main/dashboard.py): `dashboard.py`
- [Retention guidance](https://github.com/skarshad1928/telco-churn-api/blob/main/dashboard.py): `dashboard.py`

### Analytics Data

- [Telco customer data](https://github.com/skarshad1928/telco-churn-api/blob/main/Telco_customer_churn.xlsx): `Telco_customer_churn.xlsx`
- [Churn analytics](https://github.com/skarshad1928/telco-churn-api/blob/main/visual.py): `visual.py`

### Other components

- **Service representative**
- **Business analyst**

## Connections

- Service representative → Retention portal: enters profile (evidence: `README.md`)
- Retention portal → Prediction endpoint: posts prediction (evidence: `dashboard.py`)
- Prediction endpoint → K-Means model: assigns cluster (evidence: `app.py`)
- Prediction endpoint → Feature scaler: scales features (evidence: `app.py`)
- Prediction endpoint → Churn model: predicts risk (evidence: `app.py`)
- Prediction endpoint → Retention portal: returns scores (evidence: `dashboard.py`)
- Retention portal → Retention guidance: shows actions (evidence: `dashboard.py`)
- Business analyst → Churn analytics: filters insights (evidence: `README.md`)
- Churn analytics → Telco customer data: reads records (evidence: `visual.py`)
