# mlops-devops-04-26/aiops-realworld-labs architecture

> Architecture diagram of the GitHub repository mlops-devops-04-26/aiops-realworld-labs, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-06-23). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mlops-devops-04-26/aiops-realworld-labs
- Repository: https://github.com/mlops-devops-04-26/aiops-realworld-labs

## Overview

1. **Repository purpose**
   - This repo is a small AIOps lab focused on **collecting infrastructure/application metrics, training an anomaly-detection model, and running detection against live metrics**.
   - The architecture is centered around a simple offline/online pipeline rather than a large application service.

2. **Top-level structure**
   - `DAY-01/aiops-lab/` contains the actual project.
   - The main subsystems are:
     - **Metric source/configuration** in `config/`
     - **Operational orchestration** in `docker-compose.yml`
     - **Python data/ML pipeline** in `scripts/`

3. **Monitoring/metrics boundary**
   - `config/prometheus.yml` indicates **Prometheus is used as the metrics collection layer**.
   - This is the boundary where raw runtime/service metrics are scraped and made available to the Python pipeline.
   - Prometheus is the canonical data source for downstream anomaly detection.

4. **Pipeline entry points**
   - `scripts/fetch_metrics.py` is the ingestion step: it likely queries Prometheus and pulls metric samples into a local processing flow.
   - `scripts/train_model.py` is the model-building step: it consumes historical metrics and produces a trained anomaly model or model parameters.
   - `scripts/detect_anomalies.py` is the inference step: it applies the trained model to current or recent metrics and flags anomalies.

5. **Data flow**
   - The high-level flow is:
     1. Metrics are scraped into Prometheus.
     2. `fetch_metrics.py` retrieves metric data from Prometheus.
     3. `train_model.py` uses historical data to fit a model.
     4. `detect_anomalies.py` scores incoming/recent metrics against that model.
   - This creates a clear split between **data acquisition**, **training**, and **real-time detection**.

6. **Runtime and dependencies**
   - The Python code lives under `scripts/`, and `scripts/requirements.txt` defines the ML/data-processing runtime dependencies.
   - This suggests the repo is designed to be run in a controlled Python environment, likely alongside the metrics stack defined in Docker.

7. **Container/orchestration layer**
   - `docker-compose.yml` is the environment orchestration boundary.
   - It likely brings up the monitoring stack and any supporting services needed to run the lab consistently.
   - This makes the repo suitable for reproducible experiments rather than ad hoc local execution.

8. **Configuration separation**
   - `scripts/config.ini` suggests runtime parameters are externalized from code.
   - This likely holds connection details, thresholds, time windows, or model settings, keeping the scripts environment-agnostic.
   - The repo therefore has a clean split between **code**, **runtime configuration**, and **infrastructure config**.

9. **Responsibility boundaries**
   - **Prometheus/config**: metric collection and exposure
   - **Fetch script**: data retrieval from monitoring backend
   - **Training script**: offline learning from historical observations
   - **Detection script**: inference and anomaly flagging
   - **Compose file**: environment lifecycle and service wiring

10. **Likely architecture style**
    - This is a **batch + near-real-time analytics pipeline** rather than a request/response application.
    - The architecture is centered on metrics telemetry and model-driven detection, with Prometheus as the system-of-record for observability data.

11. **What an architecture diagram should show**
    - A metrics-producing system feeding Prometheus.
    - Prometheus as the central store/query endpoint.
    - Separate Python jobs for:
      - metric extraction
      - model training
      - anomaly detection
    - Shared configuration feeding the Python jobs.
    - Docker Compose as the deployment/orchestration wrapper.

12. **Project scope**
    - The repository appears to be a **single-lab, self-contained demo** for AIOps workflows.
    - There is no sign of a multi-service product backend; instead, the repo emphasizes observability data handling and ML-based operational analysis.

Main entry points: [`DAY-01/aiops-lab/scripts/fetch_metrics.py`](https://github.com/mlops-devops-04-26/aiops-realworld-labs/blob/main/DAY-01/aiops-lab/scripts/fetch_metrics.py) (Fetch Metrics), [`DAY-01/aiops-lab/scripts/train_model.py`](https://github.com/mlops-devops-04-26/aiops-realworld-labs/blob/main/DAY-01/aiops-lab/scripts/train_model.py) (Train Model), [`DAY-01/aiops-lab/scripts/detect_anomalies.py`](https://github.com/mlops-devops-04-26/aiops-realworld-labs/blob/main/DAY-01/aiops-lab/scripts/detect_anomalies.py) (Detect Anomalies), [`DAY-01/aiops-lab/docker-compose.yml`](https://github.com/mlops-devops-04-26/aiops-realworld-labs/blob/main/DAY-01/aiops-lab/docker-compose.yml) (Compose)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_orchestration["Orchestration"]
  node_docker_compose["Compose<br/>orchestrator<br/>[docker-compose.yml]"]
end

subgraph group_monitoring["Monitoring"]
  node_metrics_source(("Metrics Source<br/>runtime source"))
  node_prometheus_config["Prometheus Config<br/>scrape config<br/>[prometheus.yml]"]
  node_prometheus[("Prometheus<br/>metrics backend")]
end

subgraph group_pipeline["Python Pipeline"]
  node_runtime_config["Runtime Config<br/>job settings<br/>[config.ini]"]
  node_python_deps["Python Deps<br/>runtime deps<br/>[requirements.txt]"]
  node_fetch_metrics["Fetch Metrics<br/>ingestion job<br/>[fetch_metrics.py]"]
  node_train_model["Train Model<br/>training job<br/>[train_model.py]"]
  node_detect_anomalies["Detect Anomalies<br/>inference job"]
end

node_metrics_source -->|"scraped by"| node_prometheus_config
node_prometheus_config -->|"feeds"| node_prometheus
node_docker_compose -->|"starts"| node_prometheus
node_docker_compose -->|"runs"| node_fetch_metrics
node_docker_compose -->|"runs"| node_train_model
node_docker_compose -->|"runs"| node_detect_anomalies
node_prometheus -->|"queries"| node_fetch_metrics
node_runtime_config -->|"configures"| node_fetch_metrics
node_runtime_config -->|"configures"| node_train_model
node_runtime_config -->|"configures"| node_detect_anomalies
node_python_deps -->|"supports"| node_fetch_metrics
node_python_deps -->|"supports"| node_train_model
node_python_deps -->|"supports"| node_detect_anomalies
node_fetch_metrics -->|"historical data"| node_train_model
node_fetch_metrics -->|"recent data"| node_detect_anomalies
node_train_model -->|"model"| node_detect_anomalies

click node_docker_compose "https://github.com/mlops-devops-04-26/aiops-realworld-labs/blob/main/DAY-01/aiops-lab/docker-compose.yml"
click node_prometheus_config "https://github.com/mlops-devops-04-26/aiops-realworld-labs/blob/main/DAY-01/aiops-lab/config/prometheus.yml"
click node_runtime_config "https://github.com/mlops-devops-04-26/aiops-realworld-labs/blob/main/DAY-01/aiops-lab/scripts/config.ini"
click node_python_deps "https://github.com/mlops-devops-04-26/aiops-realworld-labs/blob/main/DAY-01/aiops-lab/scripts/requirements.txt"
click node_fetch_metrics "https://github.com/mlops-devops-04-26/aiops-realworld-labs/blob/main/DAY-01/aiops-lab/scripts/fetch_metrics.py"
click node_train_model "https://github.com/mlops-devops-04-26/aiops-realworld-labs/blob/main/DAY-01/aiops-lab/scripts/train_model.py"
click node_detect_anomalies "https://github.com/mlops-devops-04-26/aiops-realworld-labs/blob/main/DAY-01/aiops-lab/scripts/detect_anomalies.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_docker_compose toneBlue
class node_metrics_source,node_prometheus_config,node_prometheus toneAmber
class node_runtime_config,node_python_deps,node_fetch_metrics,node_train_model,node_detect_anomalies toneMint
```

## Components

### Orchestration

Environment wiring and reproducible lab setup

- [Compose](https://github.com/mlops-devops-04-26/aiops-realworld-labs/blob/main/DAY-01/aiops-lab/docker-compose.yml): orchestrator · Container and service lifecycle for the lab · `DAY-01/aiops-lab/docker-compose.yml`

### Monitoring

Metrics collection and query boundary

- **Metrics Source**: runtime source · Infrastructure or application metrics emitted by the lab environment
- [Prometheus Config](https://github.com/mlops-devops-04-26/aiops-realworld-labs/blob/main/DAY-01/aiops-lab/config/prometheus.yml): scrape config · Scrape targets and collection rules for metrics ingestion · `DAY-01/aiops-lab/config/prometheus.yml`
- **Prometheus**: metrics backend · Central scrape and query layer for telemetry

### Python Pipeline

Data acquisition, model training, and anomaly detection

- [Runtime Config](https://github.com/mlops-devops-04-26/aiops-realworld-labs/blob/main/DAY-01/aiops-lab/scripts/config.ini): job settings · Shared parameters for Python jobs such as endpoints, windows, or thresholds · `DAY-01/aiops-lab/scripts/config.ini`
- [Python Deps](https://github.com/mlops-devops-04-26/aiops-realworld-labs/blob/main/DAY-01/aiops-lab/scripts/requirements.txt): runtime deps · Python data and machine-learning environment dependencies · `DAY-01/aiops-lab/scripts/requirements.txt`
- [Fetch Metrics](https://github.com/mlops-devops-04-26/aiops-realworld-labs/blob/main/DAY-01/aiops-lab/scripts/fetch_metrics.py): ingestion job · Pulls metric samples from Prometheus into local processing · `DAY-01/aiops-lab/scripts/fetch_metrics.py`
- [Train Model](https://github.com/mlops-devops-04-26/aiops-realworld-labs/blob/main/DAY-01/aiops-lab/scripts/train_model.py): training job · Fits anomaly-detection logic from historical metrics · `DAY-01/aiops-lab/scripts/train_model.py`
- [Detect Anomalies](https://github.com/mlops-devops-04-26/aiops-realworld-labs/blob/main/DAY-01/aiops-lab/scripts/detect_anomalies.py): inference job · Scores recent metrics and flags anomalies · `DAY-01/aiops-lab/scripts/detect_anomalies.py`

## Connections

- Metrics Source → Prometheus Config: scraped by · Metrics are exposed through the scrape configuration
- Prometheus Config → Prometheus: feeds · Scrape rules define what Prometheus collects
- Compose → Prometheus: starts · Compose brings up the monitoring backend in the lab environment
- Compose → Fetch Metrics: runs · Compose provides the execution environment for the Python jobs
- Compose → Train Model: runs · Compose provides the execution environment for the Python jobs
- Compose → Detect Anomalies: runs · Compose provides the execution environment for the Python jobs
- Prometheus → Fetch Metrics: queries · The ingestion step pulls samples from Prometheus
- Runtime Config → Fetch Metrics: configures · Shared settings drive Prometheus access and extraction windows
- Runtime Config → Train Model: configures · Shared settings drive training inputs and parameters
- Runtime Config → Detect Anomalies: configures · Shared settings drive detection thresholds and inputs
- Python Deps → Fetch Metrics: supports · Runtime dependencies enable data access and processing
- Python Deps → Train Model: supports · Runtime dependencies enable model fitting
- Python Deps → Detect Anomalies: supports · Runtime dependencies enable scoring logic
- Fetch Metrics → Train Model: historical data · Retrieved metrics feed the offline training step
- Fetch Metrics → Detect Anomalies: recent data · Retrieved metrics also support live or near-real-time detection
- Train Model → Detect Anomalies: model · Trained parameters are consumed by the inference step
