Build
Project architecture
Keep UI, long-lived runtime resources, and optional peers in clear boundaries.
Content reviewed 21 October 2026
The primary desktop pattern separates the renderer from a worker. This is a runtime requirement, not just code organization.
Run two peers on your computer
Use Node 22.17+, npm and Git. In a new parent directory, get the repository and run the notes consumer. It creates two peers and an isolated loopback DHT; no model, Personal Node or public peer discovery is needed. Installation still needs network access.
git clone https://github.com/unstoppable-stack/unstoppable-dev.git p2p-walkthrough
cd p2p-walkthrough
npm ci --prefix packages/p2p
npm ci --prefix examples/p2p-notes
npm run demo --prefix examples/p2p-notesCheck the output
- RPC note: contains coffee: oat latte, returned through a paired peer's granted get procedure.
- Streamed note: contains the morning record, returned through the granted list stream.
- Source offline; replicated note: contains the note after the writer closes. This read uses downloaded local data rather than a live RPC request.
The demo exits and cleans up its temporary stores. To inspect the implementation, open examples/p2p-notes/demo.js for invites and grants, src/contract.js for procedures, and src/notes.js for storage handlers. This loopback result does not establish Internet reachability.
Choose how your app shares data
Request a selected result
Use typed RPC for a receipt lookup or a validated action. The caller needs the host online and permission for the procedure.
Read moreKeep a local read-only copy
Use openCollection, share the dataset key/version, and sync before reading. Downloaded records can remain available offline.
Allow several writers
Use the experimental collaborative database and explicitly admit each writer. Pairing alone does not grant write access.
Read moreHandle disconnects in your UI
- Renderer: UI state, user interactions, and narrow bridge calls.
- Worker: Hyperswarm, Corestore, Hyperbee, Hyperdrive, QVAC, and cleanup.
- Bridge: typed messages with timeouts, errors, and visible status.
- Optional Node: a separate peer for replication or delegated inference; local work must survive its absence.
Find the code in a generated desktop app
shop-starter/
app/index.js # UI and button handlers
app/bridge.js # sendToWorker / onWorkerMessage
electron/preload.cjs # window.unstoppable bridge
electron/main.js # window, worker startup and storage path
worker.js # Hyperbee, networking and command handlers
.unstoppable/project.json # recorded platform and profileFollow a Save through the app
UI sends a command
The Save handler in app/index.js reads the key/value inputs and calls the bridge. It never opens the database.
sendToWorker({ type: 'db-put', key, value })Worker persists the value
In worker.js, the base scaffold's db-put handler writes to Hyperbee and acknowledges completion.
await db.put(msg.key, msg.value)
send({ type: 'db-put-ok', key: msg.key })UI displays the acknowledgement
The message listener in app/index.js handles db-put-ok and displays Saved. Fetch sends db-get and renders db-get-ok. Add new commands by extending both the worker handler and the UI response handler.
These fragments explain the generated handlers; they are not standalone scripts. For new operations, validate input in the worker, return errors, and give the caller a deadline. For concurrent requests, add request IDs rather than matching replies by command type alone.
Shutdown matters
Close swarms, stores, model handles, and worker pipes explicitly. Treat reconnecting and unavailable states as normal.