# rapolupavans/ann_classification_churn architecture

> Architecture diagram of the GitHub repository rapolupavans/ann_classification_churn, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rapolupavans/ann_classification_churn
- Repository: https://github.com/rapolupavans/ann_classification_churn

## Overview

##### Project type and purpose
- From the file tree and minimal README title (“ANN_Classification_Churn”), we see this is an end-to-end machine-learning churn-prediction application built in Python.
- Major activities: data exploration & preprocessing (CSV + Jupyter notebooks), model training (Keras ANN), artifact serialization (model.h5, pickled encoders/scalers), and runtime serving (app.py).

##### Main components
a. Development Environment
- .devcontainer/devcontainer.json (defines a reproducible Docker-based workspace)
- requirements.txt (Python dependencies: Flask, TensorFlow/Keras, scikit-learn, pandas, etc.)
b. Data Sources & Artefacts
- Churn_Modelling.csv (raw data)
- model.h5 (trained ANN weights)
- scaler.pkl, label_encoder_gender.pkl, onehot_encoder_geo.pkl (preprocessing artifacts)
c. Experimentation & Training Pipeline
- experiments.ipynb (EDA, feature engineering, model training)
- prediction.ipynb (model evaluation, inference examples)
d. Model Serving / Inference
- app.py (Flask or FastAPI web service that loads the .h5 model and pickles, exposes a prediction endpoint)

##### Relationships & data flow
- Raw CSV → experiments.ipynb: data cleaning, preprocessing, train/validate split
- experiments.ipynb → model.h5 & pickle files: artifact creation
- model artifacts + app.py + requirements → Docker container (as defined in .devcontainer)
- Client request (HTTP JSON) → app.py → load pickle encoders & scaler, preprocess input → load Keras model → predict churn → JSON response back to client

##### Architectural patterns & design principles
- Separation of concerns:
- Experimentation/training notebooks are isolated from serving code.
- Preprocessing logic is serialized into reusable artifacts (scaler, encoders).
- Reproducibility: devcontainer + requirements.txt ensure environment consistency.
- Lightweight serving: Flask app focuses solely on loading artifacts and inference.

##### Elements to capture in detail
- All artifact files (model.h5, .pkl files) and their roles in preprocessing/inference
- The CSV as your sole raw data source
- Jupyter notebooks as training/exploration modules (not part of runtime)
- The Flask service (app.py) as the inference endpoint
- Environment definition (.devcontainer/devcontainer.json)

##### Putting it all together
- Top-left: Data Source (Churn_Modelling.csv)
- Far-right: Client (could be Postman, web frontend, or another service) sending requests to app.py and receiving churn predictions

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Infrastructure
    subgraph "Infrastructure"
        direction TB
        DevContainer[".devcontainer/devcontainer.json"]:::env
        Requirements["requirements.txt"]:::env
    end

    %% Data Source
    CSV["Churn_Modelling.csv"]:::data

    %% Training Pipeline
    subgraph "Training Pipeline"
        direction TB
        Experiments["experiments.ipynb"]:::code
        PredictionNB["prediction.ipynb"]:::code
        ModelH5["model.h5"]:::data
        Scaler["scaler.pkl"]:::data
        LabelEncoder["label_encoder_gender.pkl"]:::data
        OneHot["onehot_encoder_geo.pkl"]:::data
    end

    %% Serving Pipeline
    subgraph "Serving Pipeline"
        direction TB
        App["app.py"]:::code
    end

    %% Client
    Client["Client (e.g., Postman)"]:::client

    %% Connections
    DevContainer --> Experiments
    Requirements --> Experiments
    DevContainer --> App
    Requirements --> App

    CSV -->|"Train data"| Experiments
    Experiments -->|"Saved model"| ModelH5
    Experiments -->|"Saved scaler"| Scaler
    Experiments -->|"Saved gender encoder"| LabelEncoder
    Experiments -->|"Saved geo encoder"| OneHot

    ModelH5 --> PredictionNB
    Scaler --> PredictionNB
    LabelEncoder --> PredictionNB
    OneHot --> PredictionNB

    ModelH5 -->|"Load model & preprocess"| App
    Scaler --> App
    LabelEncoder --> App
    OneHot --> App

    Client -->|"Prediction request"| App
    App -->|"Prediction response"| Client

    %% Click events
    click DevContainer "https://github.com/rapolupavans/ann_classification_churn/blob/main/.devcontainer/devcontainer.json"
    click Requirements "https://github.com/rapolupavans/ann_classification_churn/blob/main/requirements.txt"
    click CSV "https://github.com/rapolupavans/ann_classification_churn/blob/main/Churn_Modelling.csv"
    click Experiments "https://github.com/rapolupavans/ann_classification_churn/blob/main/experiments.ipynb"
    click PredictionNB "https://github.com/rapolupavans/ann_classification_churn/blob/main/prediction.ipynb"
    click ModelH5 "https://github.com/rapolupavans/ann_classification_churn/blob/main/model.h5"
    click Scaler "https://github.com/rapolupavans/ann_classification_churn/blob/main/scaler.pkl"
    click LabelEncoder "https://github.com/rapolupavans/ann_classification_churn/blob/main/label_encoder_gender.pkl"
    click OneHot "https://github.com/rapolupavans/ann_classification_churn/blob/main/onehot_encoder_geo.pkl"
    click App "https://github.com/rapolupavans/ann_classification_churn/blob/main/app.py"

    %% Styles
    classDef code fill:#D0E7FF,stroke:#0B64A0,color:#0B64A0;
    classDef data fill:#E8F5E9,stroke:#2E7D32,color:#2E7D32,stroke-dasharray: 5 5;
    classDef env fill:#FFF3E0,stroke:#EF6C00,color:#E65100;
    classDef client fill:#ECEFF1,stroke:#546E7A,color:#37474F;
```
