How aaditya514/notification-service works
This is a Node.js notification microservice: clients submit channel-specific requests, the API validates and stores them, then enqueues work for asynchronous delivery. The worker dispatches email and SMS, updates notification status, retries failures, and routes exhausted jobs to the DLQ, which the API can inspect or replay. The repository also contains a preference-based dispatcher and in-app persistence helper. The README describes in-app delivery as part of worker processing, but the sampled worker only logs in-app delivery; those implementations are shown separately.
Main entry points: notificationWorker.js Job Worker · notificationQueue.js Notification Queues · notificationService.js Preference Dispatcher · emailClient.js Email Client
Components 18
API
- Express Server
src/app.js - Notification Routes
src/routes/notificationRoutes.js - Request Handlers
src/controllers/notificationController.js
Queue Processing
- Notification Queues
src/queues/notificationQueue.js - Job Worker
src/workers/notificationWorker.js
Delivery Channels
- Preference Dispatcher
src/services/notificationService.js - In-App Helper
src/services/inAppService.js - Email Client
src/utils/emailClient.js - SMS Client
src/services/smsService.js
Persistence
- Notification Records
src/models/Notification.js - User Preferences
src/models/User.js
Other components
- API Client
- Redis
- MongoDB
- SMTP Service
- Twilio
- Environment Config
src/config/index.js - Redis Settings
src/config/redisConfig.js
Connections 26
- API Client → Express Server: sends requests
README.md - Express Server → Notification Routes: mounts routes
src/app.js - Notification Routes → Request Handlers: dispatches handlers
src/routes/notificationRoutes.js - Request Handlers → Notification Records: creates and queries
src/controllers/notificationController.js - Request Handlers → Notification Queues: enqueues and replays
src/controllers/notificationController.js - Notification Queues → Redis Settings: gets connection
src/queues/notificationQueue.js - Redis Settings → Environment Config: reads URL
src/config/redisConfig.js - Notification Queues → Redis: stores jobs
README.md - Job Worker → Notification Queues: consumes jobs
README.md - Job Worker → Redis Settings: gets connection
src/workers/notificationWorker.js - Job Worker → Notification Records: updates status
src/workers/notificationWorker.js - Job Worker → Email Client: sends email
src/workers/notificationWorker.js - Email Client → Environment Config: reads credentials
src/utils/emailClient.js - Email Client → SMTP Service: sends mail
- Job Worker → SMS Client: sends SMS
src/workers/notificationWorker.js - SMS Client → Environment Config: reads credentials
src/services/smsService.js - SMS Client → Twilio: sends messages
- Job Worker → Notification Queues: adds exhausted jobs
src/workers/notificationWorker.js - Notification Records → MongoDB: persists history
README.md - Express Server → MongoDB: connects
src/app.js - Job Worker → MongoDB: connects
src/workers/notificationWorker.js - Preference Dispatcher → User Preferences: loads preferences
src/services/notificationService.js - Preference Dispatcher → Email Client: dispatches email
src/services/notificationService.js - Preference Dispatcher → SMS Client: dispatches SMS
src/services/notificationService.js - Preference Dispatcher → In-App Helper: saves in-app
src/services/notificationService.js - In-App Helper → Notification Records: creates record
src/services/inAppService.js