automerge / automerge-classic

A JSON-like data structure (a CRDT) that can be modified concurrently by different users, and merged again automatically.
http://automerge.org/
MIT License
14.77k stars 467 forks source link

Using automerge with graph data #493

Closed ghost closed 2 years ago

ghost commented 2 years ago

What would be the best approach to use automerge with graph data. Ideally I would have a graph database that works offline or at least download a part of the graph database that the user works on at the moment. While gun js is a very good use case for this, I have also looked at dbs like indradb which I can use as an embedded database. To sync changes in real time, I believe automerge would be a great fit, however I am not sure what the best approach would be.

My initial thinking was to use indradb (or another embedded graph db) to structure the data and then use documents for each node to enable real time synchronization.

P.S. If you know any other graph databases which I could run on the users machine, please let me know.

ept commented 2 years ago

The easiest way of representing graph data in Automerge would be to generate a UUID for each vertex, then have an Automerge containing a map in which the keys are those UUIDs, and the values are objects describing each vertex. The edges could then be represented by having a list of adjacent vertices on each vertex.