Certification Repository
Component Detail
Description
Data access layer for peer mentor certification records stored in Supabase. Manages CRUD operations on the certifications table and JSONB renewal history field. Provides query methods for expiry-based lookups used by reminder and dashboard components.
certification-repository
Summaries
The Certification Repository is the foundational data layer that makes all certification management capabilities possible. It ensures that certification records — the basis for compliance decisions, public listing eligibility, and renewal workflows — are stored reliably and can be queried efficiently. Without this component, no other certification feature can function. Its ability to handle expiry-based queries directly supports the automated reminder and auto-pause systems that protect the organisation from compliance lapses.
By using Supabase as the underlying store, the repository also inherits enterprise-grade security, row-level access controls, and audit trail capabilities that reduce data governance risk.
The Certification Repository has no external service dependencies, making it one of the earliest deliverables on the critical path. However, its interfaces must be finalised before dependent components — Certification Reminder Service, Certification Management Service, and dashboard components — can begin integration work.
The JSONB renewal_history field design requires early agreement on the renewal entry schema, as changes post-integration are costly. Database migration scripts for the certifications table must be part of the delivery package and tested against both fresh and existing data sets. Row-level security policies in Supabase should be reviewed by a security-aware team member before the component is promoted to production.
Provides six methods: getCertification(mentorId), upsertCertification(data), appendRenewalHistory(mentorId, renewalEntry), getExpiringCertifications(withinDays), getCertificationsByCoordinator(coordinatorId), and deleteCertification(mentorId). All operations target the Supabase certifications table via the Supabase client SDK. getExpiringCertifications(withinDays) should use a parameterised SQL query comparing expires_at to NOW() + withinDays interval for correctness. appendRenewalHistory must use Supabase's JSONB array append operator (jsonb_insert or || operator) to avoid race conditions from read-modify-write patterns.
Ensure upsertCertification uses Supabase's upsert with onConflict on mentorId. Index expires_at for performant nightly expiry scans.
Responsibilities
- Create and update certification records in Supabase
- Append renewal entries to the JSONB renewal_history field
- Query certifications expiring within a given day threshold
- Fetch certification record by mentor ID
- Delete or archive certification records on mentor offboarding
Interfaces
getCertification(mentorId)
upsertCertification(data)
appendRenewalHistory(mentorId, renewalEntry)
getExpiringCertifications(withinDays)
getCertificationsByCoordinator(coordinatorId)
deleteCertification(mentorId)
Relationships
Dependents (4)
Components that depend on this component
Related Data Entities (2)
Data entities managed by this component
Used Integrations (1)
External integrations and APIs this component relies on