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


๐ 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
Tech | Purpose |
Express.js | HTTP API for triggering emails |
Pub/Sub (GCP) | Message queue for scalability |
Brevo | Email sending service |
dotenv | Secure environment config |
Node.js | Runtime 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!
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.