Reminder Service
Component Detail
Description
Core business logic service that manages the full lifecycle of scenario-based reminders. It evaluates scenario rules against current application state, schedules reminders into the reminders table, applies deduplication logic to prevent notification flooding, and exposes APIs for preference management. Acts as the bridge between the cron-triggered evaluation engine and the FCM delivery infrastructure.
reminder-service
Responsibilities
- Evaluate all active scenario rules against database state on each cron cycle
- Write scheduled reminder records to the reminders table with scheduled_at timestamps
- Apply deduplication: ensure each scenario fires at most once per trigger event
- Expose CRUD APIs for user reminder preferences and coordinator threshold configuration
- Dispatch resolved reminders to the Scheduled Notification Infrastructure for FCM delivery
Interfaces
evaluateScenarioRules()
scheduleReminder(userId, scenarioType, scheduledAt, payload)
cancelReminder(reminderId)
getReminderPreferences(userId)
updateReminderPreferences(userId, preferences)
getCoordinatorThresholds(organizationId)
updateCoordinatorThreshold(organizationId, scenarioType, thresholdDays)
getDueReminders(now)
markReminderDelivered(reminderId)
deduplicateReminder(userId, scenarioType, triggerEntityId)
Relationships
Dependencies (2)
Components this component depends on
Dependents (2)
Components that depend on this component
Sub-Components (1)
Evaluates declarative scenario rule definitions against live PostgreSQL data to determine which reminders should fire. Each rule specifies trigger conditions (e.g., assignment.status = dispatched AND days_since_dispatch >= 10 AND contact_activity_count = 0), target audience, and notification template reference.
- Load all active scenario rule definitions
- Execute SQL-based trigger condition checks for each rule
- Identify target users (assignee, coordinator, or both) per rule
- +1 more
Related Data Entities (6)
Data entities managed by this component