Skip to content

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.

bash
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-notes

Check 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

Handle 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

text
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 profile

Follow a Save through the app

1

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.

js
sendToWorker({ type: 'db-put', key, value })
2

Worker persists the value

In worker.js, the base scaffold's db-put handler writes to Hyperbee and acknowledges completion.

js
await db.put(msg.key, msg.value)
send({ type: 'db-put-ok', key: msg.key })
3

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.

Need help? Report an issue with your CLI version, platform, command and first relevant error.