For AI agents: the documentation index is at /stratasync/docs/llms.txt. Append .md to any page URL, or send Accept: text/markdown, for the Markdown version of that page.
For AI agents: the documentation index is at llms.txt. Markdown versions are available by appending .md to any page URL, including this page's markdown.
Data flow
How mutations and deltas flow through Strata Sync, from user input to server confirmation and back.
Two primary data flows: client writes (mutations going to the server) and server pushes (deltas coming back).
Client write flow
Call a mutation method on the sync client. The change applies optimistically, persists locally, and sends to the server in the background.
sequenceDiagram participant UI as React Component participant Client as Sync Client participant Store as Identity Map participant IDB as IndexedDB participant Outbox as Outbox Manager participant Transport as Transport Adapter participant Server as API Server UI->>Client: client.update("Task", id, changes) Client->>Client: Create transaction (clientTxId + idempotency key) Client->>Store: Apply optimistic update Store-->>UI: MobX reaction (UI re-renders) Client->>IDB: Persist updated row
Optimistic apply: Creates a Transaction with an idempotency key, applies to the identity map, and persists to IndexedDB.
Batch send: The outbox batches transactions based on batchDelay (default 50 ms), reducing network overhead.
Server processing: Validates the mutation, assigns a syncId, persists, and broadcasts a delta to all clients.
Acknowledgment: The server responds with the assigned syncId. The outbox removes acknowledged transactions.
Server push flow
Deltas arrive through the WebSocket subscription when another client writes a change or the server processes your own mutation.
sequenceDiagram participant Server as API Server participant WS as WebSocket participant Transport as Transport Adapter participant Client as Sync Client participant Rebase as Rebase Engine participant Store as Identity Map participant IDB as IndexedDB participant UI as React Component Server->>WS: Delta packet (syncActions + lastSyncId) WS->>Transport: Receive delta Transport->>Client: onDelta(packet) Client->>IDB: Write batch (apply all actions) Client->>Store: Update identity map Client->>Rebase: Rebase pending transactions Rebase-->>Store: Re-apply local intent Client->>IDB: Update lastSyncId Store-->>UI: MobX reaction (UI re-renders)
Key steps
Batch write: Applies all sync actions from the DeltaPacket to IndexedDB in a single atomic write.
Rebase: If affected models have pending local transactions, the rebase engine reconciles server state with local intent.
Watermark advance: Advances lastSyncId to the packet's watermark, so the next delta fetch starts from the right place.
Rendering during sync
Delta application is designed so the UI lands on final state instead of visibly
stepping through changes.
One flush per packet, not per action. All identity map mutations for a packet
run inside a single batch(), so observers never see a half-applied packet — server
data and re-applied pending local changes appear together.
One flush per backlog, not per page. When catch-up spans multiple pages, the
pages are buffered and applied as one merged packet. A client that has been offline
for a while resumes in one step rather than animating through the queue. Use
useSyncCatchingUp() for a quiet indicator while that happens — the client is
already "syncing" and rendering cached data throughout, so don't gate rendering
on it.
One batched write, not two round trips per action. A packet resolves in memory
and persists as a single writeBatch.
Queries skip irrelevant changes.useQuery tracks which ids currently satisfy
its predicate. A delta for a model that is neither in the result set nor newly
matching is discarded without rescanning.
For per-cell rendering granularity, wrap components that read model properties in
MobX's observer(). Each property is its own observable, so a delta touching 50
rows re-renders 50 cells rather than the whole list. See the
MobX adapter.
Conflict resolution (rebase)
Field-level LWW rebase resolves conflicts between server deltas and pending local transactions. Each pending transaction stores a patch and an original snapshot. Non-overlapping changes merge cleanly; overlapping fields use the configured rebaseStrategy ("server-wins", "client-wins", or "merge").
Read and write while disconnected: the outbox queues mutations in IndexedDB until the connection returns.
sequenceDiagram participant UI as React Component participant Client as Sync Client participant IDB as IndexedDB participant Outbox as Outbox Manager participant Transport as Transport Adapter Note over Transport: Connection lost UI->>Client: client.update("Task", id, changes) Client->>Client: Create transaction Client->>IDB: Persist optimistic update Client->>Outbox: Queue transaction Client->>IDB: Persist to outbox Note over UI: UI shows changes immediately Note over Transport: Connection restored Transport->>Client: Reconnected Client->>Transport: Fetch deltas after lastSyncId Transport-->>Client: Catch-up delta packet Client->>Client: Apply deltas + rebase Outbox->>Transport: Replay pending transactions Transport-->>Outbox: Acknowledge
On reconnection, the client fetches missed deltas page by page (up to 1000 actions per page by default, 5000 at most) while hasMore is true, applies them in one flush, then replays the outbox. If the cursor has fallen behind the server's retention floor, the fetch returns bootstrapRequired and the client re-bootstraps instead; see Retention floor. Idempotency keys make retry safe, even if a mutation was sent but not acknowledged before the disconnect.
Each outbox transaction moves through these states:
stateDiagram-v2 [*] --> Queued: created Queued --> Sent: transport sends Sent --> AwaitingSync: server acknowledges AwaitingSync --> Confirmed: delta with syncId arrives Sent --> Queued: network error (retry) Sent --> Failed: server rejects Confirmed --> [*]: removed from outbox Failed --> [*]: removed from outbox
Queued (waiting to send), Sent (awaiting response), AwaitingSync (acknowledged, delta pending), Confirmed (done, removed from outbox), Failed (rejected, rolled back). Network errors move back to Queued for retry.