An open-source, production-ready, scalable real-time chat application built with modern event-driven architecture.
Built with: NestJS, Next.js, Apache Kafka, PostgreSQL, Redis, Socket.io
This is not just another chat demo - it's a production-ready foundation for building scalable real-time applications.
- ๐ฎ Gaming platforms (in-game chat, guilds, parties)
- ๐ผ Business apps (team collaboration, customer support)
- ๐ Social networks (messaging, communities)
- ๐ซ Educational platforms (virtual classrooms, Q&A)
- ๐ค AI applications (chatbots, assistants, agents)
- โ Event-driven architecture with Kafka (not just WebSocket!)
- โ Horizontal scalability out of the box
- โ Redis adapter for multi-instance WebSocket sync
- โ Complete feature set (pinning, forwarding, presence, rate limiting)
- โ Analytics & audit logging built-in
- โ Well-documented and easy to extend
Want to get started in under 5 minutes? โ โก QUICKSTART GUIDE
# Clone the repo
git clone <repo-url>
cd nest-kafka-postgres-websocket-chat-prototype
# Start everything
docker-compose up -d --build
# Access the app
# Frontend: http://localhost:3000
# Backend: http://localhost:4000That's it! ๐
- โ User signup with email, name, and password
- โ User login with email and password
- โ JWT token-based authentication
- โ Persistent authentication (token stored in localStorage)
- โ Real-time online/offline status tracking powered by Redis
- โ Automatic status updates on connection/disconnection
- โ Visual indicators for user availability
- โ Multi-device support (tracks all user's sockets)
- โ Last seen timestamp tracking
- โ Scalable presence across multiple server instances
- โ Send text messages in real-time
- โ Receive messages instantly via WebSocket
- โ Message persistence in PostgreSQL database
- โ Auto-scrolling to latest messages
- โ Sent (โ) - Message sent to server
- โ Delivered (โโ) - Message delivered to recipient's device
- โ Read (โโโ) - Message read by recipient (click on message to mark as read)
- โ Create private chat between two users
- โ Join/leave chat rooms
- โ Automatic room creation on first message
- โ Chat history persistence
- โ Real-time bidirectional communication
- โ Automatic reconnection on connection loss
- โ Connection status indicators
- โ Room-based message broadcasting
- โ NestJS modular architecture
- โ TypeORM with PostgreSQL for data persistence
- โ Redis for caching, sessions, and user presence
- โ Kafka event-driven architecture for async processing
- โ 21 Kafka topics for different event types
- โ Real-time analytics through Kafka streams
- โ Audit logging for all user actions
- โ Notification system via Kafka events
- โ Socket.io for real-time communication with Redis adapter
- โ JWT-based WebSocket authentication
- โ Rate limiting with Redis
- โ Message caching for performance
- Pin important messages to chat top
- Unpin messages
- Display pinned messages section
- Sync pinned messages across devices
- Maximum pinned messages limit (configurable)
- Forward messages to other chats/users
- Forward multiple messages at once
- Include original sender information
- Forward with additional comment
- Edit sent messages within time limit
- Show "edited" indicator
- Delete messages for self
- Delete messages for everyone
- Message edit history
- Search messages by content
- Search by sender
- Search by date range
- Jump to message in chat
- Highlight search results
- React to messages with emojis
- Multiple reactions per message
- Custom emoji support
- Reaction notifications
- Most used emojis section
- Create group chats with multiple users
- Add/remove participants
- Group admins and permissions
- Group info and settings
- Leave group functionality
- Show when user is typing
- Multiple users typing in group
- Typing timeout handling
- Optimize typing event frequency
- Reply to specific messages
- Quote messages
- Thread view for conversations
- Thread notifications
- Jump to original message
- End-to-end encryption
- Key exchange protocol
- Encrypted file sharing
- Backup encryption keys
- Security indicators
- Custom chat backgrounds
- Theme selection (dark/light/custom)
- Font size adjustment
- Notification sounds
- Chat color schemes
- Push notifications
- Email notifications
- Notification preferences
- Do not disturb mode
- Notification grouping
- Send images (JPEG, PNG, GIF)
- Send documents (PDF, DOCX, etc.)
- Send videos with preview
- Send voice messages
- File size limitations
- Image compression & thumbnails
- Download progress indicators
- One-on-one voice calls
- One-on-one video calls
- Group calls
- Screen sharing
- Call history
- WebRTC integration
- Schedule messages for later
- Recurring messages
- Edit scheduled messages
- Cancel scheduled messages
- Timezone handling
- Auto-detect language
- Translate messages on demand
- Preferred language settings
- Original message preservation
- Export chat history
- Backup to cloud
- Import chat history
- Multiple export formats (JSON, CSV, PDF)
- Block users
- Report inappropriate content
- Blocked users list
- Moderation queue
- Auto-moderation rules
- Save message templates
- Quick reply suggestions
- Canned responses
- Template categories
- Keyboard shortcuts
- Share current location
- Share live location
- Location history
- Map integration
- Privacy controls
- Disable read receipts
- Disable typing indicators
- Privacy settings per user
- Last seen status control
- Next.js 13+ with App Router
- React Hooks for state management
- Socket.io client for WebSocket
- Tailwind CSS for styling
- NestJS framework
- PostgreSQL with TypeORM
- Redis for caching, sessions, and presence
- Apache Kafka for message queue
- Socket.io for real-time events
- JWT authentication
- Users table
- Messages table
- Chats table
- Chat participants junction table
- Docker & Docker Compose
- Node.js 18+
- PostgreSQL
- Redis
- Apache Kafka
See .env.example files in both packages/backend and packages/frontend directories.
# Backend tests
cd packages/backend
npm test
# Frontend tests
cd packages/frontend
npm testComprehensive documentation is available in the /doc directory:
- ๐ Project Purpose & Vision - What this project is and why
- ๐๏ธ Architecture Overview - System architecture and components
- ๐ก WebSocket API Reference - Real-time communication API
- ๐ REST API Reference - HTTP endpoints
- ๐ Kafka Integration - Event-driven architecture
- ๐ด Redis Usage - Caching and presence
- ๐ฆ Database Schema - Data models
- ๐ฏ NestJS Backend - Backend architecture
- โ๏ธ Next.js Frontend - Frontend architecture
- ๐ฌ๐ฎ๐ Genres Research - Popular genres across books, movies/series, and games
- ๐ Source file from the issue: genres/list.md
This is an open-source project and contributions are welcome!
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Implement a feature from the TODO list
- Add tests for new functionality
- Update documentation
- Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Follow existing code style and conventions
- Write unit and integration tests
- Update documentation for new features
- Keep commits atomic and descriptive
- Add your feature to the completed list in README
Check out issues labeled good-first-issue for beginner-friendly tasks!
If you find this project useful:
- โญ Star the repository
- ๐ด Fork it for your own projects
- ๐ข Share it with others
- ๐ Report bugs and suggest features
- ๐ฌ Contribute code or documentation
MIT License - feel free to use this project for any purpose, commercial or personal.
See LICENSE file for details.
Built with โค๏ธ for the open-source community
Ready to scale from MVP to millions of users. Start building today!