# aric-davison/llmbot architecture

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

- Interactive diagram: https://gitdiagram.com/aric-davison/llmbot
- Repository: https://github.com/aric-davison/llmbot

## Overview

LLMbot is a local AI-powered Discord voice bot. A user joins a voice channel, speaks, and receives a spoken response: voice capture and VAD produce audio for the STT → LLM → TTS pipeline, whose output is played back into the channel. The graph preserves the documented model lifecycle and conversation memory alongside voice management, playback, state, and file cleanup. Relationships for unsampled modules are included only where the README or SOURCE INDEX supports them; implementation details beyond the excerpts are not assumed.

Main entry points: [`src/services/pipelineOrchestrator.js`](https://github.com/aric-davison/llmbot/blob/main/src/services/pipelineOrchestrator.js) (Pipeline orchestration), [`src/services/voiceManager.js`](https://github.com/aric-davison/llmbot/blob/main/src/services/voiceManager.js) (Voice lifecycle), [`src/utils/config.js`](https://github.com/aric-davison/llmbot/blob/main/src/utils/config.js) (Configuration), [`src/services/whisperService.js`](https://github.com/aric-davison/llmbot/blob/main/src/services/whisperService.js) (Speech recognition)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_discord["Discord and Voice"]
  node_commands["Join and leave"]
  node_discord_client["Discord gateway<br/>[discordClient.js]"]
  node_voice_manager["Voice lifecycle<br/>[voiceManager.js]"]
  node_audio_processor["VAD and capture<br/>[audioProcessor.js]"]
  node_playback["Audio playback"]
end

subgraph group_pipeline["Conversation Pipeline"]
  node_pipeline_orchestrator["Pipeline orchestration"]
  node_conversation["Conversation memory"]
  node_state_machine["Voice state<br/>[stateMachine.js]"]
end

subgraph group_models["Local AI Models"]
  node_whisper["Speech recognition<br/>[whisperService.js]"]
  node_llama_client["LLM queries<br/>[llamaCppClient.js]"]
  node_llama_server["LLM server lifecycle<br/>[llamaServer.js]"]
  node_xtts["Speech synthesis<br/>[xttsService.js]"]
end

subgraph group_runtime["Runtime Support"]
  node_audio_files["Audio file lifecycle"]
  node_config["Configuration<br/>[config.js]"]
  node_error_monitor["Error monitoring<br/>[errorMonitor.js]"]
  node_error_logger["Structured errors<br/>[errorLogger.js]"]
  node_logger["Structured logging<br/>[logger.js]"]
end

node_user(("Voice participant"))

node_user -->|"issues commands"| node_commands
node_commands -.->|"joins or leaves"| node_voice_manager
node_user -->|"speaks in channel"| node_voice_manager
node_discord_client -.->|"manages voice"| node_voice_manager
node_voice_manager -->|"captures audio"| node_audio_processor
node_audio_processor -->|"signals speech end"| node_pipeline_orchestrator
node_pipeline_orchestrator -->|"transcribes audio"| node_whisper
node_pipeline_orchestrator -->|"queries model"| node_llama_client
node_pipeline_orchestrator -->|"uses conversation context"| node_conversation
node_pipeline_orchestrator -->|"synthesizes response"| node_xtts
node_pipeline_orchestrator -->|"plays generated audio"| node_playback
node_voice_manager -->|"initializes playback"| node_playback
node_voice_manager -->|"changes voice state"| node_state_machine
node_pipeline_orchestrator -.->|"coordinates pipeline state"| node_state_machine
node_llama_server -->|"serves model queries"| node_llama_client
node_playback -->|"cleans up audio"| node_audio_files
node_whisper -->|"validates WAV"| node_audio_files
node_pipeline_orchestrator -->|"tracks pipeline errors"| node_error_monitor
node_pipeline_orchestrator -->|"records structured errors"| node_error_logger
node_pipeline_orchestrator -->|"reads settings"| node_config
node_voice_manager -->|"reads settings"| node_config
node_whisper -->|"reads settings"| node_config
node_xtts -->|"reads settings"| node_config
node_llama_client -->|"reads settings"| node_config

click node_commands "https://github.com/aric-davison/llmbot/tree/main/src/commands"
click node_discord_client "https://github.com/aric-davison/llmbot/blob/main/src/services/discordClient.js"
click node_voice_manager "https://github.com/aric-davison/llmbot/blob/main/src/services/voiceManager.js"
click node_audio_processor "https://github.com/aric-davison/llmbot/blob/main/src/services/audioProcessor.js"
click node_playback "https://github.com/aric-davison/llmbot/blob/main/src/services/audioPlaybackService.js"
click node_pipeline_orchestrator "https://github.com/aric-davison/llmbot/blob/main/src/services/pipelineOrchestrator.js"
click node_whisper "https://github.com/aric-davison/llmbot/blob/main/src/services/whisperService.js"
click node_llama_client "https://github.com/aric-davison/llmbot/blob/main/src/services/llamaCppClient.js"
click node_llama_server "https://github.com/aric-davison/llmbot/blob/main/src/services/llamaServer.js"
click node_conversation "https://github.com/aric-davison/llmbot/blob/main/src/services/conversationManager.js"
click node_xtts "https://github.com/aric-davison/llmbot/blob/main/src/services/xttsService.js"
click node_state_machine "https://github.com/aric-davison/llmbot/blob/main/src/services/stateMachine.js"
click node_audio_files "https://github.com/aric-davison/llmbot/blob/main/src/utils/audioFileManager.js"
click node_config "https://github.com/aric-davison/llmbot/blob/main/src/utils/config.js"
click node_error_monitor "https://github.com/aric-davison/llmbot/blob/main/src/utils/errorMonitor.js"
click node_error_logger "https://github.com/aric-davison/llmbot/blob/main/src/utils/errorLogger.js"
click node_logger "https://github.com/aric-davison/llmbot/blob/main/src/utils/logger.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_commands,node_discord_client,node_voice_manager,node_audio_processor,node_playback toneBlue
class node_pipeline_orchestrator,node_conversation,node_state_machine toneAmber
class node_whisper,node_llama_client,node_llama_server,node_xtts toneMint
class node_audio_files,node_config,node_error_monitor,node_error_logger,node_logger toneRose
class node_user toneIndigo
```

## Components

### Discord and Voice

- [Join and leave](https://github.com/aric-davison/llmbot/tree/main/src/commands): `src/commands`
- [Discord gateway](https://github.com/aric-davison/llmbot/blob/main/src/services/discordClient.js): `src/services/discordClient.js`
- [Voice lifecycle](https://github.com/aric-davison/llmbot/blob/main/src/services/voiceManager.js): `src/services/voiceManager.js`
- [VAD and capture](https://github.com/aric-davison/llmbot/blob/main/src/services/audioProcessor.js): `src/services/audioProcessor.js`
- [Audio playback](https://github.com/aric-davison/llmbot/blob/main/src/services/audioPlaybackService.js): `src/services/audioPlaybackService.js`

### Conversation Pipeline

- [Pipeline orchestration](https://github.com/aric-davison/llmbot/blob/main/src/services/pipelineOrchestrator.js): `src/services/pipelineOrchestrator.js`
- [Conversation memory](https://github.com/aric-davison/llmbot/blob/main/src/services/conversationManager.js): `src/services/conversationManager.js`
- [Voice state](https://github.com/aric-davison/llmbot/blob/main/src/services/stateMachine.js): `src/services/stateMachine.js`

### Local AI Models

- [Speech recognition](https://github.com/aric-davison/llmbot/blob/main/src/services/whisperService.js): `src/services/whisperService.js`
- [LLM queries](https://github.com/aric-davison/llmbot/blob/main/src/services/llamaCppClient.js): `src/services/llamaCppClient.js`
- [LLM server lifecycle](https://github.com/aric-davison/llmbot/blob/main/src/services/llamaServer.js): `src/services/llamaServer.js`
- [Speech synthesis](https://github.com/aric-davison/llmbot/blob/main/src/services/xttsService.js): `src/services/xttsService.js`

### Runtime Support

- [Audio file lifecycle](https://github.com/aric-davison/llmbot/blob/main/src/utils/audioFileManager.js): `src/utils/audioFileManager.js`
- [Configuration](https://github.com/aric-davison/llmbot/blob/main/src/utils/config.js): `src/utils/config.js`
- [Error monitoring](https://github.com/aric-davison/llmbot/blob/main/src/utils/errorMonitor.js): `src/utils/errorMonitor.js`
- [Structured errors](https://github.com/aric-davison/llmbot/blob/main/src/utils/errorLogger.js): `src/utils/errorLogger.js`
- [Structured logging](https://github.com/aric-davison/llmbot/blob/main/src/utils/logger.js): `src/utils/logger.js`

### Other components

- **Voice participant**

## Connections

- Voice participant → Join and leave: issues commands (evidence: `README.md`)
- Join and leave → Voice lifecycle: joins or leaves (evidence: `README.md`)
- Voice participant → Voice lifecycle: speaks in channel (evidence: `README.md`)
- Discord gateway → Voice lifecycle: manages voice (evidence: `README.md`)
- Voice lifecycle → VAD and capture: captures audio (evidence: `src/services/voiceManager.js`)
- VAD and capture → Pipeline orchestration: signals speech end
- Pipeline orchestration → Speech recognition: transcribes audio (evidence: `README.md`)
- Pipeline orchestration → LLM queries: queries model (evidence: `README.md`)
- Pipeline orchestration → Conversation memory: uses conversation context (evidence: `README.md`)
- Pipeline orchestration → Speech synthesis: synthesizes response (evidence: `README.md`)
- Pipeline orchestration → Audio playback: plays generated audio (evidence: `README.md`)
- Voice lifecycle → Audio playback: initializes playback (evidence: `src/services/voiceManager.js`)
- Voice lifecycle → Voice state: changes voice state (evidence: `src/services/voiceManager.js`)
- Pipeline orchestration → Voice state: coordinates pipeline state
- LLM server lifecycle → LLM queries: serves model queries (evidence: `src/services/llamaServer.js`)
- Audio playback → Audio file lifecycle: cleans up audio (evidence: `src/services/audioPlaybackService.js`)
- Speech recognition → Audio file lifecycle: validates WAV (evidence: `src/services/whisperService.js`)
- Pipeline orchestration → Error monitoring: tracks pipeline errors (evidence: `src/services/pipelineOrchestrator.js`)
- Pipeline orchestration → Structured errors: records structured errors (evidence: `src/services/pipelineOrchestrator.js`)
- Pipeline orchestration → Configuration: reads settings (evidence: `src/services/pipelineOrchestrator.js`)
- Voice lifecycle → Configuration: reads settings (evidence: `src/services/voiceManager.js`)
- Speech recognition → Configuration: reads settings (evidence: `src/services/whisperService.js`)
- Speech synthesis → Configuration: reads settings (evidence: `src/services/xttsService.js`)
- LLM queries → Configuration: reads settings (evidence: `src/services/llamaCppClient.js`)
