Modern chat app with instant messaging capabilities

A real-time chat application built with modern web technologies, featuring instant message delivery, user authentication, and a responsive interface. The application uses Socket.io for bidirectional communication, ensuring messages are delivered instantly without page refreshes. It demonstrates proficiency in handling WebSocket connections, managing real-time state, and building scalable chat systems.
Event-driven architecture with Socket.io server handling WebSocket connections, Next.js API routes for REST endpoints, PostgreSQL for message persistence, and Redis for presence tracking.
Architecture Diagram
/api/messagesRetrieve message history for a conversation
Response:
{
"messages": [
{
"id": "msg_123",
"senderId": "user_456",
"content": "Hello!",
"timestamp": "2025-01-15T10:30:00Z",
"read": true
}
],
"hasMore": false
}io.on('connection', (socket: Socket) => {
const userId = socket.handshake.auth.userId;
// Join user's personal room
socket.join(`user:${userId}`);
// Handle new messages
socket.on('message:send', async (data) => {
const message = await saveMessage({
senderId: userId,
recipientId: data.recipientId,
content: data.content,
});
// Emit to recipient
io.to(`user:${data.recipientId}`).emit('message:new', message);
// Confirm to sender
socket.emit('message:sent', message);
});
// Handle typing indicators
socket.on('typing:start', (recipientId) => {
io.to(`user:${recipientId}`).emit('typing:user', userId);
});
socket.on('disconnect', () => {
// Update user status
updateUserStatus(userId, 'offline');
});
});Message Latency
< 100ms
Concurrent Connections
500+
Message Throughput
1000 msg/s
Uptime
99.9%
Sub-100ms message delivery latency
Support for 500+ concurrent connections
99.9% message delivery success rate
Code Coverage
Test Types