# xinnan-tech/xiaozhi-esp32-server architecture

> Architecture diagram of the GitHub repository xinnan-tech/xiaozhi-esp32-server, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/xinnan-tech/xiaozhi-esp32-server
- Repository: https://github.com/xinnan-tech/xiaozhi-esp32-server

## Overview

xiaozhi-esp32-server provides backend services for ESP32 conversational devices, plus a browser-based digital-human client and a wake-word runtime. The client workflow shown in sampled code is user audio/text input or wake-word detection, followed by WebSocket connection and audio interaction; the README describes broader device conversation capabilities, but the main conversation server is not present in the supplied tree. The manager API covers agent, device, model, knowledge, and account administration. Edges are limited to sampled calls or README-level capabilities; several manager internals are represented without inferred wiring.

Main entry points: [`main/digital-human/js/ui/controller.js`](https://github.com/xinnan-tech/xiaozhi-esp32-server/blob/main/main/digital-human/js/ui/controller.js) (UI controller), [`main/digital-human/js/core/network/wakeword-bridge.js`](https://github.com/xinnan-tech/xiaozhi-esp32-server/blob/main/main/digital-human/js/core/network/wakeword-bridge.js) (Wake-word bridge), [`main/digital-human/wakeword_runtime/runtime/app.py`](https://github.com/xinnan-tech/xiaozhi-esp32-server/blob/main/main/digital-human/wakeword_runtime/runtime/app.py) (Wake-word runtime), [`main/manager-api/src/main/java/xiaozhi/modules/device/controller/DeviceController.java`](https://github.com/xinnan-tech/xiaozhi-esp32-server/blob/main/main/manager-api/src/main/java/xiaozhi/modules/device/controller/DeviceController.java) (Device management)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Digital-human client"]
  node_ui["UI controller<br/>[controller.js]"]
  node_ws["WebSocket client<br/>[websocket.js]"]
  node_audio["Audio I/O<br/>[recorder.js]"]
  node_player["Audio playback<br/>[player.js]"]
  node_wakebridge["Wake-word bridge<br/>[wakeword-bridge.js]"]
end

subgraph group_wake["Wake-word runtime"]
  node_wakeapp["Wake-word runtime<br/>[app.py]"]
  node_detector["Wake detector<br/>[detector.py]"]
end

subgraph group_admin["Management API"]
  node_agentapi["Agent management"]
  node_deviceapi["Device management"]
  node_authapi["Login and auth"]
  node_modelapi["Model configuration"]
  node_knowledgeapi["Knowledge bases"]
  node_device_service["Device services<br/>[DeviceService.java]"]
  node_db[("Management data")]
end

subgraph group_services["AI and knowledge services"]
  node_llm["LLM summaries"]
  node_rag["RAGFlow client<br/>[RAGFlowClient.java]"]
  node_provider(("AI providers"))
  node_ragflow(("RAGFlow service"))
end

node_visitor(("User"))
node_esp(("ESP32 device"))

node_visitor -->|"uses"| node_ui
node_ui -->|"connects"| node_ws
node_ui -->|"controls recording"| node_audio
node_ui -->|"reads playback"| node_player
node_ui -->|"requests wake actions"| node_wakebridge
node_wakebridge -->|"bridges events"| node_wakeapp
node_wakeapp -->|"uses detector"| node_detector
node_esp -.->|"device administration"| node_deviceapi
node_visitor -->|"authenticates"| node_authapi
node_visitor -->|"manages agents"| node_agentapi
node_visitor -->|"manages devices"| node_deviceapi
node_visitor -->|"configures models"| node_modelapi
node_visitor -->|"manages knowledge"| node_knowledgeapi
node_device_service -.->|"device records"| node_db
node_llm -->|"sends model requests"| node_provider
node_rag -->|"HTTP requests"| node_ragflow

click node_ui "https://github.com/xinnan-tech/xiaozhi-esp32-server/blob/main/main/digital-human/js/ui/controller.js"
click node_ws "https://github.com/xinnan-tech/xiaozhi-esp32-server/blob/main/main/digital-human/js/core/network/websocket.js"
click node_audio "https://github.com/xinnan-tech/xiaozhi-esp32-server/blob/main/main/digital-human/js/core/audio/recorder.js"
click node_player "https://github.com/xinnan-tech/xiaozhi-esp32-server/blob/main/main/digital-human/js/core/audio/player.js"
click node_wakebridge "https://github.com/xinnan-tech/xiaozhi-esp32-server/blob/main/main/digital-human/js/core/network/wakeword-bridge.js"
click node_wakeapp "https://github.com/xinnan-tech/xiaozhi-esp32-server/blob/main/main/digital-human/wakeword_runtime/runtime/app.py"
click node_detector "https://github.com/xinnan-tech/xiaozhi-esp32-server/blob/main/main/digital-human/wakeword_runtime/core/detector.py"
click node_agentapi "https://github.com/xinnan-tech/xiaozhi-esp32-server/blob/main/main/manager-api/src/main/java/xiaozhi/modules/agent/controller/AgentController.java"
click node_deviceapi "https://github.com/xinnan-tech/xiaozhi-esp32-server/blob/main/main/manager-api/src/main/java/xiaozhi/modules/device/controller/DeviceController.java"
click node_authapi "https://github.com/xinnan-tech/xiaozhi-esp32-server/blob/main/main/manager-api/src/main/java/xiaozhi/modules/security/controller/LoginController.java"
click node_modelapi "https://github.com/xinnan-tech/xiaozhi-esp32-server/blob/main/main/manager-api/src/main/java/xiaozhi/modules/model/controller/ModelController.java"
click node_knowledgeapi "https://github.com/xinnan-tech/xiaozhi-esp32-server/blob/main/main/manager-api/src/main/java/xiaozhi/modules/knowledge/controller/KnowledgeBaseController.java"
click node_device_service "https://github.com/xinnan-tech/xiaozhi-esp32-server/blob/main/main/manager-api/src/main/java/xiaozhi/modules/device/service/DeviceService.java"
click node_llm "https://github.com/xinnan-tech/xiaozhi-esp32-server/blob/main/main/manager-api/src/main/java/xiaozhi/modules/llm/service/impl/OpenAIStyleLLMServiceImpl.java"
click node_rag "https://github.com/xinnan-tech/xiaozhi-esp32-server/blob/main/main/manager-api/src/main/java/xiaozhi/modules/knowledge/rag/RAGFlowClient.java"

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_ui,node_ws,node_audio,node_player,node_wakebridge,node_visitor toneBlue
class node_wakeapp,node_detector toneAmber
class node_agentapi,node_deviceapi,node_authapi,node_modelapi,node_knowledgeapi,node_device_service,node_db toneMint
class node_llm,node_rag,node_provider,node_ragflow toneRose
class node_esp toneIndigo
```

## Components

### Digital-human client

- [UI controller](https://github.com/xinnan-tech/xiaozhi-esp32-server/blob/main/main/digital-human/js/ui/controller.js): `main/digital-human/js/ui/controller.js`
- [WebSocket client](https://github.com/xinnan-tech/xiaozhi-esp32-server/blob/main/main/digital-human/js/core/network/websocket.js): `main/digital-human/js/core/network/websocket.js`
- [Audio I/O](https://github.com/xinnan-tech/xiaozhi-esp32-server/blob/main/main/digital-human/js/core/audio/recorder.js): `main/digital-human/js/core/audio/recorder.js`
- [Audio playback](https://github.com/xinnan-tech/xiaozhi-esp32-server/blob/main/main/digital-human/js/core/audio/player.js): `main/digital-human/js/core/audio/player.js`
- [Wake-word bridge](https://github.com/xinnan-tech/xiaozhi-esp32-server/blob/main/main/digital-human/js/core/network/wakeword-bridge.js): `main/digital-human/js/core/network/wakeword-bridge.js`

### Wake-word runtime

- [Wake-word runtime](https://github.com/xinnan-tech/xiaozhi-esp32-server/blob/main/main/digital-human/wakeword_runtime/runtime/app.py): `main/digital-human/wakeword_runtime/runtime/app.py`
- [Wake detector](https://github.com/xinnan-tech/xiaozhi-esp32-server/blob/main/main/digital-human/wakeword_runtime/core/detector.py): `main/digital-human/wakeword_runtime/core/detector.py`

### Management API

- [Agent management](https://github.com/xinnan-tech/xiaozhi-esp32-server/blob/main/main/manager-api/src/main/java/xiaozhi/modules/agent/controller/AgentController.java): `main/manager-api/src/main/java/xiaozhi/modules/agent/controller/AgentController.java`
- [Device management](https://github.com/xinnan-tech/xiaozhi-esp32-server/blob/main/main/manager-api/src/main/java/xiaozhi/modules/device/controller/DeviceController.java): `main/manager-api/src/main/java/xiaozhi/modules/device/controller/DeviceController.java`
- [Login and auth](https://github.com/xinnan-tech/xiaozhi-esp32-server/blob/main/main/manager-api/src/main/java/xiaozhi/modules/security/controller/LoginController.java): `main/manager-api/src/main/java/xiaozhi/modules/security/controller/LoginController.java`
- [Model configuration](https://github.com/xinnan-tech/xiaozhi-esp32-server/blob/main/main/manager-api/src/main/java/xiaozhi/modules/model/controller/ModelController.java): `main/manager-api/src/main/java/xiaozhi/modules/model/controller/ModelController.java`
- [Knowledge bases](https://github.com/xinnan-tech/xiaozhi-esp32-server/blob/main/main/manager-api/src/main/java/xiaozhi/modules/knowledge/controller/KnowledgeBaseController.java): `main/manager-api/src/main/java/xiaozhi/modules/knowledge/controller/KnowledgeBaseController.java`
- [Device services](https://github.com/xinnan-tech/xiaozhi-esp32-server/blob/main/main/manager-api/src/main/java/xiaozhi/modules/device/service/DeviceService.java): `main/manager-api/src/main/java/xiaozhi/modules/device/service/DeviceService.java`
- **Management data**

### AI and knowledge services

- [LLM summaries](https://github.com/xinnan-tech/xiaozhi-esp32-server/blob/main/main/manager-api/src/main/java/xiaozhi/modules/llm/service/impl/OpenAIStyleLLMServiceImpl.java): `main/manager-api/src/main/java/xiaozhi/modules/llm/service/impl/OpenAIStyleLLMServiceImpl.java`
- [RAGFlow client](https://github.com/xinnan-tech/xiaozhi-esp32-server/blob/main/main/manager-api/src/main/java/xiaozhi/modules/knowledge/rag/RAGFlowClient.java): `main/manager-api/src/main/java/xiaozhi/modules/knowledge/rag/RAGFlowClient.java`
- **AI providers**
- **RAGFlow service**

### Other components

- **User**
- **ESP32 device**

## Connections

- User → UI controller: uses
- UI controller → WebSocket client: connects
- UI controller → Audio I/O: controls recording
- UI controller → Audio playback: reads playback
- UI controller → Wake-word bridge: requests wake actions
- Wake-word bridge → Wake-word runtime: bridges events
- Wake-word runtime → Wake detector: uses detector
- ESP32 device → Device management: device administration
- User → Login and auth: authenticates
- User → Agent management: manages agents
- User → Device management: manages devices
- User → Model configuration: configures models
- User → Knowledge bases: manages knowledge
- Device services → Management data: device records
- LLM summaries → AI providers: sends model requests
- RAGFlow client → RAGFlow service: HTTP requests
