# andyloya/safetychecker architecture

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

- Interactive diagram: https://gitdiagram.com/andyloya/safetychecker
- Repository: https://github.com/andyloya/safetychecker

## Overview

PPE Safety Monitor has two entry points: the browser check-in, where a user starts a local camera and receives PPE results, and the retained desktop monitor. In the web path, Flask accepts camera frames and delegates inference and check-in state to a shared worker; the worker calls Roboflow workflows, and the browser polls status and displays detections and counts. The README documents optional RapidAPI calls, disabled for Render. Source excerpts show the principal web routes and worker behavior; other internal inference details are grouped under main.py.

Main entry points: [`web.py`](https://github.com/andyloya/safetychecker/blob/main/web.py) (Flask routes), [`main.py`](https://github.com/andyloya/safetychecker/blob/main/main.py) (Inference worker), [`static/app.js`](https://github.com/andyloya/safetychecker/blob/main/static/app.js) (Camera and results UI), [`templates/index.html`](https://github.com/andyloya/safetychecker/blob/main/templates/index.html) (Check-in page)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_browser["Browser check-in"]
  node_browser_ui["Camera and results UI<br/>[app.js]"]
  node_web_page["Check-in page<br/>[index.html]"]
end

subgraph group_service["Web service"]
  node_web_app["Flask routes<br/>[web.py]"]
  node_access_control["Basic auth<br/>[web.py]"]
  node_health["Health endpoint<br/>[web.py]"]
end

subgraph group_inference["Inference and check-in"]
  node_inference_worker["Inference worker<br/>[main.py]"]
  node_person_scan["Person workflow<br/>[main.py]"]
  node_ppe_scan["PPE workflow<br/>[main.py]"]
  node_checkin_results["PPE check-in results<br/>[main.py]"]
end

subgraph group_desktop["Desktop monitor"]
  node_desktop_entry["Desktop monitor<br/>[main.py]"]
end

subgraph group_integrations["External services"]
  node_roboflow["Roboflow workflows"]
  node_rapidapi["RapidAPI services"]
end

node_user(("Check-in user"))
node_browser_camera["Device camera"]

node_user -->|"starts check-in"| node_browser_ui
node_browser_ui -->|"captures frames"| node_browser_camera
node_browser_ui -->|"uses page"| node_web_page
node_web_app -->|"renders"| node_web_page
node_browser_ui -->|"uploads frames"| node_web_app
node_browser_ui -->|"polls status"| node_web_app
node_browser_ui -->|"resets check-in"| node_web_app
node_web_app -->|"authenticates requests"| node_access_control
node_user -.->|"signs in"| node_access_control
node_web_app -->|"serves health"| node_health
node_web_app -->|"submits frames"| node_inference_worker
node_web_app -->|"resets and reads status"| node_inference_worker
node_inference_worker -->|"calls workflows"| node_roboflow
node_inference_worker -->|"runs person scan"| node_person_scan
node_inference_worker -.->|"runs PPE scan"| node_ppe_scan
node_inference_worker -->|"updates check-in"| node_checkin_results
node_desktop_entry -.->|"starts monitoring"| node_inference_worker
node_desktop_entry -.->|"captures frames"| node_browser_camera
node_desktop_entry -->|"sends optional alerts"| node_rapidapi

click node_browser_ui "https://github.com/andyloya/safetychecker/blob/main/static/app.js"
click node_web_page "https://github.com/andyloya/safetychecker/blob/main/templates/index.html"
click node_web_app "https://github.com/andyloya/safetychecker/blob/main/web.py"
click node_access_control "https://github.com/andyloya/safetychecker/blob/main/web.py"
click node_health "https://github.com/andyloya/safetychecker/blob/main/web.py"
click node_inference_worker "https://github.com/andyloya/safetychecker/blob/main/main.py"
click node_person_scan "https://github.com/andyloya/safetychecker/blob/main/main.py"
click node_ppe_scan "https://github.com/andyloya/safetychecker/blob/main/main.py"
click node_checkin_results "https://github.com/andyloya/safetychecker/blob/main/main.py"
click node_desktop_entry "https://github.com/andyloya/safetychecker/blob/main/main.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_browser_ui,node_web_page,node_user toneBlue
class node_web_app,node_access_control,node_health toneAmber
class node_inference_worker,node_person_scan,node_ppe_scan,node_checkin_results toneMint
class node_desktop_entry toneRose
class node_roboflow,node_rapidapi,node_browser_camera toneIndigo
```

## Components

### Browser check-in

- [Camera and results UI](https://github.com/andyloya/safetychecker/blob/main/static/app.js): `static/app.js`
- [Check-in page](https://github.com/andyloya/safetychecker/blob/main/templates/index.html): `templates/index.html`

### Web service

- [Flask routes](https://github.com/andyloya/safetychecker/blob/main/web.py): `web.py`
- [Basic auth](https://github.com/andyloya/safetychecker/blob/main/web.py): `web.py`
- [Health endpoint](https://github.com/andyloya/safetychecker/blob/main/web.py): `web.py`

### Inference and check-in

- [Inference worker](https://github.com/andyloya/safetychecker/blob/main/main.py): `main.py`
- [Person workflow](https://github.com/andyloya/safetychecker/blob/main/main.py): `main.py`
- [PPE workflow](https://github.com/andyloya/safetychecker/blob/main/main.py): `main.py`
- [PPE check-in results](https://github.com/andyloya/safetychecker/blob/main/main.py): `main.py`

### Desktop monitor

- [Desktop monitor](https://github.com/andyloya/safetychecker/blob/main/main.py): `main.py`

### External services

- **Roboflow workflows**
- **RapidAPI services**

### Other components

- **Check-in user**
- **Device camera**

## Connections

- Check-in user → Camera and results UI: starts check-in (evidence: `README.md`)
- Camera and results UI → Device camera: captures frames (evidence: `static/app.js`)
- Camera and results UI → Check-in page: uses page (evidence: `README.md`)
- Flask routes → Check-in page: renders (evidence: `web.py`)
- Camera and results UI → Flask routes: uploads frames (evidence: `static/app.js`)
- Camera and results UI → Flask routes: polls status (evidence: `static/app.js`)
- Camera and results UI → Flask routes: resets check-in (evidence: `static/app.js`)
- Flask routes → Basic auth: authenticates requests (evidence: `web.py`)
- Check-in user → Basic auth: signs in (evidence: `README.md`)
- Flask routes → Health endpoint: serves health (evidence: `web.py`)
- Flask routes → Inference worker: submits frames (evidence: `web.py`)
- Flask routes → Inference worker: resets and reads status (evidence: `web.py`)
- Inference worker → Roboflow workflows: calls workflows (evidence: `main.py`)
- Inference worker → Person workflow: runs person scan (evidence: `main.py`)
- Inference worker → PPE workflow: runs PPE scan (evidence: `main.py`)
- Inference worker → PPE check-in results: updates check-in (evidence: `main.py`)
- Desktop monitor → Inference worker: starts monitoring (evidence: `main.py`)
- Desktop monitor → Device camera: captures frames (evidence: `README.md`)
- Desktop monitor → RapidAPI services: sends optional alerts (evidence: `main.py`)
