Service Layer high complexity backend
3
Dependencies
3
Dependents
2
Entities
0
Integrations

Description

Core business logic service for managing peer mentor certifications. Handles creation of new certification records, recording renewals, computing expiry states, and initiating course enrolment requests. Acts as the single orchestrator for all certification lifecycle transitions.

Feature: Peer Mentor Certification Management

certification-management-service

Summaries

The Certification Management Service is the backbone of the programme's compliance infrastructure, governing every transition in a peer mentor's certification lifecycle — from initial issuance through renewals to automatic expiry handling. By centralising this logic in a single authoritative service, the organisation ensures consistent enforcement of compliance rules across all touchpoints, reducing the risk of data inconsistencies that could lead to regulatory exposure or audit failures. Its integration with the HLF Dynamics sync service also ensures that external stakeholder systems reflect accurate certification status, protecting partnership relationships and contractual obligations.

This is the highest-complexity component in the certification feature set and sits on the critical path for all certification-related screens and workflows. It depends on certification-repository, pause-management-service, and hlf-dynamics-sync-service — three external dependencies that must be available or stubbed before full integration testing. Development effort should account for the JSONB renewal history append logic, expiry state computation, auto-pause trigger orchestration, and course enrolment delegation. Thorough unit testing of expiry state transitions and renewal history integrity is essential.

Plan for a dedicated integration testing cycle covering the pause and Dynamics sync workflows, as failures here affect multiple downstream features.

Backend service (likely a NestJS or similar framework service class) operating on the peer_mentor_certification data model. createCertification() and recordRenewal() write to the certifications table and append to the renewal_history JSONB column atomically within a database transaction — use a repository pattern to keep SQL out of the service layer. getCertificationStatus() and getExpiringCertifications() compute state from stored dates relative to Date.now(); centralise this computation to avoid drift with frontend urgency logic. initiateEnrolment() delegates to an external integration adapter (hlf-dynamics-sync-service) and should be wrapped in a try/catch with retry semantics.

triggerAutoExpiry() coordinates with pause-management-service via an internal event or direct call — confirm whether this is synchronous or event-driven with the broader architecture team before implementation.

Responsibilities

  • Create and update certification records with issue/expiry dates and cert type
  • Append to renewal history JSONB log on each renewal
  • Compute current certification status (valid, expiring-soon, expired) based on current date
  • Initiate course enrolment by delegating to external integration
  • Trigger auto-pause workflow when certification expires

Interfaces

createCertification(mentorId, issuedAt, expiresAt, certType)
recordRenewal(mentorId, issuedAt, expiresAt)
getCertificationStatus(mentorId)
getExpiringCertifications(coordinatorId, withinDays)
initiateEnrolment(mentorId, courseId)
triggerAutoExpiry(mentorId)

Related Data Entities (2)

Data entities managed by this component

API Contract

View full contract →
REST /api/v1/certifications 7 endpoints
GET /api/v1/certifications
GET /api/v1/certifications/:id
POST /api/v1/certifications
PUT /api/v1/certifications/:id
DELETE /api/v1/certifications/:id
GET /api/v1/certifications/:id/status
+1 more