Data Layer medium complexity backend
0
Dependencies
2
Dependents
2
Entities
0
Integrations

Description

Data access layer for reading and updating the last_contact_date field per assignment. Provides queries needed by the evaluation service to identify assignments without recent contact, and write operations to update contact timestamps when activity is registered.

Feature: Assignment Follow-up Reminders

assignment-contact-tracking-repository

Summaries

This component is the operational backbone of the organisation's peer mentoring programme, ensuring no participant falls through the cracks by maintaining accurate records of when each mentee was last contacted. By reliably tracking contact history, the system can surface at-risk assignments before they become programme failures — directly protecting retention rates, participant satisfaction, and the measurable outcomes that justify programme investment. The ability to identify overdue contacts proactively reduces the manual oversight burden on coordinators, allowing staff to focus on high-value intervention rather than administrative tracking. Programmes that consistently follow up with participants see significantly higher completion rates, which translates to stronger reporting metrics for funders and stakeholders.

This is a medium-complexity data component with well-defined query boundaries, making it a predictable deliverable. It has no external service dependencies, so it can be developed and tested in isolation against a seeded database, reducing integration risk during sprint planning. The five interfaces map cleanly to distinct functional requirements — retrieval, filtering, and update — and each can be unit-tested independently. The main scheduling risk is ensuring the database schema for last_contact_date is finalised before the evaluation service team begins work, as both components share this field.

Integration testing will require coordinated test data with the activity recording flow. Budget for one sprint of backend development plus a half-sprint for integration testing with the evaluation service. No deployment complexity beyond standard backend release.

Backend data component operating against the assignments table, exposing five typed query methods consumed primarily by the contact evaluation service. getOpenAssignmentsWithContactDates() is the primary bulk read used in daily evaluation runs — ensure this query is indexed on status and last_contact_date to avoid full table scans at scale. getAssignmentsWithNoContactSince(cutoffDate) should translate to a WHERE last_contact_date < cutoffDate OR last_contact_date IS NULL query to correctly capture assignments with no contact history. updateLastContactDate() is a single-field update triggered by activity registration events — ensure it runs within the activity transaction to prevent drift between recorded activities and contact timestamps.

getAssignmentWithParticipants() performs a join to resolve peer mentor and coordinator IDs for notification dispatch; cache consideration if called frequently in batch evaluation loops.

Responsibilities

  • Query all open assignments with their last_contact_date
  • Retrieve last_contact_date for a specific assignment
  • Update last_contact_date when a new activity is recorded
  • Query assignments overdue beyond a given threshold
  • Retrieve peer mentor and coordinator IDs linked to assignment

Interfaces

getOpenAssignmentsWithContactDates(): Assignment[]
getLastContactDate(assignmentId): Date | null
updateLastContactDate(assignmentId, date)
getAssignmentsWithNoContactSince(cutoffDate): Assignment[]
getAssignmentWithParticipants(assignmentId): AssignmentWithParticipants

Relationships

Dependents (2)

Components that depend on this component

Related Data Entities (2)

Data entities managed by this component

API Contract

View full contract →
REST /api/v1/assignments 7 endpoints
GET /api/v1/assignments
GET /api/v1/assignments/:id
POST /api/v1/assignments
PUT /api/v1/assignments/:id
DELETE /api/v1/assignments/:id
PUT /api/v1/assignments/:id/last-contact
+1 more