# vikashishere/mlops-proj1---wine-quality-prediction architecture

> Architecture diagram of the GitHub repository vikashishere/mlops-proj1---wine-quality-prediction, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/vikashishere/mlops-proj1---wine-quality-prediction
- Repository: https://github.com/vikashishere/mlops-proj1---wine-quality-prediction

## Overview

1. **What this repository is**
   - An end-to-end **machine learning project for wine quality prediction**.
   - It combines an offline ML training pipeline with a small **Flask-based web application** for inference.
   - The code is organized as an installable Python package under `src/mlProject`.

2. **Top-level architecture**
   - There are two main runtime entrypoints:
     - `main.py` for running the full ML pipeline.
     - `app.py` for starting the user-facing web app.
   - The rest of the repo is split into pipeline stages, reusable components, configuration/entities, and web assets/templates.

3. **Configuration-driven design**
   - The project is heavily driven by external YAML files:
     - `config/config.yaml` for paths and workflow settings.
     - `params.yaml` for model/training hyperparameters.
     - `schema.yaml` for dataset schema and validation rules.
   - This keeps stage logic separate from environment-specific paths and model settings.

4. **ML pipeline stages**
   - The core workflow is implemented as a staged pipeline under `src/mlProject/pipeline`:
     - data ingestion
     - data validation
     - data transformation
     - model training
     - model evaluation
   - Each stage has its own `stage_XX_*.py` wrapper, which likely coordinates the corresponding component and persists outputs to `artifacts/`.

5. **Component boundary**
   - The actual business logic lives in `src/mlProject/components`:
     - `data_ingestion.py`
     - `data_validation.py`
     - `data_transformation.py`
     - `model_trainer.py`
     - `model_evaluation.py`
   - These components are the main reusable units that the pipeline stages invoke.  
   - This separation suggests the pipeline files are orchestration layers, while components hold the stage implementations.

6. **Data flow through artifacts**
   - Intermediate outputs are stored on disk in `artifacts/`, which acts as the system’s main handoff boundary between stages.
   - Observed outputs include:
     - ingested raw data (`artifacts/data_ingestion/data.csv`, `data.zip`)
     - transformed train/test splits (`artifacts/data_transformation/train.csv`, `test.csv`)
     - validation status (`artifacts/data_validation/status.txt`)
     - evaluation metrics (`artifacts/model_evaluation/metrics.json`)
     - trained model artifact (`artifacts/model_trainer/model.joblib`)
   - This implies a file-based pipeline where each stage consumes previous stage outputs and writes its own results.

7. **Training and evaluation loop**
   - The training stage produces a serialized model artifact, likely using `joblib`.
   - The evaluation stage reads the trained model and transformed test data, then writes metrics for decision-making or reporting.
   - The repository contains both research notebooks and saved artifacts, indicating the notebooks were used to prototype the final pipeline behavior.

8. **Prediction / serving path**
   - `src/mlProject/pipeline/prediction.py` appears to encapsulate inference logic for the deployed app.
   - `app.py`, together with `templates/` and `static/`, forms the web-facing boundary:
     - `templates/index.html` and `templates/results.html` are the UI pages.
     - `static/` contains CSS, JS, and images for presentation.
   - This suggests the app accepts feature input from the browser, runs prediction, and renders results.

9. **Shared infrastructure inside the package**
   - `src/mlProject/config/configuration.py` and `src/mlProject/entity/config_entity.py` likely map YAML settings into typed objects used by components.
   - `src/mlProject/utils/common.py` is probably the shared utility layer for reading YAML, logging, path handling, and artifact management.
   - `src/mlProject/logging/` centralizes runtime logging, with logs written to `logs/running_log.log`.

10. **Runtime and packaging**
   - The project uses standard Python packaging via `setup.py` and a `src/` layout.
   - `requirements.txt` defines the runtime dependencies.
   - The repo includes a `dockerfile`, indicating containerized deployment support.

11. **CI/CD and deployment architecture**
   - The README describes AWS-based deployment through GitHub Actions:
     - build a Docker image
     - push it to **AWS ECR**
     - deploy it to **AWS EC2**
   - The workflow depends on GitHub secrets for AWS credentials and repository info.
   - This means production deployment is container-based, with EC2 as the runtime host and ECR as the image registry.

12. **Research and non-production assets**
   - The `research/` folder contains notebooks for each stage of the ML workflow plus experiments and trial runs.
   - These notebooks are exploratory and not part of the production pipeline, but they explain how the final components were derived.
   - The checked-in sample datasets and artifacts make the repo reproducible and easier to inspect.

13. **Key architectural boundaries to diagram**
   - Separate the system into:
     - **Web/UI layer**: Flask app, templates, static assets
     - **Inference layer**: prediction pipeline + saved model artifact
     - **Training pipeline**: ingestion → validation → transformation → training → evaluation
     - **Configuration layer**: YAML configs, schema, params
     - **Persistence layer**: `artifacts/` and logs
     - **Deployment layer**: Docker + GitHub Actions + AWS ECR/EC2

14. **Overall flow**
   - Source data enters at ingestion, is validated against schema, transformed into model-ready splits, used to train and evaluate a model, then serialized into artifacts.
   - The web app reads the trained artifact for prediction requests.
   - CI/CD packages the app into a Docker image and deploys that image to AWS infrastructure.

Main entry points: [`app.py`](https://github.com/vikashishere/mlops-proj1---wine-quality-prediction/blob/master/app.py) (app.py), [`src/mlProject/utils/common.py`](https://github.com/vikashishere/mlops-proj1---wine-quality-prediction/blob/master/src/mlProject/utils/common.py) (common.py), [`src/mlProject/logging`](https://github.com/vikashishere/mlops-proj1---wine-quality-prediction/tree/master/src/mlProject/logging) (logging), [`src/mlProject/config/configuration.py`](https://github.com/vikashishere/mlops-proj1---wine-quality-prediction/blob/master/src/mlProject/config/configuration.py) (configuration.py)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_grp_web["Web UI"]
  node_app_py["app.py<br/>flask app<br/>[app.py]"]
  node_templates_index["index.html<br/>template<br/>[index.html]"]
  node_templates_results["results.html<br/>template<br/>[results.html]"]
  node_static_assets["static assets<br/>ui assets"]
end

subgraph group_grp_pipeline["ML Pipeline"]
  node_main_py["main.py<br/>pipeline entrypoint<br/>[main.py]"]
  node_stage_ingestion["ingestion stage<br/>pipeline stage"]
  node_stage_validation["validation stage<br/>pipeline stage"]
  node_stage_transform["transform stage<br/>pipeline stage"]
  node_stage_trainer["trainer stage<br/>pipeline stage"]
  node_stage_eval["eval stage<br/>pipeline stage"]
  node_pred_pipeline["prediction<br/>inference pipeline<br/>[prediction.py]"]
end

subgraph group_grp_config["Config"]
  node_config_yaml["config.yaml<br/>runtime config<br/>[config.yaml]"]
  node_params_yaml["params.yaml<br/>hyperparams<br/>[params.yaml]"]
  node_schema_yaml["schema.yaml<br/>data schema<br/>[schema.yaml]"]
end

subgraph group_grp_shared["Shared Core"]
  node_configuration_py["configuration.py<br/>config mapper<br/>[configuration.py]"]
  node_config_entity_py["config_entity.py<br/>entities<br/>[config_entity.py]"]
  node_common_py["common.py<br/>utilities<br/>[common.py]"]
  node_logging_pkg["logging"]
end

subgraph group_grp_persist["Artifacts"]
  node_artifacts_root[("artifacts<br/>artifact store")]
  node_model_artifact["model.joblib<br/>trained model<br/>[model.joblib]"]
  node_metrics_artifact["metrics.json<br/>evaluation output<br/>[metrics.json]"]
end

subgraph group_grp_deploy["Deployment"]
  node_cicd_yaml["cicd.yaml<br/>ci workflow<br/>[cicd.yaml]"]
  node_dockerfile["dockerfile<br/>container build"]
end

node_app_py -->|"uses"| node_pred_pipeline
node_app_py -->|"renders"| node_templates_index
node_app_py -->|"renders"| node_templates_results
node_app_py -->|"serves"| node_static_assets
node_main_py -->|"runs"| node_stage_ingestion
node_stage_ingestion -->|"feeds"| node_stage_validation
node_stage_validation -->|"feeds"| node_stage_transform
node_stage_transform -->|"feeds"| node_stage_trainer
node_stage_trainer -->|"feeds"| node_stage_eval
node_configuration_py -->|"loads"| node_config_yaml
node_configuration_py -->|"loads"| node_params_yaml
node_configuration_py -->|"loads"| node_schema_yaml
node_configuration_py -->|"builds"| node_config_entity_py
node_stage_ingestion -->|"uses"| node_common_py
node_stage_validation -->|"uses"| node_common_py
node_stage_transform -->|"uses"| node_common_py
node_stage_trainer -->|"uses"| node_common_py
node_stage_eval -->|"uses"| node_common_py
node_common_py -->|"writes"| node_artifacts_root
node_stage_ingestion -->|"writes"| node_artifacts_root
node_stage_validation -->|"writes"| node_artifacts_root
node_stage_transform -->|"writes"| node_artifacts_root
node_stage_trainer -->|"produces"| node_model_artifact
node_stage_eval -->|"produces"| node_metrics_artifact
node_pred_pipeline -->|"loads"| node_model_artifact
node_pred_pipeline -->|"uses"| node_configuration_py
node_logging_pkg -->|"logs"| node_stage_ingestion
node_logging_pkg -->|"logs"| node_stage_validation
node_logging_pkg -->|"logs"| node_stage_transform
node_logging_pkg -->|"logs"| node_stage_trainer
node_logging_pkg -->|"logs"| node_stage_eval
node_cicd_yaml -->|"builds"| node_dockerfile
node_cicd_yaml -->|"deploys"| node_app_py
node_dockerfile -->|"packages"| node_app_py

click node_app_py "https://github.com/vikashishere/mlops-proj1---wine-quality-prediction/blob/master/app.py"
click node_templates_index "https://github.com/vikashishere/mlops-proj1---wine-quality-prediction/blob/master/templates/index.html"
click node_templates_results "https://github.com/vikashishere/mlops-proj1---wine-quality-prediction/blob/master/templates/results.html"
click node_static_assets "https://github.com/vikashishere/mlops-proj1---wine-quality-prediction/tree/master/static"
click node_main_py "https://github.com/vikashishere/mlops-proj1---wine-quality-prediction/blob/master/main.py"
click node_stage_ingestion "https://github.com/vikashishere/mlops-proj1---wine-quality-prediction/blob/master/src/mlProject/pipeline/stage_01_data_ingestion.py"
click node_stage_validation "https://github.com/vikashishere/mlops-proj1---wine-quality-prediction/blob/master/src/mlProject/pipeline/stage_02_data_validation.py"
click node_stage_transform "https://github.com/vikashishere/mlops-proj1---wine-quality-prediction/blob/master/src/mlProject/pipeline/stage_03_data_transformation.py"
click node_stage_trainer "https://github.com/vikashishere/mlops-proj1---wine-quality-prediction/blob/master/src/mlProject/pipeline/stage_04_model_trainer.py"
click node_stage_eval "https://github.com/vikashishere/mlops-proj1---wine-quality-prediction/blob/master/src/mlProject/pipeline/stage_05_model_evaluation.py"
click node_pred_pipeline "https://github.com/vikashishere/mlops-proj1---wine-quality-prediction/blob/master/src/mlProject/pipeline/prediction.py"
click node_config_yaml "https://github.com/vikashishere/mlops-proj1---wine-quality-prediction/blob/master/config/config.yaml"
click node_params_yaml "https://github.com/vikashishere/mlops-proj1---wine-quality-prediction/blob/master/params.yaml"
click node_schema_yaml "https://github.com/vikashishere/mlops-proj1---wine-quality-prediction/blob/master/schema.yaml"
click node_configuration_py "https://github.com/vikashishere/mlops-proj1---wine-quality-prediction/blob/master/src/mlProject/config/configuration.py"
click node_config_entity_py "https://github.com/vikashishere/mlops-proj1---wine-quality-prediction/blob/master/src/mlProject/entity/config_entity.py"
click node_common_py "https://github.com/vikashishere/mlops-proj1---wine-quality-prediction/blob/master/src/mlProject/utils/common.py"
click node_logging_pkg "https://github.com/vikashishere/mlops-proj1---wine-quality-prediction/tree/master/src/mlProject/logging"
click node_artifacts_root "https://github.com/vikashishere/mlops-proj1---wine-quality-prediction/tree/master/artifacts"
click node_model_artifact "https://github.com/vikashishere/mlops-proj1---wine-quality-prediction/blob/master/artifacts/model_trainer/model.joblib"
click node_metrics_artifact "https://github.com/vikashishere/mlops-proj1---wine-quality-prediction/blob/master/artifacts/model_evaluation/metrics.json"
click node_cicd_yaml "https://github.com/vikashishere/mlops-proj1---wine-quality-prediction/blob/master/.github/workflows/cicd.yaml"
click node_dockerfile "https://github.com/vikashishere/mlops-proj1---wine-quality-prediction/tree/master/dockerfile"

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_app_py,node_templates_index,node_templates_results,node_static_assets toneBlue
class node_main_py,node_stage_ingestion,node_stage_validation,node_stage_transform,node_stage_trainer,node_stage_eval,node_pred_pipeline toneAmber
class node_config_yaml,node_params_yaml,node_schema_yaml toneMint
class node_configuration_py,node_config_entity_py,node_common_py,node_logging_pkg toneRose
class node_artifacts_root,node_model_artifact,node_metrics_artifact toneIndigo
class node_cicd_yaml,node_dockerfile toneTeal
```

## Components

### Web UI

Flask inference surface and browser assets

- [app.py](https://github.com/vikashishere/mlops-proj1---wine-quality-prediction/blob/master/app.py): flask app · Web entrypoint for prediction requests and result rendering · `app.py`
- [index.html](https://github.com/vikashishere/mlops-proj1---wine-quality-prediction/blob/master/templates/index.html): template · Input form page for the inference UI · `templates/index.html`
- [results.html](https://github.com/vikashishere/mlops-proj1---wine-quality-prediction/blob/master/templates/results.html): template · Prediction results page · `templates/results.html`
- [static assets](https://github.com/vikashishere/mlops-proj1---wine-quality-prediction/tree/master/static): ui assets · CSS, JS, and images used by the Flask app · `static`

### ML Pipeline

Offline training and evaluation workflow

- [main.py](https://github.com/vikashishere/mlops-proj1---wine-quality-prediction/blob/master/main.py): pipeline entrypoint · Runs the end-to-end training workflow · `main.py`
- [ingestion stage](https://github.com/vikashishere/mlops-proj1---wine-quality-prediction/blob/master/src/mlProject/pipeline/stage_01_data_ingestion.py): pipeline stage · Stage wrapper for bringing raw data into the pipeline · `src/mlProject/pipeline/stage_01_data_ingestion.py`
- [validation stage](https://github.com/vikashishere/mlops-proj1---wine-quality-prediction/blob/master/src/mlProject/pipeline/stage_02_data_validation.py): pipeline stage · Stage wrapper for schema and data checks · `src/mlProject/pipeline/stage_02_data_validation.py`
- [transform stage](https://github.com/vikashishere/mlops-proj1---wine-quality-prediction/blob/master/src/mlProject/pipeline/stage_03_data_transformation.py): pipeline stage · Stage wrapper for feature preparation and splits · `src/mlProject/pipeline/stage_03_data_transformation.py`
- [trainer stage](https://github.com/vikashishere/mlops-proj1---wine-quality-prediction/blob/master/src/mlProject/pipeline/stage_04_model_trainer.py): pipeline stage · Stage wrapper for model fitting and serialization · `src/mlProject/pipeline/stage_04_model_trainer.py`
- [eval stage](https://github.com/vikashishere/mlops-proj1---wine-quality-prediction/blob/master/src/mlProject/pipeline/stage_05_model_evaluation.py): pipeline stage · Stage wrapper for model scoring and metrics · `src/mlProject/pipeline/stage_05_model_evaluation.py`
- [prediction](https://github.com/vikashishere/mlops-proj1---wine-quality-prediction/blob/master/src/mlProject/pipeline/prediction.py): inference pipeline · Shared prediction logic used by the web app · `src/mlProject/pipeline/prediction.py`

### Config

YAML-driven settings and schema

- [config.yaml](https://github.com/vikashishere/mlops-proj1---wine-quality-prediction/blob/master/config/config.yaml): runtime config · Workflow paths and pipeline settings · `config/config.yaml`
- [params.yaml](https://github.com/vikashishere/mlops-proj1---wine-quality-prediction/blob/master/params.yaml): hyperparams · Model and training parameters · `params.yaml`
- [schema.yaml](https://github.com/vikashishere/mlops-proj1---wine-quality-prediction/blob/master/schema.yaml): data schema · Dataset columns and validation rules · `schema.yaml`

### Shared Core

Reusable package infrastructure

- [configuration.py](https://github.com/vikashishere/mlops-proj1---wine-quality-prediction/blob/master/src/mlProject/config/configuration.py): config mapper · Builds typed configuration objects from YAML · `src/mlProject/config/configuration.py`
- [config_entity.py](https://github.com/vikashishere/mlops-proj1---wine-quality-prediction/blob/master/src/mlProject/entity/config_entity.py): entities · Typed config and artifact descriptors · `src/mlProject/entity/config_entity.py`
- [common.py](https://github.com/vikashishere/mlops-proj1---wine-quality-prediction/blob/master/src/mlProject/utils/common.py): utilities · Shared helpers for YAML, paths, and artifacts · `src/mlProject/utils/common.py`
- [logging](https://github.com/vikashishere/mlops-proj1---wine-quality-prediction/tree/master/src/mlProject/logging): logging · Centralized runtime logging setup · `src/mlProject/logging`

### Artifacts

Filesystem handoff between stages

- [artifacts](https://github.com/vikashishere/mlops-proj1---wine-quality-prediction/tree/master/artifacts): artifact store · File-based handoff boundary for pipeline outputs · `artifacts`
- [model.joblib](https://github.com/vikashishere/mlops-proj1---wine-quality-prediction/blob/master/artifacts/model_trainer/model.joblib): trained model · Serialized model consumed by inference and evaluation · `artifacts/model_trainer/model.joblib`
- [metrics.json](https://github.com/vikashishere/mlops-proj1---wine-quality-prediction/blob/master/artifacts/model_evaluation/metrics.json): evaluation output · Model evaluation metrics · `artifacts/model_evaluation/metrics.json`

### Deployment

Container and CI/CD delivery

- [cicd.yaml](https://github.com/vikashishere/mlops-proj1---wine-quality-prediction/blob/master/.github/workflows/cicd.yaml): ci workflow · GitHub Actions workflow for build and deploy · `.github/workflows/cicd.yaml`
- [dockerfile](https://github.com/vikashishere/mlops-proj1---wine-quality-prediction/tree/master/dockerfile): container build · Image build definition for deployment · `dockerfile`

## Connections

- app.py → prediction: uses · Flask app delegates inference to shared prediction logic
- app.py → index.html: renders · Serves the input form page
- app.py → results.html: renders · Serves prediction results
- app.py → static assets: serves · Uses static CSS, JS, and images
- main.py → ingestion stage: runs · Starts the training workflow at ingestion
- ingestion stage → validation stage: feeds · Validation consumes ingested data outputs
- validation stage → transform stage: feeds · Transformation consumes validated data
- transform stage → trainer stage: feeds · Trainer consumes model-ready splits
- trainer stage → eval stage: feeds · Evaluation consumes the trained model
- configuration.py → config.yaml: loads · Maps workflow configuration from YAML
- configuration.py → params.yaml: loads · Reads training parameters
- configuration.py → schema.yaml: loads · Reads schema and validation rules
- configuration.py → config_entity.py: builds · Creates typed configuration objects
- ingestion stage → common.py: uses · Relies on shared helpers
- validation stage → common.py: uses · Relies on shared helpers
- transform stage → common.py: uses · Relies on shared helpers
- trainer stage → common.py: uses · Relies on shared helpers
- eval stage → common.py: uses · Relies on shared helpers
- common.py → artifacts: writes · Persists stage outputs under artifacts
- ingestion stage → artifacts: writes · Stores raw ingested dataset
- validation stage → artifacts: writes · Stores validation status
- transform stage → artifacts: writes · Stores transformed train/test splits
- trainer stage → model.joblib: produces · Serializes the trained model
- eval stage → metrics.json: produces · Writes evaluation metrics
- prediction → model.joblib: loads · Inference reads the trained model artifact
- prediction → configuration.py: uses · Shares configuration plumbing with pipeline
- logging → ingestion stage: logs · Pipeline stages emit runtime logs
- logging → validation stage: logs · Pipeline stages emit runtime logs
- logging → transform stage: logs · Pipeline stages emit runtime logs
- logging → trainer stage: logs · Pipeline stages emit runtime logs
- logging → eval stage: logs · Pipeline stages emit runtime logs
- cicd.yaml → dockerfile: builds · Workflow builds the container image
- cicd.yaml → app.py: deploys · Workflow deploys the application image
- dockerfile → app.py: packages · Container image packages the Flask app and pipeline code
