# maizeshark/desk-gui architecture

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

- Interactive diagram: https://gitdiagram.com/maizeshark/desk-gui
- Repository: https://github.com/maizeshark/desk-gui

## Overview

This is ESP32-S3 desk-control firmware: physical inputs and MQTT messages drive lighting, playback-related displays, and UI state. The main loop coordinates hardware input, MQTT processing, UI synchronization, volume publishing, and LED updates; music metadata can trigger an asynchronous album-art download. The graph preserves the documented Spotify, display, touch, encoder, and lighting capabilities. Some UI and MQTT implementation details were not excerpted, so those relationships are shown only where the README or shown callers support them.

Main entry points: [`src/frontend_ui/main.cpp`](https://github.com/maizeshark/desk-gui/blob/master/src/frontend_ui/main.cpp) (Firmware loop), [`src/frontend_ui/mqtt.cpp`](https://github.com/maizeshark/desk-gui/blob/master/src/frontend_ui/mqtt.cpp) (MQTT messaging), [`src/frontend_ui/music_player.cpp`](https://github.com/maizeshark/desk-gui/blob/master/src/frontend_ui/music_player.cpp) (Music and artwork), [`src/frontend_ui/lvgl_handler.cpp`](https://github.com/maizeshark/desk-gui/blob/master/src/frontend_ui/lvgl_handler.cpp) (LVGL drivers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application"]
  node_main["Firmware loop<br/>[main.cpp]"]
  node_state["Shared state<br/>[globals.h]"]
  node_music["Music and artwork<br/>[music_player.cpp]"]
end

subgraph group_interaction["User Interface"]
  node_lvgl["LVGL drivers<br/>[lvgl_handler.cpp]"]
  node_ui["Screens and sync<br/>[ui.cpp]"]
end

subgraph group_devices["Hardware"]
  node_hardware["Input and LEDs<br/>[hardware.cpp]"]
  node_display_config["Display configuration"]
end

subgraph group_services["Network Services"]
  node_mqtt["MQTT messaging<br/>[mqtt.cpp]"]
end

node_user(("Desk user"))
node_touch_display["Touch display"]
node_io_expander["TCA9535 controls"]
node_led_strip["WS2812B strip"]
node_broker["MQTT broker"]
node_spotify["Spotify service"]
node_image_host["Artwork host"]

node_user -->|"operates"| node_io_expander
node_io_expander -->|"provides inputs"| node_hardware
node_main -->|"initializes and polls"| node_hardware
node_hardware -->|"updates controls"| node_state
node_hardware -->|"updates LEDs"| node_led_strip
node_main -->|"initializes"| node_lvgl
node_main -->|"initializes and syncs"| node_ui
node_main -->|"runs client loop"| node_mqtt
node_main -->|"initializes"| node_music
node_lvgl -->|"uses display driver"| node_display_config
node_lvgl -->|"reads touch and draws"| node_touch_display
node_user -->|"touches"| node_touch_display
node_lvgl -->|"reads input state"| node_state
node_main -->|"uses shared state"| node_state
node_main -->|"publishes volume"| node_mqtt
node_mqtt -->|"publishes and subscribes"| node_broker
node_broker -->|"delivers messages"| node_mqtt
node_mqtt -->|"updates playback display"| node_ui
node_mqtt -->|"calls registered metadata callback"| node_music
node_music -->|"registers metadata callback"| node_mqtt
node_music -->|"downloads artwork"| node_image_host
node_music -->|"sets album art"| node_ui
node_spotify -.->|"supplies playback data"| node_broker

click node_main "https://github.com/maizeshark/desk-gui/blob/master/src/frontend_ui/main.cpp"
click node_state "https://github.com/maizeshark/desk-gui/blob/master/src/frontend_ui/globals.h"
click node_hardware "https://github.com/maizeshark/desk-gui/blob/master/src/frontend_ui/hardware.cpp"
click node_display_config "https://github.com/maizeshark/desk-gui/blob/master/src/frontend_ui/LGFX_ESP32_S3_MSP4031.hpp"
click node_lvgl "https://github.com/maizeshark/desk-gui/blob/master/src/frontend_ui/lvgl_handler.cpp"
click node_ui "https://github.com/maizeshark/desk-gui/blob/master/src/frontend_ui/ui.cpp"
click node_mqtt "https://github.com/maizeshark/desk-gui/blob/master/src/frontend_ui/mqtt.cpp"
click node_music "https://github.com/maizeshark/desk-gui/blob/master/src/frontend_ui/music_player.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_state,node_music,node_user toneBlue
class node_lvgl,node_ui toneAmber
class node_hardware,node_display_config toneMint
class node_mqtt toneRose
class node_touch_display,node_io_expander,node_led_strip,node_broker,node_spotify,node_image_host toneIndigo
```

## Components

### Application

- [Firmware loop](https://github.com/maizeshark/desk-gui/blob/master/src/frontend_ui/main.cpp): `src/frontend_ui/main.cpp`
- [Shared state](https://github.com/maizeshark/desk-gui/blob/master/src/frontend_ui/globals.h): `src/frontend_ui/globals.h`
- [Music and artwork](https://github.com/maizeshark/desk-gui/blob/master/src/frontend_ui/music_player.cpp): `src/frontend_ui/music_player.cpp`

### User Interface

- [LVGL drivers](https://github.com/maizeshark/desk-gui/blob/master/src/frontend_ui/lvgl_handler.cpp): `src/frontend_ui/lvgl_handler.cpp`
- [Screens and sync](https://github.com/maizeshark/desk-gui/blob/master/src/frontend_ui/ui.cpp): `src/frontend_ui/ui.cpp`

### Hardware

- [Input and LEDs](https://github.com/maizeshark/desk-gui/blob/master/src/frontend_ui/hardware.cpp): `src/frontend_ui/hardware.cpp`
- [Display configuration](https://github.com/maizeshark/desk-gui/blob/master/src/frontend_ui/LGFX_ESP32_S3_MSP4031.hpp): `src/frontend_ui/LGFX_ESP32_S3_MSP4031.hpp`

### Network Services

- [MQTT messaging](https://github.com/maizeshark/desk-gui/blob/master/src/frontend_ui/mqtt.cpp): `src/frontend_ui/mqtt.cpp`

### Other components

- **Desk user**
- **Touch display**
- **TCA9535 controls**
- **WS2812B strip**
- **MQTT broker**
- **Spotify service**
- **Artwork host**

## Connections

- Desk user → TCA9535 controls: operates (evidence: `README.md`)
- TCA9535 controls → Input and LEDs: provides inputs (evidence: `src/frontend_ui/hardware.cpp`)
- Firmware loop → Input and LEDs: initializes and polls (evidence: `src/frontend_ui/main.cpp`)
- Input and LEDs → Shared state: updates controls (evidence: `src/frontend_ui/hardware.cpp`)
- Input and LEDs → WS2812B strip: updates LEDs (evidence: `src/frontend_ui/hardware.cpp`)
- Firmware loop → LVGL drivers: initializes (evidence: `src/frontend_ui/main.cpp`)
- Firmware loop → Screens and sync: initializes and syncs (evidence: `src/frontend_ui/main.cpp`)
- Firmware loop → MQTT messaging: runs client loop (evidence: `src/frontend_ui/main.cpp`)
- Firmware loop → Music and artwork: initializes (evidence: `src/frontend_ui/main.cpp`)
- LVGL drivers → Display configuration: uses display driver (evidence: `src/frontend_ui/LGFX_ESP32_S3_MSP4031.hpp`)
- LVGL drivers → Touch display: reads touch and draws (evidence: `src/frontend_ui/lvgl_handler.cpp`)
- Desk user → Touch display: touches (evidence: `README.md`)
- LVGL drivers → Shared state: reads input state (evidence: `src/frontend_ui/lvgl_handler.cpp`)
- Firmware loop → Shared state: uses shared state (evidence: `src/frontend_ui/main.cpp`)
- Firmware loop → MQTT messaging: publishes volume (evidence: `src/frontend_ui/main.cpp`)
- MQTT messaging → MQTT broker: publishes and subscribes (evidence: `src/frontend_ui/mqtt.cpp`)
- MQTT broker → MQTT messaging: delivers messages (evidence: `src/frontend_ui/mqtt.cpp`)
- MQTT messaging → Screens and sync: updates playback display (evidence: `src/frontend_ui/mqtt.cpp`)
- MQTT messaging → Music and artwork: calls registered metadata callback (evidence: `src/frontend_ui/music_player.cpp`)
- Music and artwork → MQTT messaging: registers metadata callback (evidence: `src/frontend_ui/music_player.cpp`)
- Music and artwork → Artwork host: downloads artwork (evidence: `src/frontend_ui/music_player.cpp`)
- Music and artwork → Screens and sync: sets album art (evidence: `src/frontend_ui/music_player.cpp`)
- Spotify service → MQTT broker: supplies playback data (evidence: `README.md`)
