Case study // 03
WhatsApp Message Service
Prepaid, queue-backed WhatsApp campaigns with ACID billing and Meta Cloud API delivery — designed for frontend clients, not a demo UI.
Role · Backend / platform engineer
Overview
Direct Meta API calls are slow, rate-limited, and hard to bill. Businesses need reliable bulk send, personalization, wallet accounting, and campaign observability. This service productizes WhatsApp outreach: register → fund wallet → send campaign → track outcomes → refund on permanent failures — without blocking the HTTP request path.
Architecture
Layered Express API: routes → auth/validation → controllers → services. Campaign creation atomically writes MongoDB records, deducts tokens, and enqueues BullMQ jobs. Workers deliver via a WhatsApp provider isolation layer and write outcomes back — refunding the wallet when jobs fail.
- Versioned REST under /api/v1 with uniform success envelopes
- Provider pattern isolates Meta Graph API
- Request-ID correlated Winston logging
- Docker Compose for app + Redis; graceful shutdown
Features
Challenges → Solutions
Concurrent wallet overdrafts
Atomic conditional debit with MongoDB sessions
Slow / flaky Meta sends
BullMQ retries + rate limiter at the worker boundary
Charge without delivery
Failure classification with automatic token refunds
Heavy campaign lists
Cursor pagination + projections for list endpoints
Tech stack
Positioning
Backend messaging platform designed for frontend clients — not a React/Next UI case study. Prepaid ledger is ready for payment-gateway webhooks; full gateway integration is a roadmap item.
Next