core PK: id 11 required 1 unique

Description

A training course available for peer mentor enrollment — covering peer mentor certification courses, career workshops, and continuing education programs. Courses have capacity limits, schedules, and recurrence patterns. Completing a course can automatically generate a certification for the enrolled user.

20
Attributes
7
Indexes
10
Validation Rules
16
CRUD Operations

Data Structure

Name Type Description Constraints
id uuid Primary key — unique course identifier generated on creation
PKrequiredunique
organization_id uuid Foreign key to the organization that owns and manages this course catalog entry. Enforces multi-tenancy — all queries must be scoped to this value.
required
created_by uuid Foreign key to the user (coordinator or org admin) who created this course record
required
title string Display name of the course shown in listings and enrollment screens. Must be human-readable and organization-specific.
required
description text Full course description covering learning objectives, prerequisites, and what peer mentors can expect. Displayed on the Course Enrollment Screen.
-
course_type enum Classification of the course purpose. Drives whether attendance automatically issues a certification and which certification template applies.
required
status enum Lifecycle status of the course. Only published courses appear in the peer mentor course listing. Cancelled courses retain enrollment records for historical reporting.
required
capacity integer Maximum number of participants allowed. NULL indicates unlimited capacity. Enforced at enrollment time by checking current enrollment count against this value.
-
event_date datetime Primary date and time when the course takes place (start of first session). Stored in UTC, displayed in user's local timezone.
required
end_date datetime Date and time when the course ends. For multi-day workshops (e.g., Blindeforbundet career workshops spanning two days), this differs from event_date. NULL for single-session courses.
-
location string Physical or virtual location of the course. For in-person courses: venue name and address. For virtual: meeting link or platform name.
-
recurrence_pattern json JSON object describing if and how the course repeats. Schema: { frequency: 'none'|'weekly'|'monthly'|'annually', interval: integer, end_after_occurrences: integer|null, end_date: ISO8601|null }. NULL or frequency:'none' means one-time course.
-
auto_issue_certification boolean When true, the Certification Service automatically creates a certification record for each user whose enrollment status transitions to 'attended'. Drives HLF's in-app certification management requirement.
required
certification_validity_months integer Number of months a certification issued from this course remains valid before it enters 'expiring-soon' status. Required when auto_issue_certification is true. Typically 12 or 24 months for HLF peer mentor certificates.
-
category string Free-text category tag used for filtering in the Course List Screen. Examples: 'Peer Mentor Certification', 'Career Development', 'Refresher'. Organization-defined.
-
registration_deadline datetime Cutoff datetime after which new enrollments are no longer accepted. If NULL, enrollment is open until event_date. Stored in UTC.
-
waitlist_enabled boolean When true and capacity is full, new enrollment attempts create a waitlist entry (status: waitlisted) rather than being rejected. Waitlisted users are promoted if a registered participant withdraws.
required
metadata json Extensible JSON bag for organization-specific course fields not covered by the standard schema. Examples: instructor name, required equipment, prerequisite course IDs.
-
created_at datetime UTC timestamp when the course record was first created
required
updated_at datetime UTC timestamp of the last update to any course field. Auto-updated on every write.
required

Database Indexes

idx_course_organization_id
btree

Columns: organization_id

idx_course_event_date
btree

Columns: event_date

idx_course_organization_status
btree

Columns: organization_id, status

idx_course_organization_event_date
btree

Columns: organization_id, event_date

idx_course_status
btree

Columns: status

idx_course_course_type
btree

Columns: course_type

idx_course_registration_deadline
btree

Columns: registration_deadline

Validation Rules

title_not_empty error

Validation failed

event_date_future_on_create error

Validation failed

end_date_after_event_date error

Validation failed

registration_deadline_before_event_date error

Validation failed

capacity_positive_integer error

Validation failed

certification_validity_months_range error

Validation failed

recurrence_pattern_schema_valid error

Validation failed

organization_id_exists error

Validation failed

status_transition_valid error

Validation failed

description_max_length error

Validation failed

Business Rules

capacity_enforcement
on_create

When a user attempts to enroll and capacity is not NULL, the current count of enrollments with status 'registered' must be strictly less than capacity. If capacity is reached and waitlist_enabled is true, the enrollment is created with status 'waitlisted'. If waitlist_enabled is false, enrollment is rejected with a capacity-full error.

registration_deadline_enforcement
on_create

If registration_deadline is set, new enrollment attempts after that datetime are rejected regardless of remaining capacity. This check occurs server-side in Course Management Service before creating the enrollment record.

auto_certification_on_attendance
on_update

When a course_enrollment record transitions to status 'attended' AND the parent course has auto_issue_certification=true, Certification Service is invoked to issue a certification for that user linked to this course. certification_validity_months from the course determines the certification expiry_date.

organization_scope_isolation
always

All course queries must be scoped to the requesting user's organization_id resolved from JWT claims. No user may read, update, or enroll in courses belonging to a different organization. Enforced at service and repository layers.

published_only_visible_to_peer_mentors
always

Course List Screen and Course Enrollment Screen only surface courses with status='published'. Draft and cancelled courses are accessible only to coordinators and organization administrators in administrative views.

cancellation_preserves_enrollment_history
on_update

When a course status is set to 'cancelled', existing enrollment records are NOT deleted. Enrolled users receive a push notification. The course remains readable in history and reporting queries but disappears from the active enrollment screen.

waitlist_promotion_on_withdrawal
on_update

When a registered enrollment is withdrawn, Course Management Service checks for the oldest waitlisted enrollment for the same course and promotes it to 'registered', sending a confirmation push notification to the promoted user.

certification_validity_required_for_auto_issue
on_update

A course cannot be published (status transition draft→published) if auto_issue_certification=true and certification_validity_months is NULL. Coordinators must specify the validity period before the course is visible to peer mentors.

Storage Configuration

Storage Type
primary_table
Location
main_db
Partitioning
No Partitioning
Retention
Permanent Storage

Entity Relationships

certification
outgoing one_to_many

A course issues certifications to users who successfully complete it

optional
course_enrollment
outgoing one_to_many

A course has many enrollment records tracking registration and attendance per participant

required
organization
incoming one_to_many

An organization manages its own catalog of training courses and certification programs

required