DocsConceptsLocal-First

Local-First Architecture

TopGun is designed for the modern “Local-First” web. It fundamentally changes how applications interact with data, inverting the traditional client-server relationship.

The Philosophy

In a Local-First app, the primary data source is the local database on the user’s device. The network is treated as an optional enhancement, rather than a critical dependency.

Traditional (Cloud-First)

Client → Network → Server → DB
  • "Dumb" terminals fetch data via API
  • Requires constant connectivity
  • Latency on every interaction
  • Spinners and loading states

TopGun (Local-First)

Client ↔ Local DB ↔ Network ↔ Server
  • The Client is a Replica
  • Works perfectly offline
  • Zero-latency reads and writes
  • Optimistic UI by default

Why it matters

Traditional architectures degrade user experience by introducing network latency into every interaction. TopGun ensures your app feels native and responsive, regardless of network conditions—whether in a tunnel, an elevator, or on a flaky 3G connection.

⚡️

Zero-Latency UI

Reads and writes happen locally against an in-memory CRDT. The UI updates in less than 16ms (one frame).

💾

Offline Capability

Data is persisted to IndexedDB (Browser) or SQLite (Mobile/Desktop). Your app works without internet.

🔄

Real-Time Sync

Automatic background synchronization using efficient Merkle Trees and WebSockets when the network becomes available.