Data Layer medium complexity backendmobile
0
Dependencies
0
Dependents
3
Entities
0
Integrations

Description

Data access layer for assignment lifecycle management. Implements Supabase row-level security to enforce that peer mentors read only their own rows while coordinators access their full team scope. All state transition writes are append-only to preserve the immutable audit trail.

Feature: Assignment Status Tracking

assignment-status-repository

Responsibilities

  • Provide role-scoped read queries with RLS enforcement
  • Write immutable state transition records to assignment_dispatches
  • Query stale assignments for auto-reminder processing
  • Support pagination and filtering for large assignment lists

Interfaces

getAssignmentById(assignmentId)
getAssignmentsByPeerMentor(peerMentorId, filters)
getAssignmentsByCoordinator(coordinatorId, filters)
getAssignmentsByOrganization(organizationId, filters)
insertStateTransition(assignmentId, state, actorId, timestamp)
getStateHistory(assignmentId)
getStaleAssignments(thresholdDate, excludeTerminalStates)
countOpenAssignments(scopeId)
countOverdueAssignments(scopeId, thresholdDays)
getLatestState(assignmentId)
subscribeToAssignmentChanges(scopeId)