Build a Scalable Email Notification System using Google Pub/Sub & Brevo (Node.js + Express)

Vivek KumarVivek Kumar
3 min read

๐Ÿ“– Introduction

In modern web applications, sending transactional emails โ€” like welcome emails, password resets, or notifications โ€” is a core feature. But sending 100s or 1000s of emails reliably, quickly, and without blocking the main server thread?

Thatโ€™s a challenge.

In this Article, weโ€™ll walk through how to build a production-ready email system using:

โœ… Google Cloud Pub/Sub for queuing
โœ… Brevo (Sendinblue) for email delivery
โœ… Node.js with Express.js as the API
โœ… Modular, scalable architecture ready for the real world

No prior GCP experience required. Beginner-friendly setup โ€” explained step by step.

๐Ÿง  What Youโ€™ll Learn

  • How to decouple email sending using queues

  • How to use Google Cloud Pub/Sub in Node.js

  • How to send dynamic transactional emails via Brevo

  • A full working architecture you can test locally or deploy to production

๐Ÿ—‚๏ธ Project Architecture Overview

Hereโ€™s how the system works:

User/API triggers email โž Node.js (Express API) โž Publishes messages โž Google Cloud Pub/Sub โž Subscriber (Node.js Worker) โž Brevo โž Email sent

Letโ€™s visualize it:

๐Ÿ“ฆ Diagram (System Flow)

graph LR
A[Frontend/API] --> B[Express Server Producer]
B --> C[Google Pub/Sub Topic]
C --> D[Subscriber Service]
D --> E[Brevo API]
E --> F[User's Inbox]

๐Ÿ› ๏ธ Tools & Technologies

TechPurpose
Express.jsHTTP API for triggering emails
Pub/Sub (GCP)Message queue for scalability
BrevoEmail sending service
dotenvSecure environment config
Node.jsRuntime for both API & worker

โš™๏ธ Step-by-Step Setup

๐Ÿ“‚ GitHub Repository

To make things easy for developers, the entire setup and step-by-step guide is available in the GitHub repo:

๐Ÿ‘‰ GitHub: https://github.com/Vivek-018/email-service.git

Features included:

โœ… Modular folder structure โœ… Working REST API route to send bulk emails
โœ… Google Cloud Pub/Sub integration
โœ… Brevo API connection using dynamic templates โœ… Secure environment config โœ… Ready to run locally or deploy to production

๐Ÿงช Local Demo

Once cloned, youโ€™ll be able to:

  • Start a Node.js server

  • Publish email messages to Pub/Sub

  • Automatically send real emails using Brevo to test accounts

All you need is:

  • A Brevo account

  • A Google Cloud project with Pub/Sub enabled

  • Node.js installed locally

Full setup instructions are in the README.

๐Ÿ” End-to-End Email Flow

  • You call POST /api/send-bulk-email with a list of users.

  • The Express server publishes email jobs to Google Cloud Pub/Sub.

  • The subscriber service listens to the topic, processes messages one-by-one.

  • Each message triggers an email via Brevo.

  • User receives a personalized email in their inbox.

๐Ÿš€ Why This is Scalable

  • Pub/Sub decouples producer & consumer โ€” the API never waits for email delivery

  • Pub/Sub automatically retries failed messages

  • Multiple subscribers can run in parallel to handle large volumes

  • Brevo handles email limits, spam compliance, delivery optimization

๐Ÿ’ก Production Tips

  • Add retry/backoff logic on the subscriber

  • Use dead-letter topics for failed email jobs

  • Use monitoring tools like Google Cloud Logging

  • Deploy subscriber as a background worker or Cloud Run service

๐Ÿ“‚ Source Code

You can find the complete working setup on GitHub:

๐Ÿ‘‰ GitHub Repository: https://github.com/Vivek-018/email-service.git

โœ… Conclusion

By combining Google Pub/Sub with Brevo, you've built a reliable and scalable system that can send thousands of emails efficiently โ€” without blocking your app or overloading your email provider.

This architecture is perfect for onboarding emails, alerts, reminders, receipts, and more.

Now go scale your communication like a pro!

Need Help?

Drop your questions below or open an issue in the GitHub repo!

0
Subscribe to my newsletter

Read articles from Vivek Kumar directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Vivek Kumar
Vivek Kumar

๐Ÿš€ Full-Stack Web Developer | Problem-Solver Passionate about building solutions that simplify lives. From streamlining workflows to creating seamless digital experiences, I thrive on turning complex challenges into elegant, intuitive technology. Sharing insights, code, and real-world problem-solving to empower the dev community.