24 lines
1.3 KiB
Markdown
24 lines
1.3 KiB
Markdown
# 模块边界与所有权
|
||
|
||
后端是共享 PostgreSQL 的模块化单体,API 与 Worker 是独立运行时。跨模块调用通过 `Tiku.Application` 契约,模块实现由 `Tiku.Infrastructure/Modules` 统一注册。
|
||
|
||
## 依赖方向
|
||
|
||
- API Controller 不得引用 `Tiku.Infrastructure` 或 `TikuDbContext`。
|
||
- 业务模块通过 Application 查询/命令契约协作,不直接依赖其他模块的 Infrastructure 类型。
|
||
- `TikuDbContext` 是统一事务入口;DbSet 按领域拆到 `Persistence/Modules`,Migration 和模型快照仍全局唯一。
|
||
- `AddInfrastructure` 组合 Platform Core、Auth、Content、Learning、Tenant Admin、Commerce、Jobs 和 Platform 模块。
|
||
- 后台任务处理器实现 `IBackgroundJobHandler`,在所属模块注册;Jobs 模块只负责队列、租约、调度和处理器查找。
|
||
- 新 Service 聚合超过 800 行会被 `ArchitectureBoundaryTests` 阻止;既有超限服务不得超过记录的债务基线。
|
||
|
||
## API audience
|
||
|
||
- `/api/platform/*`:平台控制面。
|
||
- `/api/tenant/*`:租户管理后台。
|
||
- `/api/student/*`:学生业务。
|
||
- `/api/public/*`:匿名公开读取。
|
||
- `/api/system/*`:健康与内部诊断。
|
||
- `/api/integrations/*`:外部系统回调。
|
||
|
||
旧 audience 路由不提供兼容入口。路由变化必须同步更新 OpenAPI 客户端和对应前端。
|