Building a Real-Time Chat Platform
· 3 min
What Is ChatFly?
ChatFly is a free chat platform designed around one idea: jump in and start talking. There is no sign-up form, no email verification, no profile to fill out. You pick a name, choose a room, and you are chatting within seconds. The platform supports public chat rooms, private custom rooms, a chat roulette feature for meeting random people, and built-in games you can play with other users in the room.
Architecture Overview
Real-time messaging requires persistent connections, and ChatFly handles this through the AWS WebSocket API. When a user connects, API Gateway establishes a WebSocket connection and registers the session in DynamoDB. Every message sent through the socket triggers a Lambda function that broadcasts to all connected users in the same room.
User Browser
|
v
CloudFront (Static Assets from S3)
|
v
API Gateway (WebSocket API)
|
v
Lambda Functions (Connect / Disconnect / Message / Roulette)
|
v
DynamoDB (Sessions, Rooms, Messages, Game State)
This serverless approach means the platform scales automatically. Whether ten users are online or ten thousand, AWS provisions exactly the compute needed and nothing more.
Key Features
Custom Rooms let users create their own spaces with a shareable link. Room creators can set a topic, toggle visibility between public and private, and moderate participants. Room metadata is stored in DynamoDB with a TTL so inactive rooms clean themselves up automatically.
Chat Roulette pairs users randomly for one-on-one conversations. A dedicated Lambda function maintains a waiting queue in DynamoDB. When two users are available, it creates a private session and notifies both via their WebSocket connections.
Built-In Games turn chat rooms into lightweight hangout spaces. Game state is managed server-side in DynamoDB to prevent cheating, and moves are broadcast to all players through the same WebSocket pipeline used for chat messages.
Performance
WebSocket connections are managed at the edge through CloudFront, keeping latency under 50ms for most users. Message delivery averages 30ms end-to-end. Static assets are served from S3 through CloudFront with aggressive caching, so the initial page load completes in under one second. DynamoDB on-demand capacity ensures consistent single-digit millisecond reads and writes regardless of traffic spikes.