# shivammitra/datascienceproject architecture

> Architecture diagram of the GitHub repository shivammitra/datascienceproject, 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/datascienceproject
- Repository: https://github.com/shivammitra/datascienceproject

## Overview

#### Purpose and Entry Points
This is a config-driven Python machine-learning project that runs an end-to-end training/evaluation workflow and provides an application-facing prediction path. Batch orchestration starts in `main.py`; application serving starts in `app.py`. The installable implementation is under `src/datascience/`, while exploratory development is captured in `research/`.

#### Pipeline Orchestration
Each training stage has a dedicated pipeline wrapper, enabling independent execution or composition by the main orchestrator:
- `src/datascience/pipeline/data_ingestion_pipeline.py`
- `src/datascience/pipeline/data_validation_pipeline.py`
- `src/datascience/pipeline/data_transformation_pipeline.py`
- `src/datascience/pipeline/model_trainer_pipeline.py`
- `src/datascience/pipeline/model_evaluation_pipeline.py`

The intended control flow is ingestion → validation → transformation → training → evaluation/tracking. `src/datascience/pipeline/prediction_pipeline.py` forms the separate inference boundary used by the application layer.

#### Core ML Stages
Implementation logic is separated from orchestration into reusable components:
- Raw-data acquisition/storage: `src/datascience/components/data_ingestion.py`
- Schema and quality gate: `src/datascience/components/data_validation.py`
- Feature engineering/preprocessing: `src/datascience/components/data_transformation.py`
- Model fitting and artifact generation: `src/datascience/components/model_trainer.py`
- Metric calculation, comparison, and experiment logging: `src/datascience/components/model_evaluation.py`

Validation is the primary boundary preventing malformed data from reaching feature generation and training.

#### Configuration and Contracts
Runtime behavior is declared through YAML and converted into typed/configuration entities:
- Global pipeline configuration: `config/config.yaml`
- Model/experiment parameters: `params.yaml`
- Dataset schema contract: `schema.yaml`
- Configuration loading/assembly: `src/datascience/config/configuration.py`
- Stage configuration entities: `src/datascience/entity/config_entity.py`

This creates a clear split: YAML owns environment-specific paths, parameters, and schemas; components consume resolved stage-specific configuration rather than embedding those concerns.

#### Serving and Prediction Boundary
`app.py` is the deployment/application entry point, with HTML presentation resources in:
- `templates/index.html`
- `templates/results.html`

It should delegate inference concerns to `src/datascience/pipeline/prediction_pipeline.py`, keeping request/UI handling separate from model-loading and prediction logic.

#### Experimentation, Tracking, and Runtime
Jupyter notebooks document and prototype the same lifecycle before code is promoted into package components, notably `research/1_data_ingestion.ipynb` through `research/5_model_evaluation.ipynb`. The project targets Python 3.8+ and is packaged via `setup.py`. MLflow is the experiment-tracking integration, with optional DagsHub-backed collaboration/tracking. Container execution is defined by `Dockerfile`; external tracking-server connectivity is an infrastructure dependency when evaluation logs remotely.

Main entry points: [`src/datascience/entity/config_entity.py`](https://github.com/shivammitra/datascienceproject/blob/main/src/datascience/entity/config_entity.py) (Stage config entities), [`src/datascience/config/configuration.py`](https://github.com/shivammitra/datascienceproject/blob/main/src/datascience/config/configuration.py) (Configuration loader), [`src/datascience/pipeline/data_ingestion_pipeline.py`](https://github.com/shivammitra/datascienceproject/blob/main/src/datascience/pipeline/data_ingestion_pipeline.py) (Ingestion pipeline), [`src/datascience/pipeline/data_validation_pipeline.py`](https://github.com/shivammitra/datascienceproject/blob/main/src/datascience/pipeline/data_validation_pipeline.py) (Validation pipeline)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_batch["Batch ML workflow"]
  node_main["Batch entry point<br/>Python entry point<br/>[main.py]"]
  node_ingestion_pipeline["Ingestion pipeline<br/>pipeline wrapper"]
  node_validation_pipeline["Validation pipeline<br/>pipeline wrapper"]
  node_transformation_pipeline["Transformation pipeline<br/>pipeline wrapper"]
  node_trainer_pipeline["Training pipeline<br/>pipeline wrapper"]
  node_evaluation_pipeline["Evaluation pipeline<br/>pipeline wrapper"]
  node_ingestion["Data ingestion<br/>ML component<br/>[data_ingestion.py]"]
  node_validation["Data validation<br/>ML component<br/>[data_validation.py]"]
  node_transformation["Data transformation<br/>ML component"]
  node_trainer["Model trainer<br/>ML component<br/>[model_trainer.py]"]
  node_evaluation["Model evaluation<br/>ML component"]
end

subgraph group_config["Configuration contracts"]
  node_config_yaml["Pipeline config<br/>YAML configuration<br/>[config.yaml]"]
  node_params_yaml["Model parameters<br/>YAML parameters<br/>[params.yaml]"]
  node_schema_yaml["Dataset schema<br/>YAML contract<br/>[schema.yaml]"]
  node_configuration["Configuration loader<br/>configuration assembly<br/>[configuration.py]"]
  node_config_entities["Stage config entities<br/>typed contracts<br/>[config_entity.py]"]
end

subgraph group_serving["Application serving"]
  node_app["Application entry point<br/>Python application<br/>[app.py]"]
  node_templates["HTML templates<br/>presentation resources"]
  node_prediction_pipeline["Prediction pipeline<br/>inference boundary"]
end

node_mlflow[("MLflow tracking<br/>external experiment service")]

node_main -->|"starts"| node_ingestion_pipeline
node_ingestion_pipeline -->|"raw data"| node_validation_pipeline
node_validation_pipeline -->|"validated data"| node_transformation_pipeline
node_transformation_pipeline -->|"features"| node_trainer_pipeline
node_trainer_pipeline -->|"model artifacts"| node_evaluation_pipeline
node_ingestion_pipeline -->|"orchestrates"| node_ingestion
node_validation_pipeline -->|"orchestrates"| node_validation
node_transformation_pipeline -->|"orchestrates"| node_transformation
node_trainer_pipeline -->|"orchestrates"| node_trainer
node_evaluation_pipeline -->|"orchestrates"| node_evaluation
node_config_yaml -->|"paths"| node_configuration
node_params_yaml -->|"parameters"| node_configuration
node_schema_yaml -->|"schema"| node_configuration
node_configuration -->|"resolves"| node_config_entities
node_config_entities -.->|"stage config"| node_ingestion
node_config_entities -.->|"stage config"| node_validation
node_config_entities -.->|"stage config"| node_transformation
node_config_entities -.->|"stage config"| node_trainer
node_config_entities -.->|"stage config"| node_evaluation
node_evaluation -->|"metrics and runs"| node_mlflow
node_app -->|"renders"| node_templates
node_app -->|"delegates inference"| node_prediction_pipeline

click node_main "https://github.com/shivammitra/datascienceproject/blob/main/main.py"
click node_ingestion_pipeline "https://github.com/shivammitra/datascienceproject/blob/main/src/datascience/pipeline/data_ingestion_pipeline.py"
click node_validation_pipeline "https://github.com/shivammitra/datascienceproject/blob/main/src/datascience/pipeline/data_validation_pipeline.py"
click node_transformation_pipeline "https://github.com/shivammitra/datascienceproject/blob/main/src/datascience/pipeline/data_transformation_pipeline.py"
click node_trainer_pipeline "https://github.com/shivammitra/datascienceproject/blob/main/src/datascience/pipeline/model_trainer_pipeline.py"
click node_evaluation_pipeline "https://github.com/shivammitra/datascienceproject/blob/main/src/datascience/pipeline/model_evaluation_pipeline.py"
click node_ingestion "https://github.com/shivammitra/datascienceproject/blob/main/src/datascience/components/data_ingestion.py"
click node_validation "https://github.com/shivammitra/datascienceproject/blob/main/src/datascience/components/data_validation.py"
click node_transformation "https://github.com/shivammitra/datascienceproject/blob/main/src/datascience/components/data_transformation.py"
click node_trainer "https://github.com/shivammitra/datascienceproject/blob/main/src/datascience/components/model_trainer.py"
click node_evaluation "https://github.com/shivammitra/datascienceproject/blob/main/src/datascience/components/model_evaluation.py"
click node_config_yaml "https://github.com/shivammitra/datascienceproject/blob/main/config/config.yaml"
click node_params_yaml "https://github.com/shivammitra/datascienceproject/blob/main/params.yaml"
click node_schema_yaml "https://github.com/shivammitra/datascienceproject/blob/main/schema.yaml"
click node_configuration "https://github.com/shivammitra/datascienceproject/blob/main/src/datascience/config/configuration.py"
click node_config_entities "https://github.com/shivammitra/datascienceproject/blob/main/src/datascience/entity/config_entity.py"
click node_app "https://github.com/shivammitra/datascienceproject/blob/main/app.py"
click node_prediction_pipeline "https://github.com/shivammitra/datascienceproject/blob/main/src/datascience/pipeline/prediction_pipeline.py"

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_main,node_ingestion_pipeline,node_validation_pipeline,node_transformation_pipeline,node_trainer_pipeline,node_evaluation_pipeline,node_ingestion,node_validation,node_transformation,node_trainer,node_evaluation toneBlue
class node_config_yaml,node_params_yaml,node_schema_yaml,node_configuration,node_config_entities toneAmber
class node_app,node_templates,node_prediction_pipeline toneMint
class node_mlflow toneNeutral
```

## Components

### Batch ML workflow

Config-driven training and evaluation stages.

- [Batch entry point](https://github.com/shivammitra/datascienceproject/blob/main/main.py): Python entry point · `main.py`
- [Ingestion pipeline](https://github.com/shivammitra/datascienceproject/blob/main/src/datascience/pipeline/data_ingestion_pipeline.py): pipeline wrapper · `src/datascience/pipeline/data_ingestion_pipeline.py`
- [Validation pipeline](https://github.com/shivammitra/datascienceproject/blob/main/src/datascience/pipeline/data_validation_pipeline.py): pipeline wrapper · `src/datascience/pipeline/data_validation_pipeline.py`
- [Transformation pipeline](https://github.com/shivammitra/datascienceproject/blob/main/src/datascience/pipeline/data_transformation_pipeline.py): pipeline wrapper · `src/datascience/pipeline/data_transformation_pipeline.py`
- [Training pipeline](https://github.com/shivammitra/datascienceproject/blob/main/src/datascience/pipeline/model_trainer_pipeline.py): pipeline wrapper · `src/datascience/pipeline/model_trainer_pipeline.py`
- [Evaluation pipeline](https://github.com/shivammitra/datascienceproject/blob/main/src/datascience/pipeline/model_evaluation_pipeline.py): pipeline wrapper · `src/datascience/pipeline/model_evaluation_pipeline.py`
- [Data ingestion](https://github.com/shivammitra/datascienceproject/blob/main/src/datascience/components/data_ingestion.py): ML component · Acquires and stores raw data. · `src/datascience/components/data_ingestion.py`
- [Data validation](https://github.com/shivammitra/datascienceproject/blob/main/src/datascience/components/data_validation.py): ML component · Schema and quality gate before feature generation. · `src/datascience/components/data_validation.py`
- [Data transformation](https://github.com/shivammitra/datascienceproject/blob/main/src/datascience/components/data_transformation.py): ML component · Builds preprocessing and features. · `src/datascience/components/data_transformation.py`
- [Model trainer](https://github.com/shivammitra/datascienceproject/blob/main/src/datascience/components/model_trainer.py): ML component · Fits models and generates artifacts. · `src/datascience/components/model_trainer.py`
- [Model evaluation](https://github.com/shivammitra/datascienceproject/blob/main/src/datascience/components/model_evaluation.py): ML component · Calculates metrics, compares models, and logs experiments. · `src/datascience/components/model_evaluation.py`

### Configuration contracts

YAML is resolved into stage-specific entities.

- [Pipeline config](https://github.com/shivammitra/datascienceproject/blob/main/config/config.yaml): YAML configuration · `config/config.yaml`
- [Model parameters](https://github.com/shivammitra/datascienceproject/blob/main/params.yaml): YAML parameters · `params.yaml`
- [Dataset schema](https://github.com/shivammitra/datascienceproject/blob/main/schema.yaml): YAML contract · `schema.yaml`
- [Configuration loader](https://github.com/shivammitra/datascienceproject/blob/main/src/datascience/config/configuration.py): configuration assembly · `src/datascience/config/configuration.py`
- [Stage config entities](https://github.com/shivammitra/datascienceproject/blob/main/src/datascience/entity/config_entity.py): typed contracts · `src/datascience/entity/config_entity.py`

### Application serving

UI handling is separated from inference.

- [Application entry point](https://github.com/shivammitra/datascienceproject/blob/main/app.py): Python application · `app.py`
- **HTML templates**: presentation resources · Index and results views.
- [Prediction pipeline](https://github.com/shivammitra/datascienceproject/blob/main/src/datascience/pipeline/prediction_pipeline.py): inference boundary · Loads model artifacts and produces predictions. · `src/datascience/pipeline/prediction_pipeline.py`

### Other components

- **MLflow tracking**: external experiment service · May connect to a remote tracking server or DagsHub.

## Connections

- Batch entry point → Ingestion pipeline: starts
- Ingestion pipeline → Validation pipeline: raw data
- Validation pipeline → Transformation pipeline: validated data
- Transformation pipeline → Training pipeline: features
- Training pipeline → Evaluation pipeline: model artifacts
- Ingestion pipeline → Data ingestion: orchestrates
- Validation pipeline → Data validation: orchestrates
- Transformation pipeline → Data transformation: orchestrates
- Training pipeline → Model trainer: orchestrates
- Evaluation pipeline → Model evaluation: orchestrates
- Pipeline config → Configuration loader: paths
- Model parameters → Configuration loader: parameters
- Dataset schema → Configuration loader: schema
- Configuration loader → Stage config entities: resolves
- Stage config entities → Data ingestion: stage config
- Stage config entities → Data validation: stage config
- Stage config entities → Data transformation: stage config
- Stage config entities → Model trainer: stage config
- Stage config entities → Model evaluation: stage config
- Model evaluation → MLflow tracking: metrics and runs
- Application entry point → HTML templates: renders
- Application entry point → Prediction pipeline: delegates inference
