🌐 Experience Live Demo • 📖 About • 📸 Interface • 🌟 Features • 🏛️ Architecture • 🔐 Cryptography • 🚀 Quick Start • 📡 API Docs
SecureChat is an open-source, privacy-first real-time messaging platform engineered on the principle of Zero-Knowledge Architecture and deployed live on Vercel.
In standard messaging platforms, central backend servers ingest and store plaintext messages, exposing user communications to unauthorized database reads, network interception, and insider threats. SecureChat fundamentally eliminates this vulnerability:
- Client-Side Cryptography: Every message, media payload, and file attachment is encrypted and decrypted strictly inside the client's web browser using native Web Cryptography (
SubtleCrypto). - Zero Plaintext Ingestion: The server and database store only high-entropy AES-256-GCM ciphertexts accompanied by cryptographically random 96-bit initialization vectors.
- Zero Server-Side Master Keys: Encryption keys are derived on the fly from user passphrases using PBKDF2 with 100,000 iterations of SHA-256. The backend has no computational capability to decrypt or read transmitted chat streams.
- Dual Real-Time Engine: Seamlessly transitions between full-duplex WebSockets (for dedicated VPS/Docker hosts) and HTTP Serverless Live Sync (for Vercel serverless functions).
- Discord-Inspired Experience: Delivers an intuitive, desktop-class Discord interface featuring multi-channel navigation, live online member rosters, markdown formatting with JetBrains Mono code highlights, audio feedback cues, and emoji reactions.
fastapi • end-to-end-encryption • e2ee • zero-knowledge • cryptography • aes-256-gcm • chat-app • chat-application • discord-clone • realtime • websockets • python • security • privacy • fullstack • asyncio • vercel
The platform is actively deployed and globally accessible on Vercel:
👉 https://securechat-rouge.vercel.app
# 1. Clone the repository
git clone https://github.com/Coderaryanyadav/SecureChat.git
cd SecureChat
# 2. Deploy via Vercel CLI
npx vercel --prodNote: The included
vercel.jsonroutes incoming requests between FastAPI serverless functions and global Edge CDN static delivery.
| Category | Capability | Details |
|---|---|---|
| 🔐 Security | Zero-Knowledge E2EE | AES-256-GCM authenticated cipher with unique 96-bit IV per message. |
| 🔑 Authentication | Cryptographic Recovery | 32-character deterministic recovery hex token (no email / third-party trackers). |
| ⚡ Real-Time | Dual Transport Core | Stateful bidirectional WebSockets with fallback serverless live polling. |
| 🎨 UI / UX | Discord-Inspired Design | Sidebar channels, member presence, custom sound synthesis, and multi-theme engine. |
| 📝 Rich Media | Markdown & Code Highlighting | JetBrains Mono code blocks, inline code, bold, italics, and safe auto-linking. |
| 📁 Data Transfer | Encrypted Attachments | Drag-and-drop & clipboard (Ctrl+V) paste with immediate browser encryption. |
| 🛡️ Defense-in-Depth | Fintech-Grade Hardening | Bcrypt password hashing (12 rounds), SlowAPI rate limiters, SQLite parameterized queries, CSP headers. |
| 📦 Sovereignty | GDPR Compliance | 1-click JSON data export and permanent account self-deletion. |
flowchart TD
subgraph Client ["Client Browser (Zero-Knowledge Isolation)"]
UI["Discord-Replica UI (Channels, Chat, Members)"]
Crypto["Web Crypto API (SubtleCrypto)<br/>PBKDF2 100,000 Rounds + AES-256-GCM"]
Storage["Local Storage (Encrypted Room State)"]
UI <--> Crypto
Crypto <--> Storage
end
subgraph Transport ["Dual Real-Time Transport Layer"]
WS["Full-Duplex WebSocket (/ws/{rid}/{user})<br/>(VPS / Docker / Local Host)"]
HTTP["Serverless Live Sync (/api/rooms/{rid}/messages)<br/>(Vercel Edge & Serverless Functions)"]
end
subgraph Backend ["FastAPI Core Engine (Python 3.10+)"]
Router["FastAPI Application Router"]
Limiter["SlowAPI Rate Limiter"]
AuthModule["Bcrypt Authentication Engine"]
DB[("SQLite WAL Database / Persistent Storage")]
end
Crypto <-->|"Encrypted Ciphertext Only"| Transport
Transport <--> Router
Router --> Limiter
Router --> AuthModule
Router --> DB
Passphrase ──▶ [ PBKDF2 (SHA-256, 100,000 Iterations, Salt = Room ID) ] ──▶ 256-bit AES-GCM Key
│
Plaintext Message ──▶ [ AES-256-GCM (Key + Random 96-bit IV) ] ──▶ Encrypted Ciphertext Payload
-
Key Derivation (
PBKDF2):- Salt: Room ID (ensures identical passphrases generate distinct cryptographic keys across separate rooms).
- Work Factor:
100,000rounds ofSHA-256. - Result: 256-bit raw key imported into
AES-GCMformat.
-
Authenticated Encryption (
AES-256-GCM):- Generates a fresh 96-bit (12-byte) initialization vector (
iv) viawindow.crypto.getRandomValues(). - Galois/Counter Mode ensures confidentiality and cryptographic integrity against payload tampering.
- Wire format transmitted to server:
{ "id": "msg-8f12a4b0-391a-41e8-a15d", "room": "general", "sender": "alex_cipher", "content": { "iv": "dGVzdElWYmFzZTY0MTI=", "data": "ZW5jcnlwdGVkQ2lwaGVydGV4dERhdGE==" }, "type": "message", "timestamp": "2026-11-23T00:15:00.000Z" }
- Generates a fresh 96-bit (12-byte) initialization vector (
- Python 3.10+
- Modern Web Browser with Web Cryptography API support (Chrome, Brave, Firefox, Safari, Edge)
# Clone the repository
git clone https://github.com/Coderaryanyadav/SecureChat.git
cd SecureChat
# Create virtual environment
python3 -m venv .venv
source .venv/bin/activate
# Install dependencies
pip install -r requirements.txt# Run via start script
./start.shOr run directly with python3:
export DEV_MODE=1
python3 server/main.pyOpen http://localhost:8000 in your browser.
The repository includes a comprehensive automated test suite covering sanitization filters, user authentication, and encrypted room messaging:
# Activate virtual environment
source .venv/bin/activate
# Run pytest
PYTHONPATH=. pytest -v| Endpoint | Method | Rate Limit | Description |
|---|---|---|---|
/health |
GET, HEAD |
None | Operational health check & service status |
/api/register |
POST |
15 / hour | Account registration; returns 32-char hex recovery key |
/api/login |
POST |
30 / min | User login; issues secure session cookie |
/api/logout |
POST |
None | Terminate active user session |
/api/recover |
POST |
None | Reset account password using secret recovery key |
/api/save-room |
POST |
60 / min | Save channel reference to user's saved list |
/api/history/{uid} |
GET |
None | Retrieve user's joined channel list |
/api/rooms/{rid}/messages |
GET |
None | Poll room messages & active member roster |
/api/rooms/{rid}/messages |
POST |
120 / min | Submit encrypted message or media payload |
/api/ws-token |
GET |
None | Mint 60-second handshake token for WebSocket connection |
/api/export |
GET |
None | Export user account metadata and room logs (GDPR) |
/api/delete-account |
POST |
None | Permanently delete account and associated history |
/ws/{rid}/{user} |
WebSocket |
30 msg / 10s | Stateful bidirectional WebSocket connection |
- Zero Plaintext Storage: Plaintext message content never reaches the server or persistent database.
- Strict Input Validation:
- Room IDs and usernames are enforced against
^[a-z0-9_-]+$, normalized to lowercase, and bounded (3–50 chars). - Passwords require a minimum of 8 characters (up to 128 chars).
- Room IDs and usernames are enforced against
- SQL Injection Prevention:
- Parameterized SQLite queries (
?placeholders) throughout the entire codebase. Zero string concatenation.
- Parameterized SQLite queries (
- XSS & Content Security Policy (CSP):
- Text rendered into the DOM utilizes strict text nodes and character entity escaping.
- Security headers enforced:
X-Content-Type-Options: nosniff,X-Frame-Options: DENY,X-XSS-Protection: 1; mode=block.
- Brute-Force Protection:
- Sliding-window rate limiters across all registration, login, and message submission endpoints via
SlowAPI.
- Sliding-window rate limiters across all registration, login, and message submission endpoints via
This project is open-source software licensed under the MIT License.

