# 7wp81x/duckesp architecture

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

- Interactive diagram: https://gitdiagram.com/7wp81x/duckesp
- Repository: https://github.com/7wp81x/duckesp

## Overview

DuckESP is ESP32 firmware controlled through a WiFi-hosted web interface. The main workflow is browser editing or uploading a DuckyScript, saving it to onboard storage, then running it as BLE keyboard input on a paired target. The README also documents settings, device scanning and name cloning. These responsibilities appear to live in one firmware file; the excerpts show only parts of its UI, handlers, interpreter and setup, so some documented links cite the README rather than sampled implementation.

Main entry points: [`src/main.cpp`](https://github.com/7wp81x/duckesp/blob/main/src/main.cpp) (Web interface)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web control"]
  node_browser["Web interface<br/>[main.cpp]"]
  node_webserver["HTTP server<br/>[main.cpp]"]
  node_wifi_ap["WiFi access point<br/>[main.cpp]"]
end

subgraph group_payload["Payload handling"]
  node_payload_editor["Script editor<br/>[main.cpp]"]
  node_upload["Script upload<br/>[main.cpp]"]
  node_profiles["Profile handlers<br/>[main.cpp]"]
  node_storage[("LittleFS storage<br/>[main.cpp]")]
  node_interpreter["Ducky interpreter<br/>[main.cpp]"]
end

subgraph group_wireless["Wireless device"]
  node_ble_keyboard["BLE keyboard<br/>[main.cpp]"]
  node_scanner["BLE scanner<br/>[main.cpp]"]
  node_clone["Device cloning<br/>[main.cpp]"]
end

subgraph group_config["Device configuration"]
  node_settings["Settings handlers<br/>[main.cpp]"]
  node_preferences[("Saved preferences<br/>[main.cpp]")]
end

node_operator(("Operator"))
node_target(("Paired target"))

node_operator -->|"controls"| node_browser
node_browser -->|"connects through"| node_wifi_ap
node_browser -->|"requests routes"| node_webserver
node_browser -->|"lists profiles"| node_profiles
node_browser -->|"uploads scripts"| node_upload
node_browser -->|"configures"| node_settings
node_browser -->|"starts scans"| node_scanner
node_browser -->|"requests clone"| node_clone
node_webserver -->|"routes requests"| node_profiles
node_upload -->|"saves scripts"| node_storage
node_profiles -->|"reads and writes"| node_storage
node_profiles -->|"runs payload"| node_interpreter
node_interpreter -->|"sends keystrokes"| node_ble_keyboard
node_ble_keyboard -->|"injects keystrokes"| node_target
node_scanner -->|"offers device names"| node_clone
node_clone -->|"stores BLE name"| node_preferences
node_settings -->|"saves configuration"| node_preferences
node_settings -->|"changes WiFi settings"| node_wifi_ap
node_settings -->|"changes advertised name"| node_ble_keyboard

click node_browser "https://github.com/7wp81x/duckesp/blob/main/src/main.cpp"
click node_webserver "https://github.com/7wp81x/duckesp/blob/main/src/main.cpp"
click node_payload_editor "https://github.com/7wp81x/duckesp/blob/main/src/main.cpp"
click node_upload "https://github.com/7wp81x/duckesp/blob/main/src/main.cpp"
click node_profiles "https://github.com/7wp81x/duckesp/blob/main/src/main.cpp"
click node_storage "https://github.com/7wp81x/duckesp/blob/main/src/main.cpp"
click node_interpreter "https://github.com/7wp81x/duckesp/blob/main/src/main.cpp"
click node_ble_keyboard "https://github.com/7wp81x/duckesp/blob/main/src/main.cpp"
click node_scanner "https://github.com/7wp81x/duckesp/blob/main/src/main.cpp"
click node_clone "https://github.com/7wp81x/duckesp/blob/main/src/main.cpp"
click node_settings "https://github.com/7wp81x/duckesp/blob/main/src/main.cpp"
click node_preferences "https://github.com/7wp81x/duckesp/blob/main/src/main.cpp"
click node_wifi_ap "https://github.com/7wp81x/duckesp/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_browser,node_webserver,node_wifi_ap toneBlue
class node_payload_editor,node_upload,node_profiles,node_storage,node_interpreter toneAmber
class node_ble_keyboard,node_scanner,node_clone toneMint
class node_settings,node_preferences toneRose
class node_operator,node_target toneIndigo
```

## Components

### Web control

- [Web interface](https://github.com/7wp81x/duckesp/blob/main/src/main.cpp): `src/main.cpp`
- [HTTP server](https://github.com/7wp81x/duckesp/blob/main/src/main.cpp): `src/main.cpp`
- [WiFi access point](https://github.com/7wp81x/duckesp/blob/main/src/main.cpp): `src/main.cpp`

### Payload handling

- [Script editor](https://github.com/7wp81x/duckesp/blob/main/src/main.cpp): `src/main.cpp`
- [Script upload](https://github.com/7wp81x/duckesp/blob/main/src/main.cpp): `src/main.cpp`
- [Profile handlers](https://github.com/7wp81x/duckesp/blob/main/src/main.cpp): `src/main.cpp`
- [LittleFS storage](https://github.com/7wp81x/duckesp/blob/main/src/main.cpp): `src/main.cpp`
- [Ducky interpreter](https://github.com/7wp81x/duckesp/blob/main/src/main.cpp): `src/main.cpp`

### Wireless device

- [BLE keyboard](https://github.com/7wp81x/duckesp/blob/main/src/main.cpp): `src/main.cpp`
- [BLE scanner](https://github.com/7wp81x/duckesp/blob/main/src/main.cpp): `src/main.cpp`
- [Device cloning](https://github.com/7wp81x/duckesp/blob/main/src/main.cpp): `src/main.cpp`

### Device configuration

- [Settings handlers](https://github.com/7wp81x/duckesp/blob/main/src/main.cpp): `src/main.cpp`
- [Saved preferences](https://github.com/7wp81x/duckesp/blob/main/src/main.cpp): `src/main.cpp`

### Other components

- **Operator**
- **Paired target**

## Connections

- Operator → Web interface: controls (evidence: `README.md`)
- Web interface → WiFi access point: connects through (evidence: `README.md`)
- Web interface → HTTP server: requests routes (evidence: `src/main.cpp`)
- Web interface → Profile handlers: lists profiles (evidence: `src/main.cpp`)
- Web interface → Script upload: uploads scripts (evidence: `src/main.cpp`)
- Web interface → Settings handlers: configures (evidence: `README.md`)
- Web interface → BLE scanner: starts scans (evidence: `src/main.cpp`)
- Web interface → Device cloning: requests clone (evidence: `src/main.cpp`)
- HTTP server → Profile handlers: routes requests (evidence: `src/main.cpp`)
- Script upload → LittleFS storage: saves scripts (evidence: `README.md`)
- Profile handlers → LittleFS storage: reads and writes (evidence: `README.md`)
- Profile handlers → Ducky interpreter: runs payload (evidence: `README.md`)
- Ducky interpreter → BLE keyboard: sends keystrokes (evidence: `README.md`)
- BLE keyboard → Paired target: injects keystrokes (evidence: `README.md`)
- BLE scanner → Device cloning: offers device names (evidence: `src/main.cpp`)
- Device cloning → Saved preferences: stores BLE name (evidence: `src/main.cpp`)
- Settings handlers → Saved preferences: saves configuration (evidence: `README.md`)
- Settings handlers → WiFi access point: changes WiFi settings (evidence: `README.md`)
- Settings handlers → BLE keyboard: changes advertised name (evidence: `README.md`)
