# zeus0390/ppe-detection-for-construction-site-safety architecture

> Architecture diagram of the GitHub repository zeus0390/ppe-detection-for-construction-site-safety, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/zeus0390/ppe-detection-for-construction-site-safety
- Repository: https://github.com/zeus0390/ppe-detection-for-construction-site-safety

## Overview

This is a configurable construction-site PPE monitoring application. Its principal workflow captures camera video, detects people and PPE, evaluates violations, and delivers MQTT reports; the cloud mode additionally consumes Kinesis video, calls a deployed model, and can retain images and violation records. Local and cloud execution are selected at the entry point. The graph includes documented local mode and hardware status functionality, but wiring for unsampled modules is shown only where supported by the README or sampled source.

Main entry points: [`src/cloud/cloudapp.py`](https://github.com/zeus0390/ppe-detection-for-construction-site-safety/blob/main/src/cloud/cloudapp.py) (Cloud application), [`src/localapp.py`](https://github.com/zeus0390/ppe-detection-for-construction-site-safety/blob/main/src/localapp.py) (Local application), [`src/detection.py`](https://github.com/zeus0390/ppe-detection-for-construction-site-safety/blob/main/src/detection.py) (PPE detection), [`main.py`](https://github.com/zeus0390/ppe-detection-for-construction-site-safety/blob/main/main.py) (Mode selector)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Application modes"]
  node_main["Mode selector<br/>[main.py]"]
  node_localapp["Local application<br/>[localapp.py]"]
  node_cloudapp["Cloud application<br/>[cloudapp.py]"]
end

subgraph group_capture["Video input"]
  node_camera["Camera capture<br/>[camera.py]"]
  node_kinesis_consumer["Kinesis consumer"]
  node_hardware["Device indicators<br/>[indicator.py]"]
end

subgraph group_analysis["Detection and reporting"]
  node_detection["PPE detection<br/>[detection.py]"]
  node_deployed_model["Deployed model<br/>[deployedmodel.py]"]
  node_box["Bounding boxes<br/>[box.py]"]
  node_mqtt_client["MQTT client<br/>[client.py]"]
end

subgraph group_storage["Persistence"]
  node_database_crud["Database operations<br/>[crud.py]"]
  node_database_handler["Database handler<br/>[database.py]"]
  node_schema["Violation schema<br/>[tables.py]"]
end

subgraph group_cloud["Cloud integrations"]
  node_s3storage["Image storage client<br/>[s3storage.py]"]
end

node_operator(("Safety officers"))
node_camera_device(("Raspberry Pi camera"))
node_mqtt_broker(("MQTT service"))
node_relational_db[("Relational database")]
node_s3[("Amazon S3")]
node_sagemaker(("Model endpoint"))
node_kinesis(("Kinesis video service"))

node_operator -->|"selects mode"| node_main
node_main -->|"starts local"| node_localapp
node_main -->|"starts cloud"| node_cloudapp
node_camera_device -->|"provides video"| node_camera
node_localapp -->|"uses capture"| node_camera
node_localapp -->|"starts detection"| node_detection
node_camera -->|"supplies frames"| node_detection
node_detection -->|"checks overlap"| node_box
node_detection -->|"publishes reports"| node_mqtt_client
node_mqtt_client -->|"publishes MQTT"| node_mqtt_broker
node_mqtt_broker -->|"delivers reports"| node_operator
node_cloudapp -->|"consumes stream"| node_kinesis_consumer
node_kinesis -->|"provides stream"| node_kinesis_consumer
node_cloudapp -->|"requests inference"| node_deployed_model
node_deployed_model -->|"invokes endpoint"| node_sagemaker
node_cloudapp -->|"connects and configures"| node_mqtt_client
node_cloudapp -->|"records violations"| node_database_crud
node_cloudapp -->|"uploads images"| node_s3storage
node_s3storage -->|"writes objects"| node_s3
node_database_crud -->|"uses sessions"| node_database_handler
node_database_handler -->|"creates mappings"| node_schema
node_database_handler -->|"reads and writes"| node_relational_db
node_database_crud -->|"queries records"| node_relational_db
node_schema -->|"deletes linked image"| node_s3storage
node_localapp -.->|"uses indicators"| node_hardware

click node_main "https://github.com/zeus0390/ppe-detection-for-construction-site-safety/blob/main/main.py"
click node_localapp "https://github.com/zeus0390/ppe-detection-for-construction-site-safety/blob/main/src/localapp.py"
click node_cloudapp "https://github.com/zeus0390/ppe-detection-for-construction-site-safety/blob/main/src/cloud/cloudapp.py"
click node_camera "https://github.com/zeus0390/ppe-detection-for-construction-site-safety/blob/main/src/camera.py"
click node_kinesis_consumer "https://github.com/zeus0390/ppe-detection-for-construction-site-safety/blob/main/src/cloud/kinesis_video_stream_consumer.py"
click node_detection "https://github.com/zeus0390/ppe-detection-for-construction-site-safety/blob/main/src/detection.py"
click node_deployed_model "https://github.com/zeus0390/ppe-detection-for-construction-site-safety/blob/main/src/cloud/deployedmodel.py"
click node_box "https://github.com/zeus0390/ppe-detection-for-construction-site-safety/blob/main/src/box.py"
click node_mqtt_client "https://github.com/zeus0390/ppe-detection-for-construction-site-safety/blob/main/src/client.py"
click node_database_crud "https://github.com/zeus0390/ppe-detection-for-construction-site-safety/blob/main/src/db/crud.py"
click node_database_handler "https://github.com/zeus0390/ppe-detection-for-construction-site-safety/blob/main/src/db/database.py"
click node_schema "https://github.com/zeus0390/ppe-detection-for-construction-site-safety/blob/main/src/db/tables.py"
click node_s3storage "https://github.com/zeus0390/ppe-detection-for-construction-site-safety/blob/main/src/cloud/s3storage.py"
click node_hardware "https://github.com/zeus0390/ppe-detection-for-construction-site-safety/blob/main/src/indicator.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_main,node_localapp,node_cloudapp toneBlue
class node_camera,node_kinesis_consumer,node_hardware,node_relational_db,node_s3 toneAmber
class node_detection,node_deployed_model,node_box,node_mqtt_client toneMint
class node_database_crud,node_database_handler,node_schema toneRose
class node_s3storage,node_operator,node_camera_device,node_mqtt_broker,node_sagemaker,node_kinesis toneIndigo
```

## Components

### Application modes

- [Mode selector](https://github.com/zeus0390/ppe-detection-for-construction-site-safety/blob/main/main.py): `main.py`
- [Local application](https://github.com/zeus0390/ppe-detection-for-construction-site-safety/blob/main/src/localapp.py): `src/localapp.py`
- [Cloud application](https://github.com/zeus0390/ppe-detection-for-construction-site-safety/blob/main/src/cloud/cloudapp.py): `src/cloud/cloudapp.py`

### Video input

- [Camera capture](https://github.com/zeus0390/ppe-detection-for-construction-site-safety/blob/main/src/camera.py): `src/camera.py`
- [Kinesis consumer](https://github.com/zeus0390/ppe-detection-for-construction-site-safety/blob/main/src/cloud/kinesis_video_stream_consumer.py): `src/cloud/kinesis_video_stream_consumer.py`
- [Device indicators](https://github.com/zeus0390/ppe-detection-for-construction-site-safety/blob/main/src/indicator.py): `src/indicator.py`

### Detection and reporting

- [PPE detection](https://github.com/zeus0390/ppe-detection-for-construction-site-safety/blob/main/src/detection.py): `src/detection.py`
- [Deployed model](https://github.com/zeus0390/ppe-detection-for-construction-site-safety/blob/main/src/cloud/deployedmodel.py): `src/cloud/deployedmodel.py`
- [Bounding boxes](https://github.com/zeus0390/ppe-detection-for-construction-site-safety/blob/main/src/box.py): `src/box.py`
- [MQTT client](https://github.com/zeus0390/ppe-detection-for-construction-site-safety/blob/main/src/client.py): `src/client.py`

### Persistence

- [Database operations](https://github.com/zeus0390/ppe-detection-for-construction-site-safety/blob/main/src/db/crud.py): `src/db/crud.py`
- [Database handler](https://github.com/zeus0390/ppe-detection-for-construction-site-safety/blob/main/src/db/database.py): `src/db/database.py`
- [Violation schema](https://github.com/zeus0390/ppe-detection-for-construction-site-safety/blob/main/src/db/tables.py): `src/db/tables.py`

### Cloud integrations

- [Image storage client](https://github.com/zeus0390/ppe-detection-for-construction-site-safety/blob/main/src/cloud/s3storage.py): `src/cloud/s3storage.py`

### Other components

- **Safety officers**
- **Raspberry Pi camera**
- **MQTT service**
- **Relational database**
- **Amazon S3**
- **Model endpoint**
- **Kinesis video service**

## Connections

- Safety officers → Mode selector: selects mode
- Mode selector → Local application: starts local
- Mode selector → Cloud application: starts cloud
- Raspberry Pi camera → Camera capture: provides video
- Local application → Camera capture: uses capture
- Local application → PPE detection: starts detection
- Camera capture → PPE detection: supplies frames
- PPE detection → Bounding boxes: checks overlap
- PPE detection → MQTT client: publishes reports
- MQTT client → MQTT service: publishes MQTT
- MQTT service → Safety officers: delivers reports
- Cloud application → Kinesis consumer: consumes stream
- Kinesis video service → Kinesis consumer: provides stream
- Cloud application → Deployed model: requests inference
- Deployed model → Model endpoint: invokes endpoint
- Cloud application → MQTT client: connects and configures
- Cloud application → Database operations: records violations
- Cloud application → Image storage client: uploads images
- Image storage client → Amazon S3: writes objects
- Database operations → Database handler: uses sessions
- Database handler → Violation schema: creates mappings
- Database handler → Relational database: reads and writes
- Database operations → Relational database: queries records
- Violation schema → Image storage client: deletes linked image
- Local application → Device indicators: uses indicators
