SRDsExercise AIOverview
DraftDT-4662Exercise AISRDSpeakingAIEngineeringstudy-hub

Exercise AI — SRD (Overview)

SRD kỹ thuật cho runtime làm bài (do-test) của nhóm Exercise AI, hiện thực trong app study-hub (features/exercise_ai). Phần ý đồ sản phẩm nằm ở các PRD: Type 1 — Speak a Sentence, Linear Note — Student, Linear Tool — Technical Proposal.

Phạm vi

Tài liệu này mô tả luồng học viên làm bài (do-test): khởi tạo progress, làm từng câu, chấm phát âm, nộp bài; cùng API soạn nội dung (data-entry) ở mức hợp đồng REST + aggregate AiExercise. Chi tiết shape nội dung theo từng dạng bài (authoring content) là phần TBD — tham chiếu PRD Type 1Linear Note.

Các dạng bài (AiExerciseType)

EnumTênMô tả ngắn
SPEAK_A_SENTENCENói một câuHọc viên nói từng câu rời, AI chấm theo lượt (turn-based).
IMPROVE_A_SENTENCECải thiện câu nóiBiến thể turn-based: cải thiện câu đã nói.
LINEAR_TOOLCông cụ tuyến tínhDựng sơ đồ ý phân nhánh trên canvas, AI sinh câu, luyện nói cả bài.
GUIDED_PRACTICELuyện tập có hướng dẫnPlaceholder — shape chưa chốt (TBD).

exerciseTypediscriminator ở mức progress/content: một progress chỉ chứa một dạng bài, quyết định subtype của contentquestions.

Kiến trúc hệ thống

  • App: study-hub (Java 25 + Spring Boot, MongoDB, không Spring Security — JWT).
  • CQRS-lite: controller → *ServiceCommand / *ServiceQuery (interface) → handler. Command tách khỏi query.
  • Persistence: MongoDB schema-on-write (không migration tool). Progress là một document AiUserExerciseProgress (@Document), contentquestions lưu đa hình (polymorphic embedded).
  • Đa hình: content và question đều theo cây kế thừa, dispatch qua MapperFactory + CanHandleMapping (reflection theo runtime type) — không dùng switch. Mỗi subtype có entity + DTO + mapper riêng.
  • Chấm AI (Restate): chấm phát âm/turn chạy bất đồng bộ; kết quả trả về qua webhook callback server-to-server (POST /exercise-ai/dotest/marking/callback), cập nhật turn theo turnId.

Glossary

  • Progress — một phiên làm bài của học viên (AiUserExerciseProgress). Trạng thái IN_PROGRESSCOMPLETED.
  • Content — payload theo dạng bài, gắn trong progress (BaseAiExerciseProgressContent).
  • Question (progress) — tiến độ của một câu trong bài (BaseAIExerciseQuestionProgress).
  • Turn — một lượt nói/được-chấm trong dạng turn-based (AnswerTurn).
  • Canvas / Card — sơ đồ ý của LINEAR_TOOL (LinearCanvas / LinearCard).
  • Verdict — kết quả chấm phát âm (SpeechVerdict: GOOD / NEED_IMPROVE).

Đọc tiếp