# pooria0v/bike-retrain-mlops architecture

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

- Interactive diagram: https://gitdiagram.com/pooria0v/bike-retrain-mlops
- Repository: https://github.com/pooria0v/bike-retrain-mlops

## Overview

Bike Demand Auto-Retraining is an MLOps application: monthly bike-demand data is checked for drift, retrained into a challenger model when needed, evaluated against the champion, and conditionally promoted; a FastAPI service serves the champion and records operational signals. Edges follow the documented Prefect orchestration and sampled call sites. Monitoring server configuration and Grafana capabilities are documented, but their runtime wiring is not shown in source excerpts.

Main entry points: [`src/api/main.py`](https://github.com/pooria0v/bike-retrain-mlops/blob/main/src/api/main.py) (Prediction API), [`src/flows/retrain_flow.py`](https://github.com/pooria0v/bike-retrain-mlops/blob/main/src/flows/retrain_flow.py) (Retrain Flow), [`src/training/train.py`](https://github.com/pooria0v/bike-retrain-mlops/blob/main/src/training/train.py) (Model Training), [`src/training/evaluate.py`](https://github.com/pooria0v/bike-retrain-mlops/blob/main/src/training/evaluate.py) (Challenger Evaluation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Data Preparation"]
  node_monthly_data[("Monthly Data<br/>[data_prep.py]")]
end

subgraph group_retrain["Retraining Pipeline"]
  node_prefect_flow["Retrain Flow<br/>[retrain_flow.py]"]
  node_drift["Drift Detection<br/>[drift_check.py]"]
  node_trainer["Model Training<br/>[train.py]"]
  node_evaluation["Challenger Evaluation<br/>[evaluate.py]"]
  node_promotion["Model Promotion<br/>[promote.py]"]
end

subgraph group_serving["Prediction Service"]
  node_api["Prediction API<br/>[main.py]"]
  node_schemas["Request Schemas<br/>[schemas.py]"]
end

subgraph group_ops["Operational Monitoring"]
  node_prediction_log[("Prediction CSV Log")]
  node_metrics["Prometheus Metrics<br/>[metrics.py]"]
  node_prometheus["Prometheus<br/>[prometheus.yml]"]
  node_grafana["Grafana Dashboards"]
end

node_mlflow[("MLflow Registry")]
node_client(("Prediction Client"))

node_monthly_data -.->|"provides monthly inputs"| node_prefect_flow
node_prefect_flow -->|"checks drift"| node_drift
node_prefect_flow -->|"trains on drift"| node_trainer
node_prefect_flow -->|"evaluates challenger"| node_evaluation
node_prefect_flow -->|"routes decision"| node_promotion
node_trainer -->|"logs model"| node_mlflow
node_evaluation -->|"loads models"| node_mlflow
node_promotion -->|"updates aliases"| node_mlflow
node_api -->|"loads champion"| node_mlflow
node_client -->|"submits features"| node_api
node_api -->|"validates and returns"| node_schemas
node_api -->|"logs prediction"| node_prediction_log
node_api -->|"updates and exposes"| node_metrics
node_prometheus -.->|"scrapes metrics"| node_api
node_grafana -.->|"visualizes metrics"| node_prometheus

click node_monthly_data "https://github.com/pooria0v/bike-retrain-mlops/blob/main/src/data/data_prep.py"
click node_prefect_flow "https://github.com/pooria0v/bike-retrain-mlops/blob/main/src/flows/retrain_flow.py"
click node_drift "https://github.com/pooria0v/bike-retrain-mlops/blob/main/src/monitoring/drift_check.py"
click node_trainer "https://github.com/pooria0v/bike-retrain-mlops/blob/main/src/training/train.py"
click node_evaluation "https://github.com/pooria0v/bike-retrain-mlops/blob/main/src/training/evaluate.py"
click node_promotion "https://github.com/pooria0v/bike-retrain-mlops/blob/main/src/registry/promote.py"
click node_api "https://github.com/pooria0v/bike-retrain-mlops/blob/main/src/api/main.py"
click node_schemas "https://github.com/pooria0v/bike-retrain-mlops/blob/main/src/api/schemas.py"
click node_prediction_log "https://github.com/pooria0v/bike-retrain-mlops/blob/main/src/monitoring/prediction_logger.py"
click node_metrics "https://github.com/pooria0v/bike-retrain-mlops/blob/main/src/monitoring/metrics.py"
click node_prometheus "https://github.com/pooria0v/bike-retrain-mlops/blob/main/monitoring/prometheus.yml"
click node_grafana "https://github.com/pooria0v/bike-retrain-mlops/blob/main/monitoring/grafana/dashboards/bike-demand-dashboard.json"

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_monthly_data,node_client toneBlue
class node_prefect_flow,node_drift,node_trainer,node_evaluation,node_promotion,node_mlflow toneAmber
class node_api,node_schemas toneMint
class node_prediction_log,node_metrics,node_prometheus,node_grafana toneRose
```

## Components

### Data Preparation

- [Monthly Data](https://github.com/pooria0v/bike-retrain-mlops/blob/main/src/data/data_prep.py): `src/data/data_prep.py`

### Retraining Pipeline

- [Retrain Flow](https://github.com/pooria0v/bike-retrain-mlops/blob/main/src/flows/retrain_flow.py): `src/flows/retrain_flow.py`
- [Drift Detection](https://github.com/pooria0v/bike-retrain-mlops/blob/main/src/monitoring/drift_check.py): `src/monitoring/drift_check.py`
- [Model Training](https://github.com/pooria0v/bike-retrain-mlops/blob/main/src/training/train.py): `src/training/train.py`
- [Challenger Evaluation](https://github.com/pooria0v/bike-retrain-mlops/blob/main/src/training/evaluate.py): `src/training/evaluate.py`
- [Model Promotion](https://github.com/pooria0v/bike-retrain-mlops/blob/main/src/registry/promote.py): `src/registry/promote.py`

### Prediction Service

- [Prediction API](https://github.com/pooria0v/bike-retrain-mlops/blob/main/src/api/main.py): `src/api/main.py`
- [Request Schemas](https://github.com/pooria0v/bike-retrain-mlops/blob/main/src/api/schemas.py): `src/api/schemas.py`

### Operational Monitoring

- [Prediction CSV Log](https://github.com/pooria0v/bike-retrain-mlops/blob/main/src/monitoring/prediction_logger.py): `src/monitoring/prediction_logger.py`
- [Prometheus Metrics](https://github.com/pooria0v/bike-retrain-mlops/blob/main/src/monitoring/metrics.py): `src/monitoring/metrics.py`
- [Prometheus](https://github.com/pooria0v/bike-retrain-mlops/blob/main/monitoring/prometheus.yml): `monitoring/prometheus.yml`
- [Grafana Dashboards](https://github.com/pooria0v/bike-retrain-mlops/blob/main/monitoring/grafana/dashboards/bike-demand-dashboard.json): `monitoring/grafana/dashboards/bike-demand-dashboard.json`

### Other components

- **MLflow Registry**
- **Prediction Client**

## Connections

- Monthly Data → Retrain Flow: provides monthly inputs (evidence: `README.md`)
- Retrain Flow → Drift Detection: checks drift (evidence: `src/flows/retrain_flow.py`)
- Retrain Flow → Model Training: trains on drift (evidence: `src/flows/retrain_flow.py`)
- Retrain Flow → Challenger Evaluation: evaluates challenger (evidence: `src/flows/retrain_flow.py`)
- Retrain Flow → Model Promotion: routes decision (evidence: `src/flows/retrain_flow.py`)
- Model Training → MLflow Registry: logs model (evidence: `src/training/train.py`)
- Challenger Evaluation → MLflow Registry: loads models (evidence: `src/training/evaluate.py`)
- Model Promotion → MLflow Registry: updates aliases (evidence: `src/registry/promote.py`)
- Prediction API → MLflow Registry: loads champion (evidence: `src/api/main.py`)
- Prediction Client → Prediction API: submits features (evidence: `README.md`)
- Prediction API → Request Schemas: validates and returns (evidence: `src/api/main.py`)
- Prediction API → Prediction CSV Log: logs prediction (evidence: `src/api/main.py`)
- Prediction API → Prometheus Metrics: updates and exposes (evidence: `src/api/main.py`)
- Prometheus → Prediction API: scrapes metrics (evidence: `README.md`)
- Grafana Dashboards → Prometheus: visualizes metrics (evidence: `README.md`)
