kuilt
kuilt stitches peers together and keeps their shared data in sync — across WebSocket, LAN, Bluetooth, and WebRTC — without changing your app code when you swap connection paths.
It is a Kotlin Multiplatform library (JVM, Android, iOS, macOS, wasmJs).
Three building blocks — pick what you need
Connections — one API for devices to find each other and exchange messages. kuilt calls this the network fabric (
Loom/Seam). Swap WebSocket for LAN discovery or Bluetooth without touching your app logic.Replication — shared data stays in sync, even when devices edit offline or at the same time. Under the hood this uses CRDT data types such as
LWWMap,ORSet,Rga, andJsonCrdtfromkuilt-crdt. AddQuilterto propagate changes live over aSeam.Consensus — when every peer must agree on one order of decisions (turns in a game, locks, durable steps), this keeps one leader and everyone aligned. Under the hood this is
kuilt-raft.TurnSequencer(fromkuilt-game) wraps it for turn-based games.
Pick by the guarantee you need
Connect and send bytes → add a fabric only.
Shared state that survives offline edits and concurrent updates → add Replication.
Strict turn order or globally-agreed decisions → add Consensus on top.
Start with the weakest guarantee that keeps your product correct. Add stronger guarantees only where needed.
How it fits together
Think of a quilt: a loom creates sessions, a seam is one peer's view of a live session, and a swatch is one frame of bytes. Every fabric (WebSocket, Multipeer, Nearby, WebRTC) implements these three types. Your app code never deals with socket APIs, Bluetooth internals, or peer-connection objects directly.
Every peer in a session uses the same Seam interface — there is no client/server split at this layer. The same app code runs with two peers or twenty, and over relay or direct links.
Modules at a glance
Module | What it gives you |
|---|---|
| The contract ( |
| Replication data structures ( |
| Live replication over a |
| Cryptographically fair card dealing ( |
| Turn-based game facade: |
| Raft consensus — leader election, log replication, snapshots, dynamic membership, linearizable reads, leadership transfer |
| Server-cluster overlay: |
| Peer-liveness detection: |
| Membership-aware |
| Ktor WebSocket fabric ( |
| Bonjour/mDNS local-network discovery feeding a WebSocket connection |
| Apple Multipeer Connectivity fabric (iOS/macOS) |
| Google Nearby Connections fabric (Android) |
| WebRTC data-channel fabric (wasmJs) |
|
|
What kuilt is not
kuilt moves bytes between peers. It does not assign roles, manage membership lifecycles, or interpret your payload bytes. Those responsibilities belong to your app — or to kuilt-session when you need a Room with admit/leave semantics.