RabbitMailer
Multi-tenant bulk email SaaS with SMTP isolation and campaign management.
Overview
RabbitMailer is a system design exploration into multi-tenant SaaS architecture. It demonstrates how to build a secure, scalable email platform where each customer's SMTP infrastructure is isolated, data is partitioned safely, and campaign processing scales horizontally.
Problem
Building multi-tenant systems introduces security challenges: data isolation, resource fairness, and infrastructure scaling. Email delivery adds complexity with rate limiting, retry logic, and failure handling at scale.
Solution
Implemented a multi-tenant architecture where each tenant has isolated SMTP credentials and database partitioning. Used Bull Queue with Redis for reliable, distributable campaign processing. Built comprehensive rate limiting to prevent system abuse while allowing legitimate volume.
Key Workflows
- —Tenant provisioning with SMTP credential generation
- —Campaign scheduling and queue management
- —Email delivery with retry logic and dead-letter handling
- —Delivery metrics and analytics per tenant
- —Rate limit enforcement across concurrent campaigns
Technical Decisions
- —Used Bull Queue instead of raw Redis for reliable job processing with backpressure and retry mechanisms
- —Implemented database row-level security (RLS) for multi-tenant data isolation at the database level
- —Chose isolated SMTP per tenant over shared SMTP to avoid single point of failure and ensure deliverability
- —Built custom rate limiting using Redis sliding window counters for low-latency enforcement
Performance
Designed for horizontal scaling by making workers stateless. Used connection pooling for database and Redis to handle thousands of concurrent campaigns. Implemented batch operations to reduce database round trips.
Accessibility
Accessibility was less relevant for this backend-focused project, but the API is well-documented and follows RESTful conventions for clarity. Error responses provide actionable feedback for integration.
Stack
Role: Backend architecture & infrastructure