# mitesh256/customer_churn_predictor architecture

> Architecture diagram of the GitHub repository mitesh256/customer_churn_predictor, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mitesh256/customer_churn_predictor
- Repository: https://github.com/mitesh256/customer_churn_predictor

## Overview

ChurnSight collects a customer profile in a Streamlit interface, sends it to a FastAPI prediction endpoint, and displays churn probability, risk, and a stay/churn verdict. The API validates and maps inputs into the model’s feature order before predicting. The tree also includes an EDA/training notebook and saved model artifacts; the notebook’s internal workflow is not sampled, so its artifact-production links are not shown.

Main entry points: [`api.py`](https://github.com/mitesh256/customer_churn_predictor/blob/main/api.py) (Prediction endpoint), [`app.py`](https://github.com/mitesh256/customer_churn_predictor/blob/main/app.py) (Profile and results), [`best_model.pkl`](https://github.com/mitesh256/customer_churn_predictor/blob/main/best_model.pkl) (Trained model), [`feature_names.pkl`](https://github.com/mitesh256/customer_churn_predictor/blob/main/feature_names.pkl) (Feature order)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Customer interface"]
  node_streamlit["Profile and results<br/>[app.py]"]
end

subgraph group_service["Prediction service"]
  node_api["Prediction endpoint<br/>[api.py]"]
  node_input["Validate and map features<br/>[api.py]"]
  node_predict["Churn prediction<br/>[api.py]"]
end

subgraph group_assets["Model assets"]
  node_model["Trained model<br/>[best_model.pkl]"]
  node_features["Feature order<br/>[feature_names.pkl]"]
end

subgraph group_analysis["Model development"]
  node_notebook["EDA and training"]
end

node_customer(("Customer"))

node_customer -->|"enters profile"| node_streamlit
node_streamlit -->|"POST /predict"| node_api
node_api -->|"validates and maps"| node_input
node_api -->|"loads feature order"| node_features
node_api -->|"loads model"| node_model
node_api -->|"predicts"| node_predict
node_predict -->|"predicts with"| node_model
node_api -->|"returns prediction"| node_streamlit
node_streamlit -->|"shows verdict"| node_customer

click node_streamlit "https://github.com/mitesh256/customer_churn_predictor/blob/main/app.py"
click node_api "https://github.com/mitesh256/customer_churn_predictor/blob/main/api.py"
click node_input "https://github.com/mitesh256/customer_churn_predictor/blob/main/api.py"
click node_predict "https://github.com/mitesh256/customer_churn_predictor/blob/main/api.py"
click node_model "https://github.com/mitesh256/customer_churn_predictor/blob/main/best_model.pkl"
click node_features "https://github.com/mitesh256/customer_churn_predictor/blob/main/feature_names.pkl"
click node_notebook "https://github.com/mitesh256/customer_churn_predictor/blob/main/eda_and_training.ipynb"

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_streamlit toneBlue
class node_api,node_input,node_predict toneAmber
class node_model,node_features toneMint
class node_notebook toneRose
class node_customer toneIndigo
```

## Components

### Customer interface

- [Profile and results](https://github.com/mitesh256/customer_churn_predictor/blob/main/app.py): `app.py`

### Prediction service

- [Prediction endpoint](https://github.com/mitesh256/customer_churn_predictor/blob/main/api.py): `api.py`
- [Validate and map features](https://github.com/mitesh256/customer_churn_predictor/blob/main/api.py): `api.py`
- [Churn prediction](https://github.com/mitesh256/customer_churn_predictor/blob/main/api.py): `api.py`

### Model assets

- [Trained model](https://github.com/mitesh256/customer_churn_predictor/blob/main/best_model.pkl): `best_model.pkl`
- [Feature order](https://github.com/mitesh256/customer_churn_predictor/blob/main/feature_names.pkl): `feature_names.pkl`

### Model development

- [EDA and training](https://github.com/mitesh256/customer_churn_predictor/blob/main/eda_and_training.ipynb): `eda_and_training.ipynb`

### Other components

- **Customer**

## Connections

- Customer → Profile and results: enters profile
- Profile and results → Prediction endpoint: POST /predict
- Prediction endpoint → Validate and map features: validates and maps
- Prediction endpoint → Feature order: loads feature order
- Prediction endpoint → Trained model: loads model
- Prediction endpoint → Churn prediction: predicts
- Churn prediction → Trained model: predicts with
- Prediction endpoint → Profile and results: returns prediction
- Profile and results → Customer: shows verdict
