# kiramayatu/open-llm-vtuber-hana architecture

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

- Interactive diagram: https://gitdiagram.com/kiramayatu/open-llm-vtuber-hana
- Repository: https://github.com/kiramayatu/open-llm-vtuber-hana

## Overview

Open-LLM-VTuber is a voice-interactive AI companion with a Live2D avatar. Its main interaction path runs from a web/desktop client through server routes and conversation handling, using configured speech recognition and an agent/LLM before producing spoken, avatar-aware output. Chat history, MCP tools, and artifact workspaces provide supporting capabilities. The graph combines sampled source references with README-documented features; several provider implementations and client details are not shown, so their internal wiring is not expanded.

Main entry points: [`src/open_llm_vtuber/service_context.py`](https://github.com/kiramayatu/open-llm-vtuber-hana/blob/main/src/open_llm_vtuber/service_context.py) (Service context), [`src/open_llm_vtuber/routes.py`](https://github.com/kiramayatu/open-llm-vtuber-hana/blob/main/src/open_llm_vtuber/routes.py) (API routes), [`src/open_llm_vtuber/conversations/conversation_handler.py`](https://github.com/kiramayatu/open-llm-vtuber-hana/blob/main/src/open_llm_vtuber/conversations/conversation_handler.py) (Conversation handler), [`src/open_llm_vtuber/conversations/tts_manager.py`](https://github.com/kiramayatu/open-llm-vtuber-hana/blob/main/src/open_llm_vtuber/conversations/tts_manager.py) (Speech output)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Client and server"]
  node_client["Web client<br/>[main.js]"]
  node_server["HTTP server<br/>[server.py]"]
  node_routes["API routes<br/>[routes.py]"]
  node_ws["WebSocket handler"]
  node_config["Configuration<br/>[main.py]"]
end

subgraph group_conversation["Conversation and agents"]
  node_context["Service context<br/>[service_context.py]"]
  node_conversation_handler["Conversation handler"]
  node_prompts["Persona prompts<br/>[prompt_loader.py]"]
  node_agent_factory["Agent factory<br/>[agent_factory.py]"]
  node_memory_agent["Memory agent"]
  node_llm_factory["LLM factory"]
end

subgraph group_media["Speech and avatar"]
  node_asr["Speech recognition"]
  node_vad["Voice activity detection"]
  node_tts_manager["Speech output<br/>[tts_manager.py]"]
  node_tts_factory["TTS providers<br/>[tts_factory.py]"]
  node_avatar["Live2D avatar<br/>[live2d_model.py]"]
end

subgraph group_extensions["Tools and persistence"]
  node_history[("Chat history")]
  node_mcp["MCP tools<br/>[tool_executor.py]"]
  node_artifacts[("Artifact workspace<br/>[manager.py]")]
end

node_user(("User"))
node_llm_provider["LLM provider"]

node_user -->|"interacts"| node_client
node_client -.->|"sends requests"| node_server
node_server -->|"mounts routes"| node_routes
node_server -->|"initializes"| node_context
node_routes -->|"routes messages"| node_ws
node_routes -->|"uses services"| node_context
node_routes -->|"manages artifacts"| node_artifacts
node_config -.->|"configures"| node_context
node_ws -.->|"dispatches conversation"| node_conversation_handler
node_context -->|"creates agent"| node_agent_factory
node_context -->|"initializes speech recognition"| node_asr
node_context -->|"initializes voice detection"| node_vad
node_context -->|"initializes speech output"| node_tts_factory
node_context -->|"initializes tools"| node_mcp
node_conversation_handler -->|"uses chat history"| node_history
node_conversation_handler -->|"loads prompts"| node_prompts
node_conversation_handler -.->|"generates spoken replies"| node_tts_manager
node_agent_factory -->|"creates agent"| node_memory_agent
node_agent_factory -->|"creates LLM"| node_llm_factory
node_memory_agent -.->|"uses LLM"| node_llm_factory
node_llm_factory -->|"selects provider"| node_llm_provider
node_tts_manager -.->|"uses TTS engine"| node_tts_factory
node_tts_manager -->|"prepares avatar payload"| node_avatar
node_tts_manager -.->|"sends audio payload"| node_client

click node_client "https://github.com/kiramayatu/open-llm-vtuber-hana/blob/main/web_tool/main.js"
click node_server "https://github.com/kiramayatu/open-llm-vtuber-hana/blob/main/src/open_llm_vtuber/server.py"
click node_routes "https://github.com/kiramayatu/open-llm-vtuber-hana/blob/main/src/open_llm_vtuber/routes.py"
click node_ws "https://github.com/kiramayatu/open-llm-vtuber-hana/blob/main/src/open_llm_vtuber/websocket_handler.py"
click node_config "https://github.com/kiramayatu/open-llm-vtuber-hana/blob/main/src/open_llm_vtuber/config_manager/main.py"
click node_context "https://github.com/kiramayatu/open-llm-vtuber-hana/blob/main/src/open_llm_vtuber/service_context.py"
click node_conversation_handler "https://github.com/kiramayatu/open-llm-vtuber-hana/blob/main/src/open_llm_vtuber/conversations/conversation_handler.py"
click node_prompts "https://github.com/kiramayatu/open-llm-vtuber-hana/blob/main/prompts/prompt_loader.py"
click node_agent_factory "https://github.com/kiramayatu/open-llm-vtuber-hana/blob/main/src/open_llm_vtuber/agent/agent_factory.py"
click node_memory_agent "https://github.com/kiramayatu/open-llm-vtuber-hana/blob/main/src/open_llm_vtuber/agent/agents/basic_memory_agent.py"
click node_llm_factory "https://github.com/kiramayatu/open-llm-vtuber-hana/blob/main/src/open_llm_vtuber/agent/stateless_llm_factory.py"
click node_asr "https://github.com/kiramayatu/open-llm-vtuber-hana/tree/main/src/open_llm_vtuber/asr"
click node_vad "https://github.com/kiramayatu/open-llm-vtuber-hana/tree/main/src/open_llm_vtuber/vad"
click node_tts_manager "https://github.com/kiramayatu/open-llm-vtuber-hana/blob/main/src/open_llm_vtuber/conversations/tts_manager.py"
click node_tts_factory "https://github.com/kiramayatu/open-llm-vtuber-hana/blob/main/src/open_llm_vtuber/tts/tts_factory.py"
click node_avatar "https://github.com/kiramayatu/open-llm-vtuber-hana/blob/main/src/open_llm_vtuber/live2d_model.py"
click node_history "https://github.com/kiramayatu/open-llm-vtuber-hana/blob/main/src/open_llm_vtuber/chat_history_manager.py"
click node_mcp "https://github.com/kiramayatu/open-llm-vtuber-hana/blob/main/src/open_llm_vtuber/mcpp/tool_executor.py"
click node_artifacts "https://github.com/kiramayatu/open-llm-vtuber-hana/blob/main/src/open_llm_vtuber/artifacts/manager.py"

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_client,node_server,node_routes,node_ws,node_config,node_user toneBlue
class node_context,node_conversation_handler,node_prompts,node_agent_factory,node_memory_agent,node_llm_factory toneAmber
class node_asr,node_vad,node_tts_manager,node_tts_factory,node_avatar toneMint
class node_history,node_mcp,node_artifacts toneRose
class node_llm_provider toneIndigo
```

## Components

### Client and server

- [Web client](https://github.com/kiramayatu/open-llm-vtuber-hana/blob/main/web_tool/main.js): `web_tool/main.js`
- [HTTP server](https://github.com/kiramayatu/open-llm-vtuber-hana/blob/main/src/open_llm_vtuber/server.py): `src/open_llm_vtuber/server.py`
- [API routes](https://github.com/kiramayatu/open-llm-vtuber-hana/blob/main/src/open_llm_vtuber/routes.py): `src/open_llm_vtuber/routes.py`
- [WebSocket handler](https://github.com/kiramayatu/open-llm-vtuber-hana/blob/main/src/open_llm_vtuber/websocket_handler.py): `src/open_llm_vtuber/websocket_handler.py`
- [Configuration](https://github.com/kiramayatu/open-llm-vtuber-hana/blob/main/src/open_llm_vtuber/config_manager/main.py): `src/open_llm_vtuber/config_manager/main.py`

### Conversation and agents

- [Service context](https://github.com/kiramayatu/open-llm-vtuber-hana/blob/main/src/open_llm_vtuber/service_context.py): `src/open_llm_vtuber/service_context.py`
- [Conversation handler](https://github.com/kiramayatu/open-llm-vtuber-hana/blob/main/src/open_llm_vtuber/conversations/conversation_handler.py): `src/open_llm_vtuber/conversations/conversation_handler.py`
- [Persona prompts](https://github.com/kiramayatu/open-llm-vtuber-hana/blob/main/prompts/prompt_loader.py): `prompts/prompt_loader.py`
- [Agent factory](https://github.com/kiramayatu/open-llm-vtuber-hana/blob/main/src/open_llm_vtuber/agent/agent_factory.py): `src/open_llm_vtuber/agent/agent_factory.py`
- [Memory agent](https://github.com/kiramayatu/open-llm-vtuber-hana/blob/main/src/open_llm_vtuber/agent/agents/basic_memory_agent.py): `src/open_llm_vtuber/agent/agents/basic_memory_agent.py`
- [LLM factory](https://github.com/kiramayatu/open-llm-vtuber-hana/blob/main/src/open_llm_vtuber/agent/stateless_llm_factory.py): `src/open_llm_vtuber/agent/stateless_llm_factory.py`

### Speech and avatar

- [Speech recognition](https://github.com/kiramayatu/open-llm-vtuber-hana/tree/main/src/open_llm_vtuber/asr): `src/open_llm_vtuber/asr`
- [Voice activity detection](https://github.com/kiramayatu/open-llm-vtuber-hana/tree/main/src/open_llm_vtuber/vad): `src/open_llm_vtuber/vad`
- [Speech output](https://github.com/kiramayatu/open-llm-vtuber-hana/blob/main/src/open_llm_vtuber/conversations/tts_manager.py): `src/open_llm_vtuber/conversations/tts_manager.py`
- [TTS providers](https://github.com/kiramayatu/open-llm-vtuber-hana/blob/main/src/open_llm_vtuber/tts/tts_factory.py): `src/open_llm_vtuber/tts/tts_factory.py`
- [Live2D avatar](https://github.com/kiramayatu/open-llm-vtuber-hana/blob/main/src/open_llm_vtuber/live2d_model.py): `src/open_llm_vtuber/live2d_model.py`

### Tools and persistence

- [Chat history](https://github.com/kiramayatu/open-llm-vtuber-hana/blob/main/src/open_llm_vtuber/chat_history_manager.py): `src/open_llm_vtuber/chat_history_manager.py`
- [MCP tools](https://github.com/kiramayatu/open-llm-vtuber-hana/blob/main/src/open_llm_vtuber/mcpp/tool_executor.py): `src/open_llm_vtuber/mcpp/tool_executor.py`
- [Artifact workspace](https://github.com/kiramayatu/open-llm-vtuber-hana/blob/main/src/open_llm_vtuber/artifacts/manager.py): `src/open_llm_vtuber/artifacts/manager.py`

### Other components

- **User**
- **LLM provider**

## Connections

- User → Web client: interacts (evidence: `README.md`)
- Web client → HTTP server: sends requests
- HTTP server → API routes: mounts routes (evidence: `src/open_llm_vtuber/server.py`)
- HTTP server → Service context: initializes (evidence: `src/open_llm_vtuber/server.py`)
- API routes → WebSocket handler: routes messages (evidence: `src/open_llm_vtuber/routes.py`)
- API routes → Service context: uses services (evidence: `src/open_llm_vtuber/routes.py`)
- API routes → Artifact workspace: manages artifacts (evidence: `src/open_llm_vtuber/routes.py`)
- Configuration → Service context: configures
- WebSocket handler → Conversation handler: dispatches conversation
- Service context → Agent factory: creates agent (evidence: `src/open_llm_vtuber/service_context.py`)
- Service context → Speech recognition: initializes speech recognition (evidence: `src/open_llm_vtuber/service_context.py`)
- Service context → Voice activity detection: initializes voice detection (evidence: `src/open_llm_vtuber/service_context.py`)
- Service context → TTS providers: initializes speech output (evidence: `src/open_llm_vtuber/service_context.py`)
- Service context → MCP tools: initializes tools (evidence: `src/open_llm_vtuber/service_context.py`)
- Conversation handler → Chat history: uses chat history (evidence: `src/open_llm_vtuber/conversations/conversation_handler.py`)
- Conversation handler → Persona prompts: loads prompts (evidence: `src/open_llm_vtuber/conversations/conversation_handler.py`)
- Conversation handler → Speech output: generates spoken replies
- Agent factory → Memory agent: creates agent (evidence: `src/open_llm_vtuber/agent/agent_factory.py`)
- Agent factory → LLM factory: creates LLM (evidence: `src/open_llm_vtuber/agent/agent_factory.py`)
- Memory agent → LLM factory: uses LLM
- LLM factory → LLM provider: selects provider (evidence: `src/open_llm_vtuber/agent/stateless_llm_factory.py`)
- Speech output → TTS providers: uses TTS engine
- Speech output → Live2D avatar: prepares avatar payload (evidence: `src/open_llm_vtuber/conversations/tts_manager.py`)
- Speech output → Web client: sends audio payload
