# pangcrd/cyd-esp32-touchscreen-qr-web-ui architecture

> Architecture diagram of the GitHub repository pangcrd/cyd-esp32-touchscreen-qr-web-ui, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/pangcrd/cyd-esp32-touchscreen-qr-web-ui
- Repository: https://github.com/pangcrd/cyd-esp32-touchscreen-qr-web-ui

## Overview

This ESP32 firmware provides a touchscreen QR display with WiFi setup and a browser-facing web interface. The main loop initializes LVGL and the UI, then services the web server; browser-submitted text or URLs are turned into QR codes for the screen. On-device WiFi scanning and connection are handled separately, with credentials persisted in NVS and a device-address QR refreshed after connection. The README documents additional web assets, themes, and mDNS access. Several application modules it describes are absent from the supplied tree, so their paths and internal wiring cannot be verified here.

Main entry points: [`src/wifi_manager.cpp`](https://github.com/pangcrd/cyd-esp32-touchscreen-qr-web-ui/blob/main/src/wifi_manager.cpp) (WiFi manager), [`src/main.cpp`](https://github.com/pangcrd/cyd-esp32-touchscreen-qr-web-ui/blob/main/src/main.cpp) (Application loop), [`lib/lvgl-9.3.0/lvgl.h`](https://github.com/pangcrd/cyd-esp32-touchscreen-qr-web-ui/blob/main/lib/lvgl-9.3.0/lvgl.h) (LVGL runtime), [`lib/lvgl-9.3.0/src/draw/lv_draw.c`](https://github.com/pangcrd/cyd-esp32-touchscreen-qr-web-ui/blob/main/lib/lvgl-9.3.0/src/draw/lv_draw.c) (LVGL drawing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_firmware["Firmware runtime"]
  node_main["Application loop<br/>[main.cpp]"]
  node_port["LVGL port<br/>[lvgl_port.cpp]"]
  node_ntp["NTP service"]
end

subgraph group_network["Network access"]
  node_web["HTTP web server"]
  node_web_assets["Web assets"]
  node_mdns["mDNS discovery"]
  node_wifi["WiFi manager<br/>[wifi_manager.cpp]"]
  node_credentials[("WiFi credentials<br/>[wifi_manager.cpp]")]
  node_themes["Web themes"]
end

subgraph group_display["Touchscreen interface"]
  node_qr["QR generation"]
  node_ui["Device UI"]
  node_touch["Touch input"]
  node_brightness["Brightness control"]
end

subgraph group_lvgl["LVGL framework"]
  node_lvgl_runtime["LVGL runtime<br/>[lvgl.h]"]
  node_renderer["LVGL drawing<br/>[lv_draw.c]"]
end

node_browser(("Browser user"))
node_wifi_radio["WiFi network"]
node_nvs[("NVS storage")]
node_screen["Touch display"]

node_main -->|"initializes"| node_port
node_main -->|"initializes"| node_ui
node_main -->|"starts and updates"| node_ntp
node_main -->|"services"| node_web
node_browser -->|"submits text"| node_web
node_web -->|"serves"| node_web_assets
node_web -->|"passes content"| node_qr
node_qr -->|"provides QR"| node_ui
node_ui -->|"uses"| node_lvgl_runtime
node_lvgl_runtime -->|"dispatches drawing"| node_renderer
node_renderer -->|"renders"| node_screen
node_touch -->|"provides input"| node_lvgl_runtime
node_ui -->|"offers control"| node_brightness
node_web -->|"supports"| node_themes
node_wifi -->|"scans and connects"| node_wifi_radio
node_wifi -->|"updates WiFi list"| node_ui
node_wifi -->|"loads and saves"| node_credentials
node_credentials -->|"persists"| node_nvs
node_wifi -->|"updates address code"| node_qr
node_wifi -->|"initializes server"| node_web
node_mdns -.->|"advertises access"| node_web

click node_main "https://github.com/pangcrd/cyd-esp32-touchscreen-qr-web-ui/blob/main/src/main.cpp"
click node_port "https://github.com/pangcrd/cyd-esp32-touchscreen-qr-web-ui/blob/main/src/lvgl_port.cpp"
click node_wifi "https://github.com/pangcrd/cyd-esp32-touchscreen-qr-web-ui/blob/main/src/wifi_manager.cpp"
click node_credentials "https://github.com/pangcrd/cyd-esp32-touchscreen-qr-web-ui/blob/main/src/wifi_manager.cpp"
click node_lvgl_runtime "https://github.com/pangcrd/cyd-esp32-touchscreen-qr-web-ui/blob/main/lib/lvgl-9.3.0/lvgl.h"
click node_renderer "https://github.com/pangcrd/cyd-esp32-touchscreen-qr-web-ui/blob/main/lib/lvgl-9.3.0/src/draw/lv_draw.c"
click node_touch "https://github.com/pangcrd/cyd-esp32-touchscreen-qr-web-ui/blob/main/lib/XPT2046_Touchscreen/XPT2046_Touchscreen.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_port,node_ntp,node_browser toneBlue
class node_web,node_web_assets,node_mdns,node_wifi,node_credentials,node_themes,node_nvs toneAmber
class node_qr,node_ui,node_touch,node_brightness toneMint
class node_lvgl_runtime,node_renderer toneRose
class node_wifi_radio,node_screen toneIndigo
```

## Components

### Firmware runtime

- [Application loop](https://github.com/pangcrd/cyd-esp32-touchscreen-qr-web-ui/blob/main/src/main.cpp): `src/main.cpp`
- [LVGL port](https://github.com/pangcrd/cyd-esp32-touchscreen-qr-web-ui/blob/main/src/lvgl_port.cpp): `src/lvgl_port.cpp`
- **NTP service**

### Network access

- **HTTP web server**
- **Web assets**
- **mDNS discovery**
- [WiFi manager](https://github.com/pangcrd/cyd-esp32-touchscreen-qr-web-ui/blob/main/src/wifi_manager.cpp): `src/wifi_manager.cpp`
- [WiFi credentials](https://github.com/pangcrd/cyd-esp32-touchscreen-qr-web-ui/blob/main/src/wifi_manager.cpp): `src/wifi_manager.cpp`
- **Web themes**

### Touchscreen interface

- **QR generation**
- **Device UI**
- [Touch input](https://github.com/pangcrd/cyd-esp32-touchscreen-qr-web-ui/blob/main/lib/XPT2046_Touchscreen/XPT2046_Touchscreen.cpp): `lib/XPT2046_Touchscreen/XPT2046_Touchscreen.cpp`
- **Brightness control**

### LVGL framework

- [LVGL runtime](https://github.com/pangcrd/cyd-esp32-touchscreen-qr-web-ui/blob/main/lib/lvgl-9.3.0/lvgl.h): `lib/lvgl-9.3.0/lvgl.h`
- [LVGL drawing](https://github.com/pangcrd/cyd-esp32-touchscreen-qr-web-ui/blob/main/lib/lvgl-9.3.0/src/draw/lv_draw.c): `lib/lvgl-9.3.0/src/draw/lv_draw.c`

### Other components

- **Browser user**
- **WiFi network**
- **NVS storage**
- **Touch display**

## Connections

- Application loop → LVGL port: initializes
- Application loop → Device UI: initializes
- Application loop → NTP service: starts and updates
- Application loop → HTTP web server: services
- Browser user → HTTP web server: submits text
- HTTP web server → Web assets: serves
- HTTP web server → QR generation: passes content
- QR generation → Device UI: provides QR
- Device UI → LVGL runtime: uses
- LVGL runtime → LVGL drawing: dispatches drawing
- LVGL drawing → Touch display: renders
- Touch input → LVGL runtime: provides input
- Device UI → Brightness control: offers control
- HTTP web server → Web themes: supports
- WiFi manager → WiFi network: scans and connects
- WiFi manager → Device UI: updates WiFi list
- WiFi manager → WiFi credentials: loads and saves
- WiFi credentials → NVS storage: persists
- WiFi manager → QR generation: updates address code
- WiFi manager → HTTP web server: initializes server
- mDNS discovery → HTTP web server: advertises access
