Skip to content

Latest commit

 

History

History
59 lines (48 loc) · 4.65 KB

CLASS_FLOW.md

File metadata and controls

59 lines (48 loc) · 4.65 KB

TalebElm: Student Flow and Layer Boundaries

1. Target Student Journey

Register / Sign in
  → Browse Tracks
  → Choose a Track and Enroll
  → Open the first Module
  → Study ordered Lessons and their sources
  → Submit answers for the Module exam (server grades)
  → Solve practice problems (Codeforces API verification / GitHub tasks)
  → Record score, exam pass, and problem completion states
  → Unlock only the next Module when BOTH exam and required problems are passed
  → Review progress
  → Deliver Track Capstone project

This is the target MVP flow, not a claim that every step currently works. Authentication, most HTTP endpoints, the shared progression gate and problem-side unlock trigger, practice problem verification, and capstone milestone verification are not implemented yet. User/password persistence, the entity and configuration layers, Track/Module/Lesson read services, server-side exam grading, the exam-side unlock, and Track enrollment are implemented.

2. Clean Architecture Request Path

HTTP request
  → API Controller
  → Application service interface (Abstraction)
  → Application service implementation (Concrete, via IUnitOfWork)
  → Domain repository interface / UnitOfWork
  → Infrastructure repository
  → AppDbContext
  → SQLite database
  • API binds HTTP input and returns HTTP responses. It should not contain business rules or access repositories directly.
  • Application defines service contracts, implements all business logic / use cases, and owns DTOs. It receives explicit user IDs, not HttpContext or JWT types, and accesses persistence only through IUnitOfWork (never a DbContext abstraction).
  • Domain owns entities, business rules, repository contracts, and domain exceptions.
  • Infrastructure implements repositories and owns EF Core persistence (DbContext/, Configurations/, Repositories/). It contains no business logic.

3. Current Code Paths

  • GET /api/health returns healthy directly from HealthController.
  • GET /api/tracks is wired, calls ITrackService.GetPagedAsync, and returns paged track summaries. POST /api/tracks binds CreateTrackRequest and throws NotImplementedException.
  • ExamService.GetByIdAsync loads an Exam through IUnitOfWork and throws NotFoundException when missing. Server-side grading is implemented in ExamService.SubmitAsync. ExamsController endpoints remain placeholders.
  • TrackEnrollmentService.EnrollAsync validates and records track enrollment, creating the first module's progress row. The HTTP enrollment endpoint is not yet wired.
  • UserProgressService reads per-module and per-track progress. Controller actions currently return 501.
  • Program.cs composition root calls AddInfrastructure(builder.Configuration) and AddApplication(), registering SQLite, repositories, services, validators, and OpenAPI in development. Authentication and authorization middleware are not registered.

4. Target Exam & Problem Progression Path

  1. The API authenticates the learner and passes the learner ID to the Application service.
  2. ExamService loads the Exam and its questions through repository contracts.
  3. The learner submits selected option IDs. The server compares them with the stored answer key; it does not trust a client-provided score.
  4. The service uses Exam.HasPassed(score) and updates UserProgress.Score and PassedExam = true.
  5. ModuleProblemService verifies external problem solves via Codeforces public API (user.status) or TaskVerificationService verifies GitHub tasks via GitHub REST API (workflow run success and test/workflow SHA integrity check), setting UserProgress.CompletedRequiredProblems = true.
  6. Progression check runs inside the same UnitOfWork transaction after either event (exam submit or problem completion): when both PassedExam and CompletedRequiredProblems are satisfied, the service finds the next Module in the same Track by Order and unlocks that Module for this learner only.
  7. UnitOfWork.SaveChangesAsync() commits the result and progress changes together atomically.
  8. The service returns results; the controller maps domain errors to HTTP responses through the registered middleware. Unique and foreign-key violations are translated into ConflictException (409) by UnitOfWork.SaveChangesAsync. Field-keyed validation responses are produced by ExceptionHandlingMiddleware (#321); domain ValidationException responses keep the single-detail shape.

Question storage, answer submission, problem verification, enrollment initialization, and unlock behavior are still target design; they must not be described as existing functionality until implemented and tested.