Remote / Server-derived state

How they fit together

mermaid
flowchart LR
  subgraph client["browser / device"]
    app["Foldkit app (update)"] --> remote["foldkit-remote<br/>entities · plan · live<br/>optimistic · mutations"]
    surface["foldkit-surface<br/>Projection · field refs · subsets"] -- "projection + requirements" --> remote
  end
  subgraph server["server / Node"]
    rs["foldkit-remote-server<br/>Sources + authorize"] --> drizzle["foldkit-remote-drizzle<br/>SQL, optional"]
  end
  remote <-- "Effect RPC" --> rs

The client half is a Foldkit Submodel. The application embeds Remote.Model in its Model, spreads Remote.messages into its Message union, and binds the domain with Remote.make({ model: App.model.remote, entities, … }). The bound Data is the application API: a Surface reads through Data.get, Data.live, and Data.query; Data.subscriptions fetches, subscribes, and retains for the active Surfaces; update starts mutations with Data.mutate, loads more with Data.more, and reduces Remote's Messages with Data.reduce. Each compiles to a kernel function of the same name, documented as the package's Advanced section.

The server half compiles Sources into the RemoteRpc handlers. Transport is Effect RPC, so HTTP, WebSocket, worker, or in-process is an Effect layer choice; Remote does not define a transport.