System Architecture

Multi-tenant WhatsApp CRM with gateway orchestration, per-user Docker slices, and headless Chrome

Component Overview

Browser
HTTPS request
:443
nginx
SSL + reverse proxy
:3000
Gateway
Auth, billing, orchestration
:500x
Slice N
Docker + Chrome
Gateway Internals
Auth — Login, register, sessions
Billing — Stripe integration
Connect — On-demand provisioning
Monitor — 60s health checks
SSE — Real-time event relay
Proxy — API forwarding to slices
PostgreSQL
gateway.* — Users, slices, billing
slice_N.* — Per-user chats, contacts, messages

Request Flow

1
Browser requests https://app.queunir.com/api/chats
2
nginx terminates SSL, forwards to Gateway on port 3000
3
Gateway validates session cookie, resolves user's slice port from DB
4
Proxy forwards request to http://127.0.0.1:{slicePort}/api/chats
5
Slice backend reads from PostgreSQL slice_N.chats table and returns JSON

Per-User Docker Slices

Each user gets an isolated Docker container running headless Chrome + whatsapp-web.js + Express API

Component Details Notes
Container wank-slice-{N} Alpine-based Docker image
Port 5001, 5003, 5005, ... Odd numbers, auto-assigned
Browser Chromium (headless) puppeteer-extra + stealth plugin
WhatsApp whatsapp-web.js DOM-only data extraction
Database slice_N schema Shared PostgreSQL, isolated schema
Session .wwebjs_auth volume Survives container restarts

Production Server

Item Value
Server slices — 192.99.145.61 (OVH VPS)
App URL https://app.queunir.com
OS Ubuntu 25.04
Specs 16 vCPU, 64 GB RAM, 350 GB SSD
Gateway systemd wank-gateway, port 3000
Database PostgreSQL wank_saas on localhost
Frontend Vite build to /var/www/app/

Technology Stack

Frontend
React 18 + TypeScript
Vite (VITE_SAAS=1 for production)
Tailwind CSS + IBM Plex fonts
Backend (per slice)
Express + TypeScript
whatsapp-web.js + Puppeteer
PostgreSQL (per-schema isolation)
Gateway
Express + TypeScript (systemd)
Session auth + Stripe billing
Docker orchestration
Infrastructure
nginx (SSL + reverse proxy)
Docker (per-user containers)
WireGuard (optional VPN proxy)
Drill down: On-Demand Provisioning · DOM-Only Rule · CRM Layout · VPN Proxy · Back to Project