How vikashishere/mlops-proj1---wine-quality-prediction works
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 app.py · common.py common.py · logging logging · configuration.py configuration.py
Components 23
Web UI
Flask inference surface and browser assets
- app.py · Web entrypoint for prediction requests and result rendering
app.py - index.html · Input form page for the inference UI
templates/index.html - results.html · Prediction results page
templates/results.html - static assets · CSS, JS, and images used by the Flask app
static
ML Pipeline
Offline training and evaluation workflow
- main.py · Runs the end-to-end training workflow
main.py - ingestion stage · Stage wrapper for bringing raw data into the pipeline
src/mlProject/pipeline/stage_01_data_ingestion.py - validation stage · Stage wrapper for schema and data checks
src/mlProject/pipeline/stage_02_data_validation.py - transform stage · Stage wrapper for feature preparation and splits
src/mlProject/pipeline/stage_03_data_transformation.py - trainer stage · Stage wrapper for model fitting and serialization
src/mlProject/pipeline/stage_04_model_trainer.py - eval stage · Stage wrapper for model scoring and metrics
src/mlProject/pipeline/stage_05_model_evaluation.py - prediction · Shared prediction logic used by the web app
src/mlProject/pipeline/prediction.py
Config
YAML-driven settings and schema
- config.yaml · Workflow paths and pipeline settings
config/config.yaml - params.yaml · Model and training parameters
params.yaml - schema.yaml · Dataset columns and validation rules
schema.yaml
Shared Core
Reusable package infrastructure
- configuration.py · Builds typed configuration objects from YAML
src/mlProject/config/configuration.py - config_entity.py · Typed config and artifact descriptors
src/mlProject/entity/config_entity.py - common.py · Shared helpers for YAML, paths, and artifacts
src/mlProject/utils/common.py - logging · Centralized runtime logging setup
src/mlProject/logging
Artifacts
Filesystem handoff between stages
- artifacts · File-based handoff boundary for pipeline outputs
artifacts - model.joblib · Serialized model consumed by inference and evaluation
artifacts/model_trainer/model.joblib - metrics.json · Model evaluation metrics
artifacts/model_evaluation/metrics.json
Deployment
Container and CI/CD delivery
- cicd.yaml · GitHub Actions workflow for build and deploy
.github/workflows/cicd.yaml - dockerfile · Image build definition for deployment
dockerfile
Connections 34
- 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