Files
Edu/docs/modules/content/README.md
SpecialX 2ba4250165
Some checks failed
CI Go / test (push) Has been cancelled
CI Proto / lint (push) Has been cancelled
CI Python / test (push) Has been cancelled
CI TypeScript / test (push) Has been cancelled
feat(p1): complete P1 foundation stage
- monorepo: pnpm workspace + go.work + pyproject.toml + commitlint/husky
- infra: docker-compose (minimal + full profiles) + init-sql + prometheus
- arch-scan: multi-language scanner skeleton (TS/Go/Python/Proto)
- shared-proto: buf v2 + classes.proto (ClassService CRUD contract)
- api-gateway: Go/Gin + JWT HS256 auth + reverse proxy + request ID
- classes: NestJS golden template (error system + observability + middleware + CRUD + tests)
- teacher-portal: Next.js + paper-feel UI design system
- CI/CD: 4 workflows (go/ts/py/proto)
- docs: migration guide + project_rules + coding-standards + git-workflow + ui-design-system + 004 + 9 module READMEs + known-issues + spec/plan migration + roadmap
2026-07-07 23:39:37 +08:00

105 lines
3.1 KiB
Markdown
Raw Permalink 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.
# content 内容资源服务
> 版本0.1(骨架)
> 日期2026-07-07
> 状态P4 待交付
> 关联文档:[架构影响地图](../../architecture/004_architecture_impact_map.md)
---
## 1. 模块职责
content 是内容资源限界上下文,管理 Textbook、Question、KnowledgePoint 三大聚合。
负责教材管理、题库管理(含 Elasticsearch 全文检索、知识图谱构建Neo4j 存储前置依赖关系)。
为 core-edu 提供题目来源,为 ai 服务提供出题素材与知识图谱查询。
---
## 2. 技术栈
| 类别 | 技术 | 版本 | 用途 |
|------|------|------|------|
| 语言 | TypeScript | 5.5+ | 类型安全 |
| 框架 | NestJS | 10.x | 依赖注入、模块化 |
| ORM | Drizzle ORM | 0.31+ | 关系数据访问 |
| 关系库 | MySQL | 8.x | 教材/题目写模型 |
| 图数据库 | Neo4j | 5.x | 知识图谱、前置依赖 |
| 搜索 | Elasticsearch | 8.x | 题库全文检索 |
| 校验 | Zod | 3.23+ | 运行时校验 |
---
## 3. 架构图
```mermaid
graph TB
BFF[BFF 聚合层] -->|gRPC| CONTENT[content 服务]
AI[ai 服务] -->|gRPC| CONTENT
CONTENT --> TB[Textbook 模块]
CONTENT --> Q[Question 模块]
CONTENT --> KP[KnowledgePoint 模块]
CONTENT -->[(MySQL<br/>教材/题目)]
CONTENT -->[(Neo4j<br/>知识图谱)]
CONTENT -->[(ES<br/>题库索引)]
CONTENT -.事件.-> K[(Kafka<br/>edu.content.*)]
```
> 待 P4 交付时补充完整的分层架构图与多存储协同图。
---
## 4. 核心流程图
```mermaid
sequenceDiagram
participant T as 教师
participant BFF as BFF
participant CONTENT as content
participant ES as Elasticsearch
participant N as Neo4j
T->>BFF: 创建题目
BFF->>CONTENT: gRPC CreateQuestion
CONTENT->>CONTENT: 写 MySQL + Outbox
CONTENT->>ES: 异步索引题目
CONTENT->>N: 异步更新知识点关联
CONTENT-->>BFF: 成功
```
> 待 P4 交付时补充:知识图谱查询流程、题库检索流程、教材发布流程。
---
## 5. 对外契约
- **gRPC 服务**TextbookService、QuestionService、KnowledgePointService待 P4 定义 protobuf
- **领域事件**`edu.content.question.published``edu.content.textbook.updated``edu.content.knowledge.linked`
- **存储表**textbooks、questions、knowledge_points、knowledge_edges、outbox
> 待 P4 交付时补充完整 protobuf 定义与多存储 schema。
---
## 6. 依赖关系
- **上游**teacher-bff、student-bff、aigRPC 查询题库与知识图谱)
- **下游**MySQL、Neo4j、Elasticsearch、Kafka
- **跨服务**:消费 core-edu 的教学事件触发内容关联;被 data-ana 消费内容发布事件
---
## 7. 架构约束
1. 题库检索必须走 Elasticsearch禁止 MySQL LIKE 全表扫描
2. 知识图谱前置依赖查询必须走 Neo4j禁止关系库递归查询
3. MySQL 写入后必须异步同步 ES 索引与 Neo4j 关系
4. Outbox 模式强制
> 待 P4 交付时补充完整约束清单。
---
## 8. 架构决策
> 待 P4 交付时补充 ADR 记录预计包括Neo4j 选型、ES 索引策略、多存储一致性保证、CDC 引入决策。