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

Sync Visualization

Experience offline-first sync in action. Drag drones on the local map, toggle offline mode, and watch how conflicts are resolved automatically.

~16ms in productionDelays slowed for visual clarity

TOPGUNv2

Local Client A

LOCAL LIVE
D-01 | PATROL
D-02 | IDLE
D-03 | RTB
SELECTEDViper One
DRAG TO MOVE

Write Throughput

Syncing Active

Server State

ACTIVE
SERVER LIVE
D-01 | PATROL
D-02 | IDLE
D-03 | RTB
IDCOORDSTATUSHLC
D-01[20, 30]PATROL1000
D-02[60, 70]IDLE1000
D-03[80, 20]RTB1000

TopGun Architecture:

The Server acts as source of truth using Hybrid Logical Clocks (HLC) to order events. When offline, local changes are queued. Upon reconnect, Merkle Trees detect diffs, and Last-Write-Wins resolves conflicts automatically.

System Log
Waiting for input...

Peer Activity (Client B)

AUTOMATED AGENT
Injecting random updates...

TRY THIS: Go offline, then reconnect. Watch how TopGun resolves conflicting coordinates based on HLC timestamps!

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