# waqarali-wq/ppe_version1 architecture

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

- Interactive diagram: https://gitdiagram.com/waqarali-wq/ppe_version1
- Repository: https://github.com/waqarali-wq/ppe_version1

## Overview

The repository is a PPE surveillance and safety-audit application with desktop camera monitoring and command-line image/video workflows. Its main path is camera or video input → per-camera feature processing → person tracking and PPE assessment → annotated frames and operator alerts. The README also documents image-folder auditing, video tracking, persistent camera configuration, and alert decisions. Some CLI and UI implementation details were not excerpted, so those connections are shown only where the README or indexed references support them.

Main entry points: [`src/ui/main_window.py`](https://github.com/waqarali-wq/ppe_version1/blob/main/src/ui/main_window.py) (Monitoring window), [`src/ui/worker.py`](https://github.com/waqarali-wq/ppe_version1/blob/main/src/ui/worker.py) (Camera worker), [`detect_images.py`](https://github.com/waqarali-wq/ppe_version1/blob/main/detect_images.py) (Image audit CLI), [`track_video.py`](https://github.com/waqarali-wq/ppe_version1/blob/main/track_video.py) (Video audit CLI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Desktop monitoring"]
  node_desktop_app["Desktop entry<br/>[app.py]"]
  node_main_window["Monitoring window<br/>[main_window.py]"]
  node_camera_dialogs["Camera setup<br/>[dialogs.py]"]
  node_camera_tile["Camera tile<br/>[camera_tile.py]"]
  node_alerts_panel["Alerts panel<br/>[alerts_panel.py]"]
  node_alert_store[("Alert and camera store<br/>[store.py]")]
end

subgraph group_capture["Video capture"]
  node_camera_worker["Camera worker<br/>[worker.py]"]
  node_frame_source["Frame source<br/>[camera.py]"]
end

subgraph group_audit["PPE audit"]
  node_image_cli["Image audit CLI<br/>[detect_images.py]"]
  node_video_cli["Video audit CLI<br/>[track_video.py]"]
  node_feature_registry["Feature registry<br/>[features.py]"]
  node_ppe_tracker["Person tracking and fusion<br/>[tracker.py]"]
  node_ppe_detector["PPE detector<br/>[detector.py]"]
  node_pose_analyzer["Pose safety analysis<br/>[pose_analyzer.py]"]
  node_ppe_weights["PPE model weights"]
end

subgraph group_outputs["Audit outputs"]
  node_visualizer["Frame annotations<br/>[visualizer.py]"]
  node_annotated_images["Annotated images"]
  node_annotated_videos["Annotated videos"]
  node_alert_snapshots_log["Alert log and snapshots"]
end

node_operator(("Safety operator"))
node_camera_source(("Camera or video"))

node_operator -->|"launches"| node_desktop_app
node_desktop_app -->|"opens"| node_main_window
node_operator -->|"configures sources"| node_camera_dialogs
node_main_window -->|"opens"| node_camera_dialogs
node_main_window -->|"starts"| node_camera_worker
node_main_window -->|"creates"| node_camera_tile
node_main_window -->|"displays"| node_alerts_panel
node_main_window -->|"logs decisions"| node_alert_store
node_camera_source -->|"provides frames"| node_frame_source
node_camera_worker -->|"reads frames"| node_frame_source
node_camera_worker -->|"loads and runs"| node_feature_registry
node_feature_registry -.->|"uses tracking"| node_ppe_tracker
node_ppe_tracker -->|"detects PPE"| node_ppe_detector
node_ppe_tracker -->|"analyzes person crops"| node_pose_analyzer
node_ppe_detector -->|"loads weights"| node_ppe_weights
node_operator -->|"runs image audit"| node_image_cli
node_image_cli -->|"detects items"| node_ppe_detector
node_image_cli -->|"annotates images"| node_visualizer
node_image_cli -->|"writes results"| node_annotated_images
node_operator -->|"runs video audit"| node_video_cli
node_video_cli -->|"tracks and audits"| node_ppe_tracker
node_video_cli -->|"annotates frames"| node_visualizer
node_video_cli -->|"writes results"| node_annotated_videos
node_camera_worker -->|"sends frames"| node_camera_tile
node_camera_worker -->|"emits alerts"| node_main_window
node_main_window -->|"raises alerts"| node_alerts_panel
node_main_window -->|"records decisions"| node_alert_snapshots_log
node_camera_worker -->|"saves video output"| node_annotated_videos

click node_desktop_app "https://github.com/waqarali-wq/ppe_version1/blob/main/app.py"
click node_main_window "https://github.com/waqarali-wq/ppe_version1/blob/main/src/ui/main_window.py"
click node_camera_dialogs "https://github.com/waqarali-wq/ppe_version1/blob/main/src/ui/dialogs.py"
click node_camera_tile "https://github.com/waqarali-wq/ppe_version1/blob/main/src/ui/camera_tile.py"
click node_alerts_panel "https://github.com/waqarali-wq/ppe_version1/blob/main/src/ui/alerts_panel.py"
click node_alert_store "https://github.com/waqarali-wq/ppe_version1/blob/main/src/ui/store.py"
click node_camera_worker "https://github.com/waqarali-wq/ppe_version1/blob/main/src/ui/worker.py"
click node_frame_source "https://github.com/waqarali-wq/ppe_version1/blob/main/src/camera.py"
click node_image_cli "https://github.com/waqarali-wq/ppe_version1/blob/main/detect_images.py"
click node_video_cli "https://github.com/waqarali-wq/ppe_version1/blob/main/track_video.py"
click node_feature_registry "https://github.com/waqarali-wq/ppe_version1/blob/main/src/features.py"
click node_ppe_tracker "https://github.com/waqarali-wq/ppe_version1/blob/main/src/tracker.py"
click node_ppe_detector "https://github.com/waqarali-wq/ppe_version1/blob/main/src/detector.py"
click node_pose_analyzer "https://github.com/waqarali-wq/ppe_version1/blob/main/src/pose_analyzer.py"
click node_visualizer "https://github.com/waqarali-wq/ppe_version1/blob/main/src/visualizer.py"
click node_annotated_images "https://github.com/waqarali-wq/ppe_version1/tree/main/outputs/annotated_images"
click node_annotated_videos "https://github.com/waqarali-wq/ppe_version1/tree/main/outputs/annotated_videos"
click node_alert_snapshots_log "https://github.com/waqarali-wq/ppe_version1/tree/main/outputs"
click node_ppe_weights "https://github.com/waqarali-wq/ppe_version1/blob/main/models/ppe_construction_yolov8.pt"

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_desktop_app,node_main_window,node_camera_dialogs,node_camera_tile,node_alerts_panel,node_alert_store toneBlue
class node_camera_worker,node_frame_source toneAmber
class node_image_cli,node_video_cli,node_feature_registry,node_ppe_tracker,node_ppe_detector,node_pose_analyzer,node_ppe_weights toneMint
class node_visualizer,node_annotated_images,node_annotated_videos,node_alert_snapshots_log toneRose
class node_operator,node_camera_source toneIndigo
```

## Components

### Desktop monitoring

- [Desktop entry](https://github.com/waqarali-wq/ppe_version1/blob/main/app.py): `app.py`
- [Monitoring window](https://github.com/waqarali-wq/ppe_version1/blob/main/src/ui/main_window.py): `src/ui/main_window.py`
- [Camera setup](https://github.com/waqarali-wq/ppe_version1/blob/main/src/ui/dialogs.py): `src/ui/dialogs.py`
- [Camera tile](https://github.com/waqarali-wq/ppe_version1/blob/main/src/ui/camera_tile.py): `src/ui/camera_tile.py`
- [Alerts panel](https://github.com/waqarali-wq/ppe_version1/blob/main/src/ui/alerts_panel.py): `src/ui/alerts_panel.py`
- [Alert and camera store](https://github.com/waqarali-wq/ppe_version1/blob/main/src/ui/store.py): `src/ui/store.py`

### Video capture

- [Camera worker](https://github.com/waqarali-wq/ppe_version1/blob/main/src/ui/worker.py): `src/ui/worker.py`
- [Frame source](https://github.com/waqarali-wq/ppe_version1/blob/main/src/camera.py): `src/camera.py`

### PPE audit

- [Image audit CLI](https://github.com/waqarali-wq/ppe_version1/blob/main/detect_images.py): `detect_images.py`
- [Video audit CLI](https://github.com/waqarali-wq/ppe_version1/blob/main/track_video.py): `track_video.py`
- [Feature registry](https://github.com/waqarali-wq/ppe_version1/blob/main/src/features.py): `src/features.py`
- [Person tracking and fusion](https://github.com/waqarali-wq/ppe_version1/blob/main/src/tracker.py): `src/tracker.py`
- [PPE detector](https://github.com/waqarali-wq/ppe_version1/blob/main/src/detector.py): `src/detector.py`
- [Pose safety analysis](https://github.com/waqarali-wq/ppe_version1/blob/main/src/pose_analyzer.py): `src/pose_analyzer.py`
- [PPE model weights](https://github.com/waqarali-wq/ppe_version1/blob/main/models/ppe_construction_yolov8.pt): `models/ppe_construction_yolov8.pt`

### Audit outputs

- [Frame annotations](https://github.com/waqarali-wq/ppe_version1/blob/main/src/visualizer.py): `src/visualizer.py`
- [Annotated images](https://github.com/waqarali-wq/ppe_version1/tree/main/outputs/annotated_images): `outputs/annotated_images`
- [Annotated videos](https://github.com/waqarali-wq/ppe_version1/tree/main/outputs/annotated_videos): `outputs/annotated_videos`
- [Alert log and snapshots](https://github.com/waqarali-wq/ppe_version1/tree/main/outputs): `outputs`

### Other components

- **Safety operator**
- **Camera or video**

## Connections

- Safety operator → Desktop entry: launches (evidence: `app.py`)
- Desktop entry → Monitoring window: opens (evidence: `app.py`)
- Safety operator → Camera setup: configures sources (evidence: `README.md`)
- Monitoring window → Camera setup: opens (evidence: `src/ui/main_window.py`)
- Monitoring window → Camera worker: starts (evidence: `src/ui/main_window.py`)
- Monitoring window → Camera tile: creates (evidence: `src/ui/main_window.py`)
- Monitoring window → Alerts panel: displays (evidence: `src/ui/main_window.py`)
- Monitoring window → Alert and camera store: logs decisions (evidence: `src/ui/main_window.py`)
- Camera or video → Frame source: provides frames (evidence: `README.md`)
- Camera worker → Frame source: reads frames (evidence: `src/ui/worker.py`)
- Camera worker → Feature registry: loads and runs (evidence: `src/ui/worker.py`)
- Feature registry → Person tracking and fusion: uses tracking (evidence: `src/features.py`)
- Person tracking and fusion → PPE detector: detects PPE (evidence: `src/tracker.py`)
- Person tracking and fusion → Pose safety analysis: analyzes person crops (evidence: `src/tracker.py`)
- PPE detector → PPE model weights: loads weights (evidence: `src/detector.py`)
- Safety operator → Image audit CLI: runs image audit (evidence: `README.md`)
- Image audit CLI → PPE detector: detects items (evidence: `detect_images.py`)
- Image audit CLI → Frame annotations: annotates images (evidence: `detect_images.py`)
- Image audit CLI → Annotated images: writes results (evidence: `README.md`)
- Safety operator → Video audit CLI: runs video audit (evidence: `README.md`)
- Video audit CLI → Person tracking and fusion: tracks and audits (evidence: `README.md`)
- Video audit CLI → Frame annotations: annotates frames (evidence: `track_video.py`)
- Video audit CLI → Annotated videos: writes results (evidence: `README.md`)
- Camera worker → Camera tile: sends frames (evidence: `src/ui/worker.py`)
- Camera worker → Monitoring window: emits alerts (evidence: `src/ui/worker.py`)
- Monitoring window → Alerts panel: raises alerts (evidence: `src/ui/main_window.py`)
- Monitoring window → Alert log and snapshots: records decisions (evidence: `README.md`)
- Camera worker → Annotated videos: saves video output (evidence: `README.md`)
