# shivammitra/mlproject architecture

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

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

## Overview

#### Purpose and Entry Points
A Python end-to-end student-performance ML project: prepare tabular data, train and serialize a model, then serve predictions through a web UI/API. Runtime entry points are the application server at `app.py`, training orchestration at `src/pipeline/train_pipeline.py`, and inference orchestration at `src/pipeline/predict_pipeline.py`.

#### Training Data and Ingestion
Training begins with source student data, represented by `notebook/data/stud.csv`. The ingestion component splits and persists raw train/test datasets under `artifacts/`: `src/components/data_ingestion.py`, `artifacts/train.csv`, and `artifacts/test.csv`. This artifact directory is the central handoff boundary between training stages.

#### Feature Transformation
`src/components/data_transformation.py` fits preprocessing over the training split and applies the same transformation to train/test data. Its serialized preprocessor is persisted as `artifacts/preprocessor.pkl`, separating feature engineering state from model state and ensuring prediction uses training-consistent transformations.

#### Model Training and Selection
`src/components/model_trainer.py` consumes transformed datasets, evaluates candidate model behavior, and serializes the selected estimator to `artifacts/model.pkl`. CatBoost training outputs in `catboost_info/` indicate CatBoost is a material model runtime/training dependency; its logs are generated training diagnostics rather than serving inputs.

#### Pipeline Orchestration
`src/pipeline/train_pipeline.py` coordinates ingestion, transformation, and training as one batch control flow. Shared concerns—artifact serialization/loading, logging, and project-specific exceptions—are centralized in `src/utils.py`, `src/logger.py`, and `src/exception.py`. The expected flow is source CSV → train/test artifacts → fitted preprocessor → trained model artifact.

#### Prediction Serving Boundary
`src/pipeline/predict_pipeline.py` loads `artifacts/model.pkl` and `artifacts/preprocessor.pkl`, transforms incoming feature records, and returns model predictions. `app.py` exposes this capability through the HTTP application, while `templates/index.html` and `templates/home.html` provide browser-facing request/result views. Serving depends on prebuilt artifacts; it does not retrain models per request.

#### Packaging and Deployment
The application runs on Python with dependencies declared in `requirements.txt` and package metadata in `setup.py`. `Dockerfile` provides a container execution path. AWS Elastic Beanstalk configuration is present at `.ebextensions/python.config`; the repository also targets EC2 deployment. CI is defined in `.github/workflows/main.yaml`, supporting automated repository validation/deployment workflows.

Main entry points: [`src/pipeline/train_pipeline.py`](https://github.com/shivammitra/mlproject/blob/main/src/pipeline/train_pipeline.py) (Training orchestration), [`src/components/data_transformation.py`](https://github.com/shivammitra/mlproject/blob/main/src/components/data_transformation.py) (Data transformation), [`app.py`](https://github.com/shivammitra/mlproject/blob/main/app.py) (HTTP application), [`src/pipeline/predict_pipeline.py`](https://github.com/shivammitra/mlproject/blob/main/src/pipeline/predict_pipeline.py) (Prediction orchestration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_training["Training Pipeline"]
  node_source_csv["Student source CSV<br/>training data<br/>[stud.csv]"]
  node_train_pipeline["Training orchestration<br/>pipeline<br/>[train_pipeline.py]"]
  node_ingestion["Data ingestion<br/>[data_ingestion.py]"]
  node_train_csv["Train split<br/>dataset artifact<br/>[train.csv]"]
  node_test_csv["Test split<br/>dataset artifact<br/>[test.csv]"]
  node_transformation["Data transformation"]
  node_preprocessor["Fitted preprocessor<br/>ML artifact<br/>[preprocessor.pkl]"]
  node_trainer["Model trainer<br/>[model_trainer.py]"]
  node_model["Trained model<br/>ML artifact<br/>[model.pkl]"]
  node_catboost["CatBoost diagnostics<br/>training runtime"]
end

subgraph group_serving["Prediction Serving"]
  node_app{{"HTTP application<br/>application server<br/>[app.py]"}}
  node_predict_pipeline["Prediction orchestration<br/>pipeline"]
  node_browser_views["Browser views<br/>HTML templates"]
end

subgraph group_delivery["Packaging &amp; Delivery"]
  node_requirements["Python dependencies<br/>dependency manifest<br/>[requirements.txt]"]
  node_package_setup["Package metadata<br/>packaging<br/>[setup.py]"]
  node_docker["Container build<br/>deployment"]
  node_elastic_beanstalk["Elastic Beanstalk config<br/>deployment config<br/>[python.config]"]
  node_ci["CI workflow<br/>automation<br/>[main.yaml]"]
end

node_utils["Shared utilities<br/>shared runtime<br/>[utils.py]"]
node_logger["Logging<br/>shared runtime<br/>[logger.py]"]
node_exceptions["Project exceptions<br/>shared runtime<br/>[exception.py]"]

node_source_csv -->|"training input"| node_train_pipeline
node_train_pipeline -->|"runs"| node_ingestion
node_ingestion -->|"writes"| node_train_csv
node_ingestion -->|"writes"| node_test_csv
node_train_pipeline -->|"runs"| node_transformation
node_train_csv -->|"fit input"| node_transformation
node_test_csv -->|"transform input"| node_transformation
node_transformation -->|"serializes"| node_preprocessor
node_train_pipeline -->|"runs"| node_trainer
node_transformation -->|"transformed data"| node_trainer
node_trainer -->|"serializes"| node_model
node_trainer -.->|"generates logs"| node_catboost
node_train_pipeline -.->|"uses"| node_utils
node_train_pipeline -.->|"logs through"| node_logger
node_train_pipeline -.->|"uses"| node_exceptions
node_app -->|"serves requests through"| node_predict_pipeline
node_browser_views -->|"rendered by"| node_app
node_predict_pipeline -->|"loads"| node_model
node_predict_pipeline -->|"loads"| node_preprocessor
node_predict_pipeline -.->|"uses artifact loading"| node_utils
node_docker -->|"containerizes"| node_app
node_requirements -.->|"runtime dependencies"| node_app
node_package_setup -.->|"packages"| node_app
node_elastic_beanstalk -->|"deployment path"| node_docker
node_ci -.->|"builds or deploys"| node_docker

click node_source_csv "https://github.com/shivammitra/mlproject/blob/main/notebook/data/stud.csv"
click node_train_pipeline "https://github.com/shivammitra/mlproject/blob/main/src/pipeline/train_pipeline.py"
click node_ingestion "https://github.com/shivammitra/mlproject/blob/main/src/components/data_ingestion.py"
click node_train_csv "https://github.com/shivammitra/mlproject/blob/main/artifacts/train.csv"
click node_test_csv "https://github.com/shivammitra/mlproject/blob/main/artifacts/test.csv"
click node_transformation "https://github.com/shivammitra/mlproject/blob/main/src/components/data_transformation.py"
click node_preprocessor "https://github.com/shivammitra/mlproject/blob/main/artifacts/preprocessor.pkl"
click node_trainer "https://github.com/shivammitra/mlproject/blob/main/src/components/model_trainer.py"
click node_model "https://github.com/shivammitra/mlproject/blob/main/artifacts/model.pkl"
click node_catboost "https://github.com/shivammitra/mlproject/blob/main/catboost_info/catboost_training.json"
click node_utils "https://github.com/shivammitra/mlproject/blob/main/src/utils.py"
click node_logger "https://github.com/shivammitra/mlproject/blob/main/src/logger.py"
click node_exceptions "https://github.com/shivammitra/mlproject/blob/main/src/exception.py"
click node_app "https://github.com/shivammitra/mlproject/blob/main/app.py"
click node_predict_pipeline "https://github.com/shivammitra/mlproject/blob/main/src/pipeline/predict_pipeline.py"
click node_requirements "https://github.com/shivammitra/mlproject/blob/main/requirements.txt"
click node_package_setup "https://github.com/shivammitra/mlproject/blob/main/setup.py"
click node_docker "https://github.com/shivammitra/mlproject/tree/main/Dockerfile"
click node_elastic_beanstalk "https://github.com/shivammitra/mlproject/blob/main/.ebextensions/python.config"
click node_ci "https://github.com/shivammitra/mlproject/blob/main/.github/workflows/main.yaml"

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_source_csv,node_train_pipeline,node_ingestion,node_train_csv,node_test_csv,node_transformation,node_preprocessor,node_trainer,node_model,node_catboost toneBlue
class node_app,node_predict_pipeline,node_browser_views toneAmber
class node_requirements,node_package_setup,node_docker,node_elastic_beanstalk,node_ci toneMint
class node_utils,node_logger,node_exceptions toneNeutral
```

## Components

### Training Pipeline

Batch data preparation and model building.

- [Student source CSV](https://github.com/shivammitra/mlproject/blob/main/notebook/data/stud.csv): training data · `notebook/data/stud.csv`
- [Training orchestration](https://github.com/shivammitra/mlproject/blob/main/src/pipeline/train_pipeline.py): pipeline · `src/pipeline/train_pipeline.py`
- [Data ingestion](https://github.com/shivammitra/mlproject/blob/main/src/components/data_ingestion.py): Splits source data into persisted train and test sets. · `src/components/data_ingestion.py`
- [Train split](https://github.com/shivammitra/mlproject/blob/main/artifacts/train.csv): dataset artifact · `artifacts/train.csv`
- [Test split](https://github.com/shivammitra/mlproject/blob/main/artifacts/test.csv): dataset artifact · `artifacts/test.csv`
- [Data transformation](https://github.com/shivammitra/mlproject/blob/main/src/components/data_transformation.py): Fits preprocessing on training data and transforms both splits. · `src/components/data_transformation.py`
- [Fitted preprocessor](https://github.com/shivammitra/mlproject/blob/main/artifacts/preprocessor.pkl): ML artifact · `artifacts/preprocessor.pkl`
- [Model trainer](https://github.com/shivammitra/mlproject/blob/main/src/components/model_trainer.py): Evaluates candidates and persists the selected estimator. · `src/components/model_trainer.py`
- [Trained model](https://github.com/shivammitra/mlproject/blob/main/artifacts/model.pkl): ML artifact · `artifacts/model.pkl`
- [CatBoost diagnostics](https://github.com/shivammitra/mlproject/blob/main/catboost_info/catboost_training.json): training runtime · Generated CatBoost training logs, not serving inputs. · `catboost_info/catboost_training.json`

### Prediction Serving

HTTP prediction interface backed by trained artifacts.

- [HTTP application](https://github.com/shivammitra/mlproject/blob/main/app.py): application server · `app.py`
- [Prediction orchestration](https://github.com/shivammitra/mlproject/blob/main/src/pipeline/predict_pipeline.py): pipeline · Loads trained artifacts and predicts incoming records. · `src/pipeline/predict_pipeline.py`
- **Browser views**: HTML templates · Input and prediction-result pages.

### Packaging & Delivery

Container, deployment, and CI paths.

- [Python dependencies](https://github.com/shivammitra/mlproject/blob/main/requirements.txt): dependency manifest · `requirements.txt`
- [Package metadata](https://github.com/shivammitra/mlproject/blob/main/setup.py): packaging · `setup.py`
- [Container build](https://github.com/shivammitra/mlproject/tree/main/Dockerfile): deployment · `Dockerfile`
- [Elastic Beanstalk config](https://github.com/shivammitra/mlproject/blob/main/.ebextensions/python.config): deployment config · `.ebextensions/python.config`
- [CI workflow](https://github.com/shivammitra/mlproject/blob/main/.github/workflows/main.yaml): automation · Automated validation and deployment workflow. · `.github/workflows/main.yaml`

### Other components

- [Shared utilities](https://github.com/shivammitra/mlproject/blob/main/src/utils.py): shared runtime · Artifact serialization/loading and shared support functions. · `src/utils.py`
- [Logging](https://github.com/shivammitra/mlproject/blob/main/src/logger.py): shared runtime · `src/logger.py`
- [Project exceptions](https://github.com/shivammitra/mlproject/blob/main/src/exception.py): shared runtime · `src/exception.py`

## Connections

- Student source CSV → Training orchestration: training input
- Training orchestration → Data ingestion: runs
- Data ingestion → Train split: writes
- Data ingestion → Test split: writes
- Training orchestration → Data transformation: runs
- Train split → Data transformation: fit input
- Test split → Data transformation: transform input
- Data transformation → Fitted preprocessor: serializes
- Training orchestration → Model trainer: runs
- Data transformation → Model trainer: transformed data
- Model trainer → Trained model: serializes
- Model trainer → CatBoost diagnostics: generates logs
- Training orchestration → Shared utilities: uses
- Training orchestration → Logging: logs through
- Training orchestration → Project exceptions: uses
- HTTP application → Prediction orchestration: serves requests through
- Browser views → HTTP application: rendered by
- Prediction orchestration → Trained model: loads
- Prediction orchestration → Fitted preprocessor: loads
- Prediction orchestration → Shared utilities: uses artifact loading
- Container build → HTTP application: containerizes
- Python dependencies → HTTP application: runtime dependencies
- Package metadata → HTTP application: packages
- Elastic Beanstalk config → Container build: deployment path
- CI workflow → Container build: builds or deploys
