A scalable real-time chat application built using Next.js, Socket.IO, Redis, RabbitMQ, and Docker with a complete Microservices Architecture.
The application enables users to securely authenticate using Email OTP verification and communicate instantly through real-time text and image messaging.
- Email OTP Login
- Secure OTP verification
- JWT Authentication
- Protected user sessions
- View all registered users
- Start one-to-one conversations
- Update and change username
- Real-time online communication
- Instant text messaging using Socket.IO
- Real-time typing indicators
- Live chat synchronization
- Fast low-latency communication
- Send and receive images in real time
- Instant media synchronization
- Typing status (
Typing...) - Online/offline user tracking
- Instant message delivery
- Real-time image updates
The backend follows a scalable Microservices Architecture where each service handles a dedicated responsibility.
Responsible for:
- User authentication
- OTP verification
- JWT token generation
- User profile management
Responsible for:
- Real-time messaging
- Socket.IO communication
- Typing indicators
- Message storage
- Image message handling
Responsible for:
- Sending OTP emails
- Email notifications
- Mail queue processing
Responsible for:
- Centralized routing
- Request forwarding
- API aggregation
- Authentication middleware
The application uses RabbitMQ as a message broker for asynchronous communication between microservices.
- OTP email queue handling
- Event-driven communication
- Decoupled service communication
- Reliable background processing
The application uses Redis for caching and real-time performance optimization.
- Socket session storage
- User online status tracking
- Typing indicator management
- Frequently accessed data caching
- Pub/Sub communication
The entire application is fully containerized using Docker.
sudo apt-get update -ysudo apt-get install docker.io -ysudo systemctl enable docker
sudo systemctl start dockersudo usermod -aG docker $USERLogout and login again after running the above command.
sudo docker run -d \
--hostname rabbitmq-host \
--name rabbitmq-container \
-e RABBITMQ_DEFAULT_USER=admin \
-e RABBITMQ_DEFAULT_PASS=admin123 \
-p 5672:5672 \
-p 15672:15672 \
rabbitmq:3-managementAccess RabbitMQ Dashboard:
http://localhost:15672Username: admin
Password: admin123| Port | Purpose |
|---|---|
| 5672 | RabbitMQ Messaging Port |
| 15672 | RabbitMQ Management Dashboard |
docker psdocker stop rabbitmq-containerdocker start rabbitmq-containerdocker rm -f rabbitmq-container- Next.js
- TypeScript
- Tailwind CSS
- Socket.IO Client
- Node.js
- Express.js
- Socket.IO
- RabbitMQ
- Redis
- Docker
- Microservices Architecture
- MongoDB
- JWT Authentication
- Email OTP Verification
- WebSockets (Socket.IO)
- Redis Pub/Sub
chat-app/
│
├── frontend/ # Next.js Frontend
│
├── backend/
│ ├── proxy/ # API Gateway
│ ├── user/ # Authentication Service
│ ├── chat/ # Real-Time Chat Service
│ ├── mail/ # OTP & Email Service
└── README.md---
git clone https://github.com/your-username/chat-app.gitcd frontend
npm installcd backend/user-service
npm install
npm run devcd backend/chat-service
npm install
npm run devcd backend/mail-service
npm install
npm run devdocker-compose up --builddocker-compose down| Service | Port |
|---|---|
| Frontend | 3000 |
| API Gateway | 5000 |
| User | 5000 |
| Chat | 5002 |
| Mail Service | 5001 |
| MongoDB | 27017 |
| Redis | 6379 |
| RabbitMQ | 5672 |
| RabbitMQ Dashboard | 15672 |
MONGO_URI=mongodb://
PORT=
REDIS_URL=redis://redis:6379
RABBITMQ_USERNAME=
RABBITMQ_PASSWORD=
RABBITMQ_HOST=
OR
RABBITMQ_URL==amqp://rabbitmq
JWT_SECRET=
RABBITMQ_USERNAME=
RABBITMQ_PASSWORD=
RABBITMQ_HOST=
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#Google Account app user & password
USER=
PASSWORD=
----------------------------------------------------------------------------------------------------------------------------------------------------------------------
PORT=5001
RESEND_API_KEY=re_
RABBITMQ_URL=amqps://MONGO_URI=mongodb://
JWT_SECRET=
USER_SERVICE=
CHAT_SERVICE=
CLOUD_NAME=
CLOUD_API_KEY=
CLOUD_API_SECRET=
PORT=5002
FRONTEND_URL=
USER_SERVICE=
CHAT_SERVICE=
MAIL_SERVICE=
- Socket.IO real-time communication
- Redis Publisgher/Subscriber synchronization
- Live typing indicators
- Online/offline presence tracking
- Instant image sharing
- Scalable WebSocket handling
- Login with Email
- Verify OTP
- Update Profile
- Fetch Users
- Send Message
- Fetch Messages
- Upload Images
- Socket Events
- Send OTP
- Queue Email Jobs
- Group Chats
- Voice & Video Calls
- Read Receipts
- Push Notifications
- Message Reactions
- End-to-End Encryption
- Dark Mode
- File Sharing
Contributions are welcome!
- Fork the repository
- Create your branch
- Commit your changes
- Push the branch
- Open a Pull Request
This project is licensed under the MIT License.
If you like this project, give it a ⭐ on GitHub!






