WhatsApp Bridge Architecture
The WhatsApp Bridge service (apps/whatsapp-bridge) is a standalone microservice that interfaces with the WhatsApp Web API to sync client messages into Wunderkint AI CRM.
Live WhatsApp Chat Interface
Section titled “Live WhatsApp Chat Interface”1. Microservice Structure
Section titled “1. Microservice Structure”apps/whatsapp-bridge/├── src/│ ├── index.ts # Express server & socket.io entrypoint│ ├── client.ts # WhatsApp client lifecycle manager│ ├── webhooks.ts # Incoming webhook handler to apps/web│ └── handlers/ # Message parser & media attachment downloader2. Event Lifecycle
Section titled “2. Event Lifecycle”sequenceDiagram participant WA as Client Phone (WhatsApp) participant Bridge as apps/whatsapp-bridge participant Web as apps/web (Next.js 16) participant DB as Neon PostgreSQL
WA->>Bridge: Incoming Message Event Bridge->>Bridge: Parse payload & download media attachments to R2 Bridge->>Web: POST /api/integrations/whatsapp/webhook Web->>DB: Insert whatsapp_messages & update whatsapp_chats Web->>Web: Trigger TanStack Query Cache Invalidation Web->>Bridge: ACK (200 OK)