DocHub
Multi-tenant architecture with gateway proxy, Docker slice isolation, and shared PostgreSQL

SaaS Architecture

Purpose

The WhatsApp CRM SaaS platform converts the single-user CRM into a multi-tenant product. Each user gets their own isolated Docker container (“slice”) running the CRM backend and Chromium for WhatsApp Web. A central gateway service handles authentication, API proxying, billing, and monitoring. This is the live production prototype at https://app.ipnoelp.io.

Architecture

The system has four layers:

  1. nginx — SSL termination, static frontend serving, reverse proxy to gateway
  2. Gateway service — Express.js on port 3000, handles auth, proxies API calls to the correct slice
  3. Slice pool — Docker containers, each running Node.js backend + Chromium with WhatsApp Web
  4. Shared PostgreSQL — One instance with gateway schema + per-slice databases

Request Flow

Browser → nginx (:443) → Static React SPA (/var/www/app/)
                        → /api/*, /auth/*, /admin/* → Gateway (:3000)
                            → Session lookup → Proxy to slice (:500X)
                        → /socket.io/* → Gateway → WebSocket upgrade to slice

Key Architectural Decisions

Decision Rationale
Shared frontend One React build served to all users. API routing by session cookie. Eliminates N frontend containers.
Gateway proxy Central auth + routing. Users never interact directly with slice ports.
Database per slice Each slice gets its own PostgreSQL database (wa_slice_N), not shared tables. Full data isolation.
Pre-provisioned pool At least 1 warm slice always ready. New users get instant assignment.
Chromium per slice Each slice maintains its own WhatsApp Web session. Cannot be shared. Main memory consumer.

Server Specification

Resource Value
Provider OVH Cloud VPS-5
IP 192.99.145.61
Location Canada East (Beauharnois)
CPU 16 vCores
RAM 61 GB
Swap 31 GB
Disk 339 GB SSD NVMe
OS Ubuntu 25.04
Cost $40.40/month

Capacity Estimates

Metric Value
Per-slice memory ~400-500 MB
Shared services ~2 GB
Comfortable max 60-80 slices
Aggressive max ~130 slices
Pricing $9/month per slice ($4.50 launch)
Break-even 5 slices at full price

Status

Live prototype — running at https://app.ipnoelp.io with 2 active slices. Gateway, monitoring, admin dashboard, and auto-provisioning all operational.