How madhu123428/real-time-chat-application works
Pulse is a real-time chat application split across a Next.js client and user, chat, and mail services. The main workflow spans passwordless OTP login, profile and conversation discovery, then room-based messaging with presence, typing, read receipts, and optional image uploads. The user service owns authentication and user data; the chat service owns chat and message data; RabbitMQ decouples OTP delivery. Source excerpts show key controller, route, queue, and client-context behavior; other major capabilities are retained where documented in the README.
Main entry points: routes/user.ts User API routes · chat.ts Chat and message logic · app Next.js application · controllers/user.ts Account and OTP logic
Components 26
Client
- Next.js application
frontend/src/app - Login and verification
frontend/src/app/login/page.tsx - Profile page
frontend/src/app/profile/page.tsx - Chat workspace
frontend/src/app/chat/page.tsx - Chat components
frontend/src/components - App data context
frontend/src/context/AppContext.tsx - Socket context
frontend/src/context/SocketContext.tsx
Identity Service
- User API routes
backend/user/src/routes/user.ts - Account and OTP logic
backend/user/src/controllers/user.ts - User authorization
backend/user/src/middleware/isAuth.ts - User records
backend/user/src/model/User.ts - Redis OTP cache
- User MongoDB
backend/user/src/config/db.ts
Chat Service
- Chat API routes
backend/chat/src/routes/chat.ts - Chat and message logic
backend/chat/src/controllers/chat.ts - Chat authorization
backend/chat/src/middlewares/isAuth.ts - Image upload
backend/chat/src/middlewares/multer.ts - Chat records
backend/chat/src/models/Chat.ts - Message records
backend/chat/src/models/Messages.ts - Socket and rooms
backend/chat/src/config/socket.ts - Chat MongoDB
backend/chat/src/config/db.ts
Email Delivery
- RabbitMQ queue
- OTP mail consumer
backend/mail/src/consumer.ts
Other components
- Chat user
- Cloudinary media
- Gmail SMTP
Connections 29
- Chat user → Next.js application: uses
- Login and verification → User API routes: submits OTP
- App data context → User API routes: fetches profile
frontend/src/context/AppContext.tsx - App data context → Chat API routes: fetches chats
frontend/src/context/AppContext.tsx - App data context → User API routes: fetches users
frontend/src/context/AppContext.tsx - Next.js application → Login and verification: renders
- Next.js application → Profile page: renders
- Next.js application → Chat workspace: renders
- Chat workspace → Chat components: uses
- Chat workspace → Socket context: uses
- Socket context → Socket and rooms: connects
- Chat API routes → Chat authorization: guards
backend/chat/src/routes/chat.ts - Chat API routes → Image upload: uploads
backend/chat/src/routes/chat.ts - Chat API routes → Chat and message logic: dispatches
backend/chat/src/routes/chat.ts - Chat and message logic → Chat records: reads and writes
backend/chat/src/controllers/chat.ts - Chat and message logic → Message records: reads and writes
backend/chat/src/controllers/chat.ts - Chat and message logic → Socket and rooms: emits events
backend/chat/src/controllers/chat.ts - Chat and message logic → User API routes: fetches profiles
backend/chat/src/controllers/chat.ts - Image upload → Cloudinary media: uploads media
- User API routes → User authorization: guards routes
backend/user/src/routes/user.ts - User API routes → Account and OTP logic: dispatches
backend/user/src/routes/user.ts - Account and OTP logic → User records: reads and writes
backend/user/src/controllers/user.ts - Account and OTP logic → Redis OTP cache: checks OTP
backend/user/src/controllers/user.ts - Account and OTP logic → RabbitMQ queue: publishes OTP job
backend/user/src/controllers/user.ts - RabbitMQ queue → OTP mail consumer: delivers job
- OTP mail consumer → Gmail SMTP: sends email
backend/mail/src/consumer.ts - User MongoDB → User records: stores
- Chat MongoDB → Chat records: stores
- Chat MongoDB → Message records: stores