Certification Expiry Checker Service
Component Detail
Description
Nightly background service that scans all peer mentor certifications, identifies those expiring within 30 days, triggers auto-pause transitions on expiry day, and dispatches escalating reminder notifications to coordinators at 30, 14, and 7 day thresholds.
certification-expiry-checker
Summaries
This automated nightly service eliminates the compliance risk of active but uncertified peer mentors remaining in the system without human intervention. By automatically transitioning mentors to an expired status on their certification lapse date and dispatching escalating reminders to coordinators at 30, 14, and 7 days, the organization benefits from both preventive action and a defensible audit trail. This reduces the cost and disruption of coverage gaps, limits liability from non-compliant mentors working with participants, and removes a significant manual monitoring burden from coordination staff — freeing them to focus on program delivery rather than calendar tracking.
High-complexity service with four upstream dependencies: certification-status-repository, pause-management-service, pause-notification-service, and a nightly-scheduler infrastructure component. All four must be in place before end-to-end testing is possible, making this one of the later items in the delivery sequence. The scheduling mechanism — whether a Supabase Edge Function, cron job, or cloud scheduler — requires infrastructure provisioning and operational runbook documentation. Testing requires time-simulation or date-mocking capabilities to validate 30/14/7-day threshold logic and expiry-day auto-transition without waiting real days.
Failure recovery procedures (missed nightly run, partial run) must be defined before go-live to prevent silent compliance gaps.
Backend scheduled service orchestrating nightly certification compliance enforcement. Entry point is runNightlyCheck(), invoked by the nightly-scheduler. Flow: (1) getExpiringSoon(daysThreshold) queries certification-status-repository for certifications expiring within 30 days; (2) for mentors whose expiry date equals today, triggerAutoExpiry(mentorId) delegates to pause-management-service.autoExpireForCertification(); (3) sendExpiryReminder(coordinatorId, mentorId, daysRemaining) delegates to pause-notification-service for mentors at 30/14/7-day thresholds; (4) logTransitionEvent records all auto-transitions with fromStatus, toStatus, and reason for audit. getLastRunTimestamp supports monitoring and alerting on missed runs.
Time-based logic must use UTC consistently to avoid DST-related skipped or duplicate runs.
Responsibilities
- Query all certifications expiring within 30 days
- Auto-transition mentor status to expired_cert on expiry date
- Dispatch escalating reminder notifications at configured day thresholds
- Log all auto-transition events for audit purposes
Interfaces
runNightlyCheck()
getExpiringSoon(daysThreshold)
triggerAutoExpiry(mentorId)
sendExpiryReminder(coordinatorId, mentorId, daysRemaining)
getLastRunTimestamp()
logTransitionEvent(mentorId, fromStatus, toStatus, reason)
Relationships
Dependencies (4)
Components this component depends on
Related Data Entities (2)
Data entities managed by this component