# sameulah/mlops architecture

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

- Interactive diagram: https://gitdiagram.com/sameulah/mlops
- Repository: https://github.com/sameulah/mlops

## Overview

##### Project type and purpose
- This is an MLOps pipeline project (“MLOps Zoomcamp Certificate”) split into two main parts:
a. experiment-tracking: holds data, preprocessing, training code, MLflow setup, notebooks
b. orchestration: holds Airflow DAGs, Docker setup, MinIO/MLflow backend, scripts to wire up the pipeline
- Its goal is to demonstrate end-to-end machine-learning workflow: ingest raw data, preprocess, train, track experiments, register models, orchestrate with Airflow.

##### File structure
- Top-level directories:
- experiment-tracking/
– data/raw & data/processed (green_tripdata parquet → dv.pkl, train/test/val splits)
– utils/: Python modules (preprocess_data.py, train.py, hpo.py, register_model.py)
– mlflow artifacts & mlruns directory (model.pkl, MLmodel, conda/env yml, HTML reports)
– notebooks (.ipynb) showing interactive workflow
- orchestration/
– dags/: Airflow DAG definitions (ingest, preprocessing, training, full_pipeline)
– include/: shared Python code for DAG tasks (ingest.py, preprocessing.py, training.py, utils.py)
– Dockerfile, docker-compose.override.yml, packages.txt, install scripts
– mlflow backend DB and MinIO logs to emulate remote artifact storage
– slpr/: a Python virtual environment used in containers
- Patterns:
- Modular ETL/ML pipeline: ingest→preprocess→train→register
- Experiment tracking via MLflow (file store + sqlite backend)
- Orchestration via Apache Airflow running tasks in containers

##### README for additional insights
- Confirms three modules: Intro, experiment tracking & model management, orchestration & pipelines

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Container boundary
    subgraph "Containerized Environment"
        direction TB
        ContainerBoundary[/"Docker Container"\]:::boundary
        %% Orchestration Layer
        subgraph "Orchestration Layer"
            direction TB
            Airflow["Airflow Scheduler & Workers"]:::orchestration
            click Airflow "https://github.com/sameulah/mlops/tree/main/orchestration/dags/"
            Airflow -->|triggers| IngestDAG
            Airflow -->|triggers| PreDAG
            Airflow -->|triggers| TrainDAG
            Airflow -->|triggers| FullDAG

            IngestDAG["Ingest DAG"]:::compute
            click IngestDAG "https://github.com/sameulah/mlops/blob/main/orchestration/dags/ingest_dag.py"
            IngestDAG --> IngestOp

            IngestOp["Ingestion Operator\n(ingest.py)"]:::compute
            click IngestOp "https://github.com/sameulah/mlops/blob/main/orchestration/include/ingest.py"

            PreDAG["Preprocessing DAG"]:::compute
            click PreDAG "https://github.com/sameulah/mlops/blob/main/orchestration/dags/preprocessing_dag.py"
            PreDAG --> PreOp

            PreOp["Preprocessing Operator\n(preprocessing.py)"]:::compute
            click PreOp "https://github.com/sameulah/mlops/blob/main/orchestration/include/preprocessing.py"

            TrainDAG["Training DAG"]:::compute
            click TrainDAG "https://github.com/sameulah/mlops/blob/main/orchestration/dags/training_dag.py"
            TrainDAG --> TrainOp

            TrainOp["Training Operator\n(training.py)"]:::compute
            click TrainOp "https://github.com/sameulah/mlops/blob/main/orchestration/include/training.py"

            FullDAG["Full Pipeline DAG"]:::compute
            click FullDAG "https://github.com/sameulah/mlops/blob/main/orchestration/dags/full_pipeline_dag.py"
            FullDAG --> RegisterOp
        end

        %% Experiment Tracking & Storage
        subgraph "Experiment Tracking & Storage"
            direction TB
            MLflowServer["MLflow Tracking Server"]:::service
            click MLflowServer "https://github.com/sameulah/mlops/blob/main/experiment-tracking/utils/mlflow.db"
            MLflowDB["mlflow.db (SQLite)"]:::storage
            click MLflowDB "https://github.com/sameulah/mlops/blob/main/experiment-tracking/utils/mlflow.db"
            ArtifactStore["mlruns\n(Artifact Store)"]:::storage
            click ArtifactStore "https://github.com/sameulah/mlops/tree/main/experiment-tracking/utils/mlruns/"
            AltBackend["mlflow_backend2.db"]:::storage
            click AltBackend "https://github.com/sameulah/mlops/blob/main/orchestration/include/mlflow/mlflow_backend2.db"
            ArtifactsDir["artifacts/"]:::storage
            click ArtifactsDir "https://github.com/sameulah/mlops/tree/main/experiment-tracking/utils/artifacts/"
        end
    end

    %% Data Sources and MinIO
    RawData["Raw Data\n(green_tripdata_2023-01.parquet)"]:::storage
    click RawData "https://github.com/sameulah/mlops/blob/main/experiment-tracking/data/raw/green_tripdata_2023-01.parquet"
    MinIO["MinIO Object Store\n(raw & processed buckets)"]:::storage

    %% Compute Tasks (stand-alone scripts)
    PreprocessScript["Preprocess Script\n(preprocess_data.py)"]:::compute
    click PreprocessScript "https://github.com/sameulah/mlops/blob/main/experiment-tracking/utils/preprocess_data.py"
    TrainScript["Train Script\n(train.py & hpo.py)"]:::compute
    click TrainScript "https://github.com/sameulah/mlops/blob/main/experiment-tracking/utils/train.py"
    click TrainScript "https://github.com/sameulah/mlops/blob/main/experiment-tracking/utils/hpo.py"
    RegisterScript["Register Script\n(register_model.py)"]:::compute
    click RegisterScript "https://github.com/sameulah/mlops/blob/main/experiment-tracking/utils/register_model.py"

    %% Python Env and Docker files
    Dockerfile["Dockerfile"]:::infrastructure
    click Dockerfile "https://github.com/sameulah/mlops/tree/main/orchestration/Dockerfile"
    Compose["docker-compose.override.yml"]:::infrastructure
    click Compose "https://github.com/sameulah/mlops/blob/main/orchestration/docker-compose.override.yml"
    SLPR["slpr/ (venv)"]:::infrastructure
    click SLPR "https://github.com/sameulah/mlops/tree/main/orchestration/slpr/"
    Packages["packages.txt & requirements.txt"]:::infrastructure
    click Packages "https://github.com/sameulah/mlops/blob/main/orchestration/packages.txt"
    click Packages "https://github.com/sameulah/mlops/blob/main/orchestration/requirements.txt"

    %% Data Flow
    RawData -->|PUT raw data| IngestOp -->|stores| MinIO
    MinIO -->|reads raw| PreOp -->|PUT features| MinIO
    PreOp -->|logs artifacts| MLflowServer
    PreOp -->|produces splits| PreprocessScript
    MinIO -->|reads features| TrainOp -->|logs metrics & model| MLflowServer
    TrainOp -->|trains| TrainScript
    TrainOp -->|registers best| RegisterOp -->|registers| MLflowServer
    RegisterOp -->|runs| RegisterScript

    %% Scripts to server relations
    MLflowServer --> MLflowDB
    MLflowServer --> ArtifactStore
    FullDAG --> AltBackend

    %% Docker boundary relations
    ContainerBoundary --> Airflow
    ContainerBoundary --> MLflowServer

    %% Classes
    classDef compute fill:#D0E6FF,stroke:#91B5FF,color:#0B3D91;
    classDef storage fill:#DCF8C6,stroke:#7CC47B,color:#1F543E;
    classDef orchestration fill:#FFE5B4,stroke:#FFC17A,color:#7A4F01;
    classDef service fill:#F0F0F0,stroke:#CCCCCC,color:#333333;
    classDef infrastructure fill:#EFE1FF,stroke:#D1B3FF,color:#4B0082;
    classDef boundary stroke:#333333,stroke-dasharray: 5 5;
```
