A production-ready real-time chat application with WebSocket server and CLI client.
This chat application consists of two main components:
- Server: WebSocket-based messaging server with MongoDB and Redis
- Client: Terminal-based chat interface with real-time features
┌─────────────────┐ WebSocket ┌─────────────────┐
│ Chat Client │◄────────────────►│ Chat Server │
│ (Terminal) │ │ (Node.js) │
└─────────────────┘ └─────┬───────────┘
│
┌───────────────────┼───────────────────┐
│ │ │
▼ ▼ ▼
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ MongoDB │ │ Redis │ │ HTTP Monitoring │
│ (Messages) │ │ (Cache/PubSub) │ │ (Health) │
└─────────────────┘ └─────────────────┘ └─────────────────┘
- Real-time messaging with WebSocket connections
- Room-based chat with creation and joining
- User authentication and presence tracking
- Message persistence and history
- Typing indicators and user status
- Rate limiting and performance monitoring
- Node.js 18+ with WebSocket (ws) library
- MongoDB with Mongoose for data persistence
- Redis for caching and pub/sub messaging
- Terminal UI with Chalk and Inquirer.js
- Node.js 18.0.0+ - Download here
- Docker & Docker Compose - Install Docker
- Git - For cloning the repository
-
Clone the repository
git clone https://github.com/sanlamamba/chat-app.git cd chat-app -
Start database services
docker-compose up -d mongodb redis mongo-express
Wait for services to start (about 30 seconds). Verify with:
docker-compose ps
-
Setup and start the server
cd server npm install npm startServer will start on
http://localhost:3000 -
Setup and start the client (open new terminal)
cd client npm install npm start -
Start chatting!
- Enter your username when prompted
- Use
/create room-nameto create a room - Use
/join room-nameto join existing rooms - Type messages to chat
Production WebSocket server with MongoDB and Redis integration. View Server Documentation
Terminal-based chat client with real-time UI. View Client Documentation
Server Environment (.env)
PORT=3000
MONGODB_URI=mongodb://localhost:27017/realtime-chat
REDIS_URL=redis://localhost:6379Client Environment (.env)
SERVER_URL=ws://localhost:3000- Server dev:
cd server && npm run dev - Client dev:
cd client && npm run dev - Tests:
cd server && npm test - Load test:
cd server && npm run test:load
- Health check:
GET http://localhost:3000/health - Metrics:
GET http://localhost:3000/metrics - Database admin:
http://localhost:8081(Mongo Express)
For detailed documentation, see component-specific README files.