The Hybrid Offline-First In-Memory Data Grid

Invert Your
Data Architecture.

Stop building "dumb" clients. TopGun turns your client into a replica. Zero-latency reads/writes, offline-first reliability, and real-time sync powered by CRDTs and Merkle Trees.

npm install @topgunbuild/client
client.ts
import { TopGun } from '@topgunbuild/client';

// 1. Initialize Local-First DB
const db = new TopGun({
  sync: 'wss://api.topgun.build',
  persist: 'indexeddb'
});

// 2. Zero-Latency Write (Optimistic)
await db.todos.set({
  id: 'task-1',
  text: 'Ship v2',
  status: 'pending'
}); // Resolves in ~0.5ms

Live Sync Demo

Two devices, one session — watch CRDT conflict resolution happen in real time. Open in a new tab for multi-tab sync.

The Local-First Standard.

TopGun bridges the gap between scalable In-Memory Data Grids and Offline-First Client Databases.

Zero-Latency UI

Reads and writes happen locally against an in-memory CRDT. The UI updates in <16ms (one frame) using Optimistic UI patterns by default. No spinners, no waiting.

Offline Capable

The network is optional. Data is automatically persisted to IndexedDB (Browser) or SQLite (Mobile/Desktop) and synced when connectivity returns.

Merkle Tree Sync

Efficient bandwidth usage. We only exchange the modified leaves of the Merkle Tree, drastically reducing data transfer costs compared to REST/GraphQL.

Scalable Backend

A server-authoritative cluster that coordinates HLC (Hybrid Logical Clocks) and persists to standard databases like PostgreSQL or Mongo. You own your data.

Conflict Resolution

Automatic convergence via CRDTs. No manual conflict resolution code required for standard operations.

Distributed Locks

Pessimistic locking with fencing tokens prevents split-brain scenarios. Essential for critical operations like payments or inventory updates.

Real-Time

Push-based architecture via WebSockets ensures all active clients receive updates instantly.

Architecture

TopGun inverts the traditional model. The client is the primary source of truth for the UI, while the server ensures eventual consistency and persistence.

Client Device
MobileSQLite
BrowserIndexedDB
Local CRDT Store
Merkle Sync (WS)
Server Cluster
TopGun GatewayPartition Engine
PersistencePostgres / Mongo

Why TopGun?

The only solution that combines the speed of an In-Memory Data Grid with robust Offline-First capabilities.

FeatureTopGunElectricSQLFirebaseRxDB
Primary Model
Local-First IMDG
Postgres SyncCloud Doc DBLocal-First DB
Offline Support
First-Class
GoodGood Excellent
Latency
~0ms (In-Memory)
~5-10ms (SQLite)Network Dependent~5-10ms (IndexedDB)
Backend Control
Self-Hosted Cluster
Sync Service ProprietaryCouchDB / Custom
Consistency
HLC + CRDT
Rich CRDTsLWW (Server)Revision Trees
Distributed Locks
Fencing Tokens
Not Supported Not Supported Not Supported
License
Open Source
Open SourceProprietaryOpen Source