svg

Case Study · Distributed Systems & Offline-First

pebble-sync

Ultra-compact, offline-first state-based CRDT sync engine with Merkle clocks, delta replication, and tamper-evident cryptographic hash chains for edge, rural, and browser environments. Zero runtime dependencies.

RepositoryTypeScript · Zero-Dependency · Merkle Clocks · Ed25519/SHA-256

The Problem with "Offline-First"

Most "offline-first" web apps rely on last-write-wins timestamps stored in client databases. Under multi-device concurrent edits or multi-day network partitions (common for grassroots workers in rural Bihar), naive timestamps overwrite data and cause silent data loss. Meanwhile, mainstream CRDT libraries (Automerge, Yjs) can be heavyweight for low-end mobile devices and lack cryptographic auditability.

Technical Innovations in Pebble-Sync

  • State-Based CRDT Primitives: Formal implementations of Positive-Negative Counters (PNCounter), Last-Write-Wins Registers (LWWRegister), Observed-Remove Sets (ORSet), and hierarchical Collaborative Documents. All merges are provably associative, commutative, and idempotent.
  • Merkle Clock Delta Compaction: Instead of transmitting entire database states over expensive or flaky cellular networks, nodes exchange Merkle tree root hashes. The difference algorithm isolates only the missing deltas, cutting wire payload size by over 80%.
  • Tamper-Evident Cryptographic Hash Chains: Every state change operation is chained via cryptographic hashes and signed. Even in peer-to-peer or untrusted mesh sync, any malicious manipulation of historical records is mathematically detected and rejected.
  • Zero Runtime Dependencies: Written purely with modern TypeScript and standard platform cryptography. Works seamlessly in Node.js, Bun, Cloudflare Workers, and mobile browsers.

Target Alignment

Demonstrates rigorous distributed systems craftsmanship directly relevant to Ente.io (end-to-end encrypted sync cloud), ByteDance (Distributed NoSQL systems), and FOSS United builder grants.