Overview
Built a comprehensive WhatsApp Business admin panel that enables teams to manage customer conversations with AI-powered assistance. The platform handles message routing, team collaboration, template management, and intelligent response generation—all while maintaining enterprise-grade reliability.
The Challenge
The client needed to modernize their customer communication workflow. Their requirements included:
- Centralized inbox for WhatsApp Business messages
- AI assistant that understands their specific business context
- Team collaboration features with role-based access
- Multi-language support (Italian primary, English secondary)
- Reliable message delivery with retry mechanisms
- Analytics and usage tracking
The technical challenge was building an AI system that could provide genuinely useful responses without hallucinating information or requiring expensive per-query costs.
Technical Approach
Architecture Decisions
Monorepo with Workspaces: Chose npm workspaces over microservices for this project size. Shared types via a packages/shared workspace ensure API contracts are enforced at compile time. Single deployment artifact simplifies ops.
PostgreSQL + Drizzle ORM: Selected for type-safe queries, excellent JSON support, and Graphile Worker compatibility. Drizzle's schema-as-code approach makes migrations predictable. 35+ tables handle everything from messages to AI content to analytics.
Socket.IO for Real-Time: WebSocket connections enable instant message delivery and AI streaming. Four namespaces isolate different concerns: /whatsapp, /team-chat, /notifications, /ai-assistant.
Express 5 + TypeScript: Express 5's native Promise support simplifies async error handling. Feature-based directory structure keeps related code together. Each feature has router → service → repository layers.
AI Pipeline Architecture
The AI assistant follows a pipeline pattern:
- Context Preparation: Load conversation history, business facts, AI settings
- Intent Detection: Claude Haiku classifies the query type
- Handler Selection: Route to appropriate handler (knowledge, chat, clarification, web-search)
- Context Building: Handler fetches relevant content via hybrid search
- Execution: Stream response with progress events
- Post-Processing: Log usage, extract facts, update analytics
Security & Reliability
- JWT authentication with refresh token rotation
- Rate limiting on AI endpoints (prevent abuse)
- SOPS encryption for secrets at rest
- Health check endpoints for deployment verification
- Automatic rollback on failed deployments
- Structured logging with Pino for debugging
Results
The system has been running in production for 9 months, handling real customer conversations daily. Key outcomes:
- Consistent Uptime: Zero-downtime deployments with automatic rollback
- Cost Efficiency: Tiered AI approach keeps costs predictable
- Developer Experience: Full-stack TypeScript enables rapid iteration
- Extensibility: New features (voice transcription, image description) integrated with minimal architecture changes
Tech Stack Summary
Backend: Express 5, TypeScript, PostgreSQL, Drizzle ORM, Graphile Worker, Socket.IO, Pino
Frontend: React 19, Vite, TanStack Router + Query, Tailwind CSS, Radix UI, i18next
AI/ML: Claude API (Anthropic), OpenAI API, Voyage AI, pgvector, hybrid BM25+semantic search
Infrastructure: Docker, GitHub Actions, SOPS, systemd, Caddy reverse proxy
Integrations: WhatsApp Cloud API, AWS S3, Firebase Cloud Messaging, WordPress sync