# slimeboyowo/lingchat architecture

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

- Interactive diagram: https://gitdiagram.com/slimeboyowo/lingchat
- Repository: https://github.com/slimeboyowo/lingchat

## Overview

LingChat is a desktop AI companion that combines free-form character chat with a visual, voice-enabled interface, a script-driven multi-character game, and productivity features. The principal workflow is user chat through the application to AI response generation, with conversation and memory state persisted per save. The graph also preserves the documented script, emotion, vision/proactive, voice, and scheduling capabilities. Several feature links are documented but their implementation paths were not sampled, so those nodes use supported directory paths and unverified links are dashed.

Main entry points: [`src-tauri/src/ai_service/game_system/role_manager.rs`](https://github.com/slimeboyowo/lingchat/blob/main/src-tauri/src/ai_service/game_system/role_manager.rs) (Role manager), [`src/App.vue`](https://github.com/slimeboyowo/lingchat/blob/main/src/App.vue) (Application shell), [`src/components/views/CompanionMode.vue`](https://github.com/slimeboyowo/lingchat/blob/main/src/components/views/CompanionMode.vue) (Chat and pet views), [`src-tauri/src/ai_service/proactive_system`](https://github.com/slimeboyowo/lingchat/tree/main/src-tauri/src/ai_service/proactive_system) (Proactive companion)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Companion interface"]
  node_app["Application shell<br/>[App.vue]"]
  node_views["Chat and pet views<br/>[CompanionMode.vue]"]
end

subgraph group_assistant["AI conversation"]
  node_chatapi["Chat commands<br/>[chat.rs]"]
  node_roles["Role manager<br/>[role_manager.rs]"]
  node_llm["LLM providers"]
  node_memory["Memory builder<br/>[memory_builder.rs]"]
  node_persistent["Persistent memory"]
  node_emotion["Emotion recognition"]
  node_vision["Screen awareness<br/>[screen_analyzer.rs]"]
  node_proactive["Proactive companion"]
  node_tts["Speech synthesis"]
end

subgraph group_story["Story and interaction"]
  node_script["Script engine<br/>[script_manager.rs]"]
  node_eventqueue["Script event queue<br/>[event-queue.ts]"]
  node_scriptview["Script editor<br/>[ScriptEditor.vue]"]
  node_schedule["Schedules and todos"]
end

subgraph group_state["Persistence and services"]
  node_lines[("Conversation records<br/>[line.rs]")]
  node_memoryrepo[("Memory repository<br/>[memory_repo.rs]")]
  node_rolearchive["Role import and export"]
  node_lan["LAN synchronization<br/>[sync_engine.rs]"]
end

node_user(("User"))

node_user -->|"uses"| node_app
node_app -->|"routes to"| node_views
node_views -.->|"submits chat"| node_chatapi
node_chatapi -.->|"dispatches chat"| node_roles
node_roles -->|"requests generation"| node_llm
node_roles -->|"builds context"| node_memory
node_roles -->|"uses memory"| node_persistent
node_memory -->|"reads dialogue"| node_lines
node_persistent -.->|"stores memory"| node_memoryrepo
node_roles -.->|"records dialogue"| node_lines
node_app -->|"routes to"| node_scriptview
node_scriptview -.->|"edits scripts"| node_script
node_script -.->|"emits story events"| node_eventqueue
node_eventqueue -->|"queues events"| node_views
node_roles -.->|"assesses replies"| node_emotion
node_roles -.->|"uses screen context"| node_vision
node_proactive -.->|"observes activity"| node_vision
node_proactive -.->|"uses schedules"| node_schedule
node_roles -.->|"generates speech"| node_tts
node_user -->|"imports characters"| node_rolearchive
node_user -.->|"syncs devices"| node_lan

click node_app "https://github.com/slimeboyowo/lingchat/blob/main/src/App.vue"
click node_views "https://github.com/slimeboyowo/lingchat/blob/main/src/components/views/CompanionMode.vue"
click node_chatapi "https://github.com/slimeboyowo/lingchat/blob/main/src-tauri/src/api/chat.rs"
click node_roles "https://github.com/slimeboyowo/lingchat/blob/main/src-tauri/src/ai_service/game_system/role_manager.rs"
click node_llm "https://github.com/slimeboyowo/lingchat/tree/main/src-tauri/src/ai_service/llm"
click node_memory "https://github.com/slimeboyowo/lingchat/blob/main/src-tauri/src/ai_service/game_system/memory_builder.rs"
click node_persistent "https://github.com/slimeboyowo/lingchat/blob/main/src-tauri/src/ai_service/game_system/persistent_memory_system.rs"
click node_emotion "https://github.com/slimeboyowo/lingchat/tree/main/src-tauri/src/ai_service/emotion"
click node_vision "https://github.com/slimeboyowo/lingchat/blob/main/src-tauri/src/ai_service/screen_analyzer.rs"
click node_proactive "https://github.com/slimeboyowo/lingchat/tree/main/src-tauri/src/ai_service/proactive_system"
click node_tts "https://github.com/slimeboyowo/lingchat/tree/main/src-tauri/src/ai_service/tts"
click node_script "https://github.com/slimeboyowo/lingchat/blob/main/src-tauri/src/ai_service/game_system/script_engine/script_manager.rs"
click node_eventqueue "https://github.com/slimeboyowo/lingchat/blob/main/src/core/events/event-queue.ts"
click node_scriptview "https://github.com/slimeboyowo/lingchat/blob/main/src/components/views/ScriptEditor.vue"
click node_schedule "https://github.com/slimeboyowo/lingchat/blob/main/src-tauri/src/ai_service/proactive_system/schedule_manager.rs"
click node_lines "https://github.com/slimeboyowo/lingchat/blob/main/src-tauri/src/db/entities/line.rs"
click node_memoryrepo "https://github.com/slimeboyowo/lingchat/blob/main/src-tauri/src/db/managers/memory_repo.rs"
click node_rolearchive "https://github.com/slimeboyowo/lingchat/tree/main/src-tauri/src/api/role_archive"
click node_lan "https://github.com/slimeboyowo/lingchat/blob/main/src-tauri/src/lan_sync/sync_engine.rs"

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_app,node_views,node_user toneBlue
class node_chatapi,node_roles,node_llm,node_memory,node_persistent,node_emotion,node_vision,node_proactive,node_tts toneAmber
class node_script,node_eventqueue,node_scriptview,node_schedule toneMint
class node_lines,node_memoryrepo,node_rolearchive,node_lan toneRose
```

## Components

### Companion interface

- [Application shell](https://github.com/slimeboyowo/lingchat/blob/main/src/App.vue): `src/App.vue`
- [Chat and pet views](https://github.com/slimeboyowo/lingchat/blob/main/src/components/views/CompanionMode.vue): `src/components/views/CompanionMode.vue`

### AI conversation

- [Chat commands](https://github.com/slimeboyowo/lingchat/blob/main/src-tauri/src/api/chat.rs): `src-tauri/src/api/chat.rs`
- [Role manager](https://github.com/slimeboyowo/lingchat/blob/main/src-tauri/src/ai_service/game_system/role_manager.rs): `src-tauri/src/ai_service/game_system/role_manager.rs`
- [LLM providers](https://github.com/slimeboyowo/lingchat/tree/main/src-tauri/src/ai_service/llm): `src-tauri/src/ai_service/llm`
- [Memory builder](https://github.com/slimeboyowo/lingchat/blob/main/src-tauri/src/ai_service/game_system/memory_builder.rs): `src-tauri/src/ai_service/game_system/memory_builder.rs`
- [Persistent memory](https://github.com/slimeboyowo/lingchat/blob/main/src-tauri/src/ai_service/game_system/persistent_memory_system.rs): `src-tauri/src/ai_service/game_system/persistent_memory_system.rs`
- [Emotion recognition](https://github.com/slimeboyowo/lingchat/tree/main/src-tauri/src/ai_service/emotion): `src-tauri/src/ai_service/emotion`
- [Screen awareness](https://github.com/slimeboyowo/lingchat/blob/main/src-tauri/src/ai_service/screen_analyzer.rs): `src-tauri/src/ai_service/screen_analyzer.rs`
- [Proactive companion](https://github.com/slimeboyowo/lingchat/tree/main/src-tauri/src/ai_service/proactive_system): `src-tauri/src/ai_service/proactive_system`
- [Speech synthesis](https://github.com/slimeboyowo/lingchat/tree/main/src-tauri/src/ai_service/tts): `src-tauri/src/ai_service/tts`

### Story and interaction

- [Script engine](https://github.com/slimeboyowo/lingchat/blob/main/src-tauri/src/ai_service/game_system/script_engine/script_manager.rs): `src-tauri/src/ai_service/game_system/script_engine/script_manager.rs`
- [Script event queue](https://github.com/slimeboyowo/lingchat/blob/main/src/core/events/event-queue.ts): `src/core/events/event-queue.ts`
- [Script editor](https://github.com/slimeboyowo/lingchat/blob/main/src/components/views/ScriptEditor.vue): `src/components/views/ScriptEditor.vue`
- [Schedules and todos](https://github.com/slimeboyowo/lingchat/blob/main/src-tauri/src/ai_service/proactive_system/schedule_manager.rs): `src-tauri/src/ai_service/proactive_system/schedule_manager.rs`

### Persistence and services

- [Conversation records](https://github.com/slimeboyowo/lingchat/blob/main/src-tauri/src/db/entities/line.rs): `src-tauri/src/db/entities/line.rs`
- [Memory repository](https://github.com/slimeboyowo/lingchat/blob/main/src-tauri/src/db/managers/memory_repo.rs): `src-tauri/src/db/managers/memory_repo.rs`
- [Role import and export](https://github.com/slimeboyowo/lingchat/tree/main/src-tauri/src/api/role_archive): `src-tauri/src/api/role_archive`
- [LAN synchronization](https://github.com/slimeboyowo/lingchat/blob/main/src-tauri/src/lan_sync/sync_engine.rs): `src-tauri/src/lan_sync/sync_engine.rs`

### Other components

- **User**

## Connections

- User → Application shell: uses
- Application shell → Chat and pet views: routes to
- Chat and pet views → Chat commands: submits chat
- Chat commands → Role manager: dispatches chat
- Role manager → LLM providers: requests generation (evidence: `src-tauri/src/ai_service/game_system/role_manager.rs`)
- Role manager → Memory builder: builds context (evidence: `src-tauri/src/ai_service/game_system/role_manager.rs`)
- Role manager → Persistent memory: uses memory (evidence: `src-tauri/src/ai_service/game_system/role_manager.rs`)
- Memory builder → Conversation records: reads dialogue (evidence: `src-tauri/src/ai_service/game_system/memory_builder.rs`)
- Persistent memory → Memory repository: stores memory
- Role manager → Conversation records: records dialogue (evidence: `src-tauri/src/ai_service/game_system/role_manager.rs`)
- Application shell → Script editor: routes to
- Script editor → Script engine: edits scripts
- Script engine → Script event queue: emits story events
- Script event queue → Chat and pet views: queues events
- Role manager → Emotion recognition: assesses replies
- Role manager → Screen awareness: uses screen context
- Proactive companion → Screen awareness: observes activity
- Proactive companion → Schedules and todos: uses schedules
- Role manager → Speech synthesis: generates speech (evidence: `src-tauri/src/ai_service/game_system/role_manager.rs`)
- User → Role import and export: imports characters
- User → LAN synchronization: syncs devices
