# bilal-ahmed-7/mlops-sentiment-project architecture

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

- Interactive diagram: https://gitdiagram.com/bilal-ahmed-7/mlops-sentiment-project
- Repository: https://github.com/bilal-ahmed-7/mlops-sentiment-project

## Overview

This repository is an IMDB-review sentiment classifier with a model-training and prediction-serving workflow. Raw reviews are ingested and validated, cleaned and split, then used to train and evaluate a TF-IDF/logistic-regression model; eligible models can be registered and promoted. The Flask API loads a model, validates and predicts on requests, and can log privacy-preserving features for drift and performance checks. The README also describes planned Airflow, Kubeflow, Feast, BentoML, and dashboard capabilities; their code is marked as placeholder or planned. Edges reflect shown calls or README statements; unsampled subsystem internals are not inferred.

Main entry points: [`src/models/train.py`](https://github.com/bilal-ahmed-7/mlops-sentiment-project/blob/main/src/models/train.py) (Train and track), [`src/serving/app.py`](https://github.com/bilal-ahmed-7/mlops-sentiment-project/blob/main/src/serving/app.py) (Flask prediction API), [`src/monitoring/monitor.py`](https://github.com/bilal-ahmed-7/mlops-sentiment-project/blob/main/src/monitoring/monitor.py) (Drift and performance checks), [`src/features/preprocessing.py`](https://github.com/bilal-ahmed-7/mlops-sentiment-project/blob/main/src/features/preprocessing.py) (Clean and split)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Data preparation"]
  node_ingestion["Load and validate<br/>[ingestion.py]"]
  node_validation["Schema checks<br/>[validation.py]"]
  node_preprocessing["Clean and split<br/>[preprocessing.py]"]
  node_processed[("Train/val/test splits")]
end

subgraph group_model["Model lifecycle"]
  node_training["Train and track<br/>[train.py]"]
  node_evaluation["Model evaluation<br/>[evaluate.py]"]
  node_tuning["Hyperparameter tuning<br/>[tune.py]"]
  node_registry["Gated registry<br/>[register.py]"]
  node_modelartifact[("Saved model")]
end

subgraph group_serving["Prediction serving"]
  node_api["Flask prediction API<br/>[app.py]"]
  node_cleaning["Shared text cleaning<br/>[text_cleaning.py]"]
  node_loader["Model loader<br/>[model_loader.py]"]
end

subgraph group_observability["Monitoring"]
  node_features["Numeric text features<br/>[text_features.py]"]
  node_predictionlog[("Prediction log<br/>[prediction_log.py]")]
  node_monitor["Drift and performance checks<br/>[monitor.py]"]
end

subgraph group_planned["Planned extensions"]
  node_orchestration["Airflow orchestration"]
  node_kubeflow["Kubeflow pipeline"]
  node_featurestore[("Feast feature store")]
  node_bento["BentoML service<br/>[bentoml_service.py]"]
  node_dashboards["Grafana dashboards"]
end

node_dataset[("IMDB review data")]
node_mlflow[("MLflow tracking/registry")]
node_prometheus[("Prometheus metrics")]
node_pushgateway["Prometheus Pushgateway"]

node_dataset -->|"loads"| node_ingestion
node_ingestion -->|"validates"| node_validation
node_preprocessing -->|"ingests"| node_ingestion
node_preprocessing -->|"cleans"| node_cleaning
node_preprocessing -->|"writes splits"| node_processed
node_training -->|"reads splits"| node_processed
node_training -->|"computes metrics"| node_evaluation
node_training -->|"tracks run"| node_mlflow
node_training -->|"saves model"| node_modelartifact
node_tuning -->|"runs experiments"| node_training
node_registry -->|"uses tracking setup"| node_training
node_registry -->|"registers and promotes"| node_mlflow
node_api -->|"loads bundle"| node_loader
node_api -->|"validates and cleans"| node_cleaning
node_api -->|"extracts features"| node_features
node_api -->|"writes records"| node_predictionlog
node_loader -->|"loads champion"| node_mlflow
node_loader -->|"loads fallback"| node_modelartifact
node_monitor -->|"reads predictions"| node_predictionlog
node_monitor -->|"samples reference data"| node_processed
node_monitor -->|"extracts reference features"| node_features
node_api -->|"exposes metrics"| node_prometheus
node_monitor -->|"pushes drift metrics"| node_pushgateway

click node_dataset "https://github.com/bilal-ahmed-7/mlops-sentiment-project/tree/main/data/raw"
click node_ingestion "https://github.com/bilal-ahmed-7/mlops-sentiment-project/blob/main/src/data/ingestion.py"
click node_validation "https://github.com/bilal-ahmed-7/mlops-sentiment-project/blob/main/src/data/validation.py"
click node_preprocessing "https://github.com/bilal-ahmed-7/mlops-sentiment-project/blob/main/src/features/preprocessing.py"
click node_processed "https://github.com/bilal-ahmed-7/mlops-sentiment-project/tree/main/data/processed"
click node_training "https://github.com/bilal-ahmed-7/mlops-sentiment-project/blob/main/src/models/train.py"
click node_evaluation "https://github.com/bilal-ahmed-7/mlops-sentiment-project/blob/main/src/models/evaluate.py"
click node_tuning "https://github.com/bilal-ahmed-7/mlops-sentiment-project/blob/main/src/models/tune.py"
click node_registry "https://github.com/bilal-ahmed-7/mlops-sentiment-project/blob/main/src/models/register.py"
click node_modelartifact "https://github.com/bilal-ahmed-7/mlops-sentiment-project/tree/main/artifacts"
click node_api "https://github.com/bilal-ahmed-7/mlops-sentiment-project/blob/main/src/serving/app.py"
click node_cleaning "https://github.com/bilal-ahmed-7/mlops-sentiment-project/blob/main/src/features/text_cleaning.py"
click node_features "https://github.com/bilal-ahmed-7/mlops-sentiment-project/blob/main/src/features/text_features.py"
click node_loader "https://github.com/bilal-ahmed-7/mlops-sentiment-project/blob/main/src/serving/model_loader.py"
click node_predictionlog "https://github.com/bilal-ahmed-7/mlops-sentiment-project/blob/main/src/monitoring/prediction_log.py"
click node_monitor "https://github.com/bilal-ahmed-7/mlops-sentiment-project/blob/main/src/monitoring/monitor.py"
click node_orchestration "https://github.com/bilal-ahmed-7/mlops-sentiment-project/tree/main/pipelines/airflow"
click node_kubeflow "https://github.com/bilal-ahmed-7/mlops-sentiment-project/tree/main/pipelines/kubeflow"
click node_featurestore "https://github.com/bilal-ahmed-7/mlops-sentiment-project/tree/main/feature_store"
click node_bento "https://github.com/bilal-ahmed-7/mlops-sentiment-project/blob/main/src/serving/bentoml_service.py"
click node_dashboards "https://github.com/bilal-ahmed-7/mlops-sentiment-project/tree/main/monitoring/grafana"

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_ingestion,node_validation,node_preprocessing,node_processed toneBlue
class node_training,node_evaluation,node_tuning,node_registry,node_modelartifact,node_dataset,node_mlflow,node_prometheus toneAmber
class node_api,node_cleaning,node_loader toneMint
class node_features,node_predictionlog,node_monitor toneRose
class node_orchestration,node_kubeflow,node_featurestore,node_bento,node_dashboards,node_pushgateway toneIndigo
```

## Components

### Data preparation

- [Load and validate](https://github.com/bilal-ahmed-7/mlops-sentiment-project/blob/main/src/data/ingestion.py): `src/data/ingestion.py`
- [Schema checks](https://github.com/bilal-ahmed-7/mlops-sentiment-project/blob/main/src/data/validation.py): `src/data/validation.py`
- [Clean and split](https://github.com/bilal-ahmed-7/mlops-sentiment-project/blob/main/src/features/preprocessing.py): `src/features/preprocessing.py`
- [Train/val/test splits](https://github.com/bilal-ahmed-7/mlops-sentiment-project/tree/main/data/processed): `data/processed`

### Model lifecycle

- [Train and track](https://github.com/bilal-ahmed-7/mlops-sentiment-project/blob/main/src/models/train.py): `src/models/train.py`
- [Model evaluation](https://github.com/bilal-ahmed-7/mlops-sentiment-project/blob/main/src/models/evaluate.py): `src/models/evaluate.py`
- [Hyperparameter tuning](https://github.com/bilal-ahmed-7/mlops-sentiment-project/blob/main/src/models/tune.py): `src/models/tune.py`
- [Gated registry](https://github.com/bilal-ahmed-7/mlops-sentiment-project/blob/main/src/models/register.py): `src/models/register.py`
- [Saved model](https://github.com/bilal-ahmed-7/mlops-sentiment-project/tree/main/artifacts): `artifacts`

### Prediction serving

- [Flask prediction API](https://github.com/bilal-ahmed-7/mlops-sentiment-project/blob/main/src/serving/app.py): `src/serving/app.py`
- [Shared text cleaning](https://github.com/bilal-ahmed-7/mlops-sentiment-project/blob/main/src/features/text_cleaning.py): `src/features/text_cleaning.py`
- [Model loader](https://github.com/bilal-ahmed-7/mlops-sentiment-project/blob/main/src/serving/model_loader.py): `src/serving/model_loader.py`

### Monitoring

- [Numeric text features](https://github.com/bilal-ahmed-7/mlops-sentiment-project/blob/main/src/features/text_features.py): `src/features/text_features.py`
- [Prediction log](https://github.com/bilal-ahmed-7/mlops-sentiment-project/blob/main/src/monitoring/prediction_log.py): `src/monitoring/prediction_log.py`
- [Drift and performance checks](https://github.com/bilal-ahmed-7/mlops-sentiment-project/blob/main/src/monitoring/monitor.py): `src/monitoring/monitor.py`

### Planned extensions

- [Airflow orchestration](https://github.com/bilal-ahmed-7/mlops-sentiment-project/tree/main/pipelines/airflow): `pipelines/airflow`
- [Kubeflow pipeline](https://github.com/bilal-ahmed-7/mlops-sentiment-project/tree/main/pipelines/kubeflow): `pipelines/kubeflow`
- [Feast feature store](https://github.com/bilal-ahmed-7/mlops-sentiment-project/tree/main/feature_store): `feature_store`
- [BentoML service](https://github.com/bilal-ahmed-7/mlops-sentiment-project/blob/main/src/serving/bentoml_service.py): `src/serving/bentoml_service.py`
- [Grafana dashboards](https://github.com/bilal-ahmed-7/mlops-sentiment-project/tree/main/monitoring/grafana): `monitoring/grafana`

### Other components

- [IMDB review data](https://github.com/bilal-ahmed-7/mlops-sentiment-project/tree/main/data/raw): `data/raw`
- **MLflow tracking/registry**
- **Prometheus metrics**
- **Prometheus Pushgateway**

## Connections

- IMDB review data → Load and validate: loads (evidence: `src/data/ingestion.py`)
- Load and validate → Schema checks: validates (evidence: `src/data/ingestion.py`)
- Clean and split → Load and validate: ingests (evidence: `src/features/preprocessing.py`)
- Clean and split → Shared text cleaning: cleans (evidence: `src/features/preprocessing.py`)
- Clean and split → Train/val/test splits: writes splits (evidence: `README.md`)
- Train and track → Train/val/test splits: reads splits (evidence: `README.md`)
- Train and track → Model evaluation: computes metrics (evidence: `src/models/train.py`)
- Train and track → MLflow tracking/registry: tracks run (evidence: `README.md`)
- Train and track → Saved model: saves model (evidence: `README.md`)
- Hyperparameter tuning → Train and track: runs experiments (evidence: `src/models/tune.py`)
- Gated registry → Train and track: uses tracking setup (evidence: `src/models/register.py`)
- Gated registry → MLflow tracking/registry: registers and promotes (evidence: `src/models/register.py`)
- Flask prediction API → Model loader: loads bundle (evidence: `src/serving/app.py`)
- Flask prediction API → Shared text cleaning: validates and cleans (evidence: `src/serving/app.py`)
- Flask prediction API → Numeric text features: extracts features (evidence: `src/serving/app.py`)
- Flask prediction API → Prediction log: writes records (evidence: `src/serving/app.py`)
- Model loader → MLflow tracking/registry: loads champion (evidence: `README.md`)
- Model loader → Saved model: loads fallback (evidence: `README.md`)
- Drift and performance checks → Prediction log: reads predictions (evidence: `src/monitoring/monitor.py`)
- Drift and performance checks → Train/val/test splits: samples reference data (evidence: `src/monitoring/monitor.py`)
- Drift and performance checks → Numeric text features: extracts reference features (evidence: `src/monitoring/monitor.py`)
- Flask prediction API → Prometheus metrics: exposes metrics (evidence: `README.md`)
- Drift and performance checks → Prometheus Pushgateway: pushes drift metrics (evidence: `src/monitoring/monitor.py`)
