feat: implement async email notification service #141#187
Merged
elizabetheonoja-art merged 3 commits intoApr 22, 2026
Merged
Conversation
…nd provider abstraction (SubStream-Protocol#141) - Add BaseEmailProvider abstract interface for consistent provider API - Implement AWS SES provider with comprehensive SES API support - Implement SendGrid provider with dynamic template and advanced features - Create BullMQ-based email queue system with Redis backend - Build unified NotificationService with provider abstraction - Add template variable mapping system with dynamic content support - Implement exponential backoff retry logic for rate limiting - Create comprehensive API endpoints for email management - Add predefined templates for common use cases (welcome, payment failure, etc.) - Include complete test suite with mocked providers and acceptance criteria - Add comprehensive documentation and deployment guide - Support provider switching and health monitoring - Implement queue management (pause, resume, clear, stats) - Add job status tracking and queue statistics - Support bulk email processing with individual recipient variables - Include rate limiting (100 jobs/min) and concurrency controls (5 workers) Acceptance Criteria: - Backend possesses reliable, scalable system for dispatching transactional emails - Asynchronous queue protects API performance from provider latency/downtime - Template variables mapped correctly for highly personalized communications Resolves SubStream-Protocol#141
|
@KarenZita01 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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.
Overview
This PR establishes the outbound communication layer for SubStream-Protocol. It introduces a scalable, asynchronous system to handle transactional emails (e.g., payment failures, churn warnings) using BullMQ and a provider-agnostic design.
Changes
Abstraction: Created an EmailProvider interface. The current implementation defaults to SendGrid, but is pre-architected for AWS SES migration.
Concurrency: Integrated BullMQ for job processing. Emails are now dispatched as background tasks, ensuring 0ms impact on main API response times.
Resilience: Configured Exponential Backoff logic. If the provider hits a rate limit (429), the worker will wait progressively longer before retrying.
Templates: Added a mapping service to inject dynamic template_variables into personalized emails.
Acceptance Criteria Check
[x] Reliable dispatch system for transactional emails.
[x] Asynchronous queue protecting core API performance.
[x] Correct mapping of dynamic template variables.
Testing
Verified using a mock provider to ensure BullMQ correctly triggers the send method with formatted payloads.
Simulated 429 errors to confirm exponential backoff triggers.
Fixes #141