Holepunch App Composition
Overview
Use this when the problem is bigger than one library. The goal is to produce a clean architecture where the runtime boots the worker, the worker owns replication, the domain layer owns rules, and the UI consumes snapshots.
Preferred Shape
- Host shell: windowing, preload bridge, runtime lifecycle, update events.
- Worker or service: long-lived backend, managers, watchers, snapshots, file ingestion.
- Domain layer: contexts, schemas, permissions, replicated data model.
- UI layer: state store, optimistic UX where safe, rendering only.
Architectural Rules
- Keep app-specific business rules out of the host shell.
- Do not let the renderer talk to Corestore or Hyperswarm directly if a worker can own that state.
- Build one RPC surface per worker and keep it task-oriented, not storage-oriented.
- Let the worker stream snapshots or events to the UI instead of exposing many low-level queries.
Compose in This Order
- Define the replicated domain and local metadata split.
- Choose the host and runtime wiring.
- Define the worker entrypoint and ownership of managers and watchers.
- Define the RPC surface the UI actually needs.
- Shape the UI around snapshots, subscriptions, and task-level mutations.
- Add test seams at the worker and domain boundaries first.
Load References When Needed
- Read
references/blueprint.mdfor the recommended layer boundaries and build order. - Read
references/examples.mdfor example architectures that have already proven workable.