# manavitulasyan/smart-conveyor-predictive-maintenance architecture

> Architecture diagram of the GitHub repository manavitulasyan/smart-conveyor-predictive-maintenance, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/manavitulasyan/smart-conveyor-predictive-maintenance
- Repository: https://github.com/manavitulasyan/smart-conveyor-predictive-maintenance

## Overview

This repository implements conveyor-condition monitoring: sensor readings enter a FastAPI backend, are classified by a trained model, and become health status, explanations, alerts, trends, and persisted readings. It also includes a separate interactive prediction script and a model-training workflow. The sampled backend shows these runtime relationships; the README is empty and the frontend file was not sampled, so its role and connections are left unspecified.

Main entry points: [`main.py`](https://github.com/manavitulasyan/smart-conveyor-predictive-maintenance/blob/main/main.py) (FastAPI Backend), [`database.py`](https://github.com/manavitulasyan/smart-conveyor-predictive-maintenance/blob/main/database.py) (Database Session), [`ml/conveyor_model.pkl`](https://github.com/manavitulasyan/smart-conveyor-predictive-maintenance/blob/main/ml/conveyor_model.pkl) (Trained Model), [`ml/train_model.py`](https://github.com/manavitulasyan/smart-conveyor-predictive-maintenance/blob/main/ml/train_model.py) (Model Training)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Monitoring API"]
  node_backend["FastAPI Backend<br/>[main.py]"]
end

subgraph group_ml["Machine Learning"]
  node_classifier["Fault Inference<br/>[main.py]"]
  node_trained_model["Trained Model<br/>[conveyor_model.pkl]"]
  node_training["Model Training<br/>[train_model.py]"]
  node_dataset["Training Dataset<br/>[dataset.csv]"]
  node_cli_predict["Interactive Prediction<br/>[predict.py]"]
end

subgraph group_storage["Persistence"]
  node_db_config["Database Session<br/>[database.py]"]
  node_reading_model["Reading Schema<br/>[models.py]"]
  node_postgres[("PostgreSQL")]
end

subgraph group_state["Live Monitoring"]
  node_live_state["Current Health<br/>[main.py]"]
  node_trend_history["Trend History<br/>[main.py]"]
  node_alert_history["Alert History<br/>[main.py]"]
end

node_sensor_client(("Sensor Client"))
node_frontend["Web Page<br/>[index.html]"]

node_sensor_client -->|"sends readings"| node_backend
node_backend -->|"requests prediction"| node_classifier
node_backend -->|"loads model"| node_trained_model
node_training -->|"reads data"| node_dataset
node_cli_predict -->|"loads model"| node_trained_model
node_backend -->|"creates reading"| node_reading_model
node_backend -->|"opens session"| node_db_config
node_db_config -->|"configures engine"| node_postgres
node_backend -->|"commits reading"| node_postgres
node_backend -->|"updates health"| node_live_state
node_backend -->|"appends reading"| node_trend_history
node_backend -->|"appends alert"| node_alert_history

click node_backend "https://github.com/manavitulasyan/smart-conveyor-predictive-maintenance/blob/main/main.py"
click node_classifier "https://github.com/manavitulasyan/smart-conveyor-predictive-maintenance/blob/main/main.py"
click node_trained_model "https://github.com/manavitulasyan/smart-conveyor-predictive-maintenance/blob/main/ml/conveyor_model.pkl"
click node_training "https://github.com/manavitulasyan/smart-conveyor-predictive-maintenance/blob/main/ml/train_model.py"
click node_dataset "https://github.com/manavitulasyan/smart-conveyor-predictive-maintenance/blob/main/ml/dataset.csv"
click node_cli_predict "https://github.com/manavitulasyan/smart-conveyor-predictive-maintenance/blob/main/ml/predict.py"
click node_db_config "https://github.com/manavitulasyan/smart-conveyor-predictive-maintenance/blob/main/database.py"
click node_reading_model "https://github.com/manavitulasyan/smart-conveyor-predictive-maintenance/blob/main/models.py"
click node_live_state "https://github.com/manavitulasyan/smart-conveyor-predictive-maintenance/blob/main/main.py"
click node_trend_history "https://github.com/manavitulasyan/smart-conveyor-predictive-maintenance/blob/main/main.py"
click node_alert_history "https://github.com/manavitulasyan/smart-conveyor-predictive-maintenance/blob/main/main.py"
click node_frontend "https://github.com/manavitulasyan/smart-conveyor-predictive-maintenance/blob/main/index.html"

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_backend,node_sensor_client toneBlue
class node_classifier,node_trained_model,node_training,node_dataset,node_cli_predict toneAmber
class node_db_config,node_reading_model,node_postgres toneMint
class node_live_state,node_trend_history,node_alert_history toneRose
class node_frontend toneTeal
```

## Components

### Monitoring API

- [FastAPI Backend](https://github.com/manavitulasyan/smart-conveyor-predictive-maintenance/blob/main/main.py): `main.py`

### Machine Learning

- [Fault Inference](https://github.com/manavitulasyan/smart-conveyor-predictive-maintenance/blob/main/main.py): `main.py`
- [Trained Model](https://github.com/manavitulasyan/smart-conveyor-predictive-maintenance/blob/main/ml/conveyor_model.pkl): `ml/conveyor_model.pkl`
- [Model Training](https://github.com/manavitulasyan/smart-conveyor-predictive-maintenance/blob/main/ml/train_model.py): `ml/train_model.py`
- [Training Dataset](https://github.com/manavitulasyan/smart-conveyor-predictive-maintenance/blob/main/ml/dataset.csv): `ml/dataset.csv`
- [Interactive Prediction](https://github.com/manavitulasyan/smart-conveyor-predictive-maintenance/blob/main/ml/predict.py): `ml/predict.py`

### Persistence

- [Database Session](https://github.com/manavitulasyan/smart-conveyor-predictive-maintenance/blob/main/database.py): `database.py`
- [Reading Schema](https://github.com/manavitulasyan/smart-conveyor-predictive-maintenance/blob/main/models.py): `models.py`
- **PostgreSQL**

### Live Monitoring

- [Current Health](https://github.com/manavitulasyan/smart-conveyor-predictive-maintenance/blob/main/main.py): `main.py`
- [Trend History](https://github.com/manavitulasyan/smart-conveyor-predictive-maintenance/blob/main/main.py): `main.py`
- [Alert History](https://github.com/manavitulasyan/smart-conveyor-predictive-maintenance/blob/main/main.py): `main.py`

### Other components

- **Sensor Client**
- [Web Page](https://github.com/manavitulasyan/smart-conveyor-predictive-maintenance/blob/main/index.html): `index.html`

## Connections

- Sensor Client → FastAPI Backend: sends readings (evidence: `main.py`)
- FastAPI Backend → Fault Inference: requests prediction (evidence: `main.py`)
- FastAPI Backend → Trained Model: loads model (evidence: `main.py`)
- Model Training → Training Dataset: reads data (evidence: `ml/train_model.py`)
- Interactive Prediction → Trained Model: loads model (evidence: `ml/predict.py`)
- FastAPI Backend → Reading Schema: creates reading (evidence: `main.py`)
- FastAPI Backend → Database Session: opens session (evidence: `main.py`)
- Database Session → PostgreSQL: configures engine (evidence: `database.py`)
- FastAPI Backend → PostgreSQL: commits reading (evidence: `main.py`)
- FastAPI Backend → Current Health: updates health (evidence: `main.py`)
- FastAPI Backend → Trend History: appends reading (evidence: `main.py`)
- FastAPI Backend → Alert History: appends alert (evidence: `main.py`)
