Certification Expiry Nightly Cron Job
Component Detail
Description
A scheduled backend job that runs nightly to identify certifications approaching expiry and those that have expired on the current day. Invokes the CertificationReminderService for notifications and the CertificationManagementService for auto-pause transitions.
certification-expiry-cron
Summaries
The Certification Expiry Nightly Cron Job is the autonomous engine that keeps the entire certification compliance lifecycle running without manual intervention. Every night it identifies mentors whose certifications are approaching expiry or have lapsed, triggering both proactive reminders and automatic status transitions. This zero-touch operation model ensures that compliance enforcement is consistent, timely, and not dependent on coordinator availability or attention. For the organisation, this means reduced administrative overhead, lower risk of expired mentors remaining active on public platforms, and a demonstrably reliable compliance posture that supports trust with clients and regulatory stakeholders.
This component is medium complexity and is a coordinating orchestrator, meaning its own logic is relatively thin but its correctness depends entirely on the reliability of its two dependencies: Certification Reminder Service and Certification Management Service. Both must be stable and tested before end-to-end cron validation is possible. The scheduling infrastructure (cron host, timezone configuration, execution guarantees) must be decided early — whether this runs on a cloud scheduler (e.g., Supabase Edge Function cron, AWS EventBridge) affects the deployment model. Monitoring and alerting for failed nightly runs are non-negotiable acceptance criteria, as a silent failure would leave expiring certifications unprocessed.
Run logs must be retained for audit purposes.
The cron exposes scheduleNightlyRun(cronExpression) for configuration, executeExpiryCheck() as the main execution method, and onRunComplete(result)/onRunError(error) hooks for observability integration. Internally, executeExpiryCheck() should query certifications at the 30, 14, and 7-day thresholds by delegating to certification-reminder-service, and identify same-day expiries to trigger auto-pause via certification-management-service. Each invocation should be idempotent — running twice in a night must not double-send reminders or double-apply status transitions. Implement structured logging per run with a unique run ID.
Consider wrapping the entire execution in a try/catch that calls onRunError and emits an alert metric so operations teams can respond to failures before the next nightly window.
Responsibilities
- Run nightly on a configured cron schedule
- Identify certifications expiring in 30, 14, and 7 days
- Identify certifications that expired on the current date
- Invoke reminder dispatch and auto-pause workflows
Interfaces
scheduleNightlyRun(cronExpression)
executeExpiryCheck()
onRunComplete(result)
onRunError(error)
Relationships
Dependencies (2)
Components this component depends on
Related Data Entities (1)
Data entities managed by this component
Used Integrations (1)
External integrations and APIs this component relies on