docs(wiki): 全景梳理 — 更新 9 个 wiki + CLAUDE.md scope + 头脑风暴记录
Some checks failed
CI / security-audit (push) Has been cancelled
CI / rust-check (push) Has been cancelled
CI / rust-test (push) Has been cancelled
CI / frontend-build (push) Has been cancelled

基于 3 个并行探索代理的全面扫描结果,更新 wiki 数据至实际状态:
- index.md: 18 crate / 76 迁移 / 44 实体 / 77k 行 / 409 提交
- erp-health.md: 44 实体 / 21 handler / 22 权限 / 25 事件 / 6 消费者
- erp-server.md: 9 后台任务 / RLS 中间件栈
- architecture.md: 新增 erp-ai/dialysis 到依赖图 / 测试覆盖表
- testing.md: 225 单元 + 159 集成 / 4 模块零测试警告
- database.md: 76 迁移 / RLS+哈希链+盲索引+Dead Letter
- erp-core.md: PiiCrypto 加密体系 / EventBus 完整描述
- frontend.md: 163 文件 / 5 store / 10 API 文件
- CLAUDE.md: 新增 health/ai/dialysis/assessment scope

头脑风暴 4 个议题决策:
- dialysis: 接入激活
- 测试: 按风险排序(workflow > ai > message > config)
- AI: 数据桥接优先
- 路线图: AI 驱动 3 个月 5 Phase
This commit is contained in:
iven
2026-04-28 14:53:04 +08:00
parent ac1033dbaf
commit 75cd305996
10 changed files with 359 additions and 91 deletions

View File

@@ -1,6 +1,6 @@
---
title: erp-server
updated: 2026-04-25
updated: 2026-04-28
status: stable
tags: [server, axum, assembly, entry-point]
---
@@ -35,7 +35,7 @@ tags: [server, axum, assembly, entry-point]
```
AppConfig::load() → 安全检查 → init_tracing → db::connect → Migrator::up
→ 种子数据(默认租户+管理员) → Redis客户端 → EventBus(容量1024)
→ 注册6个模块 → 初始化插件引擎+恢复插件 → 5个后台任务
→ 注册7个模块 → 初始化插件引擎+恢复插件 → 8+后台任务
→ 构建Router → bind + serve → 优雅关闭(CTRL+C/SIGTERM)
```
@@ -77,18 +77,24 @@ AppState {
1. 消息监听器 — EventBus → MessageModule
2. 插件通知 — EventBus → PluginModule
3. Outbox relay — domain_events → 外部
4. 超时检查器 — 工作流任务超时处理
5. 随访逾期检查 — HealthModule 每 5 分钟扫描过期随访任务
3. Outbox relay — domain_events → 外部LISTEN/NOTIFY + 30s 兜底轮询)
4. 事件清理 — 归档 + 清理过期事件
5. 超时检查工作流任务超时处理60s
6. 随访逾期检查 — HealthModule 每 6 小时扫描过期随访任务
7. 积分过期清理 — HealthModule 每 24 小时处理过期积分
8. 预约提醒 — HealthModule 每 1 小时扫描即将到来的预约
9. 插件恢复 — 启动时恢复已安装插件
## 3. 代码逻辑
### 中间件栈
```
CORS(可配置 origins) → IP限流(公开路由) → 用户限流(受保护路由) → JWT认证
CORS(可配置 origins) → Tenant RLS(SET app.current_tenant_id) → JWT认证 → 用户限流(100 req/min/user, Redis)
```
公开路由额外IP 限流 + 账户锁定
### 配置结构
```
@@ -116,5 +122,6 @@ AppConfig
| 日期 | 变更 |
|------|------|
| 2026-04-25 | 更新为 6 模块注册8 个环境变量,新增随访逾期检查后台任务 |
| 2026-04-28 | 更新后台任务为 9 个、中间件栈含 RLS、outbox relay 机制完善 |
| 2026-04-25 | 更新为 7 模块注册8 个环境变量,新增随访逾期检查后台任务 |
| 2026-04-23 | 重构为 5 节结构,更新为当前集成状态 |