# assazzin-01/mena-mlops-project architecture

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

- Interactive diagram: https://gitdiagram.com/assazzin-01/mena-mlops-project
- Repository: https://github.com/assazzin-01/mena-mlops-project
- Video tour (about a minute): https://gitdiagram.com/assazzin-01/mena-mlops-project/video

## Overview

This repository implements an Arabic sentiment MLOps system: it prepares versioned datasets, trains and evaluates AraBERT models, serves predictions, and supports monitoring, human review, and gated retraining. The main feedback loop runs from uncertain predictions through review and candidate training to quality-gated promotion. README statements establish several system-level connections; source excerpts and the SOURCE INDEX establish selected internal calls. Other links, especially deployment wiring, are omitted where the evidence does not show them.

Main entry points: [`src/mena_mlops/serving/app.py`](https://github.com/assazzin-01/mena-mlops-project/blob/main/src/mena_mlops/serving/app.py) (Prediction API), [`src/mena_mlops/training/train.py`](https://github.com/assazzin-01/mena-mlops-project/blob/main/src/mena_mlops/training/train.py) (AraBERT training), [`src/mena_mlops/inference/streaming.py`](https://github.com/assazzin-01/mena-mlops-project/blob/main/src/mena_mlops/inference/streaming.py) (Stream consumer), [`src/mena_mlops/deployment/quality_gate.py`](https://github.com/assazzin-01/mena-mlops-project/blob/main/src/mena_mlops/deployment/quality_gate.py) (Promotion gate)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Data preparation"]
  node_data_sources[("Review sources")]
  node_pipeline["Data pipeline<br/>[data_pipeline.py]"]
  node_training_data["Training data<br/>[data.py]"]
end

subgraph group_model["Training and quality"]
  node_trainer["AraBERT training<br/>[train.py]"]
  node_evaluation["Model evaluation<br/>[evaluation.py]"]
  node_quality["Training quality<br/>[quality.py]"]
  node_promotion["Promotion gate<br/>[quality_gate.py]"]
end

subgraph group_runtime["Serving and inference"]
  node_canary["Canary rollout<br/>[canary.py]"]
  node_gateway["Prediction API<br/>[app.py]"]
  node_bento["Bento service<br/>[bento_service.py]"]
  node_batch["Batch inference<br/>[batch.py]"]
  node_stream["Stream consumer<br/>[streaming.py]"]
  node_redis["Redis Streams"]
end

subgraph group_ops["Monitoring and optimization"]
  node_drift["Drift reports<br/>[drift.py]"]
  node_psi["PSI calculation<br/>[psi.py]"]
  node_optimization["Model optimization<br/>[optimization.py]"]
  node_load_test["Load testing<br/>[load_testing.py]"]
  node_monitoring_stack["Prometheus and Grafana"]
end

subgraph group_feedback["Feedback and retraining"]
  node_feedback_store[("Feedback store<br/>[feedback.py]")]
  node_reviewer(("Human reviewer"))
  node_retraining["Candidate retraining<br/>[train.py]"]
end

node_data_sources -->|"downloads and processes"| node_pipeline
node_pipeline -->|"produces splits"| node_training_data
node_training_data -->|"loads splits"| node_trainer
node_trainer -->|"evaluates predictions"| node_evaluation
node_trainer -->|"checks metrics"| node_quality
node_quality -->|"candidate eligibility"| node_promotion
node_promotion -.->|"promotes candidate"| node_canary
node_canary -->|"routes traffic"| node_gateway
node_gateway -->|"serves predictions for"| node_batch
node_redis -->|"provides events"| node_stream
node_stream -->|"publishes predictions"| node_redis
node_stream -->|"persists uncertain predictions"| node_feedback_store
node_reviewer -->|"reviews labels"| node_feedback_store
node_feedback_store -->|"exports reviewed data"| node_retraining
node_retraining -->|"gates candidate"| node_promotion
node_drift -->|"calculates PSI"| node_psi
node_drift -->|"exports PSI metrics"| node_monitoring_stack
node_gateway -->|"exposes metrics"| node_monitoring_stack
node_optimization -->|"provides ONNX inference"| node_gateway
node_load_test -->|"tests service load"| node_gateway
node_bento -->|"reuses predictor"| node_gateway

click node_pipeline "https://github.com/assazzin-01/mena-mlops-project/blob/main/src/mena_mlops/data_pipeline.py"
click node_training_data "https://github.com/assazzin-01/mena-mlops-project/blob/main/src/mena_mlops/training/data.py"
click node_trainer "https://github.com/assazzin-01/mena-mlops-project/blob/main/src/mena_mlops/training/train.py"
click node_evaluation "https://github.com/assazzin-01/mena-mlops-project/blob/main/src/mena_mlops/training/evaluation.py"
click node_quality "https://github.com/assazzin-01/mena-mlops-project/blob/main/src/mena_mlops/quality.py"
click node_promotion "https://github.com/assazzin-01/mena-mlops-project/blob/main/src/mena_mlops/deployment/quality_gate.py"
click node_canary "https://github.com/assazzin-01/mena-mlops-project/blob/main/src/mena_mlops/deployment/canary.py"
click node_gateway "https://github.com/assazzin-01/mena-mlops-project/blob/main/src/mena_mlops/serving/app.py"
click node_bento "https://github.com/assazzin-01/mena-mlops-project/blob/main/src/mena_mlops/serving/bento_service.py"
click node_batch "https://github.com/assazzin-01/mena-mlops-project/blob/main/src/mena_mlops/inference/batch.py"
click node_stream "https://github.com/assazzin-01/mena-mlops-project/blob/main/src/mena_mlops/inference/streaming.py"
click node_feedback_store "https://github.com/assazzin-01/mena-mlops-project/blob/main/src/mena_mlops/feedback.py"
click node_retraining "https://github.com/assazzin-01/mena-mlops-project/blob/main/src/mena_mlops/training/train.py"
click node_drift "https://github.com/assazzin-01/mena-mlops-project/blob/main/src/mena_mlops/monitoring/drift.py"
click node_psi "https://github.com/assazzin-01/mena-mlops-project/blob/main/src/mena_mlops/monitoring/psi.py"
click node_optimization "https://github.com/assazzin-01/mena-mlops-project/blob/main/src/mena_mlops/optimization.py"
click node_load_test "https://github.com/assazzin-01/mena-mlops-project/blob/main/src/mena_mlops/load_testing.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_data_sources,node_pipeline,node_training_data toneBlue
class node_trainer,node_evaluation,node_quality,node_promotion toneAmber
class node_canary,node_gateway,node_bento,node_batch,node_stream,node_redis toneMint
class node_drift,node_psi,node_optimization,node_load_test,node_monitoring_stack toneRose
class node_feedback_store,node_reviewer,node_retraining toneIndigo
```

## Components

### Data preparation

- **Review sources**
- [Data pipeline](https://github.com/assazzin-01/mena-mlops-project/blob/main/src/mena_mlops/data_pipeline.py): `src/mena_mlops/data_pipeline.py`
- [Training data](https://github.com/assazzin-01/mena-mlops-project/blob/main/src/mena_mlops/training/data.py): `src/mena_mlops/training/data.py`

### Training and quality

- [AraBERT training](https://github.com/assazzin-01/mena-mlops-project/blob/main/src/mena_mlops/training/train.py): `src/mena_mlops/training/train.py`
- [Model evaluation](https://github.com/assazzin-01/mena-mlops-project/blob/main/src/mena_mlops/training/evaluation.py): `src/mena_mlops/training/evaluation.py`
- [Training quality](https://github.com/assazzin-01/mena-mlops-project/blob/main/src/mena_mlops/quality.py): `src/mena_mlops/quality.py`
- [Promotion gate](https://github.com/assazzin-01/mena-mlops-project/blob/main/src/mena_mlops/deployment/quality_gate.py): `src/mena_mlops/deployment/quality_gate.py`

### Serving and inference

- [Canary rollout](https://github.com/assazzin-01/mena-mlops-project/blob/main/src/mena_mlops/deployment/canary.py): `src/mena_mlops/deployment/canary.py`
- [Prediction API](https://github.com/assazzin-01/mena-mlops-project/blob/main/src/mena_mlops/serving/app.py): `src/mena_mlops/serving/app.py`
- [Bento service](https://github.com/assazzin-01/mena-mlops-project/blob/main/src/mena_mlops/serving/bento_service.py): `src/mena_mlops/serving/bento_service.py`
- [Batch inference](https://github.com/assazzin-01/mena-mlops-project/blob/main/src/mena_mlops/inference/batch.py): `src/mena_mlops/inference/batch.py`
- [Stream consumer](https://github.com/assazzin-01/mena-mlops-project/blob/main/src/mena_mlops/inference/streaming.py): `src/mena_mlops/inference/streaming.py`
- **Redis Streams**

### Monitoring and optimization

- [Drift reports](https://github.com/assazzin-01/mena-mlops-project/blob/main/src/mena_mlops/monitoring/drift.py): `src/mena_mlops/monitoring/drift.py`
- [PSI calculation](https://github.com/assazzin-01/mena-mlops-project/blob/main/src/mena_mlops/monitoring/psi.py): `src/mena_mlops/monitoring/psi.py`
- [Model optimization](https://github.com/assazzin-01/mena-mlops-project/blob/main/src/mena_mlops/optimization.py): `src/mena_mlops/optimization.py`
- [Load testing](https://github.com/assazzin-01/mena-mlops-project/blob/main/src/mena_mlops/load_testing.py): `src/mena_mlops/load_testing.py`
- **Prometheus and Grafana**

### Feedback and retraining

- [Feedback store](https://github.com/assazzin-01/mena-mlops-project/blob/main/src/mena_mlops/feedback.py): `src/mena_mlops/feedback.py`
- **Human reviewer**
- [Candidate retraining](https://github.com/assazzin-01/mena-mlops-project/blob/main/src/mena_mlops/training/train.py): `src/mena_mlops/training/train.py`

## Connections

- Review sources → Data pipeline: downloads and processes (evidence: `README.md`)
- Data pipeline → Training data: produces splits (evidence: `README.md`)
- Training data → AraBERT training: loads splits (evidence: `src/mena_mlops/training/train.py`)
- AraBERT training → Model evaluation: evaluates predictions (evidence: `src/mena_mlops/training/train.py`)
- AraBERT training → Training quality: checks metrics (evidence: `README.md`)
- Training quality → Promotion gate: candidate eligibility (evidence: `README.md`)
- Promotion gate → Canary rollout: promotes candidate
- Canary rollout → Prediction API: routes traffic (evidence: `README.md`)
- Prediction API → Batch inference: serves predictions for (evidence: `scripts/run_batch_inference.py`)
- Redis Streams → Stream consumer: provides events (evidence: `README.md`)
- Stream consumer → Redis Streams: publishes predictions (evidence: `README.md`)
- Stream consumer → Feedback store: persists uncertain predictions (evidence: `src/mena_mlops/inference/streaming.py`)
- Human reviewer → Feedback store: reviews labels (evidence: `README.md`)
- Feedback store → Candidate retraining: exports reviewed data (evidence: `README.md`)
- Candidate retraining → Promotion gate: gates candidate (evidence: `README.md`)
- Drift reports → PSI calculation: calculates PSI (evidence: `src/mena_mlops/monitoring/drift.py`)
- Drift reports → Prometheus and Grafana: exports PSI metrics (evidence: `README.md`)
- Prediction API → Prometheus and Grafana: exposes metrics (evidence: `README.md`)
- Model optimization → Prediction API: provides ONNX inference (evidence: `src/mena_mlops/serving/app.py`)
- Load testing → Prediction API: tests service load (evidence: `README.md`)
- Bento service → Prediction API: reuses predictor (evidence: `src/mena_mlops/serving/bento_service.py`)
