Building a Shared Code-Editor using Node.js, WebSocket and CRDT

<p>How do collaborative editing platforms like Google Docs, codeshare.io or excalidraw work?</p> <p>These platforms provide real-time collaboration, synchronization with other users and conflict-resolution mechanisms.</p> <p>Real-time communication and synchronization of document can be achieved by using WebSocket, since it enables instant updates to be sent and received as the users make an update. For example, when a change is made by User A, this information is sent to the server via WebSocket, the server then broadcasts this change to other connected users.</p> <p>The difficult part is conflict-resolution. You may be aware how difficult it is to resolve merge conflicts in a git repository. Imagine automating this process .</p> <p>Fortunately, there are many big brain people working on distributed conflict-resolution algorithms.</p> <p>Mainly, there are 2 techniques to do this:</p> <ol> <li>Operational Transformation (OT)</li> <li>Conflict-Free Replicated Data Types (CRDTs)</li> </ol> <p>I won&rsquo;t dive deep into the algorithmic details of each technique, but I&rsquo;ll quote few lines from&nbsp;<a href="https://nurkiewicz.com/2022/04/crdt.html#:~:text=The%20difference%20is%20that%20with,different%20because%20they%20are%20decentralized." rel="noopener ugc nofollow" target="_blank"><em>this&nbsp;</em></a>blog.</p> <p><a href="https://akormous.medium.com/building-a-shared-code-editor-using-node-js-websocket-and-crdt-e84e870136a1">Website</a></p>
Tags: CRDTs OT