← Back to Portfolio

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.

⚑ Real-Time Messaging
πŸ”’ Password Protected
⏱️ Auto-Expiring Rooms
πŸš€ Horizontal Scaling

Need this service for your use case or want a tailored solution?

Live Demo - Try It Out

Experience EphemeralChat in real-time. Create or join a chat room and start messaging. Rooms automatically expire after the set time.

⏱️ Please Note: This service runs on Cloud Run and may take 10-30 seconds to boot up if the instance is cold. The first request after inactivity can be slower as the container needs to start. Subsequent requests will be much faster!

Create Room

Join Room

Technology Stack & Architecture

EphemeralChat is built with a scalable architecture designed for real-time messaging and horizontal scaling. The system uses Redis pub/sub for message distribution across multiple instances, enabling high availability and performance.

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

EphemeralChat Architecture

Architecture diagram showing Redis pub/sub, WebSocket connections, and horizontal scaling

Python

Python FastAPI

High-performance async API server handling WebSocket connections and REST endpoints for room management

FastAPI

FastAPI

Modern, fast web framework for building APIs with automatic OpenAPI documentation and WebSocket support

Redis

Redis Pub/Sub

Message distribution system enabling horizontal scaling. Messages broadcast to all instances via pub/sub channels

Docker

Docker

Containerized deployment with Docker Compose for easy setup and consistent environments

Kubernetes

Horizontal Scaling

Run multiple instances behind a load balancer. Redis pub/sub ensures messages reach all instances

NGINX

Load Balancer

Distribute WebSocket connections across multiple application instances for high availability

Key Features

EphemeralChat provides a complete solution for ephemeral chat rooms with real-time messaging, automatic expiration, and horizontal scaling capabilities.

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 Documentation & Examples

Integrate EphemeralChat into your application using our RESTful API and WebSocket endpoints. Full interactive documentation is available.

πŸ“š View API Documentation

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.

Schedule a Meeting Contact Me View on GitHub Connect on LinkedIn