Data Layer low complexity Shared Component backend
0
Dependencies
1
Dependents
5
Entities
0
Integrations

Description

Data access layer for reading peer mentor pause status records and resolving coordinator relationships from the org membership table. Provides the orchestrator with validated entity data needed to construct and route notifications. Shares underlying Supabase client with the broader peer mentor data layer.

Feature: Pause Status Change Notifications

pause-status-record-repository

Summaries

The Pause Status Record Repository is a shared data access component that provides the foundational information layer for the entire peer mentor notification system. By centralizing access to mentor profiles, coordinator relationships, and notification delivery history, it ensures that every automated communication reaches the right person at the right time — protecting program integrity and coordinator oversight. Its role as a shared component means the investment made in building and validating it yields returns across multiple features simultaneously, including any future notification scenarios beyond pause and resume. The audit trail built through notification history records also supports compliance reporting and program accountability without additional development effort.

As a shared component reused across the peer mentor data layer, this repository represents a foundational deliverable that unblocks multiple downstream features. Its low complexity and reliance on the existing Supabase client means the implementation surface is small, but its shared status means QA must be thorough — bugs here affect all consumers simultaneously. The delivery plan should prioritize this component early in the sprint to maximize the time window for integration testing with dependent orchestrators. Key scheduling risk: the org membership table schema must be finalized before `getCoordinatorForMentor` can be implemented.

Notification record persistence also requires the notifications table schema to be stable, so coordinate with the database migration owner before starting implementation.

This repository wraps the shared Supabase client and exposes four clearly scoped operations: profile retrieval (`getPeerMentorProfile`), coordinator resolution (`getCoordinatorForMentor`), notification record persistence (`recordNotificationSent`), and history retrieval (`getNotificationHistory`). The coordinator lookup relies on the org membership table join — ensure this query uses an indexed foreign key to avoid full table scans at scale. The `NotificationRecord` type written by `recordNotificationSent` should include timestamp, channel, and delivery status fields to support the audit use case. Because this component is shared, changes to its interface contract must be coordinated across all consumers.

Use repository-pattern conventions consistently: no business logic inside this class, only data access and mapping to domain types. Integration tests should use a dedicated Supabase test schema.

Responsibilities

  • Fetch peer mentor profile including current pause status and name
  • Resolve coordinator ID via org membership table for a given peer mentor
  • Persist notification delivery records for audit purposes

Interfaces

getPeerMentorProfile(peerMentorId: String): PeerMentorProfile
getCoordinatorForMentor(peerMentorId: String): String
recordNotificationSent(notificationRecord: NotificationRecord)
getNotificationHistory(peerMentorId: String): List<NotificationRecord>

Relationships

Dependents (1)

Components that depend on this component

API Contract

View full contract →
REST /api/v1/notification-records 7 endpoints
GET /api/v1/notification-records
GET /api/v1/notification-records/:id
POST /api/v1/notification-records
PUT /api/v1/notification-records/:id
DELETE /api/v1/notification-records/:id
GET /api/v1/notification-records/peer-mentor-profile/:peerMentorId
+1 more