Storage approaches
How and when a document is stored often depends on the level of document collaboration needed.High collaboration
For real-time, multi-user collaboration (similar to Google Docs) using Yjs/CRDT, each client connects to a realtime collaboration service that merges all user updates.Complexity: Medium — Requires a server-side Yjs/CRDT service
- Every document edit (as a Yjs byte array) is automatically sent via WebSocket to the Yjs/CRDT service
- When all changes are merged, the service stores the new document
- Storage happens continuously on the backend
Low collaboration
For scenarios where only one user edits at a time (like SharePoint), implement a locking mechanism where users check out documents before editing.Complexity: Low — Requires storing and querying document lock/unlock state
- When the active user makes an edit, debounced changes are sent to your server which stores the document
- Alternatively, when a user saves/checks in the document, it is sent to your server for storage
- Storage is triggered by user actions on the frontend
What to store
In both low collaboration and high collaboration approaches, when the document arrives at your backend:
When the document is requested later, look up the latest version in your database and serve it from cloud storage.
Export methods
The ways to export a document are covered in Import/Export.Store the full DOCX binary for the highest fidelity version of the document.
Best practices
Unique Version IDs
Include timestamps or UUIDs to ensure uniqueness
Store Full DOCX
Preserves all formatting, comments, and tracked changes
Keep Version History
Store multiple versions for audit trails and recovery
Use Cloud Storage
S3, Google Cloud Storage, or Azure Blob Storage

