# mhmdamash/iubh-project-from-model-to-production architecture

> Architecture diagram of the GitHub repository mhmdamash/iubh-project-from-model-to-production, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mhmdamash/iubh-project-from-model-to-production
- Repository: https://github.com/mhmdamash/iubh-project-from-model-to-production

## Overview

This project generates synthetic factory readings, trains and saves an Isolation Forest pipeline, then serves anomaly scores through a Flask API. Its principal live workflow is the simulator generating readings, sending them to the API, and printing an alert when the response flags an anomaly. The API loads the model at startup and logs predictions; a health endpoint supports uptime checks. The graph follows README capabilities and sampled source; the generated data, model, and log are runtime artifacts, not files in the supplied tree.

Main entry points: [`app.py`](https://github.com/mhmdamash/iubh-project-from-model-to-production/blob/main/app.py) (Flask prediction API), [`stream_simulator.py`](https://github.com/mhmdamash/iubh-project-from-model-to-production/blob/main/stream_simulator.py) (Stream simulator), [`create_model.py`](https://github.com/mhmdamash/iubh-project-from-model-to-production/blob/main/create_model.py) (Model trainer), [`generate_data.py`](https://github.com/mhmdamash/iubh-project-from-model-to-production/blob/main/generate_data.py) (Synthetic data generator)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_training["Data and training"]
  node_data_generator["Synthetic data generator<br/>[generate_data.py]"]
  node_training_data["Sensor dataset"]
  node_model_trainer["Model trainer<br/>[create_model.py]"]
  node_trained_model["Trained pipeline"]
end

subgraph group_serving["Prediction service"]
  node_prediction_api["Flask prediction API<br/>[app.py]"]
  node_prediction_log["Prediction log"]
end

subgraph group_streaming["Live stream"]
  node_stream_simulator["Stream simulator"]
end

node_api_client(("API client"))
node_health_monitor(("Uptime monitor"))
node_operator(("Alert recipient"))

node_data_generator -->|"writes data"| node_training_data
node_model_trainer -->|"reads data"| node_training_data
node_model_trainer -->|"saves pipeline"| node_trained_model
node_prediction_api -->|"loads at startup"| node_trained_model
node_api_client -->|"requests prediction"| node_prediction_api
node_stream_simulator -->|"posts readings"| node_prediction_api
node_prediction_api -->|"returns scores"| node_stream_simulator
node_prediction_api -->|"writes predictions"| node_prediction_log
node_health_monitor -->|"checks health"| node_prediction_api
node_stream_simulator -->|"prints alerts"| node_operator

click node_data_generator "https://github.com/mhmdamash/iubh-project-from-model-to-production/blob/main/generate_data.py"
click node_model_trainer "https://github.com/mhmdamash/iubh-project-from-model-to-production/blob/main/create_model.py"
click node_prediction_api "https://github.com/mhmdamash/iubh-project-from-model-to-production/blob/main/app.py"
click node_stream_simulator "https://github.com/mhmdamash/iubh-project-from-model-to-production/blob/main/stream_simulator.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_generator,node_training_data,node_model_trainer,node_trained_model,node_api_client toneBlue
class node_prediction_api,node_prediction_log toneAmber
class node_stream_simulator toneMint
class node_health_monitor,node_operator toneIndigo
```

## Components

### Data and training

- [Synthetic data generator](https://github.com/mhmdamash/iubh-project-from-model-to-production/blob/main/generate_data.py): `generate_data.py`
- **Sensor dataset**
- [Model trainer](https://github.com/mhmdamash/iubh-project-from-model-to-production/blob/main/create_model.py): `create_model.py`
- **Trained pipeline**

### Prediction service

- [Flask prediction API](https://github.com/mhmdamash/iubh-project-from-model-to-production/blob/main/app.py): `app.py`
- **Prediction log**

### Live stream

- [Stream simulator](https://github.com/mhmdamash/iubh-project-from-model-to-production/blob/main/stream_simulator.py): `stream_simulator.py`

### Other components

- **API client**
- **Uptime monitor**
- **Alert recipient**

## Connections

- Synthetic data generator → Sensor dataset: writes data
- Model trainer → Sensor dataset: reads data
- Model trainer → Trained pipeline: saves pipeline
- Flask prediction API → Trained pipeline: loads at startup
- API client → Flask prediction API: requests prediction
- Stream simulator → Flask prediction API: posts readings
- Flask prediction API → Stream simulator: returns scores
- Flask prediction API → Prediction log: writes predictions
- Uptime monitor → Flask prediction API: checks health
- Stream simulator → Alert recipient: prints alerts
