Keywords: Distributed, Decentralized, Collaborative, Editing, CRDT, Real-time
SandEdit is a project aiming to provide a distributed collaborative editor based on Conflict-free Replicated Data Type (CRDT) using Node.js. CRDTs for sequences allow to insert or delete in the sequence without the burden of managing conflicts. It makes it ideal for real-time editing. Furthermore, contrarily to well-known editors such as Google Docs, the network architecture is decentralized. As a consequence, it avoids the single point of failure and the limitations imposed by the service.
The browser part of this project is only a prototype. It does not manage multiple documents, saving document etc... Nevertheless, it should be in the near future (hopefully).
$ npm install sandedit
$ npm install socket.io
$ cd sandedit
$ node server
siteId
socketioPort replicaAddress replicaMask
remoteAddress
$ node server 0 1337 127.0.0.1:1338 255.0.0.0 127.0.0.1:1338
var Replica = require('sandedit');
// #1 creating a new node holding a sequence
var replica = new Replica(siteId,
localAddress, localPort, localMask,
remoteAddress, remotePort);
// #2 inserting an element
// insert the character 'a' at index 0
replica.emit('insert', 'a', 0);
// #3 removing an element
// remove the character at index 0
replica.emit('remove', 0)
// #4 received a remote insertion
replica.on('INS', function(element, index){ ... });
// #5 received a remote removing
replica.on('DEL', function(index){ ... });
SandEdit uses the following packages:
- causaltrack: the structure for handling causality
- lseqarray: the distributed data structure of the array
- smokesignal: the management of the p2p decentralized network
- socket.io: the browser display
Within the web page served by socket.io: