# mohammad-oghli/ml-ops-docker architecture

> Architecture diagram of the GitHub repository mohammad-oghli/ml-ops-docker, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mohammad-oghli/ml-ops-docker
- Repository: https://github.com/mohammad-oghli/ml-ops-docker

## Overview

##### Project type and purpose
- This is a small‐scale MLOps / containerized ML inference service (“Image Classifier Case Study”).
- Its goal is to wrap a pre‐trained computer‐vision model (OpenVINO IR files: .bin/.xml) in a Docker container and expose an HTTP inference endpoint via a Python server.

##### File structure
- Top level:
- docker-compose.yml – orchestrates service(s)
- animal_classify_img (presumably sample inputs)
- image-classifier/ – the inference service code + model artifacts
- img-classify-test.ipynb – optional notebook for local testing
- image-classifier/:
- Dockerfile – build instructions
- requirements.txt – Python dependencies
- config.py – runtime parameters (ports, model path)
- server.py – Flask/FastAPI HTTP server that loads the model and serves requests
- model/ – holds the compiled model IR (.bin/.xml)
- utils/ – helper code (e.g., class label mapping)

##### README
- Confirms this is an “ML Models Containerization using Docker” case study.
- No additional architectural details beyond Dockerized inference.

##### Main components
a. Client (e.g., curl, Postman, web frontend, or notebook)
b. Docker host / Docker Compose
c. image-classifier container
- Python runtime environment
- server.py (inference API layer)
- config.py (env configuration)
- utils (label mapping, pre/post processing)
- model loader (OpenVINO Inference Engine)
- model IR files (.xml + .bin)
d. (Optional) Notebook or test harness

##### Relationships and interactions
- Client → HTTP request → Docker host/Port mapping → container’s server.py
- server.py loads config → instantiates OpenVINO inference engine → reads model IR
- Incoming image → pre-processing (utils) → model inference → post-processing → HTTP response
- Docker Compose can spin up multiple replicas or link to other services (e.g., logging, monitoring) if extended

##### Architectural patterns / design principles
- Microservice style: a single container runs a single responsibility (inference).
- Twelve‐factor app elements: configuration via config.py/env vars, dependencies via requirements.txt, stateless inference.
- Decoupling: model artifacts are read from a mounted directory or baked into the image.

##### Relevant technologies
- Docker, Docker Compose
- Python (Flask or FastAPI in server.py)
- OpenVINO Inference Engine (model IR)
- Standard Python libs & custom utils
- (Optional) Jupyter Notebook for testing

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Clients
    Notebook["Jupyter Notebook"]:::client
    Images["Sample Input Images"]:::client
    HTTP["HTTP Client"]:::client

    %% Docker Host and Compose
    subgraph "Docker Host"
        DC["docker-compose.yml"]:::service
        subgraph "Inference Service Container"
            Dk["Dockerfile"]:::service
            Req["requirements.txt"]:::service
            Config["config.py"]:::service
            Server["server.py"]:::service
            ModelLogic["model.py"]:::service
            Utils["imagenet_2012.txt"]:::data
            subgraph "Model Artifacts"
                XML["v3-small_224_1.0_float.xml"]:::data
                BIN["v3-small_224_1.0_float.bin"]:::data
            end
            INFER["OpenVINO Engine"]:::data
        end
    end

    %% Connections
    Notebook -->|"invoke inference endpoint"| Server
    Images -->|"POST image"| Server
    HTTP -->|"HTTP request"| Server
    DC -->|"orchestrates container"| Server
    Server -->|"load config"| Config
    Server -->|"install deps"| Req
    Server -->|"load model logic"| ModelLogic
    Server -->|"use utils for pre/post-processing"| Utils
    Server -->|"initialize"| INFER
    INFER -->|"reads model files"| XML
    INFER -->|"reads model files"| BIN
    INFER -->|"return inference result"| Server
    Server -->|"HTTP response"| HTTP

    %% Click Events
    click Notebook "https://github.com/mohammad-oghli/ml-ops-docker/blob/main/img-classify-test.ipynb"
    click Images "https://github.com/mohammad-oghli/ml-ops-docker/tree/main/animal_classify_img/"
    click DC "https://github.com/mohammad-oghli/ml-ops-docker/blob/main/docker-compose.yml"
    click Dk "https://github.com/mohammad-oghli/ml-ops-docker/tree/main/image-classifier/Dockerfile"
    click Req "https://github.com/mohammad-oghli/ml-ops-docker/blob/main/image-classifier/requirements.txt"
    click Config "https://github.com/mohammad-oghli/ml-ops-docker/blob/main/image-classifier/config.py"
    click Server "https://github.com/mohammad-oghli/ml-ops-docker/blob/main/image-classifier/server.py"
    click ModelLogic "https://github.com/mohammad-oghli/ml-ops-docker/blob/main/image-classifier/model.py"
    click XML "https://github.com/mohammad-oghli/ml-ops-docker/blob/main/image-classifier/model/v3-small_224_1.0_float.xml"
    click BIN "https://github.com/mohammad-oghli/ml-ops-docker/blob/main/image-classifier/model/v3-small_224_1.0_float.bin"
    click Utils "https://github.com/mohammad-oghli/ml-ops-docker/blob/main/image-classifier/utils/imagenet_2012.txt"

    %% Styles
    classDef client fill:#ADD8E6,stroke:#000
    classDef service fill:#90EE90,stroke:#000
    classDef data fill:#FFFF99,stroke:#000
```
