# nicolaschicunque/stackchan architecture

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

- Interactive diagram: https://gitdiagram.com/nicolaschicunque/stackchan
- Repository: https://github.com/nicolaschicunque/stackchan

## Overview

StackChan Community Suite is firmware for a StackChan robot, with mobile companion code and a server also present in the repository. The principal documented flow is user interaction through the launcher or voice interface, into a device capability, then to hardware, local media, or a network service. The graph preserves the README’s flagship capabilities and major optional branches. Several firmware app implementations and the server were not sampled; their internal calls are therefore not asserted.

Main entry points: [`firmware/main/apps/app_voice/app_voice.h`](https://github.com/nicolaschicunque/stackchan/blob/main/firmware/main/apps/app_voice/app_voice.h) (Voice OS), [`firmware/main/apps/common/music_engine.cpp`](https://github.com/nicolaschicunque/stackchan/blob/main/firmware/main/apps/common/music_engine.cpp) (Music and radio), [`firmware/main/apps/app_tv/app_tv.h`](https://github.com/nicolaschicunque/stackchan/blob/main/firmware/main/apps/app_tv/app_tv.h) (TV remote), [`firmware/main/apps/app_gemini/app_gemini.h`](https://github.com/nicolaschicunque/stackchan/blob/main/firmware/main/apps/app_gemini/app_gemini.h) (Gemini Live)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_device["Device firmware"]
  node_launcher["Launcher<br/>[app_launcher.cpp]"]
  node_setup["Setup<br/>[app_setup.cpp]"]
  node_avatar["Avatar<br/>[app_avatar.cpp]"]
  node_hardware["Hardware layer<br/>[hal.cpp]"]
end

subgraph group_voice["Voice and AI"]
  node_voiceapp["Voice OS<br/>[app_voice.h]"]
  node_wake["Wake detection"]
  node_gemini["Gemini Live<br/>[app_gemini.h]"]
  node_mcp["MCP bridge<br/>[app_mcp.h]"]
end

subgraph group_media["Media and control"]
  node_music["Music and radio<br/>[music_engine.cpp]"]
  node_musicweb["Music web remote"]
  node_alarm["Alarm and timer<br/>[alarm_service.cpp]"]
  node_speaker["Speaker<br/>[app_speaker.h]"]
  node_speakerweb["Speaker web service"]
  node_tv["TV remote<br/>[app_tv.h]"]
  node_tvservice["TV control service"]
  node_alarmservice["Alarm service<br/>[alarm_service.cpp]"]
end

subgraph group_platform["Community platform"]
  node_store["App Center<br/>[app_app_center.cpp]"]
  node_labs["Community apps"]
  node_server["Community API"]
end

subgraph group_mobile["Mobile companions"]
  node_android["Android companion<br/>[MainActivity.kt]"]
  node_androidbt["Android Bluetooth"]
  node_iosar["iOS AR view"]
end

node_user(("Robot user"))
node_geminiservice{{"Gemini Live API"}}
node_mcp_host{{"Optional PC host"}}
node_internet{{"Internet radio"}}
node_tvnetwork{{"Android TV devices"}}
node_ota{{"Firmware catalogs"}}
node_usb{{"USB-C audio"}}

node_user -->|"opens apps"| node_launcher
node_user -->|"speaks to"| node_voiceapp
node_voiceapp -->|"detects wake"| node_wake
node_voiceapp -->|"uses assistant"| node_gemini
node_gemini -->|"connects by WSS"| node_geminiservice
node_gemini -->|"escalates tasks"| node_mcp
node_mcp -.->|"bridges optionally"| node_mcp_host
node_voiceapp -->|"controls playback"| node_music
node_voiceapp -->|"controls alarms"| node_alarmservice
node_voiceapp -->|"controls TVs"| node_tv
node_user -->|"plays media"| node_music
node_music -->|"offers web remote"| node_musicweb
node_music -->|"streams radio"| node_internet
node_user -->|"sets timers"| node_alarm
node_user -->|"selects speaker"| node_speaker
node_speaker -->|"offers web audio"| node_speakerweb
node_speaker -->|"outputs UAC2"| node_usb
node_user -->|"pairs and controls"| node_tv
node_tv -->|"uses remote service"| node_tvservice
node_tv -->|"controls over LAN"| node_tvnetwork
node_user -->|"installs apps"| node_store
node_store -->|"fetches firmware"| node_ota
node_user -->|"customizes appearance"| node_avatar
node_user -->|"configures features"| node_setup
node_android -->|"sets up bridge"| node_androidbt
node_iosar -.->|"renders AR face"| node_user

click node_launcher "https://github.com/nicolaschicunque/stackchan/blob/main/firmware/main/apps/app_launcher/app_launcher.cpp"
click node_setup "https://github.com/nicolaschicunque/stackchan/blob/main/firmware/main/apps/app_setup/app_setup.cpp"
click node_avatar "https://github.com/nicolaschicunque/stackchan/blob/main/firmware/main/apps/app_avatar/app_avatar.cpp"
click node_hardware "https://github.com/nicolaschicunque/stackchan/blob/main/firmware/main/hal/hal.cpp"
click node_voiceapp "https://github.com/nicolaschicunque/stackchan/blob/main/firmware/main/apps/app_voice/app_voice.h"
click node_wake "https://github.com/nicolaschicunque/stackchan/blob/main/firmware/main/apps/app_voice/voice_wake_engine.cpp"
click node_gemini "https://github.com/nicolaschicunque/stackchan/blob/main/firmware/main/apps/app_gemini/app_gemini.h"
click node_mcp "https://github.com/nicolaschicunque/stackchan/blob/main/firmware/main/apps/app_mcp/app_mcp.h"
click node_music "https://github.com/nicolaschicunque/stackchan/blob/main/firmware/main/apps/common/music_engine.cpp"
click node_musicweb "https://github.com/nicolaschicunque/stackchan/blob/main/firmware/main/apps/app_music_player/music_wifi_service.cpp"
click node_alarm "https://github.com/nicolaschicunque/stackchan/blob/main/firmware/main/apps/app_alarm/alarm_service.cpp"
click node_speaker "https://github.com/nicolaschicunque/stackchan/blob/main/firmware/main/apps/app_speaker/app_speaker.h"
click node_speakerweb "https://github.com/nicolaschicunque/stackchan/blob/main/firmware/main/apps/app_speaker/speaker_wifi_service.cpp"
click node_tv "https://github.com/nicolaschicunque/stackchan/blob/main/firmware/main/apps/app_tv/app_tv.h"
click node_tvservice "https://github.com/nicolaschicunque/stackchan/blob/main/firmware/main/apps/common/tv_remote_service.cpp"
click node_alarmservice "https://github.com/nicolaschicunque/stackchan/blob/main/firmware/main/apps/app_alarm/alarm_service.cpp"
click node_store "https://github.com/nicolaschicunque/stackchan/blob/main/firmware/main/apps/app_app_center/app_app_center.cpp"
click node_labs "https://github.com/nicolaschicunque/stackchan/tree/main/firmware/main/apps"
click node_server "https://github.com/nicolaschicunque/stackchan/tree/main/server/api"
click node_android "https://github.com/nicolaschicunque/stackchan/blob/main/app/android/app/src/main/kotlin/com/m5stack/stackchan/MainActivity.kt"
click node_androidbt "https://github.com/nicolaschicunque/stackchan/blob/main/app/android/app/src/main/kotlin/com/m5stack/stackchan/bluetooth/NativeBluetoothBridge.kt"
click node_iosar "https://github.com/nicolaschicunque/stackchan/blob/main/app/ios/Runner/View/StackChanArView.swift"

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_launcher,node_setup,node_avatar,node_hardware,node_user toneBlue
class node_voiceapp,node_wake,node_gemini,node_mcp toneAmber
class node_music,node_musicweb,node_alarm,node_speaker,node_speakerweb,node_tv,node_tvservice,node_alarmservice,node_geminiservice toneMint
class node_store,node_labs,node_server toneRose
class node_android,node_androidbt,node_iosar,node_mcp_host,node_internet,node_tvnetwork,node_ota,node_usb toneIndigo
```

## Components

### Device firmware

- [Launcher](https://github.com/nicolaschicunque/stackchan/blob/main/firmware/main/apps/app_launcher/app_launcher.cpp): `firmware/main/apps/app_launcher/app_launcher.cpp`
- [Setup](https://github.com/nicolaschicunque/stackchan/blob/main/firmware/main/apps/app_setup/app_setup.cpp): `firmware/main/apps/app_setup/app_setup.cpp`
- [Avatar](https://github.com/nicolaschicunque/stackchan/blob/main/firmware/main/apps/app_avatar/app_avatar.cpp): `firmware/main/apps/app_avatar/app_avatar.cpp`
- [Hardware layer](https://github.com/nicolaschicunque/stackchan/blob/main/firmware/main/hal/hal.cpp): `firmware/main/hal/hal.cpp`

### Voice and AI

- [Voice OS](https://github.com/nicolaschicunque/stackchan/blob/main/firmware/main/apps/app_voice/app_voice.h): `firmware/main/apps/app_voice/app_voice.h`
- [Wake detection](https://github.com/nicolaschicunque/stackchan/blob/main/firmware/main/apps/app_voice/voice_wake_engine.cpp): `firmware/main/apps/app_voice/voice_wake_engine.cpp`
- [Gemini Live](https://github.com/nicolaschicunque/stackchan/blob/main/firmware/main/apps/app_gemini/app_gemini.h): `firmware/main/apps/app_gemini/app_gemini.h`
- [MCP bridge](https://github.com/nicolaschicunque/stackchan/blob/main/firmware/main/apps/app_mcp/app_mcp.h): `firmware/main/apps/app_mcp/app_mcp.h`

### Media and control

- [Music and radio](https://github.com/nicolaschicunque/stackchan/blob/main/firmware/main/apps/common/music_engine.cpp): `firmware/main/apps/common/music_engine.cpp`
- [Music web remote](https://github.com/nicolaschicunque/stackchan/blob/main/firmware/main/apps/app_music_player/music_wifi_service.cpp): `firmware/main/apps/app_music_player/music_wifi_service.cpp`
- [Alarm and timer](https://github.com/nicolaschicunque/stackchan/blob/main/firmware/main/apps/app_alarm/alarm_service.cpp): `firmware/main/apps/app_alarm/alarm_service.cpp`
- [Speaker](https://github.com/nicolaschicunque/stackchan/blob/main/firmware/main/apps/app_speaker/app_speaker.h): `firmware/main/apps/app_speaker/app_speaker.h`
- [Speaker web service](https://github.com/nicolaschicunque/stackchan/blob/main/firmware/main/apps/app_speaker/speaker_wifi_service.cpp): `firmware/main/apps/app_speaker/speaker_wifi_service.cpp`
- [TV remote](https://github.com/nicolaschicunque/stackchan/blob/main/firmware/main/apps/app_tv/app_tv.h): `firmware/main/apps/app_tv/app_tv.h`
- [TV control service](https://github.com/nicolaschicunque/stackchan/blob/main/firmware/main/apps/common/tv_remote_service.cpp): `firmware/main/apps/common/tv_remote_service.cpp`
- [Alarm service](https://github.com/nicolaschicunque/stackchan/blob/main/firmware/main/apps/app_alarm/alarm_service.cpp): `firmware/main/apps/app_alarm/alarm_service.cpp`

### Community platform

- [App Center](https://github.com/nicolaschicunque/stackchan/blob/main/firmware/main/apps/app_app_center/app_app_center.cpp): `firmware/main/apps/app_app_center/app_app_center.cpp`
- [Community apps](https://github.com/nicolaschicunque/stackchan/tree/main/firmware/main/apps): `firmware/main/apps`
- [Community API](https://github.com/nicolaschicunque/stackchan/tree/main/server/api): `server/api`

### Mobile companions

- [Android companion](https://github.com/nicolaschicunque/stackchan/blob/main/app/android/app/src/main/kotlin/com/m5stack/stackchan/MainActivity.kt): `app/android/app/src/main/kotlin/com/m5stack/stackchan/MainActivity.kt`
- [Android Bluetooth](https://github.com/nicolaschicunque/stackchan/blob/main/app/android/app/src/main/kotlin/com/m5stack/stackchan/bluetooth/NativeBluetoothBridge.kt): `app/android/app/src/main/kotlin/com/m5stack/stackchan/bluetooth/NativeBluetoothBridge.kt`
- [iOS AR view](https://github.com/nicolaschicunque/stackchan/blob/main/app/ios/Runner/View/StackChanArView.swift): `app/ios/Runner/View/StackChanArView.swift`

### Other components

- **Robot user**
- **Gemini Live API**
- **Optional PC host**
- **Internet radio**
- **Android TV devices**
- **Firmware catalogs**
- **USB-C audio**

## Connections

- Robot user → Launcher: opens apps
- Robot user → Voice OS: speaks to
- Voice OS → Wake detection: detects wake
- Voice OS → Gemini Live: uses assistant
- Gemini Live → Gemini Live API: connects by WSS
- Gemini Live → MCP bridge: escalates tasks
- MCP bridge → Optional PC host: bridges optionally
- Voice OS → Music and radio: controls playback
- Voice OS → Alarm service: controls alarms
- Voice OS → TV remote: controls TVs
- Robot user → Music and radio: plays media
- Music and radio → Music web remote: offers web remote
- Music and radio → Internet radio: streams radio
- Robot user → Alarm and timer: sets timers
- Robot user → Speaker: selects speaker
- Speaker → Speaker web service: offers web audio
- Speaker → USB-C audio: outputs UAC2
- Robot user → TV remote: pairs and controls
- TV remote → TV control service: uses remote service
- TV remote → Android TV devices: controls over LAN
- Robot user → App Center: installs apps
- App Center → Firmware catalogs: fetches firmware
- Robot user → Avatar: customizes appearance
- Robot user → Setup: configures features
- Android companion → Android Bluetooth: sets up bridge (evidence: `app/android/app/src/main/kotlin/com/m5stack/stackchan/MainActivity.kt`)
- iOS AR view → Robot user: renders AR face
