# yashkokcha24/ml-project architecture

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

- Interactive diagram: https://gitdiagram.com/yashkokcha24/ml-project
- Repository: https://github.com/yashkokcha24/ml-project

## Overview

##### Project Type and Purpose
- This is an end-to-end machine-learning pipeline project with:
- Data ingestion, preprocessing, training, and evaluation components
- A Flask-based web application for serving predictions
- Deployment configurations (AWS Elastic Beanstalk)

##### File Structure
- Top-level scripts:
- app.py / application.py – Launch the Flask server
- setup.py, requirements.txt – Packaging and dependencies
- .ebextensions/python.config – AWS EB deployment config
- Data and artifacts:
- artifact/ & src/components/artifact/ – raw CSV data
- artifacts/ & src/components/artifacts/ – serialized model.pkl, preprocessor.pkl
- Source code modules under src/:
- src/components/ – data_ingestion.py, data_transformation.py, model_trainer.py
- src/pipeline/ – train_pipeline.py, predict_pipeline.py
- src/logger.py, src/exception.py, src/utils.py – cross-cutting concerns
- Web UI templates: templates/home.html, index.html
- Notebooks folder – exploratory analysis and training history (for reference, not part of production)

##### README for Additional Insights
- Confirms ML pipeline steps, Flask inference endpoint, and deployment targets.
- No external databases; storage is file-based.
- Relies on CatBoost for modeling.

a. Main Components
1. Data Storage Layer
– Raw CSV files (artifact/data.csv, train.csv, test.csv)
2. Data Ingestion Component
– src/components/data_ingestion.py
3. Data Transformation Component
– src/components/data_transformation.py
4. Model Training Component
– src/components/model_trainer.py
– src/pipeline/train_pipeline.py
5. Artifact Store
– model.pkl, preprocessor.pkl in artifacts/
6. Prediction Pipeline
– src/pipeline/predict_pipeline.py
7. Web Application
– app.py / application.py (Flask)
– templates/*.html
8. Deployment Environment
– AWS Elastic Beanstalk via .ebextensions
9. Cross-Cutting Services
– Logging (src/logger.py)
– Exception handling (src/exception.py)
– Utility functions (src/utils.py)

b. Relationships and Data Flows
- Raw CSV → Data Ingestion → cleans and stores intermediate tables
- Ingested data → Data Transformation → feature-engineered dataset
- Transformed data → Model Training → produces model/preprocessor artifacts
- Artifacts → Saved to disk (artifacts/)
- Web App on startup → Loads preprocessor.pkl & model.pkl
- User request → Flask endpoint → Predict Pipeline → returns inference
- Deployment config → AWS EB manages scaling of the Flask app

c. Architectural Patterns & Principles
- Pipeline pattern: sequential stages for data flow
- Separation of concerns: distinct modules for ingestion, transform, training, prediction
- Single responsibility: Web UI layer only handles HTTP requests & templating
- Infrastructure as code: .ebextensions for automated deployment

d. Key Technologies & Frameworks
- Python, Flask (Web server)
- CatBoost (Modeling)
- Pickle for model artifact serialization
- AWS Elastic Beanstalk (Deployment)
- Jupyter Notebooks (EDA & model experimentation)

##### Final Recommendations
- Be exhaustive: break down each script/module into its own component if it drives a major step.
- Dependencies: show how logger, utils, and exception modules support all stages.
- Validate with code: cross-reference file names and imports to ensure nothing is missed.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Data Processing Layer"
        DS["Raw CSV Files"]:::db
        DI["Data Ingestion Service\n(src/components/data_ingestion.py)"]:::pipeline
        DT["Data Transformation Service\n(src/components/data_transformation.py)"]:::pipeline
        MT["Model Training Service\n(src/components/model_trainer.py &\nsrc/pipeline/train_pipeline.py)"]:::pipeline
    end

    subgraph "Artifact Store"
        AS["Model & Preprocessor Artifacts\n(artifacts/)"]:::db
    end

    subgraph "Serving Layer"
        WEB["Flask Web App\n(app.py, application.py)"]:::web
        PP["Predict Pipeline\n(src/pipeline/predict_pipeline.py)"]:::pipeline
        TEMP["Templates\n(home.html, index.html)"]:::web
        AWS["AWS Elastic Beanstalk"]:::cloud
    end

    subgraph "Cross-Cutting Services"
        LOG["Logger\n(src/logger.py)"]:::cross
        EXC["Exception Handler\n(src/exception.py)"]:::cross
        UTIL["Utilities\n(src/utils.py)"]:::cross
    end

    DS --> DI --> DT --> MT --> AS
    AS -.->|loads| WEB
    WEB --> TEMP
    WEB --> PP
    PP --> AS
    AWS --> WEB

    LOG --> DI
    LOG --> DT
    LOG --> MT
    LOG --> PP
    LOG --> WEB
    EXC --> DI
    EXC --> DT
    EXC --> MT
    EXC --> PP
    EXC --> WEB
    UTIL --> DI
    UTIL --> DT
    UTIL --> MT
    UTIL --> PP
    UTIL --> WEB

    classDef pipeline fill:#a8e6cf,stroke:#2e7d32,color:#000;
    classDef db fill:#d3d3d3,stroke:#696969,color:#000;
    classDef web fill:#81d4fa,stroke:#0277bd,color:#000;
    classDef cross fill:#ffd54f,stroke:#f9a825,color:#000;
    classDef cloud fill:#e1bee7,stroke:#6a1b9a,color:#000;

    click DS "https://github.com/yashkokcha24/ml-project/tree/main/artifact/"
    click DI "https://github.com/yashkokcha24/ml-project/blob/main/src/components/data_ingestion.py"
    click DT "https://github.com/yashkokcha24/ml-project/blob/main/src/components/data_transformation.py"
    click MT "https://github.com/yashkokcha24/ml-project/blob/main/src/components/model_trainer.py"
    click MT "https://github.com/yashkokcha24/ml-project/blob/main/src/pipeline/train_pipeline.py"
    click AS "https://github.com/yashkokcha24/ml-project/blob/main/artifacts/model.pkl"
    click AS "https://github.com/yashkokcha24/ml-project/blob/main/artifacts/preprocessor.pkl"
    click AS "https://github.com/yashkokcha24/ml-project/blob/main/src/components/artifacts/preprocessor.pkl"
    click PP "https://github.com/yashkokcha24/ml-project/blob/main/src/pipeline/predict_pipeline.py"
    click WEB "https://github.com/yashkokcha24/ml-project/blob/main/app.py"
    click WEB "https://github.com/yashkokcha24/ml-project/blob/main/application.py"
    click TEMP "https://github.com/yashkokcha24/ml-project/blob/main/templates/home.html"
    click TEMP "https://github.com/yashkokcha24/ml-project/blob/main/templates/index.html"
    click AWS "https://github.com/yashkokcha24/ml-project/blob/main/.ebextensions/python.config"
    click LOG "https://github.com/yashkokcha24/ml-project/blob/main/src/logger.py"
    click EXC "https://github.com/yashkokcha24/ml-project/blob/main/src/exception.py"
    click UTIL "https://github.com/yashkokcha24/ml-project/blob/main/src/utils.py"
```
