# yashrajthube/customer-churn-prediction architecture

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

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

## Overview

This is a customer-churn intelligence platform: users request predictions and review risk, explanations, customer history, analytics, and Power BI views. The main backend handles prediction and dashboard APIs; a separate ML service provides feature-based scoring and model training. The README also describes an offline data-preparation, training, evaluation, and explainability workflow. The excerpts establish key backend and ML-service calls, but do not show frontend-to-backend wiring or all documented capabilities’ implementations; those links are omitted or marked unverified.

Main entry points: [`churn-ai-platform/backend/api/routes.py`](https://github.com/yashrajthube/customer-churn-prediction/blob/main/churn-ai-platform/backend/api/routes.py) (Backend API routes), [`churn-ai-platform/ml/service/app/services/training_service.py`](https://github.com/yashrajthube/customer-churn-prediction/blob/main/churn-ai-platform/ml/service/app/services/training_service.py) (Model training), [`churn-ai-platform/ml/service/app/services/scoring_service.py`](https://github.com/yashrajthube/customer-churn-prediction/blob/main/churn-ai-platform/ml/service/app/services/scoring_service.py) (Feature scoring), [`churn-ai-platform/ml/service/app/main.py`](https://github.com/yashrajthube/customer-churn-prediction/blob/main/churn-ai-platform/ml/service/app/main.py) (ML service API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["User interface"]
  node_frontend["Churn dashboard<br/>[App.jsx]"]
  node_predictionui["Prediction views<br/>[PredictionPage.jsx]"]
  node_frontendservices["Frontend API services"]
end

subgraph group_backend["Platform API"]
  node_api["Backend API routes<br/>[routes.py]"]
  node_backendapp["Backend application<br/>[main.py]"]
  node_predict["Prediction engine"]
  node_explain["SHAP explainability"]
  node_batch["Async batch jobs"]
  node_powerbi["Power BI reporting<br/>[powerbi_service.py]"]
end

subgraph group_mlservice["ML service"]
  node_mlapp["ML service API<br/>[main.py]"]
  node_scoring["Feature scoring<br/>[scoring_service.py]"]
  node_modelstore["Active model registry<br/>[model_store.py]"]
  node_training["Model training"]
end

subgraph group_mlworkflow["Model workflow"]
  node_preparation["Data preparation"]
  node_features["Feature engineering"]
  node_preprocessing["Preprocessing pipeline"]
  node_evaluation["Model evaluation"]
end

subgraph group_integrations["Data and integrations"]
  node_backenddb[("Platform database<br/>[db.py]")]
  node_mldb[("ML service database<br/>[db.py]")]
  node_powerbireport["Power BI report<br/>[PowerBIReport.jsx]"]
  node_mlflow["MLflow tracking"]
end

node_user(("Business user"))

node_user -->|"reviews insights"| node_frontend
node_frontend -.->|"shows predictions"| node_predictionui
node_predictionui -.->|"requests scoring"| node_frontendservices
node_frontendservices -.->|"calls API"| node_api
node_backendapp -->|"mounts routes"| node_api
node_api -->|"runs predictions"| node_predict
node_api -->|"submits jobs"| node_batch
node_api -->|"requests explanations"| node_explain
node_api -->|"requests reporting"| node_powerbi
node_predict -->|"builds explanations"| node_explain
node_backendapp -->|"initializes database"| node_backenddb
node_api -->|"reads prediction data"| node_backenddb
node_mlapp -->|"dispatches scoring"| node_scoring
node_mlapp -->|"dispatches training"| node_training
node_mlapp -->|"loads active model"| node_modelstore
node_scoring -->|"loads model"| node_modelstore
node_scoring -->|"reads features"| node_mldb
node_scoring -->|"stores predictions"| node_mldb
node_training -->|"loads training data"| node_mldb
node_training -->|"logs experiments"| node_mlflow
node_user -.->|"requests scoring"| node_mlapp
node_preparation -.->|"cleans data"| node_features
node_features -.->|"engineers features"| node_preprocessing
node_preprocessing -.->|"prepares model inputs"| node_training
node_training -.->|"evaluates model"| node_evaluation
node_powerbi -.->|"serves reports"| node_powerbireport

click node_frontend "https://github.com/yashrajthube/customer-churn-prediction/blob/main/churn-ai-platform/frontend/src/App.jsx"
click node_predictionui "https://github.com/yashrajthube/customer-churn-prediction/blob/main/churn-ai-platform/frontend/src/pages/PredictionPage.jsx"
click node_frontendservices "https://github.com/yashrajthube/customer-churn-prediction/blob/main/churn-ai-platform/frontend/src/services/predictionService.js"
click node_api "https://github.com/yashrajthube/customer-churn-prediction/blob/main/churn-ai-platform/backend/api/routes.py"
click node_backendapp "https://github.com/yashrajthube/customer-churn-prediction/blob/main/churn-ai-platform/backend/main.py"
click node_predict "https://github.com/yashrajthube/customer-churn-prediction/blob/main/churn-ai-platform/backend/services/prediction_service.py"
click node_explain "https://github.com/yashrajthube/customer-churn-prediction/blob/main/churn-ai-platform/backend/services/explainability_service.py"
click node_batch "https://github.com/yashrajthube/customer-churn-prediction/blob/main/churn-ai-platform/backend/services/batch_queue_service.py"
click node_powerbi "https://github.com/yashrajthube/customer-churn-prediction/blob/main/churn-ai-platform/backend/services/powerbi_service.py"
click node_backenddb "https://github.com/yashrajthube/customer-churn-prediction/blob/main/churn-ai-platform/backend/db/db.py"
click node_mlapp "https://github.com/yashrajthube/customer-churn-prediction/blob/main/churn-ai-platform/ml/service/app/main.py"
click node_scoring "https://github.com/yashrajthube/customer-churn-prediction/blob/main/churn-ai-platform/ml/service/app/services/scoring_service.py"
click node_modelstore "https://github.com/yashrajthube/customer-churn-prediction/blob/main/churn-ai-platform/ml/service/app/services/model_store.py"
click node_training "https://github.com/yashrajthube/customer-churn-prediction/blob/main/churn-ai-platform/ml/service/app/services/training_service.py"
click node_mldb "https://github.com/yashrajthube/customer-churn-prediction/blob/main/churn-ai-platform/ml/service/app/db.py"
click node_preparation "https://github.com/yashrajthube/customer-churn-prediction/blob/main/churn-ai-platform/ml/pipeline/clean_churn_data.py"
click node_features "https://github.com/yashrajthube/customer-churn-prediction/blob/main/churn-ai-platform/ml/pipeline/feature_engineering.py"
click node_preprocessing "https://github.com/yashrajthube/customer-churn-prediction/blob/main/churn-ai-platform/ml/pipeline/preprocessing_pipeline.py"
click node_evaluation "https://github.com/yashrajthube/customer-churn-prediction/blob/main/churn-ai-platform/ml/pipeline/evaluate_churn_models.py"
click node_powerbireport "https://github.com/yashrajthube/customer-churn-prediction/blob/main/churn-ai-platform/frontend/src/components/PowerBI/PowerBIReport.jsx"

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_frontend,node_predictionui,node_frontendservices,node_user toneBlue
class node_api,node_backendapp,node_predict,node_explain,node_batch,node_powerbi toneAmber
class node_mlapp,node_scoring,node_modelstore,node_training toneMint
class node_preparation,node_features,node_preprocessing,node_evaluation toneRose
class node_backenddb,node_mldb,node_powerbireport,node_mlflow toneIndigo
```

## Components

### User interface

- [Churn dashboard](https://github.com/yashrajthube/customer-churn-prediction/blob/main/churn-ai-platform/frontend/src/App.jsx): `churn-ai-platform/frontend/src/App.jsx`
- [Prediction views](https://github.com/yashrajthube/customer-churn-prediction/blob/main/churn-ai-platform/frontend/src/pages/PredictionPage.jsx): `churn-ai-platform/frontend/src/pages/PredictionPage.jsx`
- [Frontend API services](https://github.com/yashrajthube/customer-churn-prediction/blob/main/churn-ai-platform/frontend/src/services/predictionService.js): `churn-ai-platform/frontend/src/services/predictionService.js`

### Platform API

- [Backend API routes](https://github.com/yashrajthube/customer-churn-prediction/blob/main/churn-ai-platform/backend/api/routes.py): `churn-ai-platform/backend/api/routes.py`
- [Backend application](https://github.com/yashrajthube/customer-churn-prediction/blob/main/churn-ai-platform/backend/main.py): `churn-ai-platform/backend/main.py`
- [Prediction engine](https://github.com/yashrajthube/customer-churn-prediction/blob/main/churn-ai-platform/backend/services/prediction_service.py): `churn-ai-platform/backend/services/prediction_service.py`
- [SHAP explainability](https://github.com/yashrajthube/customer-churn-prediction/blob/main/churn-ai-platform/backend/services/explainability_service.py): `churn-ai-platform/backend/services/explainability_service.py`
- [Async batch jobs](https://github.com/yashrajthube/customer-churn-prediction/blob/main/churn-ai-platform/backend/services/batch_queue_service.py): `churn-ai-platform/backend/services/batch_queue_service.py`
- [Power BI reporting](https://github.com/yashrajthube/customer-churn-prediction/blob/main/churn-ai-platform/backend/services/powerbi_service.py): `churn-ai-platform/backend/services/powerbi_service.py`

### ML service

- [ML service API](https://github.com/yashrajthube/customer-churn-prediction/blob/main/churn-ai-platform/ml/service/app/main.py): `churn-ai-platform/ml/service/app/main.py`
- [Feature scoring](https://github.com/yashrajthube/customer-churn-prediction/blob/main/churn-ai-platform/ml/service/app/services/scoring_service.py): `churn-ai-platform/ml/service/app/services/scoring_service.py`
- [Active model registry](https://github.com/yashrajthube/customer-churn-prediction/blob/main/churn-ai-platform/ml/service/app/services/model_store.py): `churn-ai-platform/ml/service/app/services/model_store.py`
- [Model training](https://github.com/yashrajthube/customer-churn-prediction/blob/main/churn-ai-platform/ml/service/app/services/training_service.py): `churn-ai-platform/ml/service/app/services/training_service.py`

### Model workflow

- [Data preparation](https://github.com/yashrajthube/customer-churn-prediction/blob/main/churn-ai-platform/ml/pipeline/clean_churn_data.py): `churn-ai-platform/ml/pipeline/clean_churn_data.py`
- [Feature engineering](https://github.com/yashrajthube/customer-churn-prediction/blob/main/churn-ai-platform/ml/pipeline/feature_engineering.py): `churn-ai-platform/ml/pipeline/feature_engineering.py`
- [Preprocessing pipeline](https://github.com/yashrajthube/customer-churn-prediction/blob/main/churn-ai-platform/ml/pipeline/preprocessing_pipeline.py): `churn-ai-platform/ml/pipeline/preprocessing_pipeline.py`
- [Model evaluation](https://github.com/yashrajthube/customer-churn-prediction/blob/main/churn-ai-platform/ml/pipeline/evaluate_churn_models.py): `churn-ai-platform/ml/pipeline/evaluate_churn_models.py`

### Data and integrations

- [Platform database](https://github.com/yashrajthube/customer-churn-prediction/blob/main/churn-ai-platform/backend/db/db.py): `churn-ai-platform/backend/db/db.py`
- [ML service database](https://github.com/yashrajthube/customer-churn-prediction/blob/main/churn-ai-platform/ml/service/app/db.py): `churn-ai-platform/ml/service/app/db.py`
- [Power BI report](https://github.com/yashrajthube/customer-churn-prediction/blob/main/churn-ai-platform/frontend/src/components/PowerBI/PowerBIReport.jsx): `churn-ai-platform/frontend/src/components/PowerBI/PowerBIReport.jsx`
- **MLflow tracking**

### Other components

- **Business user**

## Connections

- Business user → Churn dashboard: reviews insights
- Churn dashboard → Prediction views: shows predictions
- Prediction views → Frontend API services: requests scoring
- Frontend API services → Backend API routes: calls API
- Backend application → Backend API routes: mounts routes (evidence: `churn-ai-platform/backend/main.py`)
- Backend API routes → Prediction engine: runs predictions (evidence: `churn-ai-platform/backend/api/routes.py`)
- Backend API routes → Async batch jobs: submits jobs (evidence: `churn-ai-platform/backend/api/routes.py`)
- Backend API routes → SHAP explainability: requests explanations (evidence: `churn-ai-platform/backend/api/routes.py`)
- Backend API routes → Power BI reporting: requests reporting (evidence: `churn-ai-platform/backend/api/routes.py`)
- Prediction engine → SHAP explainability: builds explanations (evidence: `churn-ai-platform/backend/services/prediction_service.py`)
- Backend application → Platform database: initializes database (evidence: `churn-ai-platform/backend/main.py`)
- Backend API routes → Platform database: reads prediction data (evidence: `churn-ai-platform/backend/api/routes.py`)
- ML service API → Feature scoring: dispatches scoring (evidence: `churn-ai-platform/ml/service/app/main.py`)
- ML service API → Model training: dispatches training (evidence: `churn-ai-platform/ml/service/app/main.py`)
- ML service API → Active model registry: loads active model (evidence: `churn-ai-platform/ml/service/app/main.py`)
- Feature scoring → Active model registry: loads model (evidence: `churn-ai-platform/ml/service/app/services/scoring_service.py`)
- Feature scoring → ML service database: reads features (evidence: `churn-ai-platform/ml/service/app/services/scoring_service.py`)
- Feature scoring → ML service database: stores predictions (evidence: `churn-ai-platform/ml/service/app/services/scoring_service.py`)
- Model training → ML service database: loads training data (evidence: `churn-ai-platform/ml/service/app/services/training_service.py`)
- Model training → MLflow tracking: logs experiments (evidence: `churn-ai-platform/ml/service/app/services/training_service.py`)
- Business user → ML service API: requests scoring
- Data preparation → Feature engineering: cleans data
- Feature engineering → Preprocessing pipeline: engineers features
- Preprocessing pipeline → Model training: prepares model inputs
- Model training → Model evaluation: evaluates model
- Power BI reporting → Power BI report: serves reports
