Three state layers
- UI state (Jotai): transient interface state.
- Content state (Y.js): authoritative editor content model.
- Cache state (React Query): metadata and request cache.
Save path
- Editor updates Y.Doc locally.
- Y.Doc persists in IndexedDB and syncs across tabs.
- Binary Y.Doc state is sent to API and stored in Postgres.