Open Access Repository for Local-First Software Engineering • ISSN 2026-0729
Vol. 1 • Module 3 DOI: 10.1000/localfirst.2026.mod3
Published 2026-06-15

Zero Sync Engine Architecture and ZQL Mechanics

An exhaustive technical guide to Rocicorp's Zero sync engine, zero-cache Postgres WAL replication, zero-client IndexedDB execution, and ZQL query streaming.

Author: Aaron Boodman (Research Fellow)
Plain Text Corpus (.md)

Zero, developed by Rocicorp and released in 1.0 form in June 2026, is a general-purpose, query-driven synchronization engine for web applications[1]. Founded by Aaron Boodman, Zero combines client-side IndexedDB caching (zero-client) with a cloud middleware replica (zero-cache) that monitors PostgreSQL Write-Ahead Logs (WAL)[1]. By executing client queries using Zero Query Language (ZQL) through Incremental View Maintenance (IVM), Zero achieves zero-millisecond read response times while preserving server-side authorization authority[2].

Systemic Architectural Components

Unlike legacy sync frameworks that force applications to download an entire database up-front or manually manage REST/GraphQL caches, Zero introduces query-driven background streaming[1]. The architecture comprises three primary layers:

  1. PostgreSQL Database: The authoritative central source of truth storing persistent application records[1].
  2. zero-cache Middleware: A stateful cloud node that uses Postgres logical replication (wal_level = logical) to maintain a local SQLite read replica. It validates incoming client ZQL query parameters against server authorization rules[1].
  3. zero-client Engine: A JavaScript runtime library compiled into the client web app. It manages a client-side IndexedDB store, executing queries locally in zero milliseconds while maintaining an active WebSocket connection to zero-cache[1].
[ Browser (zero-client) ] <-- 0ms ZQL Read --> [ Local IndexedDB ]
            ^                                          |
            |--- Incremental Row Streaming (WS) -------|
            v
[ Cloud (zero-cache) ]    <-- Logical Replication -- [ Postgres WAL ]

ZQL Execution and Optimistic Mutations

When an application invokes a query via useQuery(zqlQuery), the query executes against local memory first, returning matching local records immediately within the next frame[1]. In parallel, zero-client sends the ZQL subscription parameters to zero-cache, which validates authorization, executes the query against its SQLite replica, and streams missing or updated rows over WebSockets[1].

// ZQL Query Example in Client Runtime
const zqlQuery = z.issue
  .where('status', '=', 'open')
  .related('assignee')
  .limit(50);

const [issues] = useQuery(zqlQuery); // 0ms execution from local cache

Write operations execute locally using optimistic mutations, sending mutation intents to the backend server where business rules reconcile changes before broadcasting authoritative state back down to all subscribed clients[2].

Academic Synthesis & Inquiries

Frequently Addressed Inquiries

Q: What is Rocicorp Zero?

Zero, tagged 1.0 stable in June 2026 by Rocicorp, is a query-driven synchronization engine for web apps that connects client-side IndexedDB caching (zero-client) with a Postgres WAL replication middleware (zero-cache).

Q: How does zero-cache sync with PostgreSQL?

zero-cache connects to Postgres using logical replication (wal_level = logical), listening to Write-Ahead Log changes to update an internal SQLite replica and stream row diffs to subscribed clients over WebSockets.

Q: What is ZQL (Zero Query Language)?

ZQL is a declarative TypeScript query API that executes instantly in local memory while automatically subscribing the client to real-time server diffs validated against backend authorization rules.

Works Cited & Academic References

  1. [1]Rocicorp - Zero Architectural Documentation & 1.0 Release (2026) — https://zero.rocicorp.dev/
  2. [2]InfoQ - Zero Reaches 1.0 Stable Release — https://www.infoq.com/news/2026/06/zero-version-1/