# mohamed-sellami04/hand-led-wifi architecture

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

- Interactive diagram: https://gitdiagram.com/mohamed-sellami04/hand-led-wifi
- Repository: https://github.com/mohamed-sellami04/hand-led-wifi

## Overview

This is a webcam-to-ESP32 controller: the Python application tracks a hand, maps its five fingers to a five-bit state, and sends that state to the ESP32 over HTTP; the firmware validates it and drives five GPIO-connected LEDs. The firmware also turns the LEDs off when Wi-Fi disconnects or commands stop arriving. The Python loop also displays tracking feedback, and sends an all-off state on exit. The source excerpts show both ends of the HTTP interaction; no separate storage or additional device integrations are evident.

Main entry points: [`computer/hand_control.py`](https://github.com/mohamed-sellami04/hand-led-wifi/blob/main/computer/hand_control.py) (Capture and tracking loop), [`src/main.cpp`](https://github.com/mohamed-sellami04/hand-led-wifi/blob/main/src/main.cpp) (HTTP server setup), [`computer/hand_landmarker.task`](https://github.com/mohamed-sellami04/hand-led-wifi/blob/main/computer/hand_landmarker.task) (Landmarker model)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_vision["Hand tracking"]
  node_python_loop["Capture and tracking loop<br/>[hand_control.py]"]
  node_landmarker["Hand landmarker<br/>[hand_control.py]"]
  node_model["Landmarker model"]
  node_finger_state["Finger state mapping<br/>[hand_control.py]"]
end

subgraph group_client["Python control"]
  node_send_schedule["Send scheduling<br/>[hand_control.py]"]
  node_http_sender["HTTP state sender<br/>[hand_control.py]"]
end

subgraph group_firmware["ESP32 firmware"]
  node_http_server["HTTP server setup<br/>[main.cpp]"]
  node_request_handler["LED request handler<br/>[main.cpp]"]
  node_timeout_check["Timeout and Wi-Fi check<br/>[main.cpp]"]
end

subgraph group_outputs["LED output"]
  node_led_pins["Five LED GPIOs<br/>[main.cpp]"]
end

node_webcam(("Webcam"))
node_esp32(("ESP32 device"))

node_webcam -->|"provides frames"| node_python_loop
node_python_loop -->|"detects frames"| node_landmarker
node_landmarker -->|"loads model"| node_model
node_python_loop -->|"maps landmarks"| node_finger_state
node_python_loop -->|"checks state"| node_send_schedule
node_send_schedule -->|"sends when due"| node_http_sender
node_http_sender -->|"sends HTTP state"| node_esp32
node_http_server -->|"routes /leds"| node_request_handler
node_esp32 -->|"receives HTTP"| node_http_server
node_request_handler -->|"sets GPIO levels"| node_led_pins
node_timeout_check -->|"turns LEDs off"| node_led_pins

click node_python_loop "https://github.com/mohamed-sellami04/hand-led-wifi/blob/main/computer/hand_control.py"
click node_landmarker "https://github.com/mohamed-sellami04/hand-led-wifi/blob/main/computer/hand_control.py"
click node_model "https://github.com/mohamed-sellami04/hand-led-wifi/blob/main/computer/hand_landmarker.task"
click node_finger_state "https://github.com/mohamed-sellami04/hand-led-wifi/blob/main/computer/hand_control.py"
click node_send_schedule "https://github.com/mohamed-sellami04/hand-led-wifi/blob/main/computer/hand_control.py"
click node_http_sender "https://github.com/mohamed-sellami04/hand-led-wifi/blob/main/computer/hand_control.py"
click node_http_server "https://github.com/mohamed-sellami04/hand-led-wifi/blob/main/src/main.cpp"
click node_request_handler "https://github.com/mohamed-sellami04/hand-led-wifi/blob/main/src/main.cpp"
click node_timeout_check "https://github.com/mohamed-sellami04/hand-led-wifi/blob/main/src/main.cpp"
click node_led_pins "https://github.com/mohamed-sellami04/hand-led-wifi/blob/main/src/main.cpp"

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_python_loop,node_landmarker,node_model,node_finger_state toneBlue
class node_send_schedule,node_http_sender toneAmber
class node_http_server,node_request_handler,node_timeout_check toneMint
class node_led_pins toneRose
class node_webcam,node_esp32 toneIndigo
```

## Components

### Hand tracking

- [Capture and tracking loop](https://github.com/mohamed-sellami04/hand-led-wifi/blob/main/computer/hand_control.py): `computer/hand_control.py`
- [Hand landmarker](https://github.com/mohamed-sellami04/hand-led-wifi/blob/main/computer/hand_control.py): `computer/hand_control.py`
- [Landmarker model](https://github.com/mohamed-sellami04/hand-led-wifi/blob/main/computer/hand_landmarker.task): `computer/hand_landmarker.task`
- [Finger state mapping](https://github.com/mohamed-sellami04/hand-led-wifi/blob/main/computer/hand_control.py): `computer/hand_control.py`

### Python control

- [Send scheduling](https://github.com/mohamed-sellami04/hand-led-wifi/blob/main/computer/hand_control.py): `computer/hand_control.py`
- [HTTP state sender](https://github.com/mohamed-sellami04/hand-led-wifi/blob/main/computer/hand_control.py): `computer/hand_control.py`

### ESP32 firmware

- [HTTP server setup](https://github.com/mohamed-sellami04/hand-led-wifi/blob/main/src/main.cpp): `src/main.cpp`
- [LED request handler](https://github.com/mohamed-sellami04/hand-led-wifi/blob/main/src/main.cpp): `src/main.cpp`
- [Timeout and Wi-Fi check](https://github.com/mohamed-sellami04/hand-led-wifi/blob/main/src/main.cpp): `src/main.cpp`

### LED output

- [Five LED GPIOs](https://github.com/mohamed-sellami04/hand-led-wifi/blob/main/src/main.cpp): `src/main.cpp`

### Other components

- **Webcam**
- **ESP32 device**

## Connections

- Webcam → Capture and tracking loop: provides frames (evidence: `computer/hand_control.py`)
- Capture and tracking loop → Hand landmarker: detects frames (evidence: `computer/hand_control.py`)
- Hand landmarker → Landmarker model: loads model (evidence: `computer/hand_control.py`)
- Capture and tracking loop → Finger state mapping: maps landmarks (evidence: `computer/hand_control.py`)
- Capture and tracking loop → Send scheduling: checks state (evidence: `computer/hand_control.py`)
- Send scheduling → HTTP state sender: sends when due (evidence: `computer/hand_control.py`)
- HTTP state sender → ESP32 device: sends HTTP state (evidence: `computer/hand_control.py`)
- HTTP server setup → LED request handler: routes /leds (evidence: `src/main.cpp`)
- ESP32 device → HTTP server setup: receives HTTP (evidence: `README.md`)
- LED request handler → Five LED GPIOs: sets GPIO levels (evidence: `src/main.cpp`)
- Timeout and Wi-Fi check → Five LED GPIOs: turns LEDs off (evidence: `src/main.cpp`)
