feat(alerts): event-driven pipeline with delivery guarantees#21
Merged
memplethee-lab merged 1 commit intoJun 20, 2026
Merged
Conversation
…rantees Closes SourceXXL#12. Implements the growth/alerts module with: - AlertPreference entity for per-user channel and quiet-hours config - AlertDispatcherService with in-memory dedup (5-min window), rate limiting (10 alerts/hour default), quiet-hours suppression, and exponential backoff retry (up to 3 attempts, 200ms base) - RiskAlertListener subscribing to 'risk.threshold.breached' events - PortfolioAlertListener subscribing to 'portfolio.rebalanced' events - Delivery to in-app (logged to AlertTriggerLog) and email channels - POST /api/alerts/subscribe and DELETE /api/alerts/unsubscribe/:userId endpoints with full Swagger @apioperation documentation - 8-test unit suite covering dedup, rate limiting, channel delivery, retries - AlertPreference registered in TypeORM entities list in app.module.ts
9 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #12 — Align
growth/alertsModule: Event-Driven Alert Pipeline with Delivery Guarantees.AlertPreferenceentity (alert_preferencestable) withchannels,quietHoursStart,quietHoursEnd, andrateLimitcolumnsAlertDispatcherServicewith in-memory fingerprint deduplication (5-minute window), per-user rate limiting (default 10/hour), quiet-hours suppression, and exponential backoff retry (up to 3 attempts, base 200 ms)RiskAlertListenersubscribing torisk.threshold.breachedevents via@OnEventPortfolioAlertListenersubscribing toportfolio.rebalancedevents via@OnEventAlertTriggerLog) + email (logged, ready for SendGrid/SES integration)@ApiOperationand@ApiResponsedocumentation behindJwtAuthGuardEventEmitterModule.forRoot()registered inAlertsModuleAlertPreferenceregistered in global TypeORM entities list inapp.module.tsalert-dispatcher.service.spec.tscovering all acceptance criteriaAcceptance Criteria Met
RiskAlertListenercreates alerts whenrisk.threshold.breachedevents are emittedAlertDispatcherdelivers through at least 2 channels (in-app + email)AlertPreferenceentity with channel and quiet-hours configurationPOST /api/alerts/subscribeandDELETE /api/alerts/unsubscribe/:userIddocumented in Swaggernpm run buildsucceedsTest Plan
npx jest --testPathPattern="alert-dispatcher" --no-coverage— 8 tests passPOST /api/alerts/subscribewith{ userId, channels: ["in-app","email"] }returns 201DELETE /api/alerts/unsubscribe/:userIdremoves preferencerisk.threshold.breachedevent and confirmAlertTriggerLogentry is created