# biologist79/espuino architecture

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

- Interactive diagram: https://gitdiagram.com/biologist79/espuino
- Repository: https://github.com/biologist79/espuino

## Overview

ESPuino is an ESP32 RFID-controlled audio player. Its primary workflow is assigning audio to a tag through the web interface, then scanning that tag to load the assignment and start playback. The firmware also supports physical controls, LED feedback, web streams, Bluetooth audio, file transfer, MQTT, and a REST API. The graph uses documented product flows and visible calls from the main loop; several peripheral implementations were not sampled, so their internal connections are omitted.

Main entry points: [`src/main.cpp`](https://github.com/biologist79/espuino/blob/master/src/main.cpp) (Firmware loop), [`src/AudioPlayer.cpp`](https://github.com/biologist79/espuino/blob/master/src/AudioPlayer.cpp) (Audio playback), [`src/Web.cpp`](https://github.com/biologist79/espuino/blob/master/src/Web.cpp) (Web interface), [`src/RfidConfig.cpp`](https://github.com/biologist79/espuino/blob/master/src/RfidConfig.cpp) (RFID assignments)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Firmware runtime"]
  node_main["Firmware loop<br/>[main.cpp]"]
  node_commands["Command handling<br/>[Cmd.cpp]"]
  node_system["Power and state<br/>[System.cpp]"]
end

subgraph group_media["Playback and media"]
  node_rfidconfig[("RFID assignments<br/>[RfidConfig.cpp]")]
  node_sd[("SD card files<br/>[SdCard.cpp]")]
  node_audio["Audio playback<br/>[AudioPlayer.cpp]"]
  node_stream["Web streams<br/>[AudioPlayer.cpp]"]
end

subgraph group_controls["Controls and hardware"]
  node_rfid["RFID reader<br/>[RfidRuntime.cpp]"]
  node_button["Buttons<br/>[Button.cpp]"]
  node_encoder["Rotary encoder<br/>[RotaryEncoder.cpp]"]
  node_led["LED feedback<br/>[Led.cpp]"]
  node_battery["Battery monitoring<br/>[Battery.cpp]"]
end

subgraph group_network["Network interfaces"]
  node_web["Web interface<br/>[Web.cpp]"]
  node_rest["REST API<br/>[Web.cpp]"]
  node_bluetooth["Bluetooth audio<br/>[Bluetooth.cpp]"]
  node_wlan["Wi-Fi<br/>[Wlan.cpp]"]
  node_mqtt["MQTT<br/>[Mqtt.cpp]"]
  node_ftp["FTP server<br/>[Ftp.cpp]"]
end

node_listener(("Listener"))
node_phone(("Phone"))
node_networkservice(("Network services"))

node_listener -->|"presents tag"| node_rfid
node_rfid -->|"looks up tag"| node_rfidconfig
node_rfidconfig -->|"selects media"| node_audio
node_web -->|"saves assignment"| node_rfidconfig
node_web -->|"browses and uploads"| node_sd
node_ftp -->|"copies files"| node_sd
node_audio -->|"reads local audio"| node_sd
node_audio -->|"plays streams"| node_stream
node_phone -->|"streams audio"| node_bluetooth
node_button -->|"dispatches actions"| node_commands
node_encoder -.->|"dispatches actions"| node_commands
node_main -->|"cycles"| node_button
node_main -->|"cycles"| node_audio
node_main -->|"cycles"| node_system
node_main -->|"cycles"| node_wlan
node_main -->|"cycles"| node_web
node_main -->|"cycles"| node_ftp
node_main -->|"cycles"| node_bluetooth
node_main -->|"initializes"| node_mqtt
node_main -->|"initializes"| node_rfid
node_main -->|"initializes"| node_led
node_main -->|"cycles"| node_battery
node_networkservice -->|"uses interface"| node_web
node_networkservice -->|"calls API"| node_rest
node_networkservice -->|"uses messaging"| node_mqtt

click node_main "https://github.com/biologist79/espuino/blob/master/src/main.cpp"
click node_rfid "https://github.com/biologist79/espuino/blob/master/src/RfidRuntime.cpp"
click node_rfidconfig "https://github.com/biologist79/espuino/blob/master/src/RfidConfig.cpp"
click node_web "https://github.com/biologist79/espuino/blob/master/src/Web.cpp"
click node_rest "https://github.com/biologist79/espuino/blob/master/src/Web.cpp"
click node_sd "https://github.com/biologist79/espuino/blob/master/src/SdCard.cpp"
click node_audio "https://github.com/biologist79/espuino/blob/master/src/AudioPlayer.cpp"
click node_stream "https://github.com/biologist79/espuino/blob/master/src/AudioPlayer.cpp"
click node_bluetooth "https://github.com/biologist79/espuino/blob/master/src/Bluetooth.cpp"
click node_button "https://github.com/biologist79/espuino/blob/master/src/Button.cpp"
click node_encoder "https://github.com/biologist79/espuino/blob/master/src/RotaryEncoder.cpp"
click node_commands "https://github.com/biologist79/espuino/blob/master/src/Cmd.cpp"
click node_led "https://github.com/biologist79/espuino/blob/master/src/Led.cpp"
click node_battery "https://github.com/biologist79/espuino/blob/master/src/Battery.cpp"
click node_system "https://github.com/biologist79/espuino/blob/master/src/System.cpp"
click node_wlan "https://github.com/biologist79/espuino/blob/master/src/Wlan.cpp"
click node_mqtt "https://github.com/biologist79/espuino/blob/master/src/Mqtt.cpp"
click node_ftp "https://github.com/biologist79/espuino/blob/master/src/Ftp.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_main,node_commands,node_system toneBlue
class node_rfidconfig,node_sd,node_audio,node_stream toneAmber
class node_rfid,node_button,node_encoder,node_led,node_battery toneMint
class node_web,node_rest,node_bluetooth,node_wlan,node_mqtt,node_ftp toneRose
class node_listener,node_phone,node_networkservice toneIndigo
```

## Components

### Firmware runtime

- [Firmware loop](https://github.com/biologist79/espuino/blob/master/src/main.cpp): `src/main.cpp`
- [Command handling](https://github.com/biologist79/espuino/blob/master/src/Cmd.cpp): `src/Cmd.cpp`
- [Power and state](https://github.com/biologist79/espuino/blob/master/src/System.cpp): `src/System.cpp`

### Playback and media

- [RFID assignments](https://github.com/biologist79/espuino/blob/master/src/RfidConfig.cpp): `src/RfidConfig.cpp`
- [SD card files](https://github.com/biologist79/espuino/blob/master/src/SdCard.cpp): `src/SdCard.cpp`
- [Audio playback](https://github.com/biologist79/espuino/blob/master/src/AudioPlayer.cpp): `src/AudioPlayer.cpp`
- [Web streams](https://github.com/biologist79/espuino/blob/master/src/AudioPlayer.cpp): `src/AudioPlayer.cpp`

### Controls and hardware

- [RFID reader](https://github.com/biologist79/espuino/blob/master/src/RfidRuntime.cpp): `src/RfidRuntime.cpp`
- [Buttons](https://github.com/biologist79/espuino/blob/master/src/Button.cpp): `src/Button.cpp`
- [Rotary encoder](https://github.com/biologist79/espuino/blob/master/src/RotaryEncoder.cpp): `src/RotaryEncoder.cpp`
- [LED feedback](https://github.com/biologist79/espuino/blob/master/src/Led.cpp): `src/Led.cpp`
- [Battery monitoring](https://github.com/biologist79/espuino/blob/master/src/Battery.cpp): `src/Battery.cpp`

### Network interfaces

- [Web interface](https://github.com/biologist79/espuino/blob/master/src/Web.cpp): `src/Web.cpp`
- [REST API](https://github.com/biologist79/espuino/blob/master/src/Web.cpp): `src/Web.cpp`
- [Bluetooth audio](https://github.com/biologist79/espuino/blob/master/src/Bluetooth.cpp): `src/Bluetooth.cpp`
- [Wi-Fi](https://github.com/biologist79/espuino/blob/master/src/Wlan.cpp): `src/Wlan.cpp`
- [MQTT](https://github.com/biologist79/espuino/blob/master/src/Mqtt.cpp): `src/Mqtt.cpp`
- [FTP server](https://github.com/biologist79/espuino/blob/master/src/Ftp.cpp): `src/Ftp.cpp`

### Other components

- **Listener**
- **Phone**
- **Network services**

## Connections

- Listener → RFID reader: presents tag
- RFID reader → RFID assignments: looks up tag
- RFID assignments → Audio playback: selects media
- Web interface → RFID assignments: saves assignment
- Web interface → SD card files: browses and uploads
- FTP server → SD card files: copies files
- Audio playback → SD card files: reads local audio
- Audio playback → Web streams: plays streams (evidence: `src/AudioPlayer.cpp`)
- Phone → Bluetooth audio: streams audio
- Buttons → Command handling: dispatches actions
- Rotary encoder → Command handling: dispatches actions
- Firmware loop → Buttons: cycles (evidence: `src/main.cpp`)
- Firmware loop → Audio playback: cycles (evidence: `src/main.cpp`)
- Firmware loop → Power and state: cycles (evidence: `src/main.cpp`)
- Firmware loop → Wi-Fi: cycles (evidence: `src/main.cpp`)
- Firmware loop → Web interface: cycles (evidence: `src/main.cpp`)
- Firmware loop → FTP server: cycles (evidence: `src/main.cpp`)
- Firmware loop → Bluetooth audio: cycles (evidence: `src/main.cpp`)
- Firmware loop → MQTT: initializes (evidence: `src/main.cpp`)
- Firmware loop → RFID reader: initializes (evidence: `src/main.cpp`)
- Firmware loop → LED feedback: initializes (evidence: `src/main.cpp`)
- Firmware loop → Battery monitoring: cycles (evidence: `src/main.cpp`)
- Network services → Web interface: uses interface
- Network services → REST API: calls API
- Network services → MQTT: uses messaging
