# sahilnegi4444/student-performance-indicator architecture

> Architecture diagram of the GitHub repository sahilnegi4444/student-performance-indicator, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sahilnegi4444/student-performance-indicator
- Repository: https://github.com/sahilnegi4444/student-performance-indicator

## Overview

1. This repository is a small end-to-end machine learning system for predicting a student’s math score. It has two main runtime paths: an offline training pipeline that produces saved artifacts, and an online Flask prediction app that loads those artifacts to serve predictions.

2. The data source is the student performance CSV dataset stored under `artifacts/data.csv` and `notebook/data/stud.csv`. The notebooks in `notebook/` were used for EDA and model experimentation, but the production architecture lives in `src/` and `app.py`.

3. The training flow starts in `src/pipeline/train_pipeline.py`. That pipeline orchestrates the ML lifecycle by calling components for data ingestion, transformation, hyperparameter tuning, and model training. Its purpose is to turn raw tabular data into reusable model artifacts rather than serving requests directly.

4. `src/components/data_ingestion.py` is responsible for preparing the train/test datasets stored in `artifacts/train.csv` and `artifacts/test.csv`. This is the boundary where raw input data becomes the split datasets consumed by downstream training steps.

5. `src/components/data_transformation.py` builds the preprocessing logic and saves it as `artifacts/preprocessor.pkl`. This is a key architectural boundary because the same transformation logic used during training must also be reused at inference time to keep feature handling consistent.

6. `src/components/model_trainer.py` and `src/components/hyperparameter_tuning.py` handle model selection and fitting. The README indicates Linear Regression was selected as the final model, and the trained estimator is persisted as `artifacts/model.pkl`. The architecture is therefore a classical scikit-learn training stack with serialized artifacts.

7. Prediction is separated from training in `src/pipeline/predict_pipeline.py`. The Flask app does not retrain anything; it loads the saved preprocessor and model artifacts, converts form inputs into model-ready features, and returns the predicted score.

8. `app.py` is the web entry point. It wires Flask routes to the HTML templates in `templates/index.html` and `templates/home.html`, giving the system a simple browser-based interface for entering student attributes and displaying the prediction result.

9. `src/utils.py`, `src/logger.py`, and `src/exception.py` provide cross-cutting engineering support. These are not business logic layers; they standardize reusable helpers, logging, and error handling so failures in ingestion, transformation, or inference are easier to trace.

10. The repository is built for both local development and containerized deployment. `Dockerfile`, `.dockerignore`, and `requirements_docker.txt` indicate a production-focused runtime image, and the README notes deployment on Render using Gunicorn. The full `requirements.txt` is used for local training/dev, while the Docker-specific requirements keep the serving image lighter.

11. The `artifacts/` directory is central to the system boundary between offline ML work and online inference. It contains both intermediate datasets and the final persisted model/preprocessor, making deployment possible without rerunning notebooks or retraining on every app start.

12. In diagram terms, the main flow is: dataset and experimentation in notebooks, then training pipeline in `src/pipeline/train_pipeline.py`, then persisted artifacts in `artifacts/`, then Flask request handling in `app.py`, then preprocessing and inference through `src/pipeline/predict_pipeline.py`, and finally response rendering through the templates.

Main entry points: [`app.py`](https://github.com/sahilnegi4444/student-performance-indicator/blob/main/app.py) (Flask app), [`src/components/data_ingestion.py`](https://github.com/sahilnegi4444/student-performance-indicator/blob/main/src/components/data_ingestion.py) (Ingestion), [`src/pipeline/predict_pipeline.py`](https://github.com/sahilnegi4444/student-performance-indicator/blob/main/src/pipeline/predict_pipeline.py) (Predict pipeline), [`src/components/model_trainer.py`](https://github.com/sahilnegi4444/student-performance-indicator/blob/main/src/components/model_trainer.py) (Trainer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_grp_experiment["Experimentation"]
  node_n_notebook_eda["EDA notebook"]
  node_n_notebook_train["Training notebook"]
  node_n_dataset_notebook[("Stud data<br/>dataset<br/>[stud.csv]")]
end

subgraph group_grp_training["Offline training"]
  node_n_train_pipeline["Train pipeline<br/>[train_pipeline.py]"]
  node_n_data_ingestion["Ingestion<br/>[data_ingestion.py]"]
  node_n_data_transformation["Transform"]
  node_n_hyper_tuning["Tuning"]
  node_n_model_trainer["Trainer<br/>[model_trainer.py]"]
end

subgraph group_grp_serving["Online serving"]
  node_n_predict_pipeline["Predict pipeline"]
  node_n_app["Flask app<br/>web app<br/>[app.py]"]
  node_n_templates_home["Home page<br/>template<br/>[home.html]"]
  node_n_templates_index["Input form<br/>template<br/>[index.html]"]
end

subgraph group_grp_shared["Shared support"]
  node_n_utils["Utils<br/>support<br/>[utils.py]"]
  node_n_logger["Logger<br/>support<br/>[logger.py]"]
  node_n_exception["Exceptions<br/>support<br/>[exception.py]"]
  node_n_artifacts_data[("Raw data<br/>dataset artifact<br/>[data.csv]")]
  node_n_artifacts_train[("Train split<br/>dataset artifact<br/>[train.csv]")]
  node_n_artifacts_test[("Test split<br/>dataset artifact<br/>[test.csv]")]
  node_n_artifacts_preprocessor["Preprocessor<br/>artifact<br/>[preprocessor.pkl]"]
  node_n_artifacts_model["Model<br/>artifact<br/>[model.pkl]"]
end

node_n_dataset_notebook -->|"explore"| node_n_notebook_eda
node_n_dataset_notebook -->|"prototype"| node_n_notebook_train
node_n_artifacts_data -->|"start"| node_n_train_pipeline
node_n_train_pipeline -->|"orchestrates"| node_n_data_ingestion
node_n_data_ingestion -->|"writes"| node_n_artifacts_train
node_n_data_ingestion -->|"writes"| node_n_artifacts_test
node_n_artifacts_train -->|"consumes"| node_n_data_transformation
node_n_data_transformation -->|"persists"| node_n_artifacts_preprocessor
node_n_artifacts_train -->|"consumes"| node_n_hyper_tuning
node_n_artifacts_preprocessor -->|"features"| node_n_model_trainer
node_n_hyper_tuning -->|"selects"| node_n_model_trainer
node_n_model_trainer -->|"persists"| node_n_artifacts_model
node_n_app -->|"calls"| node_n_predict_pipeline
node_n_predict_pipeline -->|"loads"| node_n_artifacts_preprocessor
node_n_predict_pipeline -->|"loads"| node_n_artifacts_model
node_n_app -->|"renders"| node_n_templates_home
node_n_app -->|"renders"| node_n_templates_index
node_n_app -->|"uses"| node_n_logger
node_n_train_pipeline -->|"uses"| node_n_logger
node_n_predict_pipeline -->|"handles"| node_n_exception
node_n_data_ingestion -->|"handles"| node_n_exception
node_n_data_transformation -->|"uses"| node_n_utils
node_n_model_trainer -->|"uses"| node_n_utils

click node_n_notebook_eda "https://github.com/sahilnegi4444/student-performance-indicator/blob/main/notebook/EDA_STUDENT_PERFORMANCE.ipynb"
click node_n_notebook_train "https://github.com/sahilnegi4444/student-performance-indicator/blob/main/notebook/MODEL_TRAINING.ipynb"
click node_n_train_pipeline "https://github.com/sahilnegi4444/student-performance-indicator/blob/main/src/pipeline/train_pipeline.py"
click node_n_data_ingestion "https://github.com/sahilnegi4444/student-performance-indicator/blob/main/src/components/data_ingestion.py"
click node_n_data_transformation "https://github.com/sahilnegi4444/student-performance-indicator/blob/main/src/components/data_transformation.py"
click node_n_hyper_tuning "https://github.com/sahilnegi4444/student-performance-indicator/blob/main/src/components/hyperparameter_tuning.py"
click node_n_model_trainer "https://github.com/sahilnegi4444/student-performance-indicator/blob/main/src/components/model_trainer.py"
click node_n_predict_pipeline "https://github.com/sahilnegi4444/student-performance-indicator/blob/main/src/pipeline/predict_pipeline.py"
click node_n_app "https://github.com/sahilnegi4444/student-performance-indicator/blob/main/app.py"
click node_n_templates_home "https://github.com/sahilnegi4444/student-performance-indicator/blob/main/templates/home.html"
click node_n_templates_index "https://github.com/sahilnegi4444/student-performance-indicator/blob/main/templates/index.html"
click node_n_utils "https://github.com/sahilnegi4444/student-performance-indicator/blob/main/src/utils.py"
click node_n_logger "https://github.com/sahilnegi4444/student-performance-indicator/blob/main/src/logger.py"
click node_n_exception "https://github.com/sahilnegi4444/student-performance-indicator/blob/main/src/exception.py"
click node_n_artifacts_data "https://github.com/sahilnegi4444/student-performance-indicator/blob/main/artifacts/data.csv"
click node_n_artifacts_train "https://github.com/sahilnegi4444/student-performance-indicator/blob/main/artifacts/train.csv"
click node_n_artifacts_test "https://github.com/sahilnegi4444/student-performance-indicator/blob/main/artifacts/test.csv"
click node_n_artifacts_preprocessor "https://github.com/sahilnegi4444/student-performance-indicator/blob/main/artifacts/preprocessor.pkl"
click node_n_artifacts_model "https://github.com/sahilnegi4444/student-performance-indicator/blob/main/artifacts/model.pkl"
click node_n_dataset_notebook "https://github.com/sahilnegi4444/student-performance-indicator/blob/main/notebook/data/stud.csv"

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_n_notebook_eda,node_n_notebook_train,node_n_dataset_notebook toneBlue
class node_n_train_pipeline,node_n_data_ingestion,node_n_data_transformation,node_n_hyper_tuning,node_n_model_trainer toneAmber
class node_n_predict_pipeline,node_n_app,node_n_templates_home,node_n_templates_index toneMint
class node_n_utils,node_n_logger,node_n_exception,node_n_artifacts_data,node_n_artifacts_train,node_n_artifacts_test,node_n_artifacts_preprocessor,node_n_artifacts_model toneRose
```

## Components

### Experimentation

Notebook-based EDA and model exploration

- [EDA notebook](https://github.com/sahilnegi4444/student-performance-indicator/blob/main/notebook/EDA_STUDENT_PERFORMANCE.ipynb): notebook · Exploratory analysis of student performance data · `notebook/EDA_STUDENT_PERFORMANCE.ipynb`
- [Training notebook](https://github.com/sahilnegi4444/student-performance-indicator/blob/main/notebook/MODEL_TRAINING.ipynb): notebook · Model experimentation and prototyping · `notebook/MODEL_TRAINING.ipynb`
- [Stud data](https://github.com/sahilnegi4444/student-performance-indicator/blob/main/notebook/data/stud.csv): dataset · Notebook copy of the student performance dataset · `notebook/data/stud.csv`

### Offline training

Batch pipeline that builds reusable ML artifacts

- [Train pipeline](https://github.com/sahilnegi4444/student-performance-indicator/blob/main/src/pipeline/train_pipeline.py): pipeline · Orchestrates ingestion, transformation, tuning, and training · `src/pipeline/train_pipeline.py`
- [Ingestion](https://github.com/sahilnegi4444/student-performance-indicator/blob/main/src/components/data_ingestion.py): Reads raw data and creates train/test splits · `src/components/data_ingestion.py`
- [Transform](https://github.com/sahilnegi4444/student-performance-indicator/blob/main/src/components/data_transformation.py): Builds preprocessing logic and feature pipeline · `src/components/data_transformation.py`
- [Tuning](https://github.com/sahilnegi4444/student-performance-indicator/blob/main/src/components/hyperparameter_tuning.py): Searches and selects the best model configuration · `src/components/hyperparameter_tuning.py`
- [Trainer](https://github.com/sahilnegi4444/student-performance-indicator/blob/main/src/components/model_trainer.py): Fits the final estimator and persists it · `src/components/model_trainer.py`

### Online serving

Flask app and inference path

- [Predict pipeline](https://github.com/sahilnegi4444/student-performance-indicator/blob/main/src/pipeline/predict_pipeline.py): pipeline · Loads artifacts and prepares inference-time features · `src/pipeline/predict_pipeline.py`
- [Flask app](https://github.com/sahilnegi4444/student-performance-indicator/blob/main/app.py): web app · HTTP entry point for browser-based prediction · `app.py`
- [Home page](https://github.com/sahilnegi4444/student-performance-indicator/blob/main/templates/home.html): template · Landing page template · `templates/home.html`
- [Input form](https://github.com/sahilnegi4444/student-performance-indicator/blob/main/templates/index.html): template · Student feature entry and result display template · `templates/index.html`

### Shared support

Cross-cutting utilities and persisted artifacts

- [Utils](https://github.com/sahilnegi4444/student-performance-indicator/blob/main/src/utils.py): support · Shared helper functions · `src/utils.py`
- [Logger](https://github.com/sahilnegi4444/student-performance-indicator/blob/main/src/logger.py): support · Logging setup used across the repo · `src/logger.py`
- [Exceptions](https://github.com/sahilnegi4444/student-performance-indicator/blob/main/src/exception.py): support · Centralized error handling and wrapping · `src/exception.py`
- [Raw data](https://github.com/sahilnegi4444/student-performance-indicator/blob/main/artifacts/data.csv): dataset artifact · Stored source dataset used for training and experimentation · `artifacts/data.csv`
- [Train split](https://github.com/sahilnegi4444/student-performance-indicator/blob/main/artifacts/train.csv): dataset artifact · Training subset produced by ingestion · `artifacts/train.csv`
- [Test split](https://github.com/sahilnegi4444/student-performance-indicator/blob/main/artifacts/test.csv): dataset artifact · Test subset produced by ingestion · `artifacts/test.csv`
- [Preprocessor](https://github.com/sahilnegi4444/student-performance-indicator/blob/main/artifacts/preprocessor.pkl): artifact · Serialized preprocessing pipeline reused at inference · `artifacts/preprocessor.pkl`
- [Model](https://github.com/sahilnegi4444/student-performance-indicator/blob/main/artifacts/model.pkl): artifact · Serialized trained estimator used for prediction · `artifacts/model.pkl`

## Connections

- Stud data → EDA notebook: explore · Notebook dataset used for EDA
- Stud data → Training notebook: prototype · Dataset used in experimentation
- Raw data → Train pipeline: start · Offline training begins from stored data
- Train pipeline → Ingestion: orchestrates · Pipeline invokes ingestion step
- Ingestion → Train split: writes · Creates training split
- Ingestion → Test split: writes · Creates test split
- Train split → Transform: consumes · Transformation uses split training data
- Transform → Preprocessor: persists · Saves fitted preprocessing pipeline
- Train split → Tuning: consumes · Tuning reads prepared training data
- Preprocessor → Trainer: features · Trainer uses shared preprocessing logic
- Tuning → Trainer: selects · Best configuration is handed to training
- Trainer → Model: persists · Saves final trained model
- Flask app → Predict pipeline: calls · Flask route delegates to inference pipeline
- Predict pipeline → Preprocessor: loads · Reuse training-time preprocessing at inference
- Predict pipeline → Model: loads · Loads trained estimator for scoring
- Flask app → Home page: renders · Serves landing page
- Flask app → Input form: renders · Serves input and result page
- Flask app → Logger: uses · App logging support
- Train pipeline → Logger: uses · Training logs and tracing
- Predict pipeline → Exceptions: handles · Inference errors are wrapped consistently
- Ingestion → Exceptions: handles · Ingestion errors are normalized
- Transform → Utils: uses · Transformation reuses shared helpers
- Trainer → Utils: uses · Training reuses common helpers
