Scenario Engine Service
Component Detail
Service Layer
high complexity
backend
3
Dependencies
1
Dependents
8
Entities
0
Integrations
Description
Server-side scheduled job that evaluates configurable scenario rules against system events and user state to determine when to dispatch notifications. Runs on a cron schedule (Vercel Cron Jobs) and supports time-based, event-based, and state-based trigger conditions. Delegates payload construction and multi-channel delivery to the shared notification delivery infrastructure, while respecting per-user opt-out preferences.
scenario-engine-service
Responsibilities
- Evaluate all active scenario rules against current system state on each cron invocation
- Resolve target users and roles for each triggered scenario based on rule conditions
- Check notification_preferences to respect user opt-outs before dispatching
- Delegate to push, email, and SMS delivery infrastructure by scenario channel priority
- Track execution history per scenario for deduplication and audit
Interfaces
evaluateScenarios(): Promise<ScenarioEvaluationResult[]>
triggerScenario(scenarioId: string, context: ScenarioContext): Promise<void>
getActiveScenarios(): Promise<Scenario[]>
isEligible(userId: string, scenarioId: string): Promise<boolean>
getScenarioHistory(scenarioId: string): Promise<ScenarioExecution[]>
Relationships
Dependencies (3)
Components this component depends on
Related Data Entities (8)
Data entities managed by this component