A real-time collaborative whiteboard built using CRDTs that enables multiple users to draw, edit, and interact on a shared canvas with conflict-free synchronization and eventual consistency.
PandaDraw is a distributed system designed to replicate and extend the capabilities of tools like Excalidraw, focusing on real-time collaboration over a 2D spatial canvas.
Unlike traditional collaborative editors that operate on linear text, PandaDraw synchronizes a graph of spatial objects (shapes) across multiple clients concurrently.
The system ensures:
- Real-time collaboration
- Conflict-free merging (CRDT)
- Offline-first capability
- Scalable architecture
Most collaborative systems (e.g., Google Docs clones) deal with linear text, which simplifies synchronization.
PandaDraw intentionally tackles a harder problem:
Synchronizing complex spatial data structures in real time across distributed clients.
This demonstrates:
- Advanced distributed systems design
- Handling concurrent updates on non-linear data
- Real-world system complexity (similar to Figma/Miro)
The name reflects the philosophy of the system:
PandaDraw hides the complexity of distributed systems behind a simple, intuitive user experience — just like a panda appears calm despite its strength.
- Multi-user real-time collaboration
- Drawing tools (rectangle, arrow, freehand)
- Shape manipulation (move, resize, delete)
- Conflict-free updates using CRDT
- Live cursors
- Selected shapes
- Active user tracking
- WebSocket-based real-time sync
- Eventual consistency
- Offline-first support (planned)
- Snapshot & history system (planned)
PandaDraw follows a CRDT-first distributed architecture. For an in-depth dive, see the Architecture Documentation.
-
Frontend (Canvas UI)
- Handles drawing interactions
- Renders shapes on canvas
- Maintains local CRDT state
-
CRDT Layer (Yjs)
- Manages shared document state
- Ensures conflict-free merging
- Generates incremental updates
-
Sync Layer (WebSocket Server)
- Relays updates between clients
- Handles connection lifecycle
- Broadcasts CRDT updates
-
Persistence Layer
- Stores snapshots of canvas state
- Logs incremental updates
- Enables recovery & versioning
-
Presence Layer
- Tracks cursor positions
- Tracks selections and active users
- Uses ephemeral state (not persisted)
- User performs an action (draw/move/edit shape)
- Local CRDT state (Yjs) updates instantly
- Yjs generates an incremental update
- Update is sent via WebSocket to server
- Server broadcasts update to other clients
- All clients merge update automatically
No central conflict resolution logic is required — CRDT guarantees convergence.
The core data structure is managed by Yjs. Shapes are stored as a map of objects.
Y.Map<shapeId, Shape>A Shape object structure:
interface Shape {
id: string; // Unique shape identifier
type: 'rectangle' | 'ellipse' | 'arrow' | 'freedraw' | 'text';
x: number;
y: number;
width: number;
height: number;
strokeColor: string;
backgroundColor: string;
isDeleted: boolean; // Tombstone for eventual consistency
}To get the project running locally, please follow the detailed instructions in our Getting Started Guide.
This project is licensed under the MIT License - see the LICENSE file for details.g