How abhinav-anil-5670/editor works
Project type and purpose
• This is a frontend-only, real-time collaborative editor built as a React single-page-app (Vite) that uses Yjs (CRDT) for shared document state and WebRTC (via the y-webrtc module) for peer-to-peer syncing. There is no traditional backend API—only a signalling server to broker WebRTC handshakes.
File structure
• Top level:
• index.html, public/ → static assets served by Vite
• src/ → React components and entrypoint (main.jsx, App.jsx)
• src/components/Editor.jsx, JoinPage.jsx, Navbar.jsx → UI for joining a room and editing
• vite.config.js, package.json → build and dev server config
• No “backend” folder—this is purely a client app that relies on an external signalling server.
README for additional insights
• Signalling server is started from node_modules/y-webrtc/bin/server.js on ws://localhost:4444
• Clients join a fixed room name via WebSocket to negotiate WebRTC
• Once peers are discovered, all document updates go over WebRTC data channels using Yjs CRDT
Main components & relationships
a. Browser Client (React SPA)
– UI layers: JoinPage → Navbar → Editor
– Yjs document instance embedded in Editor.jsx
– y-webrtc provider configured with room name and signalling server URL
b. Signalling Server (Node.js process inside y-webrtc)
– Listens on ws://localhost:4444
– Brokers WebRTC SDP offers/answers over WebSocket
c. P2P Network (WebRTC Data Channels)
– Once negotiated, peers exchange Yjs updates directly
d. Optional: Vite Dev Server (serves the bundle, handles HMR in dev)
Architectural patterns & design principles
• CRDT (Yjs) ensures conflict-free merge of concurrent edits
• P2P mesh network: each client directly wires with every other client in the same room
• Single-responsibility components in React: separation of join logic, editor UI, and shared state provider
Key takeaways
• Accurately capture the fact that there is no traditional REST API or database—only a WebSocket signalling layer plus direct P2P syncing
• Clearly delineate the boundary between client logic (React + CRDT) and the standalone signalling server
• Core real-time collaboration loop: UI ↔ Yjs ↔ y-webrtc ↔ signalling server ↔ peers