# aditya-barik/wine-quality-prediction architecture

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

- Interactive diagram: https://gitdiagram.com/aditya-barik/wine-quality-prediction
- Repository: https://github.com/aditya-barik/wine-quality-prediction

## Overview

##### Project type and purpose
- This is a full-stack ML application for predicting wine quality.
- It includes:
- A data/versioning & model-training pipeline (DVC + Python scripts)
- A prediction microservice (serving a trained model)
- A web frontend (HTML/CSS/JS) that consumes the microservice
- CI/CD workflows (`.github/workflows/ci-cd.yaml`) and deployment config (`Procfile`).

##### Main components
a. Data Ingestion & Versioning
- Raw data source (e.g., `data/remote/winequality.csv.dvc`)
- DVC remote storage
- `dvc.yaml` pipelines with stages:
1. get-data (`pipeline_01_get_data_from_remote_source.py`)
2. split (`pipeline_02_split_data_into_train_and_test.py`)
3. train+evaluate (`pipeline_03_train_and_evaluate_model.py`)
b. Artifact Store
- `models/model.joblib` (persisted in `wine_quality_prediction_service/models`)
- DVC/`dvc.lock` for reproducibility
c. Prediction Microservice
- Python service (`wine_quality_prediction_service/wine_quality_prediction.py`)
- Schema (`schema/min_max_schema.json`) for input validation
- Serves a REST API endpoint for predictions
d. Frontend Web Application
- Flask (or similar) app entrypoint (`app.py`) or a separate Flask/WSGI configured by `Procfile`
- Templates (`wine_quality_prediction_app/templates/*.html`)
- Static assets (`static/css/main.css`, `static/scripts/index.js`)
- JavaScript code calls the prediction API
e. CI/CD & Deployment
- GitHub Actions workflow
- `Procfile` for Heroku or similar PaaS
f. Tests & Validation
- Unit tests (`tests/`), config tests, fixtures
- `tox.ini` for linting and test automation

##### Relationships & Data Flow
1. Remote Data → DVC Pipeline → Processed Data & Train/Test sets
2. Training Stage → Model Artifact → DVC & models folder
3. CI/CD Pipeline → Triggers DVC pipeline, runs tests, builds Docker/Heroku release
4. Deployed Service → Loads model.joblib → Exposes REST endpoint
5. Frontend UI → Sends user input → Prediction API → Receives & displays result

##### Architectural Patterns & Design Principles
- Modular pipeline stages (clear separation of data ingestion, preprocessing, training)
- Version control for data and models (DVC)
- Microservice architecture for model serving
- Layered web app: UI layer, API layer, data/model layer
- CI/CD automation for reproducibility and quick deployment

##### Essential Elements to Capture
- Data sources & storage (local vs. remote)
- Pipeline orchestration (`dvc.yaml`, scripts in `src/`)
- Model artifact management (`models/`, `model.joblib`)
- Microservice endpoint and schema validation
- Frontend components and user interaction flow
- CI/CD & hosting environment

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% CI/CD & Deployment
    subgraph "CI/CD & Deployment"
        gha["GitHub Actions"]:::cloud
        Procfile["Procfile"]:::file
        gha -->|"runs workflow"| dvcYaml
        gha -->|"runs tests"| tests
        gha -->|"deploys via Procfile"| heroku
        click gha "https://github.com/aditya-barik/wine-quality-prediction/blob/main/.github/workflows/ci-cd.yaml"
        click Procfile "https://github.com/aditya-barik/wine-quality-prediction/tree/main/Procfile"
    end

    heroku["Hosting (Heroku)"]:::cloud

    %% Data Ingestion & Versioning
    subgraph "Data Ingestion & Versioning"
        remote["DVC Remote Storage"]:::cloud
        RawData["Raw Data (winequality.csv.dvc)"]:::storage
        DVCConfig[".dvc/config"]:::file
        dvcYaml["dvc.yaml"]:::file
        Stage1["pipeline_01_get_data_from_remote_source.py"]:::compute
        Stage2["pipeline_02_split_data_into_train_and_test.py"]:::compute
        Stage3["pipeline_03_train_and_evaluate_model.py"]:::compute
        dvcLock["dvc.lock"]:::file
        remote --> RawData
        RawData -->|"stage1"| Stage1
        Stage1 -->|"stage2"| Stage2
        Stage2 -->|"stage3"| Stage3
        dvcYaml --> Stage1
        dvcYaml --> Stage2
        dvcYaml --> Stage3
        Stage3 --> dvcLock
        click RawData "https://github.com/aditya-barik/wine-quality-prediction/blob/main/data/remote/winequality.csv.dvc"
        click DVCConfig "https://github.com/aditya-barik/wine-quality-prediction/tree/main/.dvc/config"
        click dvcYaml "https://github.com/aditya-barik/wine-quality-prediction/blob/main/dvc.yaml"
        click Stage1 "https://github.com/aditya-barik/wine-quality-prediction/blob/main/src/pipeline_01_get_data_from_remote_source.py"
        click Stage2 "https://github.com/aditya-barik/wine-quality-prediction/blob/main/src/pipeline_02_split_data_into_train_and_test.py"
        click Stage3 "https://github.com/aditya-barik/wine-quality-prediction/blob/main/src/pipeline_03_train_and_evaluate_model.py"
        click dvcLock "https://github.com/aditya-barik/wine-quality-prediction/blob/main/dvc.lock"
    end

    %% Artifact Store
    subgraph "Artifact Store"
        modelArtifact["model.joblib"]:::storage
        modelArtifact --> serviceModel
        click modelArtifact "https://github.com/aditya-barik/wine-quality-prediction/blob/main/wine_quality_prediction_service/models/model.joblib"
    end

    %% Prediction Microservice
    subgraph "Prediction Microservice"
        service["wine_quality_prediction.py"]:::service
        schema["min_max_schema.json"]:::file
        serviceModel["models/model.joblib"]:::storage
        service -->|loads model| serviceModel
        service -->|validates input| schema
        click service "https://github.com/aditya-barik/wine-quality-prediction/blob/main/wine_quality_prediction_service/wine_quality_prediction.py"
        click schema "https://github.com/aditya-barik/wine-quality-prediction/blob/main/wine_quality_prediction_service/schema/min_max_schema.json"
        click serviceModel "https://github.com/aditya-barik/wine-quality-prediction/blob/main/wine_quality_prediction_service/models/model.joblib"
    end

    %% Frontend Web Application
    subgraph "Frontend Web Application"
        app["app.py"]:::service
        templates["templates/*.html"]:::file
        css["main.css"]:::file
        js["index.js"]:::file
        app --> js
        js -->|calls Prediction API| service
        click app "https://github.com/aditya-barik/wine-quality-prediction/blob/main/app.py"
        click templates "https://github.com/aditya-barik/wine-quality-prediction/tree/main/wine_quality_prediction_app/templates/"
        click css "https://github.com/aditya-barik/wine-quality-prediction/blob/main/wine_quality_prediction_app/static/css/main.css"
        click js "https://github.com/aditya-barik/wine-quality-prediction/blob/main/wine_quality_prediction_app/static/scripts/index.js"
    end

    %% Tests & Validation
    subgraph "Tests & Validation"
        tests["tests/"]:::test
        testsConfig["test_config.py"]:::file
        tox["tox.ini"]:::file
        tests --> testsConfig
        tests --> tox
        click tests "https://github.com/aditya-barik/wine-quality-prediction/tree/main/tests/"
        click testsConfig "https://github.com/aditya-barik/wine-quality-prediction/blob/main/tests/test_config.py"
        click tox "https://github.com/aditya-barik/wine-quality-prediction/blob/main/tox.ini"
    end

    %% Relationships
    heroku -->|hosts| app
    heroku -->|hosts| service

    %% Styles
    classDef storage fill:#FFCC00,stroke:#333,stroke-width:1px;
    classDef compute fill:#CCFFCC,stroke:#333,stroke-width:1px;
    classDef service fill:#CCE5FF,stroke:#333,stroke-width:1px;
    classDef file fill:#F2F2F2,stroke:#333,stroke-width:1px;
    classDef cloud fill:#E0E0E0,stroke:#333,stroke-width:1px;
    classDef ui fill:#FFCCCC,stroke:#333,stroke-width:1px;
    classDef test fill:#FFE5CC,stroke:#333,stroke-width:1px;
```
