# webex042/coffee-predictive-maintenance architecture

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

- Interactive diagram: https://gitdiagram.com/webex042/coffee-predictive-maintenance
- Repository: https://github.com/webex042/coffee-predictive-maintenance

## Overview

This is a simulated coffee-line predictive-maintenance prototype. Its main workflow turns sensor history—either the bundled simulation or an uploaded CSV—into 24-hour failure-risk predictions, then presents machine health, explanations, recommendations, and production-impact priorities in a Streamlit control room. Training, simulation, scoring, and operator-facing outputs are distinct stages. The graph reflects the supplied excerpts and README; some scoring internals and dashboard capabilities are documented but not fully sampled.

Main entry points: [`product maintance/src/scoring.py`](https://github.com/webex042/coffee-predictive-maintenance/blob/main/product%20maintance/src/scoring.py) (History scoring), [`product maintance/dashboard/app.py`](https://github.com/webex042/coffee-predictive-maintenance/blob/main/product%20maintance/dashboard/app.py) (Control room), [`product maintance/src/simulate.py`](https://github.com/webex042/coffee-predictive-maintenance/blob/main/product%20maintance/src/simulate.py) (Sensor simulator), [`product maintance/src/train_model.py`](https://github.com/webex042/coffee-predictive-maintenance/blob/main/product%20maintance/src/train_model.py) (Model training)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Sensor data"]
  node_upload["CSV upload<br/>[app.py]"]
  node_simulator["Sensor simulator<br/>[simulate.py]"]
  node_rawdata["Sensor history<br/>[sensor_data.csv]"]
  node_config["Machine baselines<br/>[config.py]"]
  node_validator["Input validation<br/>[scoring.py]"]
end

subgraph group_ml["Prediction"]
  node_features["Feature engineering"]
  node_trainer["Model training<br/>[train_model.py]"]
  node_model["Calibrated model<br/>[model.joblib]"]
  node_scoring["History scoring<br/>[scoring.py]"]
end

subgraph group_ops["Maintenance insights"]
  node_health["Health scoring<br/>[health.py]"]
  node_recommendations["Maintenance advice"]
  node_priority["Impact ranking<br/>[priority.py]"]
end

subgraph group_ui["Operator dashboard"]
  node_dashboard["Control room<br/>[app.py]"]
  node_theme["Arcade presentation<br/>[theme.py]"]
end

node_operator(("Plant operator"))

node_simulator -->|"uses baselines"| node_config
node_simulator -->|"writes history"| node_rawdata
node_operator -->|"provides CSV"| node_upload
node_upload -->|"checks data"| node_validator
node_rawdata -->|"loads history"| node_scoring
node_validator -->|"validates input"| node_scoring
node_features -->|"builds features"| node_scoring
node_model -->|"predicts risk"| node_scoring
node_trainer -->|"uses features"| node_features
node_trainer -->|"saves model"| node_model
node_scoring -->|"returns scores"| node_dashboard
node_dashboard -->|"requests snapshot"| node_scoring
node_scoring -->|"computes health"| node_health
node_scoring -->|"requests advice"| node_recommendations
node_scoring -->|"ranks machines"| node_priority
node_dashboard -->|"styles views"| node_theme
node_operator -->|"views results"| node_dashboard

click node_upload "https://github.com/webex042/coffee-predictive-maintenance/blob/main/product%20maintance/dashboard/app.py"
click node_simulator "https://github.com/webex042/coffee-predictive-maintenance/blob/main/product%20maintance/src/simulate.py"
click node_rawdata "https://github.com/webex042/coffee-predictive-maintenance/blob/main/product%20maintance/data/raw/sensor_data.csv"
click node_config "https://github.com/webex042/coffee-predictive-maintenance/blob/main/product%20maintance/config.py"
click node_validator "https://github.com/webex042/coffee-predictive-maintenance/blob/main/product%20maintance/src/scoring.py"
click node_features "https://github.com/webex042/coffee-predictive-maintenance/blob/main/product%20maintance/src/feature_engineering.py"
click node_trainer "https://github.com/webex042/coffee-predictive-maintenance/blob/main/product%20maintance/src/train_model.py"
click node_model "https://github.com/webex042/coffee-predictive-maintenance/blob/main/product%20maintance/models/model.joblib"
click node_scoring "https://github.com/webex042/coffee-predictive-maintenance/blob/main/product%20maintance/src/scoring.py"
click node_health "https://github.com/webex042/coffee-predictive-maintenance/blob/main/product%20maintance/src/health.py"
click node_recommendations "https://github.com/webex042/coffee-predictive-maintenance/blob/main/product%20maintance/src/maintenance_rules.py"
click node_priority "https://github.com/webex042/coffee-predictive-maintenance/blob/main/product%20maintance/src/priority.py"
click node_dashboard "https://github.com/webex042/coffee-predictive-maintenance/blob/main/product%20maintance/dashboard/app.py"
click node_theme "https://github.com/webex042/coffee-predictive-maintenance/blob/main/product%20maintance/dashboard/theme.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_upload,node_simulator,node_rawdata,node_config,node_validator toneBlue
class node_features,node_trainer,node_model,node_scoring toneAmber
class node_health,node_recommendations,node_priority toneMint
class node_dashboard,node_theme toneRose
class node_operator toneIndigo
```

## Components

### Sensor data

- [CSV upload](https://github.com/webex042/coffee-predictive-maintenance/blob/main/product%20maintance/dashboard/app.py): `product maintance/dashboard/app.py`
- [Sensor simulator](https://github.com/webex042/coffee-predictive-maintenance/blob/main/product%20maintance/src/simulate.py): `product maintance/src/simulate.py`
- [Sensor history](https://github.com/webex042/coffee-predictive-maintenance/blob/main/product%20maintance/data/raw/sensor_data.csv): `product maintance/data/raw/sensor_data.csv`
- [Machine baselines](https://github.com/webex042/coffee-predictive-maintenance/blob/main/product%20maintance/config.py): `product maintance/config.py`
- [Input validation](https://github.com/webex042/coffee-predictive-maintenance/blob/main/product%20maintance/src/scoring.py): `product maintance/src/scoring.py`

### Prediction

- [Feature engineering](https://github.com/webex042/coffee-predictive-maintenance/blob/main/product%20maintance/src/feature_engineering.py): `product maintance/src/feature_engineering.py`
- [Model training](https://github.com/webex042/coffee-predictive-maintenance/blob/main/product%20maintance/src/train_model.py): `product maintance/src/train_model.py`
- [Calibrated model](https://github.com/webex042/coffee-predictive-maintenance/blob/main/product%20maintance/models/model.joblib): `product maintance/models/model.joblib`
- [History scoring](https://github.com/webex042/coffee-predictive-maintenance/blob/main/product%20maintance/src/scoring.py): `product maintance/src/scoring.py`

### Maintenance insights

- [Health scoring](https://github.com/webex042/coffee-predictive-maintenance/blob/main/product%20maintance/src/health.py): `product maintance/src/health.py`
- [Maintenance advice](https://github.com/webex042/coffee-predictive-maintenance/blob/main/product%20maintance/src/maintenance_rules.py): `product maintance/src/maintenance_rules.py`
- [Impact ranking](https://github.com/webex042/coffee-predictive-maintenance/blob/main/product%20maintance/src/priority.py): `product maintance/src/priority.py`

### Operator dashboard

- [Control room](https://github.com/webex042/coffee-predictive-maintenance/blob/main/product%20maintance/dashboard/app.py): `product maintance/dashboard/app.py`
- [Arcade presentation](https://github.com/webex042/coffee-predictive-maintenance/blob/main/product%20maintance/dashboard/theme.py): `product maintance/dashboard/theme.py`

### Other components

- **Plant operator**

## Connections

- Sensor simulator → Machine baselines: uses baselines
- Sensor simulator → Sensor history: writes history
- Plant operator → CSV upload: provides CSV
- CSV upload → Input validation: checks data
- Sensor history → History scoring: loads history
- Input validation → History scoring: validates input
- Feature engineering → History scoring: builds features
- Calibrated model → History scoring: predicts risk
- Model training → Feature engineering: uses features
- Model training → Calibrated model: saves model
- History scoring → Control room: returns scores
- Control room → History scoring: requests snapshot
- History scoring → Health scoring: computes health
- History scoring → Maintenance advice: requests advice
- History scoring → Impact ranking: ranks machines
- Control room → Arcade presentation: styles views
- Plant operator → Control room: views results
