A truly peer-to-peer secure chat application built with modern web technologies and a lightweight Python backend.
Unlike traditional chat applications (like WhatsApp or Slack) where every message you send goes through a central company server before reaching your friend, this application uses WebRTC Data Channels to establish a direct, browser-to-browser connection.
The Python backend (built with FastAPI) simply serves as an initial "Matchmaker" (Signaling Server). It helps the two browsers find each other. Once connected, the chat messages are sent encrypted, directly between peers, and the Python server is no longer involved.
This project is divided into two parts executing simultaneously:
- The Signaling Server (Python/FastAPI): Serves the HTML, CSS, and JS files, and handles WebSockets.
- The Clients (Browsers): Handle the user interface, WebRTC negotiation, and establish the P2P connection.
WebRTC requires an exchange of connection information (called SDP Offers/Answers and ICE Candidates) before a direct connection can be established.
- Setup Phase: Both peers load the web app from the FastAPI server.
- Signaling Phase: They connect to the Server's WebSocket (
/ws) to securely exchange connection parameters. - P2P Phase: A direct WebRTC Data Channel is established between the two browsers. All subsequent chat messages and emoji animations are sent horizontally across this P2P channel, completely bypassing the server.
- True P2P: Messages are completely private and never pass through a central database.
- Single-Port Design: The FastAPI server intelligently routes both standard HTTP requests (for your web interface) and WebSocket connections on exactly the same port (default
8080), making it incredibly easy to deploy to cloud providers like Render, AWS, or Google Cloud Run. - Modern UI: Features a dark mode with animated mesh gradients and floating emoji interactions synchronized between peers.
- Create a virtual environment and install dependencies:
python3 -m venv .venv source .venv/bin/activate pip install -r requirements.txt - Run the server:
python3 server.py
- Open two separate tabs pointing to
http://localhost:8080and click "Enter Lounge".

