# ayushai14/churn_prediction_ibm architecture

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

- Interactive diagram: https://gitdiagram.com/ayushai14/churn_prediction_ibm
- Repository: https://github.com/ayushai14/churn_prediction_ibm

## Overview

This repository is an end-to-end machine learning project for churn prediction, organized around a training pipeline, model evaluation, and two inference paths: an API service and a batch predictor.

The codebase is split into a few clear layers:
- `src/data`: data ingestion and preprocessing
- `src/models`: training, evaluation, and prediction logic
- `src/pipelines`: orchestration of the ML workflow
- `mlops/serving`: deployment/runtime entrypoints for online and batch inference
- `config`: runtime and model parameters
- `tests`: unit and integration coverage
- `.github/workflows`, `docker`, `dvc.yaml`, `mlflow`: automation, packaging, and experiment/data tracking

Data flow starts in `src/data/ingest.py`, which likely loads the churn dataset, and `src/data/preprocess.py`, which transforms it into model-ready features. Those steps are the boundary between raw data handling and the modeling layer.

Model lifecycle is handled in `src/models/train.py`, `evaluate.py`, and `predict.py`. Training builds the classifier, evaluation measures performance, and prediction is reused by both the pipeline and serving code. This separation suggests the repo treats inference as a thin wrapper around shared model logic rather than duplicating logic in the service layer.

`src/pipelines/pipeline.py` is the orchestration boundary for the main ML workflow. It likely coordinates ingestion, preprocessing, training, and evaluation in one repeatable run, with shared parameters coming from `config/config.yaml` and `config/model_params.yaml`.

The project uses DVC for reproducible data/model pipelines. `dvc.yaml`, `dvc.lock`, and `.dvc/` indicate dataset or artifact versioning and pipeline reproducibility are part of the architecture, so model outputs are expected to be tied to specific data and code versions.

Experiment and run tracking are supported by MLflow under `mlops/tracking/mlflow`. That makes the training side observable: metrics, parameters, and artifacts can be recorded independently of the serving runtime.

Serving is split into two modes under `mlops/serving`:
- `api/app.py` for online requests, likely exposed through a containerized API
- `batch/batch_predict.py` for offline scoring over a dataset or file
This is a key architectural boundary: one path serves low-latency predictions, the other handles scheduled or bulk prediction jobs.

Containerization is handled in `docker/`, including a dedicated API Dockerfile and a compose file. That suggests the API is packaged separately from the training environment, with an emphasis on reproducible local and deployment runs.

CI/CD is defined in GitHub Actions workflows for CI, staging, and production. The repo is therefore set up not just for experimentation but for promotion of model/service changes through automated pipelines.

Tests are organized by scope:
- unit tests for preprocessing and model behavior
- integration tests for the API
This shows the architecture is expected to keep the transformation logic stable and the serving contract verified.

`notebooks/` and `Progress.txt` appear to be exploratory and project-tracking artifacts rather than production runtime components. They likely support experimentation and documentation but are not part of the operational path.

Overall, the important architectural boundaries are:
1. raw data vs. transformed features
2. training/evaluation vs. inference
3. offline batch scoring vs. online API serving
4. code execution vs. tracked artifacts/configuration via DVC and MLflow

Main entry points: [`src/models/train.py`](https://github.com/ayushai14/churn_prediction_ibm/blob/main/src/models/train.py) (Train), [`src/pipelines/pipeline.py`](https://github.com/ayushai14/churn_prediction_ibm/blob/main/src/pipelines/pipeline.py) (Pipeline), [`mlops/serving/api/app.py`](https://github.com/ayushai14/churn_prediction_ibm/blob/main/mlops/serving/api/app.py) (API App), [`mlops/serving/batch/batch_predict.py`](https://github.com/ayushai14/churn_prediction_ibm/blob/main/mlops/serving/batch/batch_predict.py) (Batch Jobs)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_core["Core ML"]
  node_main["Main<br/>entrypoint<br/>[main.py]"]
  node_pipeline["Pipeline<br/>orchestrator<br/>[pipeline.py]"]
  node_ingest["Ingest<br/>data load<br/>[ingest.py]"]
  node_preprocess["Preprocess<br/>feature prep<br/>[preprocess.py]"]
  node_train["Train<br/>model fit<br/>[train.py]"]
  node_evaluate["Evaluate<br/>metrics<br/>[evaluate.py]"]
  node_predict["Predict<br/>inference logic<br/>[predict.py]"]
end

subgraph group_serving["Serving"]
  node_api["API App<br/>online serving<br/>[app.py]"]
  node_batch["Batch Jobs<br/>offline serving<br/>[batch_predict.py]"]
end

subgraph group_ops["Ops"]
  node_config["Config<br/>[config.yaml]"]
  node_model_params["Model Params<br/>model config<br/>[model_params.yaml]"]
  node_dvc["DVC<br/>pipeline registry<br/>[dvc.yaml]"]
  node_mlflow[("MLflow<br/>tracking store")]
  node_docker["Docker<br/>container packaging<br/>[docker-compose.yml]"]
  node_ci["CI/CD<br/>automation<br/>[ci.yml]"]
end

subgraph group_quality["Quality"]
  node_unit_tests["Unit Tests<br/>test suite<br/>[test_preprocess.py]"]
  node_api_tests["API Tests<br/>integration tests<br/>[test_api.py]"]
end

node_main -->|"runs"| node_pipeline
node_pipeline -->|"loads"| node_ingest
node_ingest -->|"cleans"| node_preprocess
node_preprocess -->|"features"| node_train
node_train -->|"scores"| node_evaluate
node_train -->|"model"| node_predict
node_pipeline -->|"orchestrates"| node_train
node_pipeline -->|"orchestrates"| node_evaluate
node_api -->|"serves"| node_predict
node_batch -->|"uses"| node_predict
node_pipeline -->|"reads"| node_config
node_train -->|"reads"| node_model_params
node_api -->|"reads"| node_config
node_batch -->|"reads"| node_config
node_dvc -->|"defines"| node_pipeline
node_dvc -->|"tracks"| node_train
node_mlflow -->|"logs"| node_train
node_mlflow -->|"logs"| node_evaluate
node_docker -->|"packages"| node_api
node_docker -->|"packages"| node_batch
node_ci -->|"runs"| node_unit_tests
node_ci -->|"runs"| node_api_tests

click node_main "https://github.com/ayushai14/churn_prediction_ibm/blob/main/main.py"
click node_pipeline "https://github.com/ayushai14/churn_prediction_ibm/blob/main/src/pipelines/pipeline.py"
click node_ingest "https://github.com/ayushai14/churn_prediction_ibm/blob/main/src/data/ingest.py"
click node_preprocess "https://github.com/ayushai14/churn_prediction_ibm/blob/main/src/data/preprocess.py"
click node_train "https://github.com/ayushai14/churn_prediction_ibm/blob/main/src/models/train.py"
click node_evaluate "https://github.com/ayushai14/churn_prediction_ibm/blob/main/src/models/evaluate.py"
click node_predict "https://github.com/ayushai14/churn_prediction_ibm/blob/main/src/models/predict.py"
click node_api "https://github.com/ayushai14/churn_prediction_ibm/blob/main/mlops/serving/api/app.py"
click node_batch "https://github.com/ayushai14/churn_prediction_ibm/blob/main/mlops/serving/batch/batch_predict.py"
click node_config "https://github.com/ayushai14/churn_prediction_ibm/blob/main/config/config.yaml"
click node_model_params "https://github.com/ayushai14/churn_prediction_ibm/blob/main/config/model_params.yaml"
click node_dvc "https://github.com/ayushai14/churn_prediction_ibm/blob/main/dvc.yaml"
click node_mlflow "https://github.com/ayushai14/churn_prediction_ibm/tree/main/mlops/tracking/mlflow"
click node_docker "https://github.com/ayushai14/churn_prediction_ibm/blob/main/docker/docker-compose.yml"
click node_ci "https://github.com/ayushai14/churn_prediction_ibm/blob/main/.github/workflows/ci.yml"
click node_unit_tests "https://github.com/ayushai14/churn_prediction_ibm/blob/main/tests/unit/test_preprocess.py"
click node_api_tests "https://github.com/ayushai14/churn_prediction_ibm/blob/main/tests/integration/test_api.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_main,node_pipeline,node_ingest,node_preprocess,node_train,node_evaluate,node_predict toneBlue
class node_api,node_batch toneAmber
class node_config,node_model_params,node_dvc,node_mlflow,node_docker,node_ci toneMint
class node_unit_tests,node_api_tests toneRose
```

## Components

### Core ML

Data preparation, training, evaluation, and pipeline orchestration.

- [Main](https://github.com/ayushai14/churn_prediction_ibm/blob/main/main.py): entrypoint · Repository entrypoint for running the churn workflow. · `main.py`
- [Pipeline](https://github.com/ayushai14/churn_prediction_ibm/blob/main/src/pipelines/pipeline.py): orchestrator · Coordinates the end-to-end ML workflow. · `src/pipelines/pipeline.py`
- [Ingest](https://github.com/ayushai14/churn_prediction_ibm/blob/main/src/data/ingest.py): data load · Loads the churn dataset from source data. · `src/data/ingest.py`
- [Preprocess](https://github.com/ayushai14/churn_prediction_ibm/blob/main/src/data/preprocess.py): feature prep · Transforms raw data into model-ready features. · `src/data/preprocess.py`
- [Train](https://github.com/ayushai14/churn_prediction_ibm/blob/main/src/models/train.py): model fit · Builds and fits the churn classifier. · `src/models/train.py`
- [Evaluate](https://github.com/ayushai14/churn_prediction_ibm/blob/main/src/models/evaluate.py): metrics · Measures model performance and compares outputs. · `src/models/evaluate.py`
- [Predict](https://github.com/ayushai14/churn_prediction_ibm/blob/main/src/models/predict.py): inference logic · Shared prediction logic reused by pipeline and serving. · `src/models/predict.py`

### Serving

Online API and offline batch prediction entrypoints.

- [API App](https://github.com/ayushai14/churn_prediction_ibm/blob/main/mlops/serving/api/app.py): online serving · HTTP inference service for real-time prediction requests. · `mlops/serving/api/app.py`
- [Batch Jobs](https://github.com/ayushai14/churn_prediction_ibm/blob/main/mlops/serving/batch/batch_predict.py): offline serving · Bulk scoring entrypoint for scheduled or file-based prediction. · `mlops/serving/batch/batch_predict.py`

### Ops

Configuration, packaging, tracking, and delivery automation.

- [Config](https://github.com/ayushai14/churn_prediction_ibm/blob/main/config/config.yaml): runtime config · Workflow and model parameters consumed across the repo. · `config/config.yaml`
- [Model Params](https://github.com/ayushai14/churn_prediction_ibm/blob/main/config/model_params.yaml): model config · Hyperparameters and model-specific settings. · `config/model_params.yaml`
- [DVC](https://github.com/ayushai14/churn_prediction_ibm/blob/main/dvc.yaml): pipeline registry · Reproducible data and model pipeline definitions. · `dvc.yaml`
- [MLflow](https://github.com/ayushai14/churn_prediction_ibm/tree/main/mlops/tracking/mlflow): tracking store · Experiment tracking and artifact logging. · `mlops/tracking/mlflow`
- [Docker](https://github.com/ayushai14/churn_prediction_ibm/blob/main/docker/docker-compose.yml): container packaging · Container definitions for reproducible runtime and deployment. · `docker/docker-compose.yml`
- [CI/CD](https://github.com/ayushai14/churn_prediction_ibm/blob/main/.github/workflows/ci.yml): automation · GitHub Actions workflows for integration and deployment. · `.github/workflows/ci.yml`

### Quality

Tests that guard model behavior and API contracts.

- [Unit Tests](https://github.com/ayushai14/churn_prediction_ibm/blob/main/tests/unit/test_preprocess.py): test suite · Validates preprocessing and model behavior. · `tests/unit/test_preprocess.py`
- [API Tests](https://github.com/ayushai14/churn_prediction_ibm/blob/main/tests/integration/test_api.py): integration tests · Checks the serving contract through the API. · `tests/integration/test_api.py`

## Connections

- Main → Pipeline: runs · Main entrypoint launches the orchestrated workflow.
- Pipeline → Ingest: loads · Pipeline begins by loading raw churn data.
- Ingest → Preprocess: cleans · Raw data is transformed into features.
- Preprocess → Train: features · Prepared features feed model training.
- Train → Evaluate: scores · Trained model is evaluated against validation data.
- Train → Predict: model · Prediction logic consumes the trained model artifact.
- Pipeline → Train: orchestrates · Pipeline coordinates training as a core stage.
- Pipeline → Evaluate: orchestrates · Pipeline coordinates evaluation as a core stage.
- API App → Predict: serves · Online API wraps shared prediction logic.
- Batch Jobs → Predict: uses · Batch scoring reuses the same inference code.
- Pipeline → Config: reads · Workflow parameters are loaded from config.
- Train → Model Params: reads · Training uses model-specific hyperparameters.
- API App → Config: reads · Serving runtime is configured from project settings.
- Batch Jobs → Config: reads · Batch inference uses shared runtime settings.
- DVC → Pipeline: defines · DVC captures the reproducible ML workflow.
- DVC → Train: tracks · Training outputs and dependencies are versioned.
- MLflow → Train: logs · Training records metrics and artifacts.
- MLflow → Evaluate: logs · Evaluation results are tracked for experiments.
- Docker → API App: packages · Container setup builds and runs the API service.
- Docker → Batch Jobs: packages · Container setup supports batch inference runtime.
- CI/CD → Unit Tests: runs · CI validates the core transformation and model logic.
- CI/CD → API Tests: runs · CI validates the serving contract.
