# azeghaanicet/mlops-project architecture

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

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

## Overview

##### Project Type and Purpose
- This is a full-stack MLOps application for real-time Iris flower classification. It combines:
- A modern web frontend (Jinja2 + Tailwind CSS)
- A REST API layer (FastAPI + Pydantic validation)
- An automated ML training pipeline (Scikit-Learn, DVC for data/model versioning)
- Containerized deployment (Docker, docker-compose)
- CI/CD hooks (GitHub Actions) and tests (pytest)

##### File-Structure Analysis
- Top level:
- app.py, schemas.py → entrypoint for FastAPI + request/response models
- src/train.py → training script
- templates/ → HTML pages (base, index, result, error)
- data/ & models/ → DVC-tracked dataset and serialized model
- metrics.json → stored evaluation metric
- Dockerfile + docker-compose.yml + Makefile + run.ps1 → dev & deployment orchestration
- tests/ → API and model unit tests
- .github/workflows/ci-pipeline.yml → CI pipeline config
- Patterns:
- Layered web app (presentation → API → service/ML → data/versioning)
- MLOps pipeline: data ingestion, training, evaluation, versioning

##### README Insights
- Lists key endpoints, stack technologies, CI/CD pointers, development vs. production steps

a. Main Components
- User Interface: Jinja2 templates + Tailwind CSS
- API Layer: FastAPI app.py → routes /, /predict, /api/predict, /health, /metrics
- Validation: Pydantic schemas in schemas.py
- ML Model: serialized iris.joblib (LogisticRegression)
- Training Pipeline: src/train.py → data split, model train → metrics.json → DVC
- Data Management: data/iris.csv + DVC for version control of data & model
- Deployment: Docker image & container orchestration via docker-compose
- Support: CI/CD workflow (GitHub Actions), tests (pytest)

b. Relationships & Interactions
- Browser → HTTP GET “/” → UI template rendered
- Browser submits form → HTTP POST “/predict” → FastAPI
- FastAPI → Pydantic → loads model → returns JSON/HTML result
- CLI / CI triggers src/train.py → reads data/iris.csv → trains model → writes metrics.json & iris.joblib → calls DVC to push artifacts
- Dockerfile builds container packaging app, templates, model, dependencies
- docker-compose orchestrates service startup (app, optional sidecars)

c. Architectural Patterns
- Layered architecture: Presentation → Application (API) → Domain (ML service) → Data (DVC storage)
- MLOps pipeline: reproducible training, versioning, model lifecycle
- 12-factor deployment: configuration via environment, containerized, stateless API

d. Key Technologies
- Frontend: Jinja2, TailwindCSS
- API: FastAPI, Uvicorn
- Validation: Pydantic
- ML: Scikit-Learn LogisticRegression
- Data Versioning: DVC
- Containerization: Docker, docker-compose
- Testing: pytest
- CI: GitHub Actions

## Diagram (Mermaid)

```mermaid
flowchart TD
  subgraph "User/Browser"
    Browser["Browser"]:::user
    UIComp["Jinja2 Templates"]:::user
  end

  subgraph "API Service"
    FastAPIApp["FastAPI App (app.py)"]:::api
    Pydantic["Pydantic Schemas (schemas.py)"]:::api
  end

  subgraph "ML Training Pipeline"
    TrainScript["Training Script (src/train.py)"]:::api
  end

  subgraph "Data Management"
    DataInput["Iris Dataset (data/iris.csv.dvc)"]:::data
    ModelArtifact["Model Artifact (models/iris.pkl.dvc)"]:::data
    MetricsNode["Metrics (metrics.json)"]:::ml
    DVC["DVC"]:::data
  end

  subgraph "Deployment & CI/CD"
    DockerfileNode["Dockerfile"]:::deployment
    Compose["docker-compose.yml"]:::deployment
    Makefile["Makefile"]:::deployment
    RunPs["run.ps1"]:::deployment
    CI["GitHub Actions CI"]:::deployment
    Tests["Automated Tests (tests/)"]:::deployment
  end

  %% Interactions
  Browser --> UIComp
  UIComp --> FastAPIApp
  FastAPIApp --> Pydantic
  Pydantic -->|loads model| ModelArtifact
  FastAPIApp -->|returns prediction| UIComp

  TrainScript --> DataInput
  TrainScript -->|trains model| ModelArtifact
  TrainScript -->|outputs metrics| MetricsNode
  DataInput --> DVC
  ModelArtifact --> DVC
  MetricsNode --> DVC

  Makefile --> DockerfileNode
  RunPs --> DockerfileNode
  CI --> DockerfileNode
  CI --> Tests

  DockerfileNode --> FastAPIApp
  Compose --> DockerfileNode
  Compose --> FastAPIApp

  %% Click Events
  click UIComp "https://github.com/azeghaanicet/mlops-project/tree/master/templates/"
  click FastAPIApp "https://github.com/azeghaanicet/mlops-project/blob/master/app.py"
  click Pydantic "https://github.com/azeghaanicet/mlops-project/blob/master/schemas.py"
  click TrainScript "https://github.com/azeghaanicet/mlops-project/blob/master/src/train.py"
  click DataInput "https://github.com/azeghaanicet/mlops-project/blob/master/data/iris.csv.dvc"
  click ModelArtifact "https://github.com/azeghaanicet/mlops-project/blob/master/models/iris.pkl.dvc"
  click MetricsNode "https://github.com/azeghaanicet/mlops-project/blob/master/metrics.json"
  click DockerfileNode "https://github.com/azeghaanicet/mlops-project/tree/master/Dockerfile"
  click Compose "https://github.com/azeghaanicet/mlops-project/blob/master/docker-compose.yml"
  click Makefile "https://github.com/azeghaanicet/mlops-project/tree/master/Makefile"
  click RunPs "https://github.com/azeghaanicet/mlops-project/blob/master/run.ps1"
  click CI "https://github.com/azeghaanicet/mlops-project/blob/master/.github/workflows/ci-pipeline.yml"
  click Tests "https://github.com/azeghaanicet/mlops-project/tree/master/tests/"

  %% Styles
  classDef user fill:#ADD8E6,stroke:#000;
  classDef api fill:#98FB98,stroke:#000;
  classDef ml fill:#FFA500,stroke:#000;
  classDef data fill:#D3D3D3,stroke:#000;
  classDef deployment fill:#D8BFD8,stroke:#000;
```
