How poravv/message-sender works
Project Type and Purpose
• Full-stack, multi-tenant messaging platform
• Backend: Node.js/Express + Baileys for WhatsApp integration
• Frontend: Bootstrap single-page UI for CSV upload, progress, status
• Queue-driven mass messaging with Redis session & lock management
• Auth: Keycloak (external identity provider)
• Deployment: Docker, Docker Compose (local), Kubernetes (production)
• CI/CD: GitHub Actions → GHCR image → Kubernetes deploy
Main Components
1. Frontend (public/index.html + public/app.js + styles.css)
2. Backend API (app.js, src/… modules)
– HTTP API layer (src/routes.js)
– Auth module (src/auth.js + Keycloak integration)
– Queue manager (src/queue.js, src/queueRedis.js)
– Session manager & locks (src/sessionManager.js, src/redisLock.js)
– Media & storage (src/media.js, src/storage/s3.js)
– Business logic (src/manager.js)
3. Redis (session store + queue datastore + distributed locks)
4. WhatsApp Gateway (Baileys library connecting to WhatsApp network)
5. External Services
– Keycloak (OIDC provider)
– AWS S3 (object storage for media, optional)
6. Infrastructure
– Docker & Docker Compose
– Kubernetes cluster (namespace sender)
• Deployment + Service + HPA (backend)
• ConfigMap, Ingress (TLS via cert-manager), PodDisruptionBudget
– Nginx Proxy Manager (external reverse proxy for multi-tenant domains)
– GitHub Actions CI/CD pipeline
Relationships and Data Flow
• User’s browser → HTTP(S) → Nginx Ingress → Backend API
• Backend API ↔ Keycloak (token introspection) for authorization
• API publishes tasks to Redis queue → Worker components consume FIFO
• Worker logic uses Baileys to send messages to WhatsApp servers
• Media files processed locally → optionally uploaded to S3 → URLs returned
• Session state and locks maintained in Redis for concurrency control
• Logs emitted to console/files, auto-rotated (Docker logging/drivers)
Architectural Patterns & Design Principles
• Layered architecture: API → business layer → infrastructure services
• Event-driven/queue-based decoupling for high throughput and retry logic
• Distributed locking (Redis) for session safety across replicas
• Twelve-factor: config via environment variables, stateless containers
• Containerized micro-deployment (monolithic code, but container-oriented)
• CI/CD with immutable images and declarative Kubernetes manifests