How FLIT Works: The Architecture of Peer-to-Peer File Transfer
Unlike traditional file hosting services that require an intermediary database or storage bucket, FLIT relies on the W3C standard WebRTC (Web Real-Time Communication) protocol to build an encrypted direct pipe between two browsers.
1. Stateless Signaling with Redis
Before two devices can establish a direct data channel, they must discover each other's network addresses. FLIT employs a stateless serverless signaling backend powered by Upstash Redis.
When a Host creates a transfer room, a temporary 8-character room code is generated. Once the Guest enters the code, both peers exchange SDP (Session Description Protocol) offers, answers, and ICE (Interactive Connectivity Establishment) candidate packets. The signaling server handles only network metadata and never touches the contents of your files.
2. NAT Traversal via STUN and TURN Relays
Most consumer devices reside behind residential routers, mobile carrier CGNATs, or corporate firewalls. FLIT queries Google STUN servers to uncover each peer's public IP and port mappings.
When direct peer-to-peer connectivity is blocked by restrictive or symmetric NAT firewalls, FLIT automatically engages high-performance TURN relays (Metered.ca). Because WebRTC mandates DTLS encryption at the transport layer, data relayed through TURN remains strictly opaque and end-to-end encrypted.
3. Flow Control & Chunking Engine
Large files are segmented into micro-chunks (typically 64 KiB to 256 KiB). FLIT's custom sender engine monitors the RTCDataChannel's bufferedAmount property to prevent buffer overflow and apply dynamic backpressure.
On the receiving end, incoming ArrayBuffer chunks are sequenced and written to persistent storage via the browser's File System Access API, OPFS (Origin Private File System), or IndexedDB, allowing files to download cleanly without overwhelming system memory.