guest@portfolio:~/projects/ephemeral-chat$ topology
CASE STUDY / 01REAL-TIME SYSTEMS
EphemeralChat
A horizontally scalable room service where WebSocket clients can land on any application instance and still share one ordered conversation.
- FastAPI
- WebSockets
- Redis Pub/Sub
- Redis TTL
EphemeralChat - Live Demo
A complete backend-focused ephemeral (self-destructing) chat rooms project. Built with FastAPI, WebSockets, and Redis for real-time messaging with automatic room expiration.
Need this service for your use case or want a tailored solution?
Live demo
External demo service. A cold start can make the first request take 10–30 seconds.
Experience EphemeralChat in real-time. Create or join a chat room and start messaging. Rooms automatically expire after the set time.
Create Room
Join Room
Implementation
Stateless FastAPI instances use Redis Pub/Sub for cross-instance delivery, presence coordination, and TTL-backed cleanup.
Core Technologies
Backend
- • Python 3.9+
- • FastAPI (Async Framework)
- • WebSockets (Real-time)
- • Pydantic (Data Validation)
Message Distribution
- • Redis (Pub/Sub)
- • Redis TTL (Auto-cleanup)
- • Connection Tracking
Infrastructure
- • Docker & Docker Compose
- • Uvicorn (ASGI Server)
- • Horizontal Scaling
- • Load Balancer Ready
Features
- • Room Expiration (TTL)
- • Password Protection
- • User Limits
Python FastAPI
High-performance async API server handling WebSocket connections and REST endpoints for room management
FastAPI
Modern, fast web framework for building APIs with automatic OpenAPI documentation and WebSocket support
Redis Pub/Sub
Message distribution system enabling horizontal scaling. Messages broadcast to all instances via pub/sub channels
Docker
Containerized deployment with Docker Compose for easy setup and consistent environments
Horizontal Scaling
Run multiple instances behind a load balancer. Redis pub/sub ensures messages reach all instances
Load Balancer
Distribute WebSocket connections across multiple application instances for high availability
Capabilities
Room lifecycle and access controls are kept explicit without adding permanent message storage.
Self-Destructing Rooms
Chat rooms automatically expire after a set time (default 10 minutes). No manual cleanup required - rooms disappear when their TTL expires.
Real-Time Messaging
WebSocket-based real-time communication ensures instant message delivery across all connected clients in a room.
Password Protection
Optional password protection for rooms. Secure your conversations with simple password-based access control.
User Limits
Configurable maximum users per room (default 20). Prevents overcrowding and maintains performance.
Horizontal Scaling
Redis pub/sub architecture enables horizontal scaling. Run multiple instances behind a load balancer for high availability.
Docker Ready
Fully containerized with Docker and Docker Compose. Deploy in seconds with a single command.
API Reference
REST room management and WebSocket connection examples for a minimal client integration.
Create Room (cURL Example)
curl -X 'POST' \
'https://ephemeralchat.hansraj.me/rooms/' \
-H 'accept: application/json' \
-H 'content-type: application/json' \
-d '{
"name": "My Chat Room",
"owner_name": "JohnDoe",
"expiry_seconds": 600,
"max_users": 20,
"password": "optional_password"
}'
Python WebSocket Example
import asyncio
import websockets
import json
async def chat_client():
uri = "ws://ephemeralchat.hansraj.me/rooms/{room_id}/ws"
async with websockets.connect(uri) as websocket:
# Send a message
message = {
"type": "message",
"content": "Hello, World!"
}
await websocket.send(json.dumps(message))
# Receive messages
async for message in websocket:
data = json.loads(message)
print(f"Received: {data}")
asyncio.run(chat_client())
JavaScript WebSocket Example
// Create room first
const createRoom = async () => {
const response = await fetch('https://ephemeralchat.hansraj.me/rooms/', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
name: 'My Chat Room',
owner_name: 'JohnDoe',
expiry_seconds: 600,
max_users: 20
})
});
const room = await response.json();
return room.room_id;
};
// Connect via WebSocket
const roomId = await createRoom();
const ws = new WebSocket(`wss://ephemeralchat.hansraj.me/rooms/${roomId}/ws`);
ws.onopen = () => {
console.log('Connected to room');
ws.send(JSON.stringify({
type: 'message',
content: 'Hello, World!'
}));
};
ws.onmessage = (event) => {
const data = JSON.parse(event.data);
console.log('Received:', data);
};
Need This Service for Your Use Case?
EphemeralChat is built with enterprise-grade architecture and can handle real-time messaging at scale. If you need a similar ephemeral chat solution for your business or want a tailored solution customized to your specific requirements, I'd love to help you build it.