Files
Edu/services/data-ana
SpecialX 0a71b02e04
Some checks failed
CI / quality-ts (push) Failing after 48s
CI / quality-go (push) Failing after 4s
CI / quality-proto (push) Failing after 2s
CI / deploy (push) Has been skipped
fix: code compliance audit and fix across all services
NestJS (6 services): implement @RequirePermission decorator with
SetMetadata+Reflector, register APP_GUARD globally, fix as assertions
to type guards, add explicit return types, fix import type for express,
fix /metrics implicit any, replace native Error with ApplicationError,
remove typeorm remnants, register LifecycleService.

teacher-bff: add logger, ApplicationError, GlobalErrorFilter, forward
real userId to downstream, log downstream failures, migrate health
controller to shared/health.

Go (2 services): interface to any, doc comments, CORS dev whitelist,
JWT secret fail-fast, push-gateway internal API auth, metrics and
readyz endpoints, remove dead code.

Python (2 services): lifespan return type, dev_mode to bool, data-ana
APIRouter, ai POST body model, ClickHouse async wrapping.
2026-07-09 17:28:27 +08:00
..

data-ana 数据分析服务

版本0.1P4 骨架) 端口3006

职责

数据分析限界上下文Python 实现),消费 core-edu 与 content 的领域事件, 构建 ClickHouse 学情宽表,计算知识点掌握度。 对外提供学情仪表盘查询、班级/年级/学校维度报表、个性化推荐数据支撑。

技术栈

  • Python 3.12+ / FastAPI 0.115+
  • clickhouse-connectClickHouse 宽表查询)
  • pydantic + pydantic-settings运行时校验与配置
  • structlog结构化日志
  • prometheus-client指标
  • OpenTelemetry分布式追踪

开发

uv sync
uv run uvicorn src.data_ana.main:app --host 0.0.0.0 --port 3006 --reload

配置

变量 默认值 说明
PORT 3006 服务端口
CLICKHOUSE_HOST localhost ClickHouse 主机
CLICKHOUSE_PORT 8123 ClickHouse HTTP 端口
CLICKHOUSE_DATABASE edu_analytics ClickHouse 数据库
OTEL_ENDPOINT http://localhost:4318 OpenTelemetry 端点
LOG_LEVEL info 日志级别

模块结构

src/data_ana/
├─ __init__.py
├─ main.py              # FastAPI 入口(健康检查 + 分析端点骨架)
├─ config.py            # pydantic-settings 配置
└─ clickhouse_client.py # ClickHouse 客户端单例

关键端点

  • GET /healthz 健康检查
  • GET /metrics Prometheus 指标
  • GET /analytics/class/{class_id}/performance 班级成绩分析P4 骨架)
  • GET /analytics/student/{student_id}/weakness 学生薄弱知识点分析P4 骨架)

对外契约

gRPC 服务 AnalyticsService 定义见 packages/shared-proto/proto/analytics.proto