A graph where abitrary part can be collaborative

Hi everyone, I have a project Idea that I would like to be offline first + real-time with yjs.
It is a kind of visual graph (not a tree) where nodes can have several parents (not one) and several children.
I would like arbitrary parts of the graph to be sharable to an arbitrary number of users.

For example,
I would like a user to start with his own local graph so his own “room”, but I would like him to be able to add users, where those users could add other users to some specific part of the graph.

Every time a user would like to add a n + 1 user to an arbitrary branch of his graph, should a new room be created? (and another, and another, and another room…) ??

I don’t know if you have ever thought about such implementation with yjs, but if you have anything to share about it, I would be really grateful…

Hi @nicolidin,

I assume that you want the users to see the changes of other users. In that case, forking a document might not be the right solution.

In general, it is not possible to share only a subset of a Yjs document. You’d need to ensure that the changes are synced back and forth between different documents. This is hard to implement, requires a central source to perform manipulations, and it is pretty inefficient (duplication of state).

Instead, I suggest representing shareable nodes as subdocuments. If you have a lot of subdocuments, you have to think about a way to sync subdocuments more efficiently over a single connection (y-websocket, and other providers don’t support that yet). Writing your own provider is not that hard, so that is what I would do instead.