FlashChat
Engineering · Architecture · Real-time

How FlashChat is built: the architecture of an anonymous chat app

FlashChat lets anyone in India start a text chat with a stranger in one tap, with no sign-up, and turn it into a video call after one email check. Behind that tap sit a single-page web app, one real-time server, a deliberately forgetful chat path, a media pipeline and a few small model services. This is how the pieces fit, and what running them has taught us.

0sign-up steps to start a chat
1HTML file for the whole app, installable on the home screen
0one-to-one chat messages written to disk
15room languages, from Hindi and Tamil to Maithili
1command to deploy, with health checks
On this page
  1. Summary
  2. Design goals
  3. The big picture
  4. The client
  5. The real-time server
  6. What is stored, and where
  7. The media pipeline
  8. Model services
  9. Deploys and observability
  10. Lessons
  11. FAQ

00Summary

TL;DR

  • The whole client is one HTML file, served as an installable web app. No app store, no install.
  • One Node.js server handles both REST and WebSocket traffic: matchmaking, chat relay, call signalling and the APIs for cards, profiles and rooms.
  • One-to-one chats are never stored. They live in server memory for the length of the chat. Rooms keep history; Saved Chat stores only end-to-end encrypted text.
  • Photos and video go through a media pipeline that re-encodes, checks and stores them, with a local cache in front of the storage bucket.
  • Moderation models run as separate small services, so a slow model can never stall the chat server.
  • Deploys are one command; open tabs pick up the new version on their own when idle.

01Design goals

Every architectural choice traces back to five goals, in this order:

  1. One tap to a conversation. No sign-up, no app install, no phone number. An anonymous identity is created on the device the first time someone opens the site, and text chat needs nothing more. Starting a call, sending photos and the social features ask for a verified email (since November 2026), which also keeps an account across phones.
  2. Forget by default. A stranger chat should leave nothing behind once it ends. Anything we keep, we keep for a reason we can state.
  3. Fast on Indian mobile networks. Servers in India, a small first load, and calls that connect even behind carrier network address translation.
  4. Cheap to run. A small team pays for this. Every component has to earn its place.
  5. Safe without being heavy-handed. Moderation that refuses what is illegal or explicit and stays out of the way of ordinary conversation.

02The big picture

FlashChat at a glance

Arrows show who talks to whom. Model services and storage sit on a private network.

Browser
Single-page app

One HTML file, a service worker for offline and install, WebRTC for calls.

Edge
CDN + reverse proxy

TLS, caching of static files, compression, request limits.

Core
App server

One Node.js process: REST APIs, WebSockets, matchmaking, chat relay, call signalling.

Relational databaseProfiles, cards, rooms, buddies, settings.
Storage bucketsPhotos (with a local disk cache) and video clips.
Model servicesPhoto checks and room text checks, on separate machines.
Call relay + emailA relay for calls that cannot go direct; an email service with fallbacks.
Everything the user sees comes from the app server or the edge cache; storage and models are never exposed directly to browsers.

The shape is intentionally plain. A single app server is simple to reason about, simple to deploy and simple to debug, and in-memory state (who is waiting, who is paired with whom) needs no coordination between processes. The parts that are slow, heavy or bursty (model inference, video transcoding, email) are pushed out of the request path or onto other machines.

03The client: one HTML file

The entire app, its markup, styles and scripts, ships as a single HTML file. That sounds unusual, and it is a conscious trade:

  • One request to a working app. There is no bundle graph to resolve on a slow connection. Heavier pieces (game engines, model weights, catalogues) load on demand.
  • No build step to break. What is in the repository is what the browser runs.
  • Installable. A service worker and manifest make it a home-screen app on Android and iPhone, with an offline page.

Supporting files that change rarely are versioned in their URL (?v=N) and cached for a year as immutable; changing one means bumping its version. The app page itself is cached at the edge for a short time and re-validated, so a deploy reaches people within minutes.

Updates without an update button

Every open tab checks a small version file once a minute while it is visible. When a new version appears and the person is not mid-chat, mid-call or typing, the tab clears its old caches and reloads into the new build. We used to also show an “Update available” banner from the service worker; the two mechanisms were never coordinated and could ask people to update to code they were already running. Now there is exactly one path, and one rule: never add a second reload trigger without retiring this one.

Themes and languages

The interface ships several visual themes built on shared design tokens, and rooms exist in English and fourteen Indian languages. Text handling assumes multi-byte scripts everywhere: lengths are checked in bytes where storage limits are in bytes, because a Devanagari character is three bytes, not one.

04The real-time server

A single Node.js process serves HTTP and WebSocket traffic. WebSockets carry everything that must feel instant: matchmaking, chat messages, typing indicators, reactions, read receipts, call signalling, room messages and notifications.

Matchmaking

When someone presses Start, the server looks for a partner in a fixed priority order:

  1. a FlashBuddy who invited this person to chat, or whom this person invited;
  2. someone waiting who shares an interest tag;
  3. anyone else waiting.

If nobody is free, the person joins a queue, and the wait adapts to how busy the site is. The queue, the pairs and the sessions are plain in-memory maps, which is why one process is a feature here rather than a limitation: pairing is a single synchronous decision with no race between servers.

Reconnects are the normal case

Phones switch between Wi-Fi and mobile data, lock their screens and lose signal in lifts, and every deploy restarts the server. So the chat path assumes connections drop:

  • Each chat line is acknowledged. A line that is not acknowledged within a few seconds is resent to the partner’s current connection, or held until they reconnect; the receiver drops duplicates by message id.
  • A dropped person has a grace window to come back to the same chat before the partner is told they left. A person who says they are leaving (closing the tab) gets a longer window than one whose connection simply died.
  • After every reconnect the client checks the chat still exists, because a restarted server has no memory of it and will not say so on its own.
  • Packets that arrive before the connection has identified itself wait for it instead of failing, so a reconnecting room tab does not go silent.

Shutting down gracefully

On a restart the server stops taking new requests, closes sockets cleanly, flushes buffered writes (such as pending notifications) to the database, drains the database pool, and exits, with a hard deadline so a stuck step can never hang a deploy.

05What is stored, and where

Data lifecycle by feature
FeatureWhere it livesHow long
One-to-one stranger chatServer memory onlyUntil the chat ends (kept only if someone reports it)
Self-destructing photos and voice notesRelayed, not stored, with two exceptions: a photo refused as explicit, and the reported person's last photos and voice notes when a chat is reported, are kept for reviewSeconds on screen, one play; kept ones 180 days
Room messagesDatabaseAs room history, so people joining later can catch up
Saved Chat between FlashBuddiesDatabase, end-to-end encryptedShort-lived; the server holds ciphertext it cannot read
Flash Cards, comments, heartsDatabaseUntil the author deletes them
Profile, buddies, settingsDatabaseUntil the account is deleted
Photos and video clipsStorage bucketsUntil the post or profile photo is removed

Database habits that matter

  • One shared connection pool with a short queue timeout. When the database is busy, requests fail fast with “try again shortly” instead of piling up.
  • Errors are classified. Every database error is mapped to “temporarily unavailable” or “timed out” versus a real bug, so the logs that say “bug” are actually bugs.
  • Pagination by (created_at, id). Timestamps have one-second resolution; paging on time alone silently skips rows that share a second.
  • Claim, then act. A state change that triggers side effects (approving a queued post, say) first updates the row conditionally and checks it won, so two clicks cannot both run the side effects.
  • Schema changes are idempotent and run at boot, so a fresh machine and an old one converge on the same schema.

06The media pipeline

Life of a photo

Phone
Resize + re-encode

Photos are shrunk and re-encoded as JPEG on the device, which also strips most metadata and saves mobile data.

Server
Check

Type sniffed from the bytes (not the file name), then the photo checks. Only what can be checked is accepted.

Storage
Store + cache

Written to the storage bucket and kept on the app server’s disk, so most views never touch the bucket.

Photos are always served from our own domain, never straight from the bucket, so the bucket stays private and every view goes through the same cache.
  • Sized copies on demand. Feeds and avatars ask for a smaller width (and a more compact image format where the browser supports it). The copy is made once, cached, and dropped together with the original.
  • The disk cache is the hot path. It keeps recently viewed photos, evicts the least recently viewed in the background, and never fills the disk. The bucket is the durable copy a rebuilt server refills from.
  • Video clips are transcoded on the server to a standard, widely playable format and resolution, with metadata stripped, and stored in a separate bucket served from a media subdomain. A frame every two seconds goes through the same photo checks. Transcoding is gated so it never starves the chat server of memory.
  • Image URLs are only trusted when we minted them, for that account. A card cannot point at someone else’s upload, so deleting one person’s card can never delete another person’s photo.

07Model services

Two kinds of model run in production: photo checks and the room text model. Both run on separate machines from the chat server, on a private network, behind their own access tokens.

The reason is a hard lesson: model inference libraries often run synchronously on their calling thread. When a text model once shared a process with the photo checks, a burst of long batches froze photo checks for minutes. Now each model has its own process and memory limit, and the chat server treats every model as optional: it waits a fixed short time, and if the answer is late, it carries on (and records the late answer for review). Uploads are the exception: a photo that cannot be checked is not posted.

In the browser, the same rule applies from the other side: any model running on the device runs in a background worker, never on the page’s main thread.

08Deploys and observability

DeployOne command

Pull the release, stamp the version, install dependencies, restart, then poll the health endpoint until the new process answers, and purge changed files from the edge cache.

LogsStructured, and queryable

Every log line also goes to an in-memory ring buffer the admin panel can filter by level, component and text, without logging in to a server.

ProbesSynthetic checks every few minutes

Real call-relay allocations on every transport, certificate expiry read from the wire, database pings, and model self-tests on a fixed set of inputs.

ReportsA nightly email

Yesterday against the week before: people, chats, content, safety queues and server health, in one email to the team.

EmailAn email service with fallbacks

Verification and recovery emails go through a chain of email services with per-key quotas and health tracking, and always keep headroom for the emails people are waiting on.

SecurityDefence in layers

A strict content security policy, rate limits per device and per network, file types checked from bytes, and inspection that fails closed.

09Lessons from running it

Most of what is in this post was learned from something going wrong. A few that changed how we build:

  • A green deploy is not proof. A soft reload once reported success while the old process kept serving old code for hours. Deploys now hard-restart and then check that the running version matches the commit.
  • Renewed is not reloaded. A certificate was renewed on disk, but the service only read it at start-up, so the one on the wire expired. Certificates are now read from the network on a schedule, and renewals restart what needs restarting.
  • In-memory counters reset on every deploy. A rotating template counter went back to zero with each daily deploy, so the first template appeared far too often. Anything that must vary across days is now derived from the item itself or read from the database.
  • Route order is behaviour. A specific route declared after a catch-all never runs. We keep literal routes above parameter routes and test them.
  • Accept only what you can inspect. A check that only understands one file type is optional for anyone who uploads another. The accepted set now equals the inspectable set, everywhere.
  • The main thread is sacred. Anything that can take more than a few milliseconds (models, large decodes, shader compilation) belongs in a worker or another process.

More on how calls connect is in our post on video calls over Indian mobile networks, and what is and is not stored is on the safety page.

10Frequently asked questions

Are FlashChat's one-to-one chats stored?

No. A one-to-one stranger chat lives in the server's memory while it runs and is dropped when it ends. It is kept only if someone reports the chat. Room messages are kept as room history, and Saved Chat stores only end-to-end encrypted text the server cannot read.

Do I need to install an app?

No. FlashChat is a web app that runs in the browser and can be added to the home screen. Updates reach every open tab automatically when it is idle.

Why is FlashChat hosted in India?

Most of our users are in India, and chat and video calls feel faster when the server is close. Our servers are in Hyderabad.