# javithnaseem-j/tele-com-customer-churn-prediction architecture

> Architecture diagram of the GitHub repository javithnaseem-j/tele-com-customer-churn-prediction, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/javithnaseem-j/tele-com-customer-churn-prediction
- Repository: https://github.com/javithnaseem-j/tele-com-customer-churn-prediction

## Overview

##### Main Components
- Data Pipeline Stages:
- Data Ingestion: Components for reading in the Tele_Comm.csv dataset (artifacts/data_ingestion, src/mlproject/components/data_ingestion.py, pipeline stage1).
- Data Validation: Validates the dataset using schema.yaml (artifacts/data_validation, src/mlproject/components/data_validation.py, pipeline stage2).
- Data Transformation: Handles preprocessing such as scaling for numerical data and label encoding for categorical features (artifacts/data_transformation, src/mlproject/components/data_transformation.py, pipeline stage3).
- Model Training: Uses a RandomForestClassifier for training (artifacts/model_trainer, src/mlproject/components/data_modeltraining.py, pipeline stage4).
- Model Evaluation: Assesses prediction metrics (artifacts/model_evaluation, src/mlproject/components/data_modelevaluation.py, pipeline stage5).

- Configuration and Control:
- Config Files: config/config.yaml, params.yaml, and the configuration module in src/mlproject/config indicate central configuration management.
- Constants and Entities: Represent key domain objects and static values which are used throughout the ML components.

- Web Interface:
- Flask App: The app.py file along with templates (index.html, results.html) represents the frontend that enables users to submit customer details and view prediction results.

- Automation & Deployment:
- Docker: Dockerfile allows containerization to support deployment.
- CI/CD: GitHub Actions configuration (.github/workflows/cicd.yaml) orchestrates automated builds/deployments, and the README gives steps to deploy to AWS using ECR and an EC2 instance.

- Research & Experimentation:
- Notebooks: The research folder houses Jupyter notebooks that likely served as the basis for experimentation and prototyping during development.

##### Relationships and Data Flow
- Data flows from the raw CSV (Tele_Comm.csv under artifacts/data_ingestion) through:
- Ingestion → Validation → Transformation → Training → Evaluation.
- The trained model (model.joblib stored in artifacts/model_trainer) is then used by the Flask application to make predictions.
- Configuration files (config.yaml, params.yaml, schema.yaml) are referenced across the pipeline to maintain consistency.
- The CI/CD components (GitHub Actions workflow, Dockerfile) ensure that updates to any part of the system trigger rebuilds, tests, and deployments.

##### Architectural Patterns & Design Principles
- Modular Pipeline: The ML pipeline is broken into stages (each with its own module and artifact output), simplifying debugging and maintenance.
- Separation of Concerns: Frontend (Flask UI), backend (ML pipeline), and configuration (~config files) are logically separated.
- Containerization & CI/CD: Using Docker and GitHub Actions reflects a modern approach to deployment and continuous integration.
- Code Reuse: The “src/mlproject” directory encapsulates components, configuration, constants, entities, and utility functions needed by different stages.

##### Specify Relevant Technologies & Frameworks
- Flask: For building the web interface.
- Scikit-learn (implied from RandomForestClassifier): For ML model training.
- Docker: For containerizing the application.
- GitHub Actions: For CI/CD automation.
- AWS (ECR, EC2): For deployment.
- YAML: Used in configuration files (e.g., config.yaml, schema.yaml).
- Jupyter Notebooks: For research and exploratory analyses.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "ML Pipeline"
        subgraph "Data Ingestion Stage"
            DI1["Data Ingestion (Data Folder)"]
            DI2["Data Ingestion (Component)"]
            DI3["Data Ingestion (Pipeline)"]
        end
        subgraph "Data Validation Stage"
            DV1["Data Validation (Artifacts)"]
            DV2["Data Validation (Schema)"]
            DV3["Data Validation (Component)"]
            DV4["Data Validation (Pipeline)"]
        end
        subgraph "Data Transformation Stage"
            DT1["Data Transformation (Artifacts)"]
            DT2["Data Transformation (Component)"]
            DT3["Data Transformation (Pipeline)"]
        end
        subgraph "Model Training Stage"
            MT1["Model Training (Artifacts)"]
            MT2["Model Training (Component)"]
            MT3["Model Training (Pipeline)"]
        end
        subgraph "Model Evaluation Stage"
            ME1["Model Evaluation (Artifacts)"]
            ME2["Model Evaluation (Component)"]
            ME3["Model Evaluation (Pipeline)"]
        end
    end

    DI3 -->|"stage"| DV1
    DV4 -->|"stage"| DT1
    DT3 -->|"stage"| MT1
    MT3 -->|"stage"| ME1
    MT1 -->|"trained_model"| WI1

    subgraph "Configuration & Control"
        Config1["Config Folder"]
        Config2["Params File"]
        Config3["Config Module"]
        Config4["Constants & Entities"]
    end

    Config3 ---|"feeds"| DI1

    subgraph "Web Interface"
        WI1["Flask App"]
        WI2["Templates"]
    end

    subgraph "Deployment & Automation"
        DA1["Docker"]
        DA2["CI/CD Workflow"]
    end

    WI1 -->|"containerized_in"| DA1
    DA1 -->|"triggered_by"| DA2
    DA2 -->|"deploys_to"| AWS["AWS (ECR & EC2)"]:::external

    subgraph "Research & Experimentation"
        RE1["Research Notebooks"]
    end

    %% Click Events
    click DI1 "https://github.com/javithnaseem-j/tele-com-customer-churn-prediction/tree/main/artifacts/data_ingestion"
    click DI2 "https://github.com/javithnaseem-j/tele-com-customer-churn-prediction/blob/main/src/mlproject/components/data_ingestion.py"
    click DI3 "https://github.com/javithnaseem-j/tele-com-customer-churn-prediction/blob/main/src/mlproject/pipeline/stage1_data_ingestion.py"

    click DV1 "https://github.com/javithnaseem-j/tele-com-customer-churn-prediction/tree/main/artifacts/data_validation"
    click DV2 "https://github.com/javithnaseem-j/tele-com-customer-churn-prediction/blob/main/schema.yaml"
    click DV3 "https://github.com/javithnaseem-j/tele-com-customer-churn-prediction/blob/main/src/mlproject/components/data_validation.py"
    click DV4 "https://github.com/javithnaseem-j/tele-com-customer-churn-prediction/blob/main/src/mlproject/pipeline/stage2_data_validation.py"

    click DT1 "https://github.com/javithnaseem-j/tele-com-customer-churn-prediction/tree/main/artifacts/data_transformation"
    click DT2 "https://github.com/javithnaseem-j/tele-com-customer-churn-prediction/blob/main/src/mlproject/components/data_transformation.py"
    click DT3 "https://github.com/javithnaseem-j/tele-com-customer-churn-prediction/blob/main/src/mlproject/pipeline/stage3_data_transformation.py"

    click MT1 "https://github.com/javithnaseem-j/tele-com-customer-churn-prediction/tree/main/artifacts/model_trainer"
    click MT2 "https://github.com/javithnaseem-j/tele-com-customer-churn-prediction/blob/main/src/mlproject/components/data_modeltraining.py"
    click MT3 "https://github.com/javithnaseem-j/tele-com-customer-churn-prediction/blob/main/src/mlproject/pipeline/stage4_modeltraining.py"

    click ME1 "https://github.com/javithnaseem-j/tele-com-customer-churn-prediction/tree/main/artifacts/model_evaluation"
    click ME2 "https://github.com/javithnaseem-j/tele-com-customer-churn-prediction/blob/main/src/mlproject/components/data_modelevaluation.py"
    click ME3 "https://github.com/javithnaseem-j/tele-com-customer-churn-prediction/blob/main/src/mlproject/pipeline/stage5_data_evalution.py"

    click Config1 "https://github.com/javithnaseem-j/tele-com-customer-churn-prediction/tree/main/config"
    click Config2 "https://github.com/javithnaseem-j/tele-com-customer-churn-prediction/blob/main/params.yaml"
    click Config3 "https://github.com/javithnaseem-j/tele-com-customer-churn-prediction/tree/main/src/mlproject/config"
    click Config4 "https://github.com/javithnaseem-j/tele-com-customer-churn-prediction/tree/main/src/mlproject/constants"

    click WI1 "https://github.com/javithnaseem-j/tele-com-customer-churn-prediction/blob/main/app.py"
    click WI2 "https://github.com/javithnaseem-j/tele-com-customer-churn-prediction/tree/main/templates"

    click DA1 "https://github.com/javithnaseem-j/tele-com-customer-churn-prediction/tree/main/Dockerfile"
    click DA2 "https://github.com/javithnaseem-j/tele-com-customer-churn-prediction/blob/main/.github/workflows/cicd.yaml"

    click RE1 "https://github.com/javithnaseem-j/tele-com-customer-churn-prediction/tree/main/research"

    %% Styles
    classDef pipeline fill:#AED6F1,stroke:#1F618D,stroke-width:2px;
    classDef config fill:#A9DFBF,stroke:#145A32,stroke-width:2px;
    classDef web fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef deploy fill:#F5CBA7,stroke:#873600,stroke-width:2px;
    classDef external fill:#FADBD8,stroke:#922B21,stroke-width:2px;

    class DI1,DI2,DI3,DV1,DV2,DV3,DV4,DT1,DT2,DT3,MT1,MT2,MT3,ME1,ME2,ME3 pipeline;
    class Config1,Config2,Config3,Config4 config;
    class WI1,WI2 web;
    class DA1,DA2 deploy;
    class AWS,RE1 external;
```
