# krishnaik06/mlproject architecture

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

- Interactive diagram: https://gitdiagram.com/krishnaik06/mlproject
- Repository: https://github.com/krishnaik06/mlproject

## Overview

##### Project type and purpose
- This is an end-to-end machine learning web application built in Python.
- It provides both model training (offline) and prediction (online) capabilities, wrapped in a Flask app and intended for deployment via AWS Elastic Beanstalk.

##### File structure
- Top-level:
- app.py – Flask entry point, serves HTML templates and prediction endpoints.
- artifacts/ – stores raw & processed data, trained model, preprocessor, test/train CSVs.
- catboost_info/ – logs and metadata from CatBoost training.
- notebook/ – Jupyter notebooks for EDA and model training (reproducibility).
- requirements.txt, setup.py – dependency and packaging config.
- .ebextensions/ – AWS EB deployment config.
- src/ – core Python package.
- components/ – modules for data_ingestion, data_transformation, model_trainer.
- pipeline/ – orchestrators for train_pipeline and predict_pipeline.
- exception.py, logger.py, utils.py – support code for error handling and logging.

##### README
- Describes the project as an end-to-end ML workflow.
- Key operations: ingest → transform → train → save artifacts → predict.

##### Main components & interactions
a. Frontend (User):
- Browser or UI client
- HTML templates: home.html (input form), index.html (results)
b. API / Web Server:
- app.py (Flask)
- Routes:
- “/” – render input form
- “/predict” – accept features, invoke predict_pipeline
c. Prediction Pipeline (src/pipeline/predict_pipeline.py):
- Load preprocessor.pkl and model.pkl from artifacts
- Transform incoming data, produce prediction
d. Training Pipeline (src/pipeline/train_pipeline.py) – offline:
- DataIngestion → DataTransformation → ModelTrainer
- Save model.pkl, preprocessor.pkl, update catboost_info logs
e. Artifacts Store:
- Local disk folder “artifacts/” (could be S3 in a future microservices expansion)
f. Logging & Exception Handling:
- src/logger.py and src/exception.py capture runtime events, errors
g. Deployment:
- AWS Elastic Beanstalk
- .ebextensions/python.config configures Python runtime

##### Architectural patterns & design principles
- Modular “pipeline” pattern – clear separation of data ingestion, transformation, training, prediction.
- MVC-lite for web layer – templates (View), app.py (Controller), components & pipelines (Model).
- Artifact versioning – ML artifacts are serialized and stored for reproducibility.
- Single-process monolith suitable for small-scale deployment; can evolve into microservices (e.g. separate training service).

##### Detailed checklist for the principal software engineer
- Separate the system into at least these components: UI, API, ML‐processing pipelines, data/artifacts, and deployment infrastructure.
- Both training and inference workflows.
- Files/modules responsible for each step (e.g., src/components/model_trainer.py).
- External dependencies: GitHub Actions, AWS EB, Python packages from requirements.txt.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% UI Layer
    subgraph "UI Layer"
        direction TB
        Browser("Browser / UI"):::ui
        HomeTemplate("templates/home.html"):::ui
        IndexTemplate("templates/index.html"):::ui
    end

    %% Web/API Layer
    subgraph "Web/API Layer"
        direction TB
        FlaskApp("Flask App (app.py)"):::api
        RouteHome("Route: \"/\""):::api
        RoutePredict("Route: \"/predict\""):::api
    end

    %% Processing Layer
    subgraph "Processing Layer"
        direction TB
        subgraph "Online Prediction"
            direction TB
            PredictPipeline("predict_pipeline\n(src/pipeline/predict_pipeline.py)"):::pipeline
        end
        subgraph "Offline Training"
            direction TB
            TrainPipeline("train_pipeline\n(src/pipeline/train_pipeline.py)"):::pipeline
            DataIngestion("DataIngestion\n(src/components/data_ingestion.py)"):::pipeline
            DataTransformation("DataTransformation\n(src/components/data_transformation.py)"):::pipeline
            ModelTrainer("ModelTrainer\n(src/components/model_trainer.py)"):::pipeline
        end
    end

    %% Data/Artifacts Layer
    subgraph "Data & Artifacts"
        direction TB
        RawData("Raw Data\n(artifacts/data.csv)"):::storage
        ArtifactStore("Artifacts Store\n(artifacts/)"):::storage
    end

    %% Support Modules
    subgraph "Support Modules"
        direction TB
        Logger("Logging Module\n(src/logger.py)"):::logging
        ExceptionHandler("Exception Module\n(src/exception.py)"):::exception
        Utils("Utility Functions\n(src/utils.py)"):::utility
    end

    %% DevOps Layer
    subgraph "DevOps & Deployment"
        direction TB
        AWS_EB("AWS Elastic Beanstalk\n(.ebextensions/python.config)"):::devops
        CICD("GitHub Actions CI/CD\n(.github/workflows/main_studentssperformance3.yml)"):::devops
        Dependencies("Requirements & Packaging\n(requirements.txt, setup.py)"):::devops
    end

    %% UI to API
    Browser -->|Load form| FlaskApp
    FlaskApp -->|Render| HomeTemplate
    Browser -->|Submit features| FlaskApp
    FlaskApp -->|Invoke| PredictPipeline

    %% Prediction Flow
    PredictPipeline -->|Load preprocessor & model| ArtifactStore
    ArtifactStore -->|Provide artifacts| PredictPipeline
    PredictPipeline -->|Return result| FlaskApp
    FlaskApp -->|Render| IndexTemplate
    IndexTemplate -->|Display to| Browser

    %% Training Flow
    RawData -->|Feed data| TrainPipeline
    TrainPipeline --> DataIngestion
    DataIngestion --> DataTransformation
    DataTransformation --> ModelTrainer
    ModelTrainer -->|Save model & preprocessor| ArtifactStore

    %% Support modules usage
    FlaskApp --> Logger
    PredictPipeline --> Logger
    TrainPipeline --> Logger
    DataIngestion --> Logger
    DataTransformation --> Logger
    ModelTrainer --> Logger

    FlaskApp --> ExceptionHandler
    PredictPipeline --> ExceptionHandler
    TrainPipeline --> ExceptionHandler

    FlaskApp --> Utils
    PredictPipeline --> Utils
    TrainPipeline --> Utils

    %% DevOps connections
    FlaskApp --> AWS_EB
    AWS_EB --> CICD
    CICD --> Dependencies

    %% Click Events
    click HomeTemplate "https://github.com/krishnaik06/mlproject/blob/main/templates/home.html"
    click IndexTemplate "https://github.com/krishnaik06/mlproject/blob/main/templates/index.html"
    click FlaskApp "https://github.com/krishnaik06/mlproject/blob/main/app.py"
    click PredictPipeline "https://github.com/krishnaik06/mlproject/blob/main/src/pipeline/predict_pipeline.py"
    click TrainPipeline "https://github.com/krishnaik06/mlproject/blob/main/src/pipeline/train_pipeline.py"
    click DataIngestion "https://github.com/krishnaik06/mlproject/blob/main/src/components/data_ingestion.py"
    click DataTransformation "https://github.com/krishnaik06/mlproject/blob/main/src/components/data_transformation.py"
    click ModelTrainer "https://github.com/krishnaik06/mlproject/blob/main/src/components/model_trainer.py"
    click Logger "https://github.com/krishnaik06/mlproject/blob/main/src/logger.py"
    click ExceptionHandler "https://github.com/krishnaik06/mlproject/blob/main/src/exception.py"
    click Utils "https://github.com/krishnaik06/mlproject/blob/main/src/utils.py"
    click AWS_EB "https://github.com/krishnaik06/mlproject/blob/main/.ebextensions/python.config"
    click CICD "https://github.com/krishnaik06/mlproject/blob/main/.github/workflows/main_studentssperformance3.yml"
    click Dependencies "https://github.com/krishnaik06/mlproject/blob/main/requirements.txt"
    click Dependencies "https://github.com/krishnaik06/mlproject/blob/main/setup.py"

    %% Styles
    classDef ui fill:#D0E6FF,stroke:#333,stroke-width:1px
    classDef api fill:#DFFFE0,stroke:#333,stroke-width:1px
    classDef pipeline fill:#FFE5CC,stroke:#333,stroke-width:1px
    classDef storage fill:#EFEFEF,stroke:#333,stroke-width:1px
    classDef devops fill:#F3E6FF,stroke:#333,stroke-width:1px
    classDef logging fill:#FFF0B3,stroke:#333,stroke-width:1px
    classDef exception fill:#FFD6D6,stroke:#333,stroke-width:1px
    classDef utility fill:#F5F5CC,stroke:#333,stroke-width:1px
```
