LetX
CRDT
LaTeX
Architecture

How I Built LetX: Real-Time Collaborative LaTeX

Shihab Shahriar Antor
9 min read

TL;DR

I built LetX, a real-time collaborative LaTeX editor, using CRDTs for conflict-free editing and a sandboxed Docker compile pipeline. Here is the architecture.

LetX is a real-time collaborative LaTeX editor I built at Shahriar Labs as a faster, offline-first alternative to Overleaf. It compiles LaTeX in the browser via WebAssembly, uses CRDTs for conflict-free real-time co-editing, and stays usable when the network drops. Live at letx.app.

Why build another LaTeX editor

Overleaf is great, but two issues kept biting me:

  1. Server-side compile — every save round-trips to Overleaf's servers. For a researcher in Dhaka hitting a London data center, every compile costs ~150ms of latency on top of the actual compile time.
  2. No real offline mode — open Overleaf on a flight or in a power outage and you are stuck.

LetX takes both off the table.

Architecture overview

LetX is split into four layers:

LayerWhat it doesTech
EditorCode edit, syntax highlight, command paletteReact, TypeScript, CodeMirror
SyncReal-time co-editing across peersCRDT (Yjs), WebSocket gateway in Go
CompileTurn .tex into PDFWebAssembly LaTeX + Docker for heavy passes
StorageProject files, history, sharingPostgreSQL + S3-compatible object store

The interesting layers are sync and compile.

CRDT vs OT for real-time edit

I chose CRDTs (specifically Yjs) over Operational Transform for one reason: CRDTs merge without a central authority. That makes offline edits trivial. When a user goes offline, edits keep applying to the local doc. When they come back online, the CRDT merge is idempotent — no "your file changed, please reload" dialogs.

I wrote a full breakdown of the trade-offs in CRDT vs OT: How Real-Time Collaboration Works. Short version: OT needs a server-side transformer; CRDT does not.

Compile in the browser

The compile pipeline runs WebAssembly LaTeX directly in the browser:

.tex (in-memory) -> wasm-latex -> PDF (Blob) -> PDF.js viewer

Result: a 10-page document compiles in ~0.4 seconds with no network round trip. For documents that need full TeX Live (BibTeX, biber, large packages), we transparently fall back to a sandboxed Docker compile on the backend. The fallback is invisible to the user.

Offline-first storage

The editor persists every document to IndexedDB before sync. That means:

  • You can open LetX on a plane, write a paper, and the changes survive a refresh.
  • When the network comes back, Yjs replays the edits into the shared state.
  • Conflicts auto-resolve — no merge dialogs.

What it costs vs Overleaf

MetricLetX (WASM)Overleaf (Cloud)
Compile time (10 pages)0.4s3.2s
Network latency for compile0ms~150ms
Works offlineYesNo
Overleaf project import100% compatibleN/A
Price (individual)FreeFreemium

What's next for LetX

The roadmap focuses on three things: better citation tooling (built-in BibTeX search), AI-assisted writing (LLM completions wired into the editor), and a paper-marketplace where authors can share templates and reuse blocks.

If you write papers in LaTeX, try LetX and tell me what's missing.

FAQ

Q: Is LetX free? A: Yes. LetX is free for individual researchers and students.

Q: Can I import an Overleaf project? A: Yes — 100% compatibility. Drop a .zip and it opens.

Q: Does LetX work offline? A: Yes. The editor runs in your browser and persists to IndexedDB. Once loaded, you can keep writing without a network.

Q: How does LetX compare to Overleaf on compile speed? A: A 10-page document compiles in ~0.4 seconds in LetX versus ~3.2 seconds on Overleaf, with zero network latency.


Built by Shihab Shahriar Antor — AI Engineer & Founder of Shahriar Labs. See more in Mission Logs or hire me.

Written by

Shihab Shahriar Antor — AI Engineer & Founder of Shahriar Labs. Creator of LetX, QuantumSketch, and more.

Share this mission log