Encrypted Chat

Project brief

Project Overview
Real-time chat with browser-encrypted message storage and image uploads, live delivery, and WebRTC audio and video calls.
My Contribution
Designed and built device-side encryption, message and media delivery, presence, call signaling, and WebRTC calls.

The Problem

A real-time messenger needs to deliver messages, images, and calls promptly while protecting stored conversation content. Message and image payloads must be encrypted before reaching the server, but users still need to recover their conversations on another device and receive timely delivery, presence, and call updates.

100% Solo DevelopmentEncrypted Messenger conversation interface alongside an overview of encryption, calls, and authentication.
Encrypted Messenger’s conversation interface and overview of its communication architecture.

The Engineering

A real-time chat application combining browser-encrypted message storage and image uploads with WebRTC voice and video calls. Each payload receives its own AES-256-GCM key, wrapped for both participants with RSA-OAEP. Firestore coordinates conversation updates and call signaling, while password-encrypted key backups support access from additional devices.

How It Works

  1. Unlock the chat

    The browser loads local keys or decrypts a password-protected backup on another device.

  2. Encrypt and send

    The device encrypts each payload and wraps its key for both participants before sending.

  3. Receive and read

    The recipient decrypts stored payloads locally while Firestore synchronizes conversation and delivery updates.

  4. Start a call

    Call signaling connects participants through WebRTC for audio and video calls.

Engineering Decisions

Protecting stored conversation content had to work alongside everyday expectations: opening a chat on another device, seeing new messages promptly, and starting a call. The design separates local encryption and key recovery from the shared updates that coordinate a conversation.

Device-side encryption

Stored text and images reach the server encrypted. Each payload uses a fresh AES-GCM key, wrapped with RSA-OAEP for each participant and decrypted locally; notifications and link previews remain outside this encryption boundary.

Password-encrypted backups

Opening conversations on another device requires recoverable keys without plaintext uploads. Private keys stay in IndexedDB; backups use PBKDF2 password derivation and AES-GCM encryption before storage in an owner-scoped Firestore record.

Participant-scoped updates

Both participants need timely messages, typing indicators, delivery receipts, and incoming call updates. Participant-scoped real-time updates keep conversations synchronized and coordinate the signaling needed to establish audio and video calls.

System Architecture

System architecture — Encrypted Chat

Encrypted messages & images

Sender

AES-GCM encrypts payloads; RSA-OAEP wraps keys.

  • Next.js
Ciphertext storage

Encrypted messages and image files.

  • Firestore
  • Cloud Storage
Recipient

Keys unwrap and payloads decrypt locally.

  • Next.js

Encryption scope. Private keys stay local with password-encrypted backups. Server-side notifications and link previews sit outside the encrypted payload boundary.

Audio & video calls

CallerWebRTCDirect media · TURN relay when neededRecipient

Firestore handles call signaling and presence. Next.js APIs support passkeys, push delivery and ICE credentials.

Cloud RunNext.js app and APIs, with Firebase for identity and live state.

The Results

Stored message and image payloads reach the server already encrypted. Each payload uses a fresh AES-256-GCM key, wrapped separately for the sender and recipient, and private-key backups are password-encrypted for recovery on another device. Real-time updates and WebRTC calls share the conversation interface; server-processed notifications and link previews remain outside the stored-payload encryption boundary.