Overview
Plant Together enables seamless real-time collaboration using Yjs CRDT (Conflict-free Replicated Data Type) technology and WebSocket connections. Multiple users can edit diagrams simultaneously with instant synchronization and automatic conflict resolution.How Collaboration Works
Architecture
Plant Together’s collaboration system consists of three main components:Yjs Document (Y.Doc)
A shared data structure that holds the diagram content. Each document in a room has its own Yjs document.
WebSocket Provider
Maintains real-time connection to the server and synchronizes changes between all connected clients.
All changes are transmitted as binary update messages, making synchronization extremely efficient even for large diagrams.
Real-time Editing Features
Instant Synchronization
Every keystroke is synchronized in real-time:- How It Works
- Code Implementation
- User types in the editor
- Monaco binding detects the change
- Yjs generates an update message
- WebSocket sends the update to the server
- Server broadcasts to all connected clients
- Other clients apply the update to their local document
- Monaco updates their editor view
Seeing Other Users
User Awareness
Plant Together shows you who else is in the room and where they’re editing: Features:- Colored cursors show each user’s position
- Username labels appear on hover
- Selection highlighting shows what text others have selected
- Unique colors automatically assigned to each user
Username Generation
- Authenticated Users
- Guest Users
Users who are logged in see their account display name:Example: “Sarah Chen”, “alex.dev”
Color Assignment
Each user gets a unique color generated from their username:Colors are deterministic - the same username always gets the same color across sessions.
Document Management
Multiple Documents Per Room
Each room can contain multiple documents, allowing you to organize related diagrams:Switch Between Documents
Click any document name in the sidebar to switch to it. Your WebSocket connection will automatically reconnect to the new document.
Document Synchronization Events
All document operations are broadcast to other users:Offline Sync and Conflict Resolution
How Offline Sync Works
Plant Together uses Yjs CRDTs which automatically handle conflicts and enable offline editing.
- Offline Editing
- Conflict Resolution
- Data Persistence
- Connection lost - WebSocket disconnects
- Continue editing - Changes are stored locally in the Yjs document
- Connection restored - Provider automatically reconnects
- Sync happens - Local changes are sent to server
- Conflicts resolved - Yjs merges changes intelligently
Your work is never lost during temporary disconnections.
Connection States
Connected
Connected
Indicator: Cursor updates appear instantlyBehavior:
- All changes sync in real-time
- Other users visible with cursors
- Full collaboration features enabled
Connecting
Connecting
Indicator: Brief moment when switching documentsBehavior:
- Editor remains functional
- Changes queued for sync
- Usually resolves in less than 500ms
Disconnected
Disconnected
Indicator: Other users’ cursors disappearBehavior:
- Editor still works normally
- Changes stored locally
- Auto-reconnect attempts every few seconds
- All changes will sync when reconnected
Best Practices for Collaboration
Communicate Changes
Use external chat (Slack, Discord) to coordinate major changes:
- “Refactoring the class diagram now”
- “Adding new sequence diagram to Doc3”
- “Can everyone review before I merge?”
Organize Documents
Create separate documents for different diagram types:
architecture-overviewapi-sequence-diagramsdatabase-schemadeployment-diagram
Avoid Simultaneous Major Edits
While Yjs handles conflicts well, coordinate on large refactors:
- Assign different documents to different people
- Take turns for major restructuring
- Use comments in the diagram code
Save Regularly
Although auto-sync is reliable, periodically export important work:
- Use the export feature
- Keep local backups of critical diagrams
- Export before major changes
Troubleshooting
Changes Not Appearing for Others
Changes Not Appearing for Others
Possible causes:
- Network connectivity issues
- WebSocket server temporarily down
- Browser tab in background (throttled)
- Check your internet connection
- Refresh the page to reconnect
- Ensure browser isn’t throttling the tab
- Check browser console for WebSocket errors
Can't See Other Users' Cursors
Can't See Other Users' Cursors
Possible causes:
- They’re viewing a different document
- Awareness state not synchronized yet
- Browser cache issues
- Confirm you’re on the same document
- Wait a few seconds for awareness to sync
- Refresh the page (you won’t lose work)
Editor Feels Laggy
Editor Feels Laggy
Possible causes:
- Very large diagram (>1000 lines)
- Slow network connection
- Many simultaneous users (10+)
- Split large diagrams into multiple documents
- Check network speed and latency
- Close other bandwidth-intensive applications
- Consider breaking up the room for team sub-groups
'Document Not Found' Error
'Document Not Found' Error
Cause: Document was deleted by another userSolution: You’ll automatically switch to the first available document. If all documents were deleted, create a new one.
Technical Details
WebSocket Connection
Yjs Document Lifecycle
Next Steps
Export Your Work
Learn how to export diagrams in multiple formats
Private Room Access
Control who can access your collaborative rooms
API Documentation
Integrate document management into your apps
Architecture
Understand the technical architecture