# dzakyalfitra/smart-apd-detection architecture

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

- Interactive diagram: https://gitdiagram.com/dzakyalfitra/smart-apd-detection
- Repository: https://github.com/dzakyalfitra/smart-apd-detection

## Overview

This repository implements real-time protective-equipment compliance detection, with an optional monocular distance-estimation display and Arduino feedback. The main workflow captures webcam frames, runs the trained YOLO model, maps detections to compliance states, and sends serial commands for LED/buzzer behavior. The README also documents model training in a notebook. The tree contains duplicate scripts in nested and outer project directories; sampled copies show the same behavior. Notebook and firmware internals were not sampled, so their links rely on README statements.

Main entry points: [`Project Kendali Cerdas/od.py`](https://github.com/dzakyalfitra/smart-apd-detection/blob/master/Project%20Kendali%20Cerdas/od.py) (Main Detector), [`Project Kendali Cerdas/Project Kendali Cerdas/od.py`](https://github.com/dzakyalfitra/smart-apd-detection/blob/master/Project%20Kendali%20Cerdas/Project%20Kendali%20Cerdas/od.py) (Nested Detector), [`Project Kendali Cerdas/best.pt`](https://github.com/dzakyalfitra/smart-apd-detection/blob/master/Project%20Kendali%20Cerdas/best.pt) (YOLO Weights), [`Project Kendali Cerdas/Project Kendali Cerdas/best.pt`](https://github.com/dzakyalfitra/smart-apd-detection/blob/master/Project%20Kendali%20Cerdas/Project%20Kendali%20Cerdas/best.pt) (Nested Weights)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Live Detection"]
  node_main["Main Detector<br/>[od.py]"]
  node_nested_main["Nested Detector<br/>[od.py]"]
  node_distance["Distance Variant<br/>[import cv2.py]"]
  node_nested_distance["Nested Distance<br/>[import cv2.py]"]
end

subgraph group_modeling["Model Development"]
  node_weights["YOLO Weights<br/>[best.pt]"]
  node_nested_weights["Nested Weights<br/>[best.pt]"]
  node_training["YOLO Training<br/>[OD.ipynb]"]
  node_nested_training["Nested Training<br/>[OD.ipynb]"]
end

subgraph group_feedback["Arduino Feedback"]
  node_arduino["Arduino Firmware<br/>[sketch_nov11a.ino]"]
  node_nested_arduino["Nested Firmware<br/>[sketch_nov11a.ino]"]
  node_outputs["LEDs and Buzzer"]
end

node_webcam(("Webcam"))

node_webcam -->|"provides frames"| node_main
node_webcam -->|"provides frames"| node_nested_main
node_webcam -->|"provides frames"| node_distance
node_webcam -->|"provides frames"| node_nested_distance
node_main -->|"loads model"| node_weights
node_nested_main -->|"loads model"| node_nested_weights
node_distance -->|"loads model"| node_weights
node_nested_distance -->|"loads model"| node_nested_weights
node_training -.->|"trains weights"| node_weights
node_nested_training -.->|"trains weights"| node_nested_weights
node_main -->|"sends serial states"| node_arduino
node_nested_main -.->|"sends serial states"| node_nested_arduino
node_arduino -.->|"controls"| node_outputs
node_nested_arduino -.->|"controls"| node_outputs

click node_main "https://github.com/dzakyalfitra/smart-apd-detection/blob/master/Project%20Kendali%20Cerdas/od.py"
click node_nested_main "https://github.com/dzakyalfitra/smart-apd-detection/blob/master/Project%20Kendali%20Cerdas/Project%20Kendali%20Cerdas/od.py"
click node_distance "https://github.com/dzakyalfitra/smart-apd-detection/blob/master/Project%20Kendali%20Cerdas/import%20cv2.py"
click node_nested_distance "https://github.com/dzakyalfitra/smart-apd-detection/blob/master/Project%20Kendali%20Cerdas/Project%20Kendali%20Cerdas/import%20cv2.py"
click node_weights "https://github.com/dzakyalfitra/smart-apd-detection/blob/master/Project%20Kendali%20Cerdas/best.pt"
click node_nested_weights "https://github.com/dzakyalfitra/smart-apd-detection/blob/master/Project%20Kendali%20Cerdas/Project%20Kendali%20Cerdas/best.pt"
click node_training "https://github.com/dzakyalfitra/smart-apd-detection/blob/master/Project%20Kendali%20Cerdas/OD.ipynb"
click node_nested_training "https://github.com/dzakyalfitra/smart-apd-detection/blob/master/Project%20Kendali%20Cerdas/Project%20Kendali%20Cerdas/OD.ipynb"
click node_arduino "https://github.com/dzakyalfitra/smart-apd-detection/blob/master/Project%20Kendali%20Cerdas/sketch_nov11a/sketch_nov11a.ino"
click node_nested_arduino "https://github.com/dzakyalfitra/smart-apd-detection/blob/master/Project%20Kendali%20Cerdas/Project%20Kendali%20Cerdas/sketch_nov11a/sketch_nov11a.ino"

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_nested_main,node_distance,node_nested_distance toneBlue
class node_weights,node_nested_weights,node_training,node_nested_training toneAmber
class node_arduino,node_nested_arduino,node_outputs toneMint
class node_webcam toneIndigo
```

## Components

### Live Detection

- [Main Detector](https://github.com/dzakyalfitra/smart-apd-detection/blob/master/Project%20Kendali%20Cerdas/od.py): `Project Kendali Cerdas/od.py`
- [Nested Detector](https://github.com/dzakyalfitra/smart-apd-detection/blob/master/Project%20Kendali%20Cerdas/Project%20Kendali%20Cerdas/od.py): `Project Kendali Cerdas/Project Kendali Cerdas/od.py`
- [Distance Variant](https://github.com/dzakyalfitra/smart-apd-detection/blob/master/Project%20Kendali%20Cerdas/import%20cv2.py): `Project Kendali Cerdas/import cv2.py`
- [Nested Distance](https://github.com/dzakyalfitra/smart-apd-detection/blob/master/Project%20Kendali%20Cerdas/Project%20Kendali%20Cerdas/import%20cv2.py): `Project Kendali Cerdas/Project Kendali Cerdas/import cv2.py`

### Model Development

- [YOLO Weights](https://github.com/dzakyalfitra/smart-apd-detection/blob/master/Project%20Kendali%20Cerdas/best.pt): `Project Kendali Cerdas/best.pt`
- [Nested Weights](https://github.com/dzakyalfitra/smart-apd-detection/blob/master/Project%20Kendali%20Cerdas/Project%20Kendali%20Cerdas/best.pt): `Project Kendali Cerdas/Project Kendali Cerdas/best.pt`
- [YOLO Training](https://github.com/dzakyalfitra/smart-apd-detection/blob/master/Project%20Kendali%20Cerdas/OD.ipynb): `Project Kendali Cerdas/OD.ipynb`
- [Nested Training](https://github.com/dzakyalfitra/smart-apd-detection/blob/master/Project%20Kendali%20Cerdas/Project%20Kendali%20Cerdas/OD.ipynb): `Project Kendali Cerdas/Project Kendali Cerdas/OD.ipynb`

### Arduino Feedback

- [Arduino Firmware](https://github.com/dzakyalfitra/smart-apd-detection/blob/master/Project%20Kendali%20Cerdas/sketch_nov11a/sketch_nov11a.ino): `Project Kendali Cerdas/sketch_nov11a/sketch_nov11a.ino`
- [Nested Firmware](https://github.com/dzakyalfitra/smart-apd-detection/blob/master/Project%20Kendali%20Cerdas/Project%20Kendali%20Cerdas/sketch_nov11a/sketch_nov11a.ino): `Project Kendali Cerdas/Project Kendali Cerdas/sketch_nov11a/sketch_nov11a.ino`
- **LEDs and Buzzer**

### Other components

- **Webcam**

## Connections

- Webcam → Main Detector: provides frames (evidence: `Project Kendali Cerdas/od.py`)
- Webcam → Nested Detector: provides frames (evidence: `Project Kendali Cerdas/Project Kendali Cerdas/od.py`)
- Webcam → Distance Variant: provides frames (evidence: `Project Kendali Cerdas/import cv2.py`)
- Webcam → Nested Distance: provides frames (evidence: `Project Kendali Cerdas/Project Kendali Cerdas/import cv2.py`)
- Main Detector → YOLO Weights: loads model (evidence: `Project Kendali Cerdas/od.py`)
- Nested Detector → Nested Weights: loads model (evidence: `Project Kendali Cerdas/Project Kendali Cerdas/od.py`)
- Distance Variant → YOLO Weights: loads model (evidence: `Project Kendali Cerdas/import cv2.py`)
- Nested Distance → Nested Weights: loads model (evidence: `Project Kendali Cerdas/Project Kendali Cerdas/import cv2.py`)
- YOLO Training → YOLO Weights: trains weights (evidence: `README.md`)
- Nested Training → Nested Weights: trains weights (evidence: `README.md`)
- Main Detector → Arduino Firmware: sends serial states (evidence: `Project Kendali Cerdas/od.py`)
- Nested Detector → Nested Firmware: sends serial states (evidence: `README.md`)
- Arduino Firmware → LEDs and Buzzer: controls (evidence: `README.md`)
- Nested Firmware → LEDs and Buzzer: controls (evidence: `README.md`)
