Available for work Dhaka / Bangladesh Portfolio / MMXXVI
I.Feature / APIs001 / 005
Backend Architecture Brief

Designing a Content Subscription API in NestJS.

A deep dive into building scalable, high-throughput email dispatches, webhook systems, and local verification loops for premium SaaS products.

By Irfan Hasan / Software Developer Published January 2025 / 7 min read
Subscription API flow Collage
FIG. 01 / Dispatcher Engine
II.Article / System Map002 / 005

01. Event daemons: processing dispatch queues.

When sending notifications or digests to thousands of subscribers, synchronous execution blocks the main application process. We architected a multi-worker event dispatcher in Node.js/NestJS that reads batches from the database and processes dispatches asynchronously using isolated worker threads.

This design prevents latency spikes on user-facing API routes, ensuring that sub-millisecond page edits never suffer from backend process congestion.

02. Webhook verification: cryptographic signs.

Trust is crucial when syncing subscriber actions with third-party providers. Our NestJS webhook endpoints sign outgoing payloads using HMAC-SHA256 signatures, allowing recipient systems to cryptographically verify that the event payload originated from our servers.

By enforcing unique replay-prevention headers and timestamp verification thresholds, we prevent replay attacks and secure internal system events.

Cryptographic sign verification protects system webhooks from external tampering.

03. Local verification: mock dispatcher hooks.

To avoid polluting production mail services during sandbox builds, we created local-first dispatch controllers. Developers can run and inspect email deliveries within the terminal daemon without initiating real mail requests.

This local validation loop mirrors the live provider runtime, allowing local testing of complex retry limits and failover states before deployment.

04. Optimizing throughput: concurrent limits.

By tuning Express middleware thread limits and adjusting database pool limits inside NestJS, the subscriber service achieves a stable throughput of 850 dispatches per second on standard EC2 instances—with complete error logging and automated failure retries.