# anxi78/yuanbao_bot_client architecture

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

- Interactive diagram: https://gitdiagram.com/anxi78/yuanbao_bot_client
- Repository: https://github.com/anxi78/yuanbao_bot_client

## Overview

YuanBao Bot Client is a Python WebSocket client for interacting with Tencent Yuanbao Bot. Its main workflow is terminal commands into the sender, which authenticates and exchanges messages with the platform; the README documents messaging, group operations, media, automation, and AI-image features. A separate monitor listens for group events, stores messages in SQLite, and handles recall notifications. Plugin loading and the lexicon engine are additional runtime capabilities. The excerpts are partial, so some documented features are represented at the sender boundary rather than as independently verified internal modules.

Main entry points: [`sender.py`](https://github.com/anxi78/yuanbao_bot_client/blob/main/sender.py) (Command handling), [`group_monitor.py`](https://github.com/anxi78/yuanbao_bot_client/blob/main/group_monitor.py) (Monitor client), [`plugin_loader.py`](https://github.com/anxi78/yuanbao_bot_client/blob/main/plugin_loader.py) (Plugin API), [`plugins/example/main.py`](https://github.com/anxi78/yuanbao_bot_client/blob/main/plugins/example/main.py) (Example plugin)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Interactive client"]
  node_sender["Interactive sender<br/>[sender.py]"]
  node_auth["Bot authentication<br/>[sender.py]"]
  node_ws["WebSocket session<br/>[sender.py]"]
  node_commands["Command handling<br/>[sender.py]"]
  node_messaging["Message operations<br/>[sender.py]"]
  node_groups["Group operations<br/>[sender.py]"]
  node_automation["Auto-reply and proxy<br/>[sender.py]"]
  node_media["Media and stickers<br/>[sender.py]"]
end

subgraph group_extensions["Extensions"]
  node_pluginmanager["Plugin manager<br/>[plugin_loader.py]"]
  node_pluginapi["Plugin API<br/>[plugin_loader.py]"]
  node_exampleplugin["Example plugin<br/>[main.py]"]
end

subgraph group_monitor["Group monitoring"]
  node_monitorclient["Monitor client<br/>[group_monitor.py]"]
  node_store[("Message store<br/>[group_monitor.py]")]
  node_recall["Recall handling<br/>[group_monitor.py]"]
end

subgraph group_lexicon["Reply rules"]
  node_lexengine["Lexicon engine<br/>[lexicon.py]"]
  node_rules["Rule text files"]
end

node_operator(("Terminal user"))
node_cos(("Tencent COS"))
node_yuanbao(("Yuanbao platform"))

node_operator -->|"enters commands"| node_sender
node_sender -->|"dispatches input"| node_commands
node_sender -->|"signs in"| node_auth
node_auth -->|"requests token"| node_yuanbao
node_sender -->|"starts session"| node_ws
node_ws -->|"exchanges events"| node_yuanbao
node_commands -->|"invokes sends"| node_messaging
node_commands -->|"queries groups"| node_groups
node_commands -->|"controls modes"| node_automation
node_commands -->|"sends media"| node_media
node_media -.->|"uploads files"| node_cos
node_pluginmanager -->|"loads plugin"| node_exampleplugin
node_exampleplugin -->|"registers handlers"| node_pluginapi
node_pluginapi -->|"calls sender"| node_sender
node_operator -->|"starts monitor"| node_monitorclient
node_monitorclient -->|"listens and sends"| node_yuanbao
node_monitorclient -->|"stores messages"| node_store
node_monitorclient -->|"handles recall events"| node_recall
node_recall -->|"looks up originals"| node_store
node_recall -->|"sends notifications"| node_yuanbao
node_lexengine -->|"loads rules"| node_rules

click node_sender "https://github.com/anxi78/yuanbao_bot_client/blob/main/sender.py"
click node_auth "https://github.com/anxi78/yuanbao_bot_client/blob/main/sender.py"
click node_ws "https://github.com/anxi78/yuanbao_bot_client/blob/main/sender.py"
click node_commands "https://github.com/anxi78/yuanbao_bot_client/blob/main/sender.py"
click node_messaging "https://github.com/anxi78/yuanbao_bot_client/blob/main/sender.py"
click node_groups "https://github.com/anxi78/yuanbao_bot_client/blob/main/sender.py"
click node_automation "https://github.com/anxi78/yuanbao_bot_client/blob/main/sender.py"
click node_media "https://github.com/anxi78/yuanbao_bot_client/blob/main/sender.py"
click node_pluginmanager "https://github.com/anxi78/yuanbao_bot_client/blob/main/plugin_loader.py"
click node_pluginapi "https://github.com/anxi78/yuanbao_bot_client/blob/main/plugin_loader.py"
click node_exampleplugin "https://github.com/anxi78/yuanbao_bot_client/blob/main/plugins/example/main.py"
click node_monitorclient "https://github.com/anxi78/yuanbao_bot_client/blob/main/group_monitor.py"
click node_store "https://github.com/anxi78/yuanbao_bot_client/blob/main/group_monitor.py"
click node_recall "https://github.com/anxi78/yuanbao_bot_client/blob/main/group_monitor.py"
click node_lexengine "https://github.com/anxi78/yuanbao_bot_client/blob/main/lexicon.py"
click node_rules "https://github.com/anxi78/yuanbao_bot_client/tree/main/%E8%AF%8D%E5%BA%93"

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_sender,node_auth,node_ws,node_commands,node_messaging,node_groups,node_automation,node_media,node_operator toneBlue
class node_pluginmanager,node_pluginapi,node_exampleplugin toneAmber
class node_monitorclient,node_store,node_recall toneMint
class node_lexengine,node_rules toneRose
class node_cos,node_yuanbao toneIndigo
```

## Components

### Interactive client

- [Interactive sender](https://github.com/anxi78/yuanbao_bot_client/blob/main/sender.py): `sender.py`
- [Bot authentication](https://github.com/anxi78/yuanbao_bot_client/blob/main/sender.py): `sender.py`
- [WebSocket session](https://github.com/anxi78/yuanbao_bot_client/blob/main/sender.py): `sender.py`
- [Command handling](https://github.com/anxi78/yuanbao_bot_client/blob/main/sender.py): `sender.py`
- [Message operations](https://github.com/anxi78/yuanbao_bot_client/blob/main/sender.py): `sender.py`
- [Group operations](https://github.com/anxi78/yuanbao_bot_client/blob/main/sender.py): `sender.py`
- [Auto-reply and proxy](https://github.com/anxi78/yuanbao_bot_client/blob/main/sender.py): `sender.py`
- [Media and stickers](https://github.com/anxi78/yuanbao_bot_client/blob/main/sender.py): `sender.py`

### Extensions

- [Plugin manager](https://github.com/anxi78/yuanbao_bot_client/blob/main/plugin_loader.py): `plugin_loader.py`
- [Plugin API](https://github.com/anxi78/yuanbao_bot_client/blob/main/plugin_loader.py): `plugin_loader.py`
- [Example plugin](https://github.com/anxi78/yuanbao_bot_client/blob/main/plugins/example/main.py): `plugins/example/main.py`

### Group monitoring

- [Monitor client](https://github.com/anxi78/yuanbao_bot_client/blob/main/group_monitor.py): `group_monitor.py`
- [Message store](https://github.com/anxi78/yuanbao_bot_client/blob/main/group_monitor.py): `group_monitor.py`
- [Recall handling](https://github.com/anxi78/yuanbao_bot_client/blob/main/group_monitor.py): `group_monitor.py`

### Reply rules

- [Lexicon engine](https://github.com/anxi78/yuanbao_bot_client/blob/main/lexicon.py): `lexicon.py`
- [Rule text files](https://github.com/anxi78/yuanbao_bot_client/tree/main/%E8%AF%8D%E5%BA%93): `词库`

### Other components

- **Terminal user**
- **Tencent COS**
- **Yuanbao platform**

## Connections

- Terminal user → Interactive sender: enters commands
- Interactive sender → Command handling: dispatches input
- Interactive sender → Bot authentication: signs in
- Bot authentication → Yuanbao platform: requests token
- Interactive sender → WebSocket session: starts session
- WebSocket session → Yuanbao platform: exchanges events
- Command handling → Message operations: invokes sends
- Command handling → Group operations: queries groups
- Command handling → Auto-reply and proxy: controls modes
- Command handling → Media and stickers: sends media
- Media and stickers → Tencent COS: uploads files
- Plugin manager → Example plugin: loads plugin
- Example plugin → Plugin API: registers handlers
- Plugin API → Interactive sender: calls sender
- Terminal user → Monitor client: starts monitor
- Monitor client → Yuanbao platform: listens and sends
- Monitor client → Message store: stores messages
- Monitor client → Recall handling: handles recall events
- Recall handling → Message store: looks up originals
- Recall handling → Yuanbao platform: sends notifications
- Lexicon engine → Rule text files: loads rules
