# counhopig/vex-bot architecture

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

- Interactive diagram: https://gitdiagram.com/counhopig/vex-bot
- Repository: https://github.com/counhopig/vex-bot

## Overview

Vex is a self-hosted personal assistant whose principal workflow is an owner message arriving through WeChat or WebChat, being handled in a conversation session, and producing a response or tool action. The daemon coordinates shared sessions, configured models, workspace context, tools, approvals, and scheduled work. Long-term memory, Skills, persona editing, and proactive heartbeat tasks are meaningful supporting capabilities. Relationships are limited to the supplied excerpts, SOURCE INDEX references, and README statements; several runtime integrations are documented but not shown in detail.

Main entry points: [`src/daemon.ts`](https://github.com/counhopig/vex-bot/blob/main/src/daemon.ts) (Daemon coordinator), [`src/gateway/server.ts`](https://github.com/counhopig/vex-bot/blob/main/src/gateway/server.ts) (Web gateway), [`src/core/session.ts`](https://github.com/counhopig/vex-bot/blob/main/src/core/session.ts) (Conversation agent), [`src/core/sessionManager.ts`](https://github.com/counhopig/vex-bot/blob/main/src/core/sessionManager.ts) (Session manager)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["User interfaces"]
  node_wechat["WeChat channel<br/>[channel.ts]"]
  node_webclient["WebChat client<br/>[app.js]"]
  node_gateway["Web gateway<br/>[server.ts]"]
end

subgraph group_runtime["Assistant runtime"]
  node_daemon["Daemon coordinator<br/>[daemon.ts]"]
  node_sessions["Session manager<br/>[sessionManager.ts]"]
  node_session["Conversation agent<br/>[session.ts]"]
  node_events["Event bus<br/>[events.ts]"]
  node_models["Model providers<br/>[models.ts]"]
end

subgraph group_capabilities["Assistant capabilities"]
  node_tools["Assistant tools<br/>[registry.ts]"]
  node_approvals["Shared approvals<br/>[approvals.ts]"]
  node_memory["Memory search<br/>[memory.ts]"]
  node_skills["Skills<br/>[discovery.ts]"]
  node_bundled["Bundled Skills"]
  node_scheduler["Scheduled tasks<br/>[index.ts]"]
end

subgraph group_operations["Configuration and operations"]
  node_config["Configuration<br/>[load.ts]"]
  node_auth["Web authentication<br/>[auth.ts]"]
end

subgraph group_persistence["Workspace and storage"]
  node_workspace["Workspace and persona<br/>[workspace.ts]"]
  node_transcripts["Conversation transcripts<br/>[jsonl.ts]"]
  node_atomic["Atomic file storage<br/>[atomic.ts]"]
end

node_owner(("Owner"))

node_owner -->|"messages"| node_wechat
node_owner -->|"messages"| node_webclient
node_webclient -->|"connects to"| node_gateway
node_wechat -->|"shares conversations"| node_sessions
node_gateway -->|"routes messages"| node_sessions
node_gateway -->|"checks access"| node_auth
node_daemon -->|"starts"| node_gateway
node_daemon -->|"opens sessions"| node_sessions
node_sessions -->|"opens"| node_session
node_session -->|"persists messages"| node_transcripts
node_session -->|"emits events"| node_events
node_sessions -->|"subscribes"| node_events
node_gateway -->|"broadcasts updates"| node_events
node_daemon -->|"resolves models"| node_models
node_session -.->|"uses model"| node_models
node_session -.->|"runs tools"| node_tools
node_daemon -.->|"coordinates approvals"| node_approvals
node_gateway -->|"serves approval actions"| node_approvals
node_daemon -->|"starts scheduler"| node_scheduler
node_scheduler -->|"saves schedules"| node_atomic
node_daemon -->|"ensures workspace"| node_workspace
node_daemon -->|"initializes memory"| node_memory
node_skills -->|"adds prompt context"| node_workspace
node_skills -.->|"discovers skills"| node_bundled
node_daemon -->|"loads configuration"| node_config
node_config -->|"writes configuration"| node_atomic

click node_wechat "https://github.com/counhopig/vex-bot/blob/main/src/channels/wechat/channel.ts"
click node_webclient "https://github.com/counhopig/vex-bot/blob/main/src/web/static/app.js"
click node_gateway "https://github.com/counhopig/vex-bot/blob/main/src/gateway/server.ts"
click node_daemon "https://github.com/counhopig/vex-bot/blob/main/src/daemon.ts"
click node_sessions "https://github.com/counhopig/vex-bot/blob/main/src/core/sessionManager.ts"
click node_session "https://github.com/counhopig/vex-bot/blob/main/src/core/session.ts"
click node_events "https://github.com/counhopig/vex-bot/blob/main/src/core/events.ts"
click node_models "https://github.com/counhopig/vex-bot/blob/main/src/providers/models.ts"
click node_tools "https://github.com/counhopig/vex-bot/blob/main/src/tools/registry.ts"
click node_approvals "https://github.com/counhopig/vex-bot/blob/main/src/policy/approvals.ts"
click node_memory "https://github.com/counhopig/vex-bot/blob/main/src/index/memory.ts"
click node_skills "https://github.com/counhopig/vex-bot/blob/main/src/skills/discovery.ts"
click node_bundled "https://github.com/counhopig/vex-bot/tree/main/skills"
click node_scheduler "https://github.com/counhopig/vex-bot/blob/main/src/scheduler/index.ts"
click node_config "https://github.com/counhopig/vex-bot/blob/main/src/config/load.ts"
click node_auth "https://github.com/counhopig/vex-bot/blob/main/src/gateway/auth.ts"
click node_workspace "https://github.com/counhopig/vex-bot/blob/main/src/workspace/workspace.ts"
click node_transcripts "https://github.com/counhopig/vex-bot/blob/main/src/store/jsonl.ts"
click node_atomic "https://github.com/counhopig/vex-bot/blob/main/src/store/atomic.ts"

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_wechat,node_webclient,node_gateway toneBlue
class node_daemon,node_sessions,node_session,node_events,node_models toneAmber
class node_tools,node_approvals,node_memory,node_skills,node_bundled,node_scheduler toneMint
class node_config,node_auth toneRose
class node_workspace,node_transcripts,node_atomic,node_owner toneIndigo
```

## Components

### User interfaces

- [WeChat channel](https://github.com/counhopig/vex-bot/blob/main/src/channels/wechat/channel.ts): `src/channels/wechat/channel.ts`
- [WebChat client](https://github.com/counhopig/vex-bot/blob/main/src/web/static/app.js): `src/web/static/app.js`
- [Web gateway](https://github.com/counhopig/vex-bot/blob/main/src/gateway/server.ts): `src/gateway/server.ts`

### Assistant runtime

- [Daemon coordinator](https://github.com/counhopig/vex-bot/blob/main/src/daemon.ts): `src/daemon.ts`
- [Session manager](https://github.com/counhopig/vex-bot/blob/main/src/core/sessionManager.ts): `src/core/sessionManager.ts`
- [Conversation agent](https://github.com/counhopig/vex-bot/blob/main/src/core/session.ts): `src/core/session.ts`
- [Event bus](https://github.com/counhopig/vex-bot/blob/main/src/core/events.ts): `src/core/events.ts`
- [Model providers](https://github.com/counhopig/vex-bot/blob/main/src/providers/models.ts): `src/providers/models.ts`

### Assistant capabilities

- [Assistant tools](https://github.com/counhopig/vex-bot/blob/main/src/tools/registry.ts): `src/tools/registry.ts`
- [Shared approvals](https://github.com/counhopig/vex-bot/blob/main/src/policy/approvals.ts): `src/policy/approvals.ts`
- [Memory search](https://github.com/counhopig/vex-bot/blob/main/src/index/memory.ts): `src/index/memory.ts`
- [Skills](https://github.com/counhopig/vex-bot/blob/main/src/skills/discovery.ts): `src/skills/discovery.ts`
- [Bundled Skills](https://github.com/counhopig/vex-bot/tree/main/skills): `skills`
- [Scheduled tasks](https://github.com/counhopig/vex-bot/blob/main/src/scheduler/index.ts): `src/scheduler/index.ts`

### Configuration and operations

- [Configuration](https://github.com/counhopig/vex-bot/blob/main/src/config/load.ts): `src/config/load.ts`
- [Web authentication](https://github.com/counhopig/vex-bot/blob/main/src/gateway/auth.ts): `src/gateway/auth.ts`

### Workspace and storage

- [Workspace and persona](https://github.com/counhopig/vex-bot/blob/main/src/workspace/workspace.ts): `src/workspace/workspace.ts`
- [Conversation transcripts](https://github.com/counhopig/vex-bot/blob/main/src/store/jsonl.ts): `src/store/jsonl.ts`
- [Atomic file storage](https://github.com/counhopig/vex-bot/blob/main/src/store/atomic.ts): `src/store/atomic.ts`

### Other components

- **Owner**

## Connections

- Owner → WeChat channel: messages
- Owner → WebChat client: messages
- WebChat client → Web gateway: connects to
- WeChat channel → Session manager: shares conversations
- Web gateway → Session manager: routes messages (evidence: `src/gateway/server.ts`)
- Web gateway → Web authentication: checks access (evidence: `src/gateway/server.ts`)
- Daemon coordinator → Web gateway: starts (evidence: `src/daemon.ts`)
- Daemon coordinator → Session manager: opens sessions (evidence: `src/daemon.ts`)
- Session manager → Conversation agent: opens (evidence: `src/core/sessionManager.ts`)
- Conversation agent → Conversation transcripts: persists messages (evidence: `src/core/session.ts`)
- Conversation agent → Event bus: emits events (evidence: `src/core/session.ts`)
- Session manager → Event bus: subscribes (evidence: `src/core/sessionManager.ts`)
- Web gateway → Event bus: broadcasts updates (evidence: `src/gateway/server.ts`)
- Daemon coordinator → Model providers: resolves models (evidence: `src/daemon.ts`)
- Conversation agent → Model providers: uses model
- Conversation agent → Assistant tools: runs tools
- Daemon coordinator → Shared approvals: coordinates approvals (evidence: `src/daemon.ts`)
- Web gateway → Shared approvals: serves approval actions (evidence: `src/gateway/server.ts`)
- Daemon coordinator → Scheduled tasks: starts scheduler (evidence: `src/daemon.ts`)
- Scheduled tasks → Atomic file storage: saves schedules (evidence: `src/scheduler/index.ts`)
- Daemon coordinator → Workspace and persona: ensures workspace (evidence: `src/daemon.ts`)
- Daemon coordinator → Memory search: initializes memory (evidence: `src/daemon.ts`)
- Skills → Workspace and persona: adds prompt context (evidence: `src/skills/discovery.ts`)
- Skills → Bundled Skills: discovers skills
- Daemon coordinator → Configuration: loads configuration (evidence: `src/daemon.ts`)
- Configuration → Atomic file storage: writes configuration (evidence: `src/config/load.ts`)
