- 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
2.7 KiB
2.7 KiB
ERP 平台底座 — 知识库
项目画像
模块化 SaaS ERP 底座,Rust + React 技术栈,提供身份权限/工作流/消息/配置四大基础模块,支持行业业务模块快速插接。
关键数字:
- 8 个 Rust crate(4 个 placeholder),1 个前端 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 |