feat(p4): content analysis service with Neo4j knowledge graph and ClickHouse analytics

P4 阶段交付物:
- services/content: 内容资源服务(NestJS)
  - textbooks: 教材 CRUD + 知识图谱绑定
  - config/neo4j.ts: Neo4j driver 单例
  - textbooks.service.ts: MySQL CRUD + Neo4j 知识图谱(createKnowledgeGraph/getPrerequisites)
  - package.json: 补充 @opentelemetry/sdk-node + exporter-trace-otlp-http
- services/data-ana: 数据分析服务(Python FastAPI)
  - main.py: FastAPI + /healthz + class_performance + student_weakness 骨架
  - clickhouse_client.py: ClickHouse 客户端封装
  - config.py: 环境变量配置
- packages/shared-proto/proto/content.proto: TextbookService + KnowledgeGraphService 契约
- packages/shared-proto/proto/analytics.proto: AnalyticsService 契约(class_performance/student_weakness)
This commit is contained in:
SpecialX
2026-07-08 01:38:35 +08:00
parent 23246ade6d
commit 9850bfcfd1
28 changed files with 936 additions and 0 deletions

View File

@@ -0,0 +1,61 @@
syntax = "proto3";
package next_edu_cloud.analytics.v1;
service AnalyticsService {
rpc GetClassPerformance(GetClassPerformanceRequest) returns (ClassPerformance);
rpc GetStudentWeakness(GetStudentWeaknessRequest) returns (StudentWeakness);
rpc GetLearningTrend(GetLearningTrendRequest) returns (LearningTrend);
}
message GetClassPerformanceRequest {
string class_id = 1;
string subject_id = 2;
int64 start_date = 3;
int64 end_date = 4;
}
message ClassPerformance {
string class_id = 1;
double average_score = 2;
double pass_rate = 3;
repeated StudentScore scores = 4;
}
message StudentScore {
string student_id = 1;
double score = 2;
string grade = 3;
}
message GetStudentWeaknessRequest {
string student_id = 1;
string subject_id = 2;
}
message StudentWeakness {
string student_id = 1;
repeated WeakPoint weak_points = 2;
}
message WeakPoint {
string knowledge_point_id = 1;
string title = 2;
double mastery = 3;
}
message GetLearningTrendRequest {
string student_id = 1;
int64 start_date = 2;
int64 end_date = 3;
}
message LearningTrend {
string student_id = 1;
repeated TrendPoint points = 2;
}
message TrendPoint {
int64 date = 1;
double score = 2;
}

View File

@@ -0,0 +1,47 @@
syntax = "proto3";
package next_edu_cloud.content.v1;
service TextbookService {
rpc CreateTextbook(CreateTextbookRequest) returns (Textbook);
rpc GetTextbook(GetTextbookRequest) returns (Textbook);
rpc ListTextbooks(ListTextbooksRequest) returns (ListTextbooksResponse);
}
service KnowledgeGraphService {
rpc GetPrerequisites(GetPrerequisitesRequest) returns (KnowledgePointsResponse);
rpc GetLearningPath(GetLearningPathRequest) returns (LearningPath);
}
message Textbook {
string id = 1;
string title = 2;
string subject_id = 3;
string grade_id = 4;
string version = 5;
}
message CreateTextbookRequest {
string title = 1;
string subject_id = 2;
string grade_id = 3;
string version = 4;
}
message GetTextbookRequest { string id = 1; }
message ListTextbooksRequest { string subject_id = 1; string grade_id = 2; }
message ListTextbooksResponse { repeated Textbook textbooks = 1; }
message KnowledgePoint {
string id = 1;
string title = 2;
}
message GetPrerequisitesRequest { string knowledge_point_id = 1; }
message KnowledgePointsResponse { repeated KnowledgePoint points = 1; }
message GetLearningPathRequest { string student_id = 1; string subject_id = 2; }
message LearningPath {
repeated KnowledgePoint points = 1;
repeated string recommended_order = 2;
}