Files
tiku-backend.net/docs/architecture/module-boundaries.md
xiong 4751e738b1
Some checks failed
ci / release-gate (push) Has been cancelled
清理文档
2026-08-03 13:41:03 +08:00

24 lines
1.3 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.

# 模块边界与所有权
后端是共享 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 客户端和对应前端。