# spider-loki/smart-ppe-monitoring-system architecture

> Architecture diagram of the GitHub repository spider-loki/smart-ppe-monitoring-system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/spider-loki/smart-ppe-monitoring-system
- Repository: https://github.com/spider-loki/smart-ppe-monitoring-system

## Overview

Smart PPE is an industrial safety monitoring product: camera video is analyzed for worker identity and PPE compliance, attendance/compliance is recorded, and operators review live status, worker records, alerts, and reports in a web dashboard. The README documents the detection, API, dashboard, and MySQL roles; sampled source confirms worker-photo synchronization, worker-management requests, reporting utilities, and email delivery. Several page implementations and detection-to-API details were not sampled, so those connections are shown only where documentation supports them.

Main entry points: [`frontend/src/App.jsx`](https://github.com/spider-loki/smart-ppe-monitoring-system/blob/master/frontend/src/App.jsx) (Routes and layout), [`backend/api/backend_app.py`](https://github.com/spider-loki/smart-ppe-monitoring-system/blob/master/backend/api/backend_app.py) (Backend API), [`backend/detection/ppe_stream_server.py`](https://github.com/spider-loki/smart-ppe-monitoring-system/blob/master/backend/detection/ppe_stream_server.py) (PPE detector), [`backend/utils/email_sender.py`](https://github.com/spider-loki/smart-ppe-monitoring-system/blob/master/backend/utils/email_sender.py) (Email alerts)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_detection["Detection and streaming"]
  node_detector["PPE detector"]
  node_worker_sync["Worker photo sync<br/>[sync_workers.py]"]
end

subgraph group_backend["Backend services"]
  node_api["Backend API<br/>[backend_app.py]"]
  node_mysql[("MySQL PPE data")]
end

subgraph group_dashboard["Web dashboard"]
  node_entry["React entry<br/>[main.jsx]"]
  node_app["Routes and layout<br/>[App.jsx]"]
  node_theme["Theme state<br/>[ThemeContext.jsx]"]
  node_roles["Role state"]
  node_workers["Worker management<br/>[Workers.jsx]"]
  node_login["Login page<br/>[Login.jsx]"]
  node_dashboard_page["Safety dashboard<br/>[Dashboard.jsx]"]
  node_attendance["Attendance history<br/>[Attendance.jsx]"]
  node_reports["Compliance reports<br/>[Reports.jsx]"]
  node_alerts["Alerts<br/>[Alerts.jsx]"]
  node_announcements["Announcements<br/>[Announcements.jsx]"]
  node_settings["System settings<br/>[Settings.jsx]"]
  node_api_client["HTTP client<br/>[client.js]"]
end

subgraph group_support["Shared utilities"]
  node_email["Email alerts<br/>[email_sender.py]"]
  node_report_utils["CSV reporting<br/>[report_utils.py]"]
end

node_camera(("Camera"))
node_browser(("Dashboard user"))
node_smtp(("SMTP server<br/>external system"))

node_camera -->|"supplies video"| node_detector
node_detector -->|"records attendance"| node_api
node_detector -->|"streams video"| node_browser
node_worker_sync -->|"fetches worker photos"| node_api
node_api -->|"reads and writes"| node_mysql
node_api -->|"generates CSV reports"| node_report_utils
node_api -->|"sends violation alerts"| node_email
node_browser -->|"opens dashboard"| node_entry
node_entry -->|"renders"| node_app
node_app -->|"provides theme state"| node_theme
node_app -->|"provides role state"| node_roles
node_app -->|"routes to"| node_login
node_app -->|"routes to"| node_dashboard_page
node_app -->|"routes to"| node_workers
node_app -->|"routes to"| node_attendance
node_app -->|"routes to"| node_reports
node_app -->|"routes to"| node_alerts
node_app -->|"routes to"| node_announcements
node_app -->|"routes to"| node_settings
node_workers -->|"calls"| node_api_client
node_api_client -.->|"sends API requests"| node_api
node_email -->|"loads alert settings"| node_mysql
node_email -->|"sends messages"| node_smtp

click node_detector "https://github.com/spider-loki/smart-ppe-monitoring-system/blob/master/backend/detection/ppe_stream_server.py"
click node_worker_sync "https://github.com/spider-loki/smart-ppe-monitoring-system/blob/master/backend/detection/sync_workers.py"
click node_api "https://github.com/spider-loki/smart-ppe-monitoring-system/blob/master/backend/api/backend_app.py"
click node_email "https://github.com/spider-loki/smart-ppe-monitoring-system/blob/master/backend/utils/email_sender.py"
click node_report_utils "https://github.com/spider-loki/smart-ppe-monitoring-system/blob/master/backend/utils/report_utils.py"
click node_entry "https://github.com/spider-loki/smart-ppe-monitoring-system/blob/master/frontend/src/main.jsx"
click node_app "https://github.com/spider-loki/smart-ppe-monitoring-system/blob/master/frontend/src/App.jsx"
click node_theme "https://github.com/spider-loki/smart-ppe-monitoring-system/blob/master/frontend/src/contexts/ThemeContext.jsx"
click node_roles "https://github.com/spider-loki/smart-ppe-monitoring-system/blob/master/frontend/src/contexts/UserRoleContext.jsx"
click node_workers "https://github.com/spider-loki/smart-ppe-monitoring-system/blob/master/frontend/src/pages/Workers.jsx"
click node_login "https://github.com/spider-loki/smart-ppe-monitoring-system/blob/master/frontend/src/pages/Login.jsx"
click node_dashboard_page "https://github.com/spider-loki/smart-ppe-monitoring-system/blob/master/frontend/src/pages/Dashboard.jsx"
click node_attendance "https://github.com/spider-loki/smart-ppe-monitoring-system/blob/master/frontend/src/pages/Attendance.jsx"
click node_reports "https://github.com/spider-loki/smart-ppe-monitoring-system/blob/master/frontend/src/pages/Reports.jsx"
click node_alerts "https://github.com/spider-loki/smart-ppe-monitoring-system/blob/master/frontend/src/pages/Alerts.jsx"
click node_announcements "https://github.com/spider-loki/smart-ppe-monitoring-system/blob/master/frontend/src/pages/Announcements.jsx"
click node_settings "https://github.com/spider-loki/smart-ppe-monitoring-system/blob/master/frontend/src/pages/Settings.jsx"
click node_api_client "https://github.com/spider-loki/smart-ppe-monitoring-system/blob/master/frontend/src/api/client.js"

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_detector,node_worker_sync,node_browser toneBlue
class node_api,node_mysql toneAmber
class node_entry,node_app,node_theme,node_roles,node_workers,node_login,node_dashboard_page,node_attendance,node_reports,node_alerts,node_announcements,node_settings,node_api_client,node_smtp toneMint
class node_email,node_report_utils toneRose
class node_camera toneIndigo
```

## Components

### Detection and streaming

- [PPE detector](https://github.com/spider-loki/smart-ppe-monitoring-system/blob/master/backend/detection/ppe_stream_server.py): `backend/detection/ppe_stream_server.py`
- [Worker photo sync](https://github.com/spider-loki/smart-ppe-monitoring-system/blob/master/backend/detection/sync_workers.py): `backend/detection/sync_workers.py`

### Backend services

- [Backend API](https://github.com/spider-loki/smart-ppe-monitoring-system/blob/master/backend/api/backend_app.py): `backend/api/backend_app.py`
- **MySQL PPE data**

### Web dashboard

- [React entry](https://github.com/spider-loki/smart-ppe-monitoring-system/blob/master/frontend/src/main.jsx): `frontend/src/main.jsx`
- [Routes and layout](https://github.com/spider-loki/smart-ppe-monitoring-system/blob/master/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Theme state](https://github.com/spider-loki/smart-ppe-monitoring-system/blob/master/frontend/src/contexts/ThemeContext.jsx): `frontend/src/contexts/ThemeContext.jsx`
- [Role state](https://github.com/spider-loki/smart-ppe-monitoring-system/blob/master/frontend/src/contexts/UserRoleContext.jsx): `frontend/src/contexts/UserRoleContext.jsx`
- [Worker management](https://github.com/spider-loki/smart-ppe-monitoring-system/blob/master/frontend/src/pages/Workers.jsx): `frontend/src/pages/Workers.jsx`
- [Login page](https://github.com/spider-loki/smart-ppe-monitoring-system/blob/master/frontend/src/pages/Login.jsx): `frontend/src/pages/Login.jsx`
- [Safety dashboard](https://github.com/spider-loki/smart-ppe-monitoring-system/blob/master/frontend/src/pages/Dashboard.jsx): `frontend/src/pages/Dashboard.jsx`
- [Attendance history](https://github.com/spider-loki/smart-ppe-monitoring-system/blob/master/frontend/src/pages/Attendance.jsx): `frontend/src/pages/Attendance.jsx`
- [Compliance reports](https://github.com/spider-loki/smart-ppe-monitoring-system/blob/master/frontend/src/pages/Reports.jsx): `frontend/src/pages/Reports.jsx`
- [Alerts](https://github.com/spider-loki/smart-ppe-monitoring-system/blob/master/frontend/src/pages/Alerts.jsx): `frontend/src/pages/Alerts.jsx`
- [Announcements](https://github.com/spider-loki/smart-ppe-monitoring-system/blob/master/frontend/src/pages/Announcements.jsx): `frontend/src/pages/Announcements.jsx`
- [System settings](https://github.com/spider-loki/smart-ppe-monitoring-system/blob/master/frontend/src/pages/Settings.jsx): `frontend/src/pages/Settings.jsx`
- [HTTP client](https://github.com/spider-loki/smart-ppe-monitoring-system/blob/master/frontend/src/api/client.js): `frontend/src/api/client.js`

### Shared utilities

- [Email alerts](https://github.com/spider-loki/smart-ppe-monitoring-system/blob/master/backend/utils/email_sender.py): `backend/utils/email_sender.py`
- [CSV reporting](https://github.com/spider-loki/smart-ppe-monitoring-system/blob/master/backend/utils/report_utils.py): `backend/utils/report_utils.py`

### Other components

- **Camera**
- **Dashboard user**
- **SMTP server**: external system

## Connections

- Camera → PPE detector: supplies video (evidence: `README.md`)
- PPE detector → Backend API: records attendance (evidence: `README.md`)
- PPE detector → Dashboard user: streams video (evidence: `README.md`)
- Worker photo sync → Backend API: fetches worker photos (evidence: `backend/detection/sync_workers.py`)
- Backend API → MySQL PPE data: reads and writes (evidence: `backend/api/backend_app.py`)
- Backend API → CSV reporting: generates CSV reports (evidence: `backend/api/backend_app.py`)
- Backend API → Email alerts: sends violation alerts (evidence: `backend/api/backend_app.py`)
- Dashboard user → React entry: opens dashboard (evidence: `README.md`)
- React entry → Routes and layout: renders (evidence: `frontend/src/main.jsx`)
- Routes and layout → Theme state: provides theme state (evidence: `frontend/src/App.jsx`)
- Routes and layout → Role state: provides role state (evidence: `frontend/src/App.jsx`)
- Routes and layout → Login page: routes to (evidence: `frontend/src/App.jsx`)
- Routes and layout → Safety dashboard: routes to (evidence: `frontend/src/App.jsx`)
- Routes and layout → Worker management: routes to (evidence: `frontend/src/App.jsx`)
- Routes and layout → Attendance history: routes to (evidence: `frontend/src/App.jsx`)
- Routes and layout → Compliance reports: routes to (evidence: `frontend/src/App.jsx`)
- Routes and layout → Alerts: routes to (evidence: `frontend/src/App.jsx`)
- Routes and layout → Announcements: routes to (evidence: `frontend/src/App.jsx`)
- Routes and layout → System settings: routes to (evidence: `frontend/src/App.jsx`)
- Worker management → HTTP client: calls (evidence: `frontend/src/pages/Workers.jsx`)
- HTTP client → Backend API: sends API requests (evidence: `README.md`)
- Email alerts → MySQL PPE data: loads alert settings (evidence: `backend/utils/email_sender.py`)
- Email alerts → SMTP server: sends messages (evidence: `backend/utils/email_sender.py`)
