CourseRepository
Component Detail
Description
Manages all persistence operations for courses, enrollments, and completion records. Provides a typed data access layer over the underlying database, abstracting query logic from the service layer. Ensures data integrity for enrollment state and completion linkage used by the certification pipeline.
course-repository
Sources & reasoning
HLF explicitly requires in-app course registration as part of their certification workflow (line 114), and Barnekreftforeningen shares the need for onboarding and follow-up training (line 123). The priority matrix (line 155) marks this SHOULD Phase 3, confirming v1.1 per third-phase normalization. The feature is foundational to certification-training and directly enables the certificate and renewal reminder features.
-
docs/source/likeperson.md · line 114Kursadministrasjon og sertifisering: Påmelding til kurs i appen, automatisk påminnelse ved utløp, digitale sertifikater. Det fysiske kortet er et «adelsmerke» og skal leve parallelt.
-
docs/source/likeperson.md · line 123Kursadministrasjon (delt med HLF) for opplæring av nye likepersoner og oppfølgingskurs.
-
docs/source/likeperson.md · line 155Kursadministrasjon / sertifisering | ✓ | - | - | ✓ | ✓ | SHOULD (HLF + Barnekreft) | 3
Responsibilities
- Query and return course records with optional filtering by status or organization
- Create and update enrollment records tied to user and course identifiers
- Persist course completion events with timestamps for certification tracking
- Retrieve enrollment history per user for profile and reporting use cases
- Enforce uniqueness constraints to prevent duplicate enrollment records
Interfaces
findAllCourses(filter?: CourseFilter): Promise<Course[]>
findCourseById(courseId: string): Promise<Course | null>
createEnrollment(userId: string, courseId: string): Promise<Enrollment>
updateEnrollmentStatus(enrollmentId: string, status: EnrollmentStatus): Promise<void>
recordCompletion(userId: string, courseId: string, completedAt: Date): Promise<Completion>
findEnrollmentsByUser(userId: string): Promise<Enrollment[]>