How punkuz/whatsapp-backend works
This NestJS starter implements account signup/login, user lookup and updates, and chat through both HTTP endpoints and a WebSocket gateway. The principal flow is a client request routed to an authentication or chat entry point, then handled by a service that verifies or persists domain data. PostgreSQL is configured at application startup; Redis provides a separate Pub/Sub service, but the available evidence does not show a chat component consuming it. Gateway behavior is represented only at the service/guard boundary because its implementation details were not excerpted.
Main entry points: auth.service.ts Auth Service · chat.service.ts Chat Service · chat.gateway.ts WebSocket Gateway · main.ts Nest Bootstrap
Components 19
Application Runtime
- Nest Bootstrap
src/main.ts - Application Modules
src/app.module.ts
Accounts and Authentication
- Auth HTTP API
src/auth/auth.controller.ts - Auth Service
src/auth/auth.service.ts - HTTP Guard
src/auth/guards/http.guard.ts - User HTTP API
src/user/user.controller.ts - User Service
src/user/user.service.ts - User Account
src/user/entities/user.entity.ts
Chat
- Chat HTTP API
src/chat/chat.controller.ts - WebSocket Gateway
src/chat/chat.gateway.ts - WebSocket Guard
src/chat/guards/ws.guard.ts - Chat Service
src/chat/chat.service.ts - Conversations
src/chat/entities/conversation.entity.ts - Messages
src/chat/entities/message.entity.ts
Persistence and Messaging
- PostgreSQL
- Redis Pub/Sub Service
src/redis/redis.service.ts - Redis
- JWT Service
Other components
- Client
Connections 20
- Client → Nest Bootstrap: starts request
- Nest Bootstrap → Application Modules: boots
src/main.ts - Application Modules → PostgreSQL: configures
src/app.module.ts - Client → Auth HTTP API: submits credentials
- Auth HTTP API → Auth Service: delegates
src/auth/auth.controller.ts - Auth Service → User Account: reads and writes
src/auth/auth.service.ts - Auth Service → JWT Service: signs and verifies
src/auth/auth.service.ts - HTTP Guard → Auth Service: verifies tokens
src/auth/guards/http.guard.ts - Client → User HTTP API: requests user data
- User HTTP API → User Service: delegates
src/user/user.controller.ts - User Service → User Account: queries and updates
src/user/user.service.ts - Client → Chat HTTP API: requests conversations
- Chat HTTP API → Chat Service: delegates
src/chat/chat.controller.ts - Client → WebSocket Gateway: opens socket
- WebSocket Gateway → WebSocket Guard: checks connection
src/chat/chat.gateway.ts - WebSocket Gateway → Chat Service: delegates chat operations
src/chat/chat.gateway.ts - Chat Service → Conversations: queries and saves
src/chat/chat.service.ts - Chat Service → Messages: queries and saves
src/chat/chat.service.ts - Conversations → Messages: relates messages
src/chat/entities/conversation.entity.ts - Redis Pub/Sub Service → Redis: publishes and subscribes
src/redis/redis.service.ts