# sathiyasenpai/deskbot architecture

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

- Interactive diagram: https://gitdiagram.com/sathiyasenpai/deskbot
- Repository: https://github.com/sathiyasenpai/deskbot

## Overview

DeskBot is an ESP32 desktop companion paired with a Node.js brain on a phone or computer. The main interaction path is sensing and local behavior selection on the robot, WebSocket communication with the server for AI processing, then returning audio or status to the robot. The firmware also supports offline sensor-driven interaction, animated eyes and LEDs, servo gestures, and RTC alarms; Wi-Fi setup and a browser client are separate capabilities. Several server and firmware relationships are documented, but unsampled implementation details are not inferred.

Main entry points: [`esp32/src/main.cpp`](https://github.com/sathiyasenpai/deskbot/blob/main/esp32/src/main.cpp) (Interaction controller), [`server/ai-services.js`](https://github.com/sathiyasenpai/deskbot/blob/main/server/ai-services.js) (AI services), [`esp32/src/behaviors.h`](https://github.com/sathiyasenpai/deskbot/blob/main/esp32/src/behaviors.h) (Behavior states), [`esp32/src/websocket_client.h`](https://github.com/sathiyasenpai/deskbot/blob/main/esp32/src/websocket_client.h) (Robot WebSocket)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_firmware["Robot firmware"]
  node_controller["Interaction controller<br/>[main.cpp]"]
  node_behaviors["Behavior states<br/>[behaviors.h]"]
  node_eyes["Eye animation<br/>[eye_engine.h]"]
  node_wifi["Wi-Fi setup<br/>[wifi_manager.h]"]
  node_websocket["Robot WebSocket<br/>[websocket_client.h]"]
end

subgraph group_hardware["Sensing and actuation"]
  node_sensors["Touch and motion<br/>[sensors.h]"]
  node_microphone["Microphone capture<br/>[mic_manager.h]"]
  node_rtc["Clock and alarms<br/>[rtc_manager.h]"]
  node_servo["Servo gestures<br/>[servo_controller.h]"]
  node_leds["LED moods<br/>[led_controller.h]"]
  node_audio["Audio playback<br/>[audio_manager.h]"]
end

subgraph group_brain["Node.js brain"]
  node_server["Brain server<br/>[server.js]"]
  node_ai["AI services<br/>[ai-services.js]"]
end

subgraph group_client["Browser client"]
  node_browser["Browser client<br/>[app.js]"]
end

node_person(("Person"))
node_edge_tts["Edge TTS"]
node_piper["Piper TTS"]
node_ollama["Ollama LLM"]
node_groq_gemini["Groq or Gemini"]

node_person -->|"touches"| node_sensors
node_sensors -->|"reports input"| node_controller
node_microphone -->|"provides audio"| node_controller
node_rtc -->|"provides time and alarms"| node_controller
node_controller -->|"selects states"| node_behaviors
node_controller -->|"updates display"| node_eyes
node_controller -->|"triggers gestures"| node_servo
node_controller -->|"sets mood"| node_leds
node_controller -->|"plays audio"| node_audio
node_controller -->|"sends and receives"| node_websocket
node_controller -->|"connects network"| node_wifi
node_behaviors -->|"defines expressions"| node_eyes
node_websocket -->|"exchanges messages"| node_server
node_server -->|"delegates AI work"| node_ai
node_ai -.->|"generates speech"| node_edge_tts
node_ai -.->|"generates speech"| node_piper
node_ai -.->|"requests chat"| node_ollama
node_ai -.->|"requests chat"| node_groq_gemini
node_person -.->|"uses interface"| node_browser

click node_controller "https://github.com/sathiyasenpai/deskbot/blob/main/esp32/src/main.cpp"
click node_behaviors "https://github.com/sathiyasenpai/deskbot/blob/main/esp32/src/behaviors.h"
click node_eyes "https://github.com/sathiyasenpai/deskbot/blob/main/esp32/src/eye_engine.h"
click node_wifi "https://github.com/sathiyasenpai/deskbot/blob/main/esp32/src/wifi_manager.h"
click node_sensors "https://github.com/sathiyasenpai/deskbot/blob/main/esp32/src/sensors.h"
click node_microphone "https://github.com/sathiyasenpai/deskbot/blob/main/esp32/src/mic_manager.h"
click node_rtc "https://github.com/sathiyasenpai/deskbot/blob/main/esp32/src/rtc_manager.h"
click node_servo "https://github.com/sathiyasenpai/deskbot/blob/main/esp32/src/servo_controller.h"
click node_leds "https://github.com/sathiyasenpai/deskbot/blob/main/esp32/src/led_controller.h"
click node_audio "https://github.com/sathiyasenpai/deskbot/blob/main/esp32/src/audio_manager.h"
click node_websocket "https://github.com/sathiyasenpai/deskbot/blob/main/esp32/src/websocket_client.h"
click node_server "https://github.com/sathiyasenpai/deskbot/blob/main/server/server.js"
click node_ai "https://github.com/sathiyasenpai/deskbot/blob/main/server/ai-services.js"
click node_browser "https://github.com/sathiyasenpai/deskbot/blob/main/server/public/app.js"

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_controller,node_behaviors,node_eyes,node_wifi,node_websocket toneBlue
class node_sensors,node_microphone,node_rtc,node_servo,node_leds,node_audio toneAmber
class node_server,node_ai toneMint
class node_browser toneRose
class node_person,node_edge_tts,node_piper,node_ollama,node_groq_gemini toneIndigo
```

## Components

### Robot firmware

- [Interaction controller](https://github.com/sathiyasenpai/deskbot/blob/main/esp32/src/main.cpp): `esp32/src/main.cpp`
- [Behavior states](https://github.com/sathiyasenpai/deskbot/blob/main/esp32/src/behaviors.h): `esp32/src/behaviors.h`
- [Eye animation](https://github.com/sathiyasenpai/deskbot/blob/main/esp32/src/eye_engine.h): `esp32/src/eye_engine.h`
- [Wi-Fi setup](https://github.com/sathiyasenpai/deskbot/blob/main/esp32/src/wifi_manager.h): `esp32/src/wifi_manager.h`
- [Robot WebSocket](https://github.com/sathiyasenpai/deskbot/blob/main/esp32/src/websocket_client.h): `esp32/src/websocket_client.h`

### Sensing and actuation

- [Touch and motion](https://github.com/sathiyasenpai/deskbot/blob/main/esp32/src/sensors.h): `esp32/src/sensors.h`
- [Microphone capture](https://github.com/sathiyasenpai/deskbot/blob/main/esp32/src/mic_manager.h): `esp32/src/mic_manager.h`
- [Clock and alarms](https://github.com/sathiyasenpai/deskbot/blob/main/esp32/src/rtc_manager.h): `esp32/src/rtc_manager.h`
- [Servo gestures](https://github.com/sathiyasenpai/deskbot/blob/main/esp32/src/servo_controller.h): `esp32/src/servo_controller.h`
- [LED moods](https://github.com/sathiyasenpai/deskbot/blob/main/esp32/src/led_controller.h): `esp32/src/led_controller.h`
- [Audio playback](https://github.com/sathiyasenpai/deskbot/blob/main/esp32/src/audio_manager.h): `esp32/src/audio_manager.h`

### Node.js brain

- [Brain server](https://github.com/sathiyasenpai/deskbot/blob/main/server/server.js): `server/server.js`
- [AI services](https://github.com/sathiyasenpai/deskbot/blob/main/server/ai-services.js): `server/ai-services.js`

### Browser client

- [Browser client](https://github.com/sathiyasenpai/deskbot/blob/main/server/public/app.js): `server/public/app.js`

### Other components

- **Person**
- **Edge TTS**
- **Piper TTS**
- **Ollama LLM**
- **Groq or Gemini**

## Connections

- Person → Touch and motion: touches (evidence: `README.md`)
- Touch and motion → Interaction controller: reports input (evidence: `esp32/src/main.cpp`)
- Microphone capture → Interaction controller: provides audio (evidence: `esp32/src/main.cpp`)
- Clock and alarms → Interaction controller: provides time and alarms (evidence: `esp32/src/main.cpp`)
- Interaction controller → Behavior states: selects states (evidence: `esp32/src/main.cpp`)
- Interaction controller → Eye animation: updates display (evidence: `esp32/src/main.cpp`)
- Interaction controller → Servo gestures: triggers gestures (evidence: `esp32/src/main.cpp`)
- Interaction controller → LED moods: sets mood (evidence: `esp32/src/main.cpp`)
- Interaction controller → Audio playback: plays audio (evidence: `esp32/src/main.cpp`)
- Interaction controller → Robot WebSocket: sends and receives (evidence: `esp32/src/main.cpp`)
- Interaction controller → Wi-Fi setup: connects network (evidence: `esp32/src/main.cpp`)
- Behavior states → Eye animation: defines expressions (evidence: `esp32/src/eye_engine.h`)
- Robot WebSocket → Brain server: exchanges messages (evidence: `README.md`)
- Brain server → AI services: delegates AI work (evidence: `server/server.js`)
- AI services → Edge TTS: generates speech (evidence: `README.md`)
- AI services → Piper TTS: generates speech (evidence: `README.md`)
- AI services → Ollama LLM: requests chat (evidence: `README.md`)
- AI services → Groq or Gemini: requests chat (evidence: `README.md`)
- Person → Browser client: uses interface
