# anandsuraj/churn-prediction-ml-pipeline architecture

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

- Interactive diagram: https://gitdiagram.com/anandsuraj/churn-prediction-ml-pipeline
- Repository: https://github.com/anandsuraj/churn-prediction-ml-pipeline

## Overview

#### Purpose and Entry Points
This repository implements an end-to-end customer-churn ML data pipeline for the IBM Telco dataset: ingest, validate, clean, engineer/store features, version artifacts, and train a binary classifier. The primary local orchestrator is `main_pipeline.py`; individual stages live under `src/`. Scheduled/containerized execution is provided by `airflow/dags/churn_prediction_pipeline.py` and `docker-compose.yml`.

#### Pipeline Orchestration
`main_pipeline.py` is the sequential control-plane entry point for running the Python pipeline. Airflow provides an alternative DAG-based orchestration boundary, with its own setup/configuration under `airflow/setup_airflow.py` and `airflow/airflow.cfg`. The DAG should invoke or coordinate the same stage contracts rather than own duplicate business logic.

Paths: `main_pipeline.py`, `airflow/dags/churn_prediction_pipeline.py`, `airflow/setup_airflow.py`

#### Ingestion and Raw Data Boundary
Ingestion obtains customer data from CSV and potentially the Hugging Face API, then hands it to raw-data organization/storage. This establishes the immutable source-data boundary before validation or transformations. Raw and exploratory data are rooted under `data/eda/raw` and `data/eda/cleaned`, despite README references to broader `data/raw` and `data/cleaned` locations.

Paths: `src/data_ingestion.py`, `src/raw_data_storage.py`, `data/eda/raw`

#### Quality, Preparation, and Transformation
Validation checks data quality/integrity before preparation. Preparation cleans and normalizes records; transformation then produces model-oriented engineered datasets. This is the central data-state progression: raw input → validated/cleaned data → processed training features. Logging is centralized through the utility logger and persisted under `logs/`.

Paths: `src/data_validation.py`, `src/data_preparation.py`, `src/data_transformation_storage.py`

#### Feature Store and Persistence
Engineered features are managed separately from transformation logic through a CSV-backed feature-store layer. The committed sample artifact indicates the current local serving/storage contract; the README identifies Redis or PostgreSQL as future production extensions. Database schema initialization supports relational metadata or operational persistence, with SQLite local and PostgreSQL intended for production.

Paths: `src/feature_store.py`, `data/feature_store/churn_features_sample.csv`, `database/init.sql`

#### Versioning and Reproducibility
DVC is the artifact/versioning boundary for data pipeline outputs and potentially model inputs. Root `dvc.yaml`/`dvc.lock` and the nested `config/dvc` configuration imply tracked, reproducible pipeline stages or alternative DVC project configuration. Remote storage may be configured externally, including cloud/S3 credentials supplied through environment variables.

Paths: `src/data_versioning.py`, `dvc.yaml`, `config/dvc/dvc.yaml`

#### Model Build and Runtime Infrastructure
Model training consumes the prepared/feature-store data and writes model artifacts under `data/models`. Python dependencies are defined in `requirements.txt`. Docker packages the runtime, while Compose likely coordinates the application and Airflow services. Environment configuration is externalized via `.env.example`; external dependencies include Kaggle source data, Hugging Face API, optional S3/DVC remote, and SQLite/PostgreSQL.

Paths: `src/build_model.py`, `data/models/.gitkeep`, `Dockerfile`

Main entry points: [`dvc.yaml`](https://github.com/anandsuraj/churn-prediction-ml-pipeline/blob/main/dvc.yaml) (DVC Pipeline), [`main_pipeline.py`](https://github.com/anandsuraj/churn-prediction-ml-pipeline/blob/main/main_pipeline.py) (Local Pipeline), [`airflow/dags/churn_prediction_pipeline.py`](https://github.com/anandsuraj/churn-prediction-ml-pipeline/blob/main/airflow/dags/churn_prediction_pipeline.py) (Airflow DAG), [`src/feature_store.py`](https://github.com/anandsuraj/churn-prediction-ml-pipeline/blob/main/src/feature_store.py) (Feature Store)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_orchestration["Orchestration"]
  node_local_pipeline["Local Pipeline<br/>Python orchestrator<br/>[main_pipeline.py]"]
  node_airflow_dag["Airflow DAG<br/>scheduled orchestrator"]
  node_airflow_setup["Airflow Setup<br/>Airflow bootstrap<br/>[setup_airflow.py]"]
end

subgraph group_data_pipeline["Data Pipeline"]
  node_source_data(("Customer Data Sources<br/>CSV / Hugging Face"))
  node_ingestion["Data Ingestion<br/>pipeline stage<br/>[data_ingestion.py]"]
  node_raw_storage["Raw Data Storage<br/>pipeline stage"]
  node_validation["Data Validation<br/>pipeline stage<br/>[data_validation.py]"]
  node_preparation["Data Preparation<br/>pipeline stage"]
  node_transformation["Feature Transformation<br/>pipeline stage"]
  node_model_training["Model Training<br/>binary classifier builder<br/>[build_model.py]"]
end

subgraph group_storage["Storage &amp; Reproducibility"]
  node_raw_data[("Raw Dataset")]
  node_feature_store["Feature Store<br/>CSV feature-store layer<br/>[feature_store.py]"]
  node_feature_artifact[("Churn Features<br/>feature artifact")]
  node_data_versioning["Data Versioning<br/>DVC integration<br/>[data_versioning.py]"]
  node_dvc_pipeline["DVC Pipeline<br/>artifact versioning<br/>[dvc.yaml]"]
  node_database_schema[("Database Schema<br/>SQLite / PostgreSQL schema<br/>[init.sql]")]
  node_model_artifacts[("Model Artifacts<br/>trained models<br/>[.gitkeep]")]
end

subgraph group_runtime["Runtime &amp; Deployment"]
  node_container_runtime["Container Runtime<br/>Docker image"]
  node_compose["Service Composition<br/>Docker Compose<br/>[docker-compose.yml]"]
  node_central_logging["Central Logging<br/>pipeline observability"]
end

node_local_pipeline -->|"runs"| node_ingestion
node_airflow_dag -.->|"coordinates stages"| node_local_pipeline
node_airflow_setup -->|"configures"| node_airflow_dag
node_source_data -->|"supplies"| node_ingestion
node_ingestion -->|"hands off"| node_raw_storage
node_raw_storage -->|"writes"| node_raw_data
node_raw_data -->|"input"| node_validation
node_validation -->|"validated data"| node_preparation
node_preparation -->|"cleaned data"| node_transformation
node_transformation -->|"engineered features"| node_feature_store
node_feature_store -->|"persists"| node_feature_artifact
node_feature_artifact -->|"training input"| node_model_training
node_model_training -->|"writes"| node_model_artifacts
node_data_versioning -->|"uses"| node_dvc_pipeline
node_dvc_pipeline -.->|"tracks outputs"| node_raw_data
node_dvc_pipeline -.->|"tracks outputs"| node_feature_artifact
node_dvc_pipeline -.->|"tracks artifacts"| node_model_artifacts
node_feature_store -.->|"optional relational persistence"| node_database_schema
node_container_runtime -->|"packages"| node_local_pipeline
node_compose -->|"runs"| node_container_runtime
node_compose -->|"hosts scheduling"| node_airflow_dag
node_local_pipeline -.->|"emits logs"| node_central_logging
node_airflow_dag -.->|"emits logs"| node_central_logging

click node_local_pipeline "https://github.com/anandsuraj/churn-prediction-ml-pipeline/blob/main/main_pipeline.py"
click node_airflow_dag "https://github.com/anandsuraj/churn-prediction-ml-pipeline/blob/main/airflow/dags/churn_prediction_pipeline.py"
click node_airflow_setup "https://github.com/anandsuraj/churn-prediction-ml-pipeline/blob/main/airflow/setup_airflow.py"
click node_ingestion "https://github.com/anandsuraj/churn-prediction-ml-pipeline/blob/main/src/data_ingestion.py"
click node_raw_storage "https://github.com/anandsuraj/churn-prediction-ml-pipeline/blob/main/src/raw_data_storage.py"
click node_raw_data "https://github.com/anandsuraj/churn-prediction-ml-pipeline/tree/main/data/eda/raw"
click node_validation "https://github.com/anandsuraj/churn-prediction-ml-pipeline/blob/main/src/data_validation.py"
click node_preparation "https://github.com/anandsuraj/churn-prediction-ml-pipeline/blob/main/src/data_preparation.py"
click node_transformation "https://github.com/anandsuraj/churn-prediction-ml-pipeline/blob/main/src/data_transformation_storage.py"
click node_feature_store "https://github.com/anandsuraj/churn-prediction-ml-pipeline/blob/main/src/feature_store.py"
click node_feature_artifact "https://github.com/anandsuraj/churn-prediction-ml-pipeline/blob/main/data/feature_store/churn_features_sample.csv"
click node_data_versioning "https://github.com/anandsuraj/churn-prediction-ml-pipeline/blob/main/src/data_versioning.py"
click node_dvc_pipeline "https://github.com/anandsuraj/churn-prediction-ml-pipeline/blob/main/dvc.yaml"
click node_database_schema "https://github.com/anandsuraj/churn-prediction-ml-pipeline/blob/main/database/init.sql"
click node_model_training "https://github.com/anandsuraj/churn-prediction-ml-pipeline/blob/main/src/build_model.py"
click node_model_artifacts "https://github.com/anandsuraj/churn-prediction-ml-pipeline/blob/main/data/models/.gitkeep"
click node_container_runtime "https://github.com/anandsuraj/churn-prediction-ml-pipeline/blob/main/Dockerfile"
click node_compose "https://github.com/anandsuraj/churn-prediction-ml-pipeline/blob/main/docker-compose.yml"

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_local_pipeline,node_airflow_dag,node_airflow_setup toneBlue
class node_source_data,node_ingestion,node_raw_storage,node_validation,node_preparation,node_transformation,node_model_training toneAmber
class node_raw_data,node_feature_store,node_feature_artifact,node_data_versioning,node_dvc_pipeline,node_database_schema,node_model_artifacts toneMint
class node_container_runtime,node_compose,node_central_logging toneRose
```

## Components

### Orchestration

- [Local Pipeline](https://github.com/anandsuraj/churn-prediction-ml-pipeline/blob/main/main_pipeline.py): Python orchestrator · Sequential control-plane entry point. · `main_pipeline.py`
- [Airflow DAG](https://github.com/anandsuraj/churn-prediction-ml-pipeline/blob/main/airflow/dags/churn_prediction_pipeline.py): scheduled orchestrator · Alternative scheduled execution boundary. · `airflow/dags/churn_prediction_pipeline.py`
- [Airflow Setup](https://github.com/anandsuraj/churn-prediction-ml-pipeline/blob/main/airflow/setup_airflow.py): Airflow bootstrap · `airflow/setup_airflow.py`

### Data Pipeline

- **Customer Data Sources**: CSV / Hugging Face · IBM Telco churn inputs.
- [Data Ingestion](https://github.com/anandsuraj/churn-prediction-ml-pipeline/blob/main/src/data_ingestion.py): pipeline stage · `src/data_ingestion.py`
- [Raw Data Storage](https://github.com/anandsuraj/churn-prediction-ml-pipeline/blob/main/src/raw_data_storage.py): pipeline stage · Immutable source-data boundary. · `src/raw_data_storage.py`
- [Data Validation](https://github.com/anandsuraj/churn-prediction-ml-pipeline/blob/main/src/data_validation.py): pipeline stage · `src/data_validation.py`
- [Data Preparation](https://github.com/anandsuraj/churn-prediction-ml-pipeline/blob/main/src/data_preparation.py): pipeline stage · Cleans and normalizes records. · `src/data_preparation.py`
- [Feature Transformation](https://github.com/anandsuraj/churn-prediction-ml-pipeline/blob/main/src/data_transformation_storage.py): pipeline stage · Produces model-oriented engineered data. · `src/data_transformation_storage.py`
- [Model Training](https://github.com/anandsuraj/churn-prediction-ml-pipeline/blob/main/src/build_model.py): binary classifier builder · `src/build_model.py`

### Storage & Reproducibility

- [Raw Dataset](https://github.com/anandsuraj/churn-prediction-ml-pipeline/tree/main/data/eda/raw): raw data · `data/eda/raw`
- [Feature Store](https://github.com/anandsuraj/churn-prediction-ml-pipeline/blob/main/src/feature_store.py): CSV feature-store layer · `src/feature_store.py`
- [Churn Features](https://github.com/anandsuraj/churn-prediction-ml-pipeline/blob/main/data/feature_store/churn_features_sample.csv): feature artifact · Current local feature storage contract. · `data/feature_store/churn_features_sample.csv`
- [Data Versioning](https://github.com/anandsuraj/churn-prediction-ml-pipeline/blob/main/src/data_versioning.py): DVC integration · `src/data_versioning.py`
- [DVC Pipeline](https://github.com/anandsuraj/churn-prediction-ml-pipeline/blob/main/dvc.yaml): artifact versioning · Reproducible pipeline-stage definition. · `dvc.yaml`
- [Database Schema](https://github.com/anandsuraj/churn-prediction-ml-pipeline/blob/main/database/init.sql): SQLite / PostgreSQL schema · Supports local and production persistence. · `database/init.sql`
- [Model Artifacts](https://github.com/anandsuraj/churn-prediction-ml-pipeline/blob/main/data/models/.gitkeep): trained models · `data/models/.gitkeep`

### Runtime & Deployment

- [Container Runtime](https://github.com/anandsuraj/churn-prediction-ml-pipeline/blob/main/Dockerfile): Docker image · `Dockerfile`
- [Service Composition](https://github.com/anandsuraj/churn-prediction-ml-pipeline/blob/main/docker-compose.yml): Docker Compose · Coordinates application and Airflow services. · `docker-compose.yml`
- **Central Logging**: pipeline observability · Pipeline stages persist logs under logs/.

## Connections

- Local Pipeline → Data Ingestion: runs
- Airflow DAG → Local Pipeline: coordinates stages
- Airflow Setup → Airflow DAG: configures
- Customer Data Sources → Data Ingestion: supplies
- Data Ingestion → Raw Data Storage: hands off
- Raw Data Storage → Raw Dataset: writes
- Raw Dataset → Data Validation: input
- Data Validation → Data Preparation: validated data
- Data Preparation → Feature Transformation: cleaned data
- Feature Transformation → Feature Store: engineered features
- Feature Store → Churn Features: persists
- Churn Features → Model Training: training input
- Model Training → Model Artifacts: writes
- Data Versioning → DVC Pipeline: uses
- DVC Pipeline → Raw Dataset: tracks outputs
- DVC Pipeline → Churn Features: tracks outputs
- DVC Pipeline → Model Artifacts: tracks artifacts
- Feature Store → Database Schema: optional relational persistence
- Container Runtime → Local Pipeline: packages
- Service Composition → Container Runtime: runs
- Service Composition → Airflow DAG: hosts scheduling
- Local Pipeline → Central Logging: emits logs
- Airflow DAG → Central Logging: emits logs
