Course Repository
Component Detail
Data Layer
medium complexity
backend
0
Dependencies
4
Dependents
1
Entities
0
Integrations
Description
Data access layer for the courses and course_enrollments tables. Provides multi-tenant-safe queries scoped to the user's organization, with support for capacity aggregation, waitlist ordering, and enrollment lookup by user.
course-repository
Responsibilities
- Fetch course catalog scoped to the user's organization_id
- Create and update enrollment records with FIFO waitlist ordering
- Query enrolled and waitlisted counts per course for capacity checks
- Retrieve full enrollment history for a given user including completion status
- Atomically promote the first waitlisted user when a slot opens
Interfaces
findCoursesByOrganization(organizationId): Course[]
findCourseById(courseId): Course
createEnrollment(userId, courseId): Enrollment
deleteEnrollment(enrollmentId): void
findEnrollmentsByUser(userId): Enrollment[]
countEnrolledAndWaitlisted(courseId): CapacitySummary
promoteFirstWaitlisted(courseId): Enrollment | null
markAttendanceConfirmed(enrollmentId): void
Relationships
Dependents (4)
Components that depend on this component