Files
erp/wiki/index.md
iven 810eef769f feat(server): integrate AppState, ModuleRegistry, health check, and graceful shutdown
- Add AppState with DB, Config, EventBus, ModuleRegistry via Axum State
- ModuleRegistry now uses Arc for Clone support, builder-pattern register()
- Add /api/v1/health endpoint returning status, version, registered modules
- Add graceful shutdown on CTRL+C / SIGTERM
- erp-common utils: ID generation, timestamp helpers, code generator with tests
- Config structs now derive Clone for state sharing
- Update wiki to reflect Phase 1 completion
2026-04-11 01:19:30 +08:00

69 lines
2.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# ERP 平台底座 — 知识库
## 项目画像
**模块化 SaaS ERP 底座**Rust + React 技术栈,提供身份权限/工作流/消息/配置四大基础模块,支持行业业务模块快速插接。
关键数字:
- 8 个 Rust crate4 个 placeholder1 个前端 SPA
- 1 个数据库迁移tenant 表)
- Health Check API (`/api/v1/health`)
- Phase 1 基础设施完成
## 模块导航树
### L1 基础层
- [[erp-core]] — 错误体系 · 事件总线 · 模块 trait · 共享类型
- [[erp-common]] — ID 生成 · 时间戳 · 编号生成工具
### L2 业务层(均为 placeholder
- erp-auth — 身份与权限Phase 2
- erp-config — 系统配置Phase 3
- erp-workflow — 工作流引擎Phase 4
- erp-message — 消息中心Phase 5
### L3 组装层
- [[erp-server]] — Axum 服务入口 · AppState · ModuleRegistry 集成 · 配置加载 · 数据库连接 · 优雅关闭
### 基础设施
- [[database]] — SeaORM 迁移 · 多租户表结构 · 软删除模式
- [[infrastructure]] — Docker Compose · PostgreSQL 16 · Redis 7
- [[frontend]] — React SPA · Ant Design 布局 · Zustand 状态
### 横切关注点
- [[architecture]] — 架构决策记录 · 设计原则 · 技术选型理由
## 核心架构决策
**模块间如何通信?** 通过 [[erp-core]] 的 EventBus 发布/订阅 DomainEvent不直接依赖。
**多租户怎么隔离?** 共享数据库 + tenant_id 列过滤,中间件从 JWT 注入 TenantContext。详见 [[database]] 和 [[architecture]]。
**错误怎么传播?** 业务 crate 用 thiserror → AppError → Axum IntoResponse 自动转 HTTP。详见 [[erp-core]] 错误处理链。
**状态如何共享?** AppState 包含 DB、Config、EventBus、ModuleRegistry通过 Axum State 提取器注入所有 handler。
**ModuleRegistry 怎么工作?** 每个 Phase 2+ 的业务模块实现 ErpModule trait在 main.rs 中链式注册。registry 自动构建路由和事件处理器。
**版本差异怎么办?** package.json 使用 React 19 + Ant Design 6比规格文档更新以实际代码为准。
## 开发进度
| Phase | 内容 | 状态 |
|-------|------|------|
| 1 | 基础设施 | 完成 |
| 2 | 身份与权限 | 待开始 |
| 3 | 系统配置 | 待开始 |
| 4 | 工作流引擎 | 待开始 |
| 5 | 消息中心 | 待开始 |
| 6 | 整合与打磨 | 待开始 |
## 关键文档索引
| 文档 | 位置 |
|------|------|
| 设计规格 | `docs/superpowers/specs/2026-04-10-erp-platform-base-design.md` |
| 实施计划 | `docs/superpowers/plans/2026-04-10-erp-platform-base-plan.md` |
| 协作规则 | `CLAUDE.md` |
| 设计评审 | `plans/squishy-pondering-aho-agent-a23c7497aadc6da41.md` |