Back

Case study

WA Blast

Multi-Tenant WhatsApp SaaS

wablast.in

Visit live site

Product preview

Screenshots

Overview

Architected WaBlast SaaS — a multi-tenant WhatsApp platform with NestJS and Fastify, Prisma and PostgreSQL, Redis and BullMQ, Meta Cloud API webhooks, Socket.IO realtime, a React Flow automation engine, Razorpay billing and entitlements, a Serwist PWA customer app, and Docker/nginx deployment on wablast.in.

Problem & goal

The Challenge

Indian SMBs need one workspace to run WhatsApp marketing, conversational automation, catalog commerce, and lead pipelines — without juggling separate tools, fragile webhook scripts, or custom Meta integrations.

WaBlast operates a subscription SaaS where tenants connect their WhatsApp Business lines, subscribe to product pillars — Marketing, Automation, Commerce, and Lead Management — and manage day-to-day operations from a customer PWA while platform operators govern plans, tenants, and Meta app configuration from a separate admin console.

Target users

Who It's For

  • Tenant owners and staff — campaigns, WhatsApp inbox, flow builder, orders, leads, and jobs from the customer app

  • End consumers — WhatsApp messages, catalog checkout, public lead forms, and job feedback links

  • Platform operators — plans, features, tenants, subscriptions, audit, and platform Meta settings from the admin console

Core capabilities

Platform Modules

Auth & multi-tenancy

Secure login with Google OAuth, workspaces, role-based permissions, and team invitations across tenant and platform scopes.

WhatsApp integration

Meta Cloud API adapter with multi-tenant webhooks and product-scoped phone line assignment per pillar.

Marketing

Contacts, groups, templates, compose builder, paced campaign execution, and a WhatsApp one-to-one chat inbox.

Automation

Visual chat-flow builder with a runtime executor, PDF generation, webhooks, and payment branches.

Commerce

Product catalog, orders, delivery zones, Meta catalog sync, and Razorpay checkout inside flows.

Lead management

Multi-source lead ingest, CRM, jobs with line items and payments, PDF documents, and public feedback forms.

Billing

Razorpay subscriptions, GST invoices, and entitlement-driven feature gates with tenant overrides.

Real-time

Live campaign progress, WhatsApp chat updates, and tenant events via a real-time gateway.

Platform admin

Dedicated console for plans, features, tenant lifecycle, and platform-level Meta app configuration.

High-level design

System Architecture

The platform ships as three deployable applications sharing one domain model: a Next.js customer PWA for marketing, automation, commerce, and lead management; a Next.js admin console for platform operations; and a NestJS API on a high-performance HTTP adapter handling versioned REST endpoints, Meta-compatible webhook ingress, and a real-time gateway. PostgreSQL stores tenant-centric relational data with Prisma. Redis powers BullMQ background job queues for webhooks, campaigns, and catalog sync.

External integrations include Meta Cloud API, Razorpay, Resend email, DigitalOcean Spaces for media, Firebase push, and Puppeteer for HTML-to-PDF generation. Inbound WhatsApp payloads are enqueued asynchronously with database idempotency before domain handlers run. Secure authentication with role-based access, encrypted integration credentials, webhook signature verification, and entitlement-driven feature gates protect tenant data and platform operations.

Production stack

Technology Stack

Frontend

  • Next.js
  • React.js
  • TypeScript
  • TanStack Query
  • React Flow
  • Serwist PWA

Backend

  • NestJS
  • Fastify
  • Prisma
  • BullMQ
  • Socket.IO

Data & messaging

  • PostgreSQL
  • Redis
  • Firebase Cloud Messaging

Infrastructure

  • Docker
  • Nginx
  • DigitalOcean Spaces
  • Razorpay

Meta Cloud API layer

WhatsApp Integration

Adapter pattern

Per-tenant connections route outbound messages through a shared Cloud API client with product context for marketing, automation, commerce, or lead management.

Webhook pipeline

Inbound payloads verified and enqueued to background workers with idempotency keys before fan-out to chat, flow executor, commerce, and lead handlers.

Template & catalog sync

Template sync for campaigns and batch catalog sync for WhatsApp commerce with pacing and rate-limit backoff.

Product-scoped lines

Tenants can assign distinct WhatsApp connections per product pillar when marketing, automation, commerce, and leads need separate phone lines.

Visual builder & runtime

Automation Flow Engine

Flow builder

React Flow graph editor stores node graphs as JSON with simulation preview before live sends.

Node types

Message, input, condition, calculation, list, form, webhook, Razorpay payment branch, commerce checkout, PDF, email, and delay nodes.

Session state

Per-conversation session tracking with variable interpolation and Handlebars PDF templates.

Data source queries

SQL and query nodes against tenant-connected databases with validated identifiers and safe preview queries.

Default commerce flow

Auto-provisioned checkout flow for new WhatsApp commerce connections so tenants can sell immediately.

Campaigns & catalog

Marketing & Commerce

Campaign execution

Active campaigns chunk contacts by target groups, rotate templates, and send with configurable pacing, jitter, and rate-limit handling.

WA inbox

Conversations with notes, assignee, scheduled messages, and rich media compose backed by cloud object storage.

Contact management

Import from CSV, spreadsheets, or live queries against connected data sources; organize into groups for targeting.

Product catalog

Variants, brands, categories, service charges, and delivery zones with Meta catalog batch sync.

Orders & payments

Status templates, receipt and invoice PDF defaults, Meta utility templates, and Razorpay payment links on orders and in automation checkout.

Subscriptions & feature gates

Billing & Entitlements

Plan pillars

Plans segmented by marketing, automation, commerce, and lead management with trial and addon quantity support.

Razorpay billing

Subscription orders with webhook signature verification and GST invoice PDF generation.

Entitlement merge

Multiple active subscriptions merge into additive feature caps enforced by entitlement-driven route guards.

Tenant overrides

Platform operators can override feature limits per tenant without changing base plan definitions.

Live updates

Real-Time & Notifications

Campaign progress

Real-time gateway broadcasts execution status and delivery counts as campaigns send.

WA chat stream

New messages and read state pushed live to inbox views with tenant membership re-validation on subscribe.

Firebase push

Device token registration with foreground toasts and background delivery for chat and lead alerts.

Email

Transactional email for invites, verification, and password reset via Resend.

Challenges solved

Engineering Highlights

01

Meta webhook retries duplicate processing

Database idempotency keys per message id and composite keys for delivery status lifecycle events.

02

Meta rate limits during broadcasts

Campaign processor with delay, jitter, consecutive rate-limit cap, and pause/resume on executions.

03

Multi-product WhatsApp on one tenant

Product-scoped phone assignments so marketing, automation, commerce, and leads can use distinct connections.

04

Flow race on rapid inbound messages

Optional conversation lock with TTL to serialize automation per tenant and phone line.

05

Subscription feature overlap

Additive merge of numeric caps across active plans into a single entitlement view per tenant.

06

PWA and realtime on mobile

Serwist offline shell with Socket.IO campaign and chat hooks plus FCM fallback for background delivery.

07

Tenant database credentials in SaaS

Encrypted credentials at rest with safe preview queries and validated SQL identifiers for data source nodes.

Built for production load

Performance & Scale

  • BullMQ workers offload webhooks, campaigns, catalog sync, and scheduled WhatsApp messages

  • Campaign pacing and chunking respect Meta rate limits with configurable backoff

  • Redis-backed idempotency and optional conversation locks for dedupe

  • Stateless API scales horizontally behind nginx with shared JWT and Redis state

  • Prisma selective includes and pagination on tenant-scoped list endpoints

  • TanStack Query cache on customer and admin apps with targeted invalidation per product

  • Serwist PWA precaching for faster customer dashboard repeat loads

Operations

Deployment

The production stack runs in Docker containers — database, cache, API, customer app, admin console, reverse proxy, and automated TLS — with scheduled database backups and health checks on core services. Asia/Kolkata timezone is applied across services. Structured log rotation keeps API disk usage bounded for ongoing operations.

Roadmap

What's Next

  • Dedicated worker tier split from API process for large send volumes

  • Read replicas for analytics dashboards off hot OLTP workloads

  • WhatsApp Flows builder UI with deeper Meta Flow JSON parity

  • AI-assisted template and flow suggestions from campaign and chat analytics

  • Multi-region deployment for webhook latency and data residency

  • Advanced deliverability dashboard with template quality and opt-in tracking

  • Additional payment gateways beside Razorpay for international tenants