# aagmans/staywise_cc architecture

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

- Interactive diagram: https://gitdiagram.com/aagmans/staywise_cc
- Repository: https://github.com/aagmans/staywise_cc

## Overview

StayWise is a telecom churn-risk prediction product with a Python model-development workflow, a Flask prediction API, a browser-based customer assessment tool, and a separate interactive CLI. A customer enters profile data in the web form or CLI; the runtime preprocesses it, scores churn probability, applies a decision threshold, and presents risk guidance. The web tool also shows SHAP explanations and can generate a PDF report. README documents the modeling stages; sampled source confirms API loading, web requests, and explanation wiring, but not every training-stage file interaction.

Main entry points: [`app.py`](https://github.com/aagmans/staywise_cc/blob/main/app.py) (Flask prediction API), [`frontend/predict.js`](https://github.com/aagmans/staywise_cc/blob/main/frontend/predict.js) (Web assessment), [`01_data_inspection.py`](https://github.com/aagmans/staywise_cc/blob/main/01_data_inspection.py) (Data inspection), [`03_data_cleaning.py`](https://github.com/aagmans/staywise_cc/blob/main/03_data_cleaning.py) (Clean and engineer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_modeling["Model development"]
  node_inspection["Data inspection"]
  node_eda["Exploratory analysis<br/>[02_eda.py]"]
  node_cleaning["Clean and engineer"]
  node_split["Train validation test"]
  node_preprocess["Feature preprocessing"]
  node_imbalance["Class imbalance"]
  node_compare["Model comparison"]
  node_threshold["Threshold tuning"]
  node_evaluation["Held-out evaluation"]
  node_save["Save model artifacts<br/>[10_save_model.py]"]
end

subgraph group_runtime["Prediction runtime"]
  node_api["Flask prediction API<br/>[app.py]"]
  node_explain["SHAP explanations<br/>[explain.py]"]
  node_cli["CLI predictor"]
end

subgraph group_experience["Customer experience"]
  node_predictor["Web assessment<br/>[predict.js]"]
  node_report["PDF risk report<br/>[predict.js]"]
  node_landing["Product landing page<br/>[main.js]"]
end

node_analyst(("Data scientist"))
node_rawdata[("Telco dataset")]
node_clean_data[("Cleaned data<br/>[telco_cleaned.csv]")]
node_artifacts[("Model artifacts")]
node_customer(("Telecom user"))

node_analyst -->|"inspects"| node_inspection
node_rawdata -.->|"examines"| node_inspection
node_inspection -->|"analyzes"| node_eda
node_eda -->|"informs"| node_cleaning
node_rawdata -->|"cleans"| node_cleaning
node_cleaning -->|"produces"| node_clean_data
node_clean_data -->|"partitions"| node_split
node_split -->|"feeds"| node_preprocess
node_preprocess -->|"supports"| node_imbalance
node_imbalance -->|"informs"| node_compare
node_compare -->|"selects model"| node_threshold
node_threshold -->|"sets threshold"| node_evaluation
node_evaluation -->|"validates"| node_save
node_save -->|"writes"| node_artifacts
node_customer -->|"enters profile"| node_predictor
node_predictor -->|"posts prediction"| node_api
node_cli -.->|"loads"| node_artifacts
node_api -->|"loads"| node_artifacts
node_api -->|"reads background data"| node_clean_data
node_api -->|"builds explainer"| node_explain
node_api -->|"returns risk result"| node_predictor
node_predictor -->|"generates"| node_report
node_customer -->|"provides details"| node_cli
node_customer -.->|"views product"| node_landing

click node_rawdata "https://github.com/aagmans/staywise_cc/blob/main/data/Telco_customer_churn.xlsx"
click node_inspection "https://github.com/aagmans/staywise_cc/blob/main/01_data_inspection.py"
click node_eda "https://github.com/aagmans/staywise_cc/blob/main/02_eda.py"
click node_cleaning "https://github.com/aagmans/staywise_cc/blob/main/03_data_cleaning.py"
click node_clean_data "https://github.com/aagmans/staywise_cc/blob/main/data/telco_cleaned.csv"
click node_split "https://github.com/aagmans/staywise_cc/blob/main/04_train_test_split.py"
click node_preprocess "https://github.com/aagmans/staywise_cc/blob/main/05_preprocessing.py"
click node_imbalance "https://github.com/aagmans/staywise_cc/blob/main/06_class_imbalance.py"
click node_compare "https://github.com/aagmans/staywise_cc/blob/main/07_model_comparison.py"
click node_threshold "https://github.com/aagmans/staywise_cc/blob/main/08_logistic_threshold.py"
click node_evaluation "https://github.com/aagmans/staywise_cc/blob/main/09_final_test_evaluation.py"
click node_save "https://github.com/aagmans/staywise_cc/blob/main/10_save_model.py"
click node_artifacts "https://github.com/aagmans/staywise_cc/tree/main/models"
click node_api "https://github.com/aagmans/staywise_cc/blob/main/app.py"
click node_explain "https://github.com/aagmans/staywise_cc/blob/main/explain.py"
click node_cli "https://github.com/aagmans/staywise_cc/blob/main/12_interactive_prediction.py"
click node_predictor "https://github.com/aagmans/staywise_cc/blob/main/frontend/predict.js"
click node_report "https://github.com/aagmans/staywise_cc/blob/main/frontend/predict.js"
click node_landing "https://github.com/aagmans/staywise_cc/blob/main/frontend/main.js"

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_inspection,node_eda,node_cleaning,node_split,node_preprocess,node_imbalance,node_compare,node_threshold,node_evaluation,node_save,node_customer toneBlue
class node_api,node_explain,node_cli,node_rawdata,node_clean_data,node_artifacts toneAmber
class node_predictor,node_report,node_landing toneMint
class node_analyst toneIndigo
```

## Components

### Model development

- [Data inspection](https://github.com/aagmans/staywise_cc/blob/main/01_data_inspection.py): `01_data_inspection.py`
- [Exploratory analysis](https://github.com/aagmans/staywise_cc/blob/main/02_eda.py): `02_eda.py`
- [Clean and engineer](https://github.com/aagmans/staywise_cc/blob/main/03_data_cleaning.py): `03_data_cleaning.py`
- [Train validation test](https://github.com/aagmans/staywise_cc/blob/main/04_train_test_split.py): `04_train_test_split.py`
- [Feature preprocessing](https://github.com/aagmans/staywise_cc/blob/main/05_preprocessing.py): `05_preprocessing.py`
- [Class imbalance](https://github.com/aagmans/staywise_cc/blob/main/06_class_imbalance.py): `06_class_imbalance.py`
- [Model comparison](https://github.com/aagmans/staywise_cc/blob/main/07_model_comparison.py): `07_model_comparison.py`
- [Threshold tuning](https://github.com/aagmans/staywise_cc/blob/main/08_logistic_threshold.py): `08_logistic_threshold.py`
- [Held-out evaluation](https://github.com/aagmans/staywise_cc/blob/main/09_final_test_evaluation.py): `09_final_test_evaluation.py`
- [Save model artifacts](https://github.com/aagmans/staywise_cc/blob/main/10_save_model.py): `10_save_model.py`

### Prediction runtime

- [Flask prediction API](https://github.com/aagmans/staywise_cc/blob/main/app.py): `app.py`
- [SHAP explanations](https://github.com/aagmans/staywise_cc/blob/main/explain.py): `explain.py`
- [CLI predictor](https://github.com/aagmans/staywise_cc/blob/main/12_interactive_prediction.py): `12_interactive_prediction.py`

### Customer experience

- [Web assessment](https://github.com/aagmans/staywise_cc/blob/main/frontend/predict.js): `frontend/predict.js`
- [PDF risk report](https://github.com/aagmans/staywise_cc/blob/main/frontend/predict.js): `frontend/predict.js`
- [Product landing page](https://github.com/aagmans/staywise_cc/blob/main/frontend/main.js): `frontend/main.js`

### Other components

- **Data scientist**
- [Telco dataset](https://github.com/aagmans/staywise_cc/blob/main/data/Telco_customer_churn.xlsx): `data/Telco_customer_churn.xlsx`
- [Cleaned data](https://github.com/aagmans/staywise_cc/blob/main/data/telco_cleaned.csv): `data/telco_cleaned.csv`
- [Model artifacts](https://github.com/aagmans/staywise_cc/tree/main/models): `models`
- **Telecom user**

## Connections

- Data scientist → Data inspection: inspects (evidence: `README.md`)
- Telco dataset → Data inspection: examines
- Data inspection → Exploratory analysis: analyzes (evidence: `README.md`)
- Exploratory analysis → Clean and engineer: informs (evidence: `README.md`)
- Telco dataset → Clean and engineer: cleans (evidence: `README.md`)
- Clean and engineer → Cleaned data: produces (evidence: `README.md`)
- Cleaned data → Train validation test: partitions (evidence: `README.md`)
- Train validation test → Feature preprocessing: feeds (evidence: `README.md`)
- Feature preprocessing → Class imbalance: supports (evidence: `README.md`)
- Class imbalance → Model comparison: informs (evidence: `README.md`)
- Model comparison → Threshold tuning: selects model (evidence: `README.md`)
- Threshold tuning → Held-out evaluation: sets threshold (evidence: `README.md`)
- Held-out evaluation → Save model artifacts: validates (evidence: `README.md`)
- Save model artifacts → Model artifacts: writes (evidence: `10_save_model.py`)
- Telecom user → Web assessment: enters profile (evidence: `README.md`)
- Web assessment → Flask prediction API: posts prediction (evidence: `frontend/predict.js`)
- CLI predictor → Model artifacts: loads
- Flask prediction API → Model artifacts: loads (evidence: `app.py`)
- Flask prediction API → Cleaned data: reads background data (evidence: `app.py`)
- Flask prediction API → SHAP explanations: builds explainer (evidence: `app.py`)
- Flask prediction API → Web assessment: returns risk result (evidence: `frontend/predict.js`)
- Web assessment → PDF risk report: generates (evidence: `frontend/predict.js`)
- Telecom user → CLI predictor: provides details (evidence: `README.md`)
- Telecom user → Product landing page: views product
