# yxxbc/dsh-balance-plugin architecture

> Architecture diagram of the GitHub repository yxxbc/dsh-balance-plugin, 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/yxxbc/dsh-balance-plugin
- Repository: https://github.com/yxxbc/dsh-balance-plugin

## Overview

DeepSeek Harness 插件为用户提供余额监控、用量统计、第三方插件管理和更新入口。主要流程是：用户在 Harness 输入框工具栏打开面板，客户端通过 HTTP RPC 请求宿主；宿主读取凭据并查询 DeepSeek 余额，或返回用量与插件信息，客户端再呈现结果。余额告警、充值入口和模型工具扩展了主流程。用量图表、性能指标和插件管理能力主要依据 README；由于源码节选不完整，未推断未展示的事件订阅、存储和路由调用细节。

Main entry points: [`lib/client.js`](https://github.com/yxxbc/dsh-balance-plugin/blob/main/lib/client.js) (面板与 RPC 客户端), [`lib/index.js`](https://github.com/yxxbc/dsh-balance-plugin/blob/main/lib/index.js) (HTTP RPC 路由)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Harness 客户端"]
  node_client["面板与 RPC 客户端<br/>[client.js]"]
end

subgraph group_balance["余额服务"]
  node_host["插件宿主入口<br/>[index.js]"]
  node_routes["HTTP RPC 路由<br/>[index.js]"]
  node_balance_poll["账户余额轮询<br/>[index.js]"]
  node_credentials["凭据读取<br/>[index.js]"]
  node_thresholds["双币种告警配置<br/>[index.js]"]
  node_quota_tool["余额查询工具<br/>[index.js]"]
  node_config[("插件配置持久化")]
end

subgraph group_usage["用量统计"]
  node_usage_state["用量与性能数据<br/>[index.js]"]
  node_usage_views["统计图表与明细<br/>[client.js]"]
end

subgraph group_plugins["插件管理"]
  node_plugin_inventory["第三方插件清单<br/>[index.js]"]
  node_plugin_actions["插件目录与操作<br/>[index.js]"]
  node_plugin_update["检查与更新<br/>[index.js]"]
end

node_user(("Harness 用户"))
node_harness["DeepSeek Harness"]
node_deepseek["DeepSeek API"]
node_topup["官方充值入口"]
node_shell["Harness Shell"]

node_user -->|"打开面板"| node_client
node_harness -->|"加载插件"| node_client
node_client -->|"POST RPC"| node_routes
node_routes -->|"返回 JSON"| node_client
node_host -->|"注册路由"| node_routes
node_host -->|"读取凭据"| node_credentials
node_credentials -->|"提供密钥"| node_balance_poll
node_balance_poll -->|"查询余额"| node_deepseek
node_host -->|"轮询账户"| node_balance_poll
node_routes -->|"处理余额请求"| node_balance_poll
node_balance_poll -->|"评估阈值"| node_thresholds
node_client -->|"打开充值页"| node_topup
node_routes -->|"处理用量请求"| node_usage_state
node_usage_state -->|"提供统计数据"| node_routes
node_client -->|"渲染用量"| node_usage_views
node_client -->|"请求插件清单"| node_plugin_inventory
node_routes -->|"读取清单"| node_plugin_inventory
node_client -->|"触发插件操作"| node_plugin_actions
node_routes -->|"处理操作请求"| node_plugin_actions
node_plugin_actions -->|"执行管理命令"| node_shell
node_client -->|"请求检查或更新"| node_plugin_update
node_routes -->|"处理更新请求"| node_plugin_update
node_plugin_update -->|"执行更新命令"| node_shell
node_quota_tool -->|"触发余额查询"| node_balance_poll
node_host -->|"注册工具"| node_quota_tool
node_host -->|"读写设置"| node_config

click node_client "https://github.com/yxxbc/dsh-balance-plugin/blob/main/lib/client.js"
click node_host "https://github.com/yxxbc/dsh-balance-plugin/blob/main/lib/index.js"
click node_routes "https://github.com/yxxbc/dsh-balance-plugin/blob/main/lib/index.js"
click node_balance_poll "https://github.com/yxxbc/dsh-balance-plugin/blob/main/lib/index.js"
click node_credentials "https://github.com/yxxbc/dsh-balance-plugin/blob/main/lib/index.js"
click node_thresholds "https://github.com/yxxbc/dsh-balance-plugin/blob/main/lib/index.js"
click node_quota_tool "https://github.com/yxxbc/dsh-balance-plugin/blob/main/lib/index.js"
click node_usage_state "https://github.com/yxxbc/dsh-balance-plugin/blob/main/lib/index.js"
click node_usage_views "https://github.com/yxxbc/dsh-balance-plugin/blob/main/lib/client.js"
click node_plugin_inventory "https://github.com/yxxbc/dsh-balance-plugin/blob/main/lib/index.js"
click node_plugin_actions "https://github.com/yxxbc/dsh-balance-plugin/blob/main/lib/index.js"
click node_plugin_update "https://github.com/yxxbc/dsh-balance-plugin/blob/main/lib/index.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_client toneBlue
class node_host,node_routes,node_balance_poll,node_credentials,node_thresholds,node_quota_tool,node_config toneAmber
class node_usage_state,node_usage_views,node_deepseek toneMint
class node_plugin_inventory,node_plugin_actions,node_plugin_update toneRose
class node_user,node_harness,node_topup,node_shell toneIndigo
```

## Components

### Harness 客户端

- [面板与 RPC 客户端](https://github.com/yxxbc/dsh-balance-plugin/blob/main/lib/client.js): `lib/client.js`

### 余额服务

- [插件宿主入口](https://github.com/yxxbc/dsh-balance-plugin/blob/main/lib/index.js): `lib/index.js`
- [HTTP RPC 路由](https://github.com/yxxbc/dsh-balance-plugin/blob/main/lib/index.js): `lib/index.js`
- [账户余额轮询](https://github.com/yxxbc/dsh-balance-plugin/blob/main/lib/index.js): `lib/index.js`
- [凭据读取](https://github.com/yxxbc/dsh-balance-plugin/blob/main/lib/index.js): `lib/index.js`
- [双币种告警配置](https://github.com/yxxbc/dsh-balance-plugin/blob/main/lib/index.js): `lib/index.js`
- [余额查询工具](https://github.com/yxxbc/dsh-balance-plugin/blob/main/lib/index.js): `lib/index.js`
- **插件配置持久化**

### 用量统计

- [用量与性能数据](https://github.com/yxxbc/dsh-balance-plugin/blob/main/lib/index.js): `lib/index.js`
- [统计图表与明细](https://github.com/yxxbc/dsh-balance-plugin/blob/main/lib/client.js): `lib/client.js`

### 插件管理

- [第三方插件清单](https://github.com/yxxbc/dsh-balance-plugin/blob/main/lib/index.js): `lib/index.js`
- [插件目录与操作](https://github.com/yxxbc/dsh-balance-plugin/blob/main/lib/index.js): `lib/index.js`
- [检查与更新](https://github.com/yxxbc/dsh-balance-plugin/blob/main/lib/index.js): `lib/index.js`

### Other components

- **Harness 用户**
- **DeepSeek Harness**
- **DeepSeek API**
- **官方充值入口**
- **Harness Shell**

## Connections

- Harness 用户 → 面板与 RPC 客户端: 打开面板
- DeepSeek Harness → 面板与 RPC 客户端: 加载插件
- 面板与 RPC 客户端 → HTTP RPC 路由: POST RPC
- HTTP RPC 路由 → 面板与 RPC 客户端: 返回 JSON
- 插件宿主入口 → HTTP RPC 路由: 注册路由
- 插件宿主入口 → 凭据读取: 读取凭据
- 凭据读取 → 账户余额轮询: 提供密钥
- 账户余额轮询 → DeepSeek API: 查询余额
- 插件宿主入口 → 账户余额轮询: 轮询账户
- HTTP RPC 路由 → 账户余额轮询: 处理余额请求
- 账户余额轮询 → 双币种告警配置: 评估阈值
- 面板与 RPC 客户端 → 官方充值入口: 打开充值页
- HTTP RPC 路由 → 用量与性能数据: 处理用量请求
- 用量与性能数据 → HTTP RPC 路由: 提供统计数据
- 面板与 RPC 客户端 → 统计图表与明细: 渲染用量
- 面板与 RPC 客户端 → 第三方插件清单: 请求插件清单
- HTTP RPC 路由 → 第三方插件清单: 读取清单
- 面板与 RPC 客户端 → 插件目录与操作: 触发插件操作
- HTTP RPC 路由 → 插件目录与操作: 处理操作请求
- 插件目录与操作 → Harness Shell: 执行管理命令
- 面板与 RPC 客户端 → 检查与更新: 请求检查或更新
- HTTP RPC 路由 → 检查与更新: 处理更新请求
- 检查与更新 → Harness Shell: 执行更新命令
- 余额查询工具 → 账户余额轮询: 触发余额查询
- 插件宿主入口 → 余额查询工具: 注册工具
- 插件宿主入口 → 插件配置持久化: 读写设置
