Remote / Server-derived state
How they fit together
Diagram source
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" --> rsThe client half is a Foldkit Submodel. The application embeds Remote.Model
in its Model, folds Remote's Messages under one variant of its Message union
(Remote.fold) or spreads Remote.messages into it, 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,
live(Data, …), 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 (Data.get to
Remote.select, Data.subscriptions to Remote.observe, observeLive and
Remote.retain), documented as the package's
Advanced section.
The server half compiles Sources into the RemoteRpc handlers. The client is
a RemoteClient Layer: Effect RPC, JSON over POST (Remote.http), a
MessagePort, or an in-process server. Which one is a deployment choice; what
a read or a write means does not change with it.