fluttergraphcloudlocaldata-synchronization

Is there a local Graph DB (e.g. Neo4j) for Flutter that optionally syncs with the cloud?


do you have a smart approach to tackle the following challenge? A flutter app wants to model its data in a graph structure. This graph structure includes meta information about objects, text based information and links to files (e.g. images, videos, audios, documents). These files are stored in a seperate file storage (to keep the graph light). This solution should work locally and optionally sync (as fast as possible) with the cloud. So I suppose there had to be some sort of local server that hosts both a graph database and file storage as well as some mechanism that can sync (ideally in the background?) these data with an instance in a cloud (to enable syncronization across devices). How would you go about developing a solution in flutter for this? Please let me know if you need more information.

Thank you and kind regards, Niklas

I already did my own research on this but don't find a graph db integration for flutter where I can run a local instance that syncs with the cloud. I would expect that my problem is not that unique and there's some frameworks for it. I'd like to understand this better by hearing how you would tackle the problem. Thank you.


Solution

  • It's a little unclear to me based on your question what problem you are actually trying to solve here, but for my answer I'm going to assume you are looking for some kind of realtime sync that stores locally while offline, and then automatically detects a network connection and syncs again.

    There really isn't a native neo4j solution here currently, nor, honestly, do I expect there ever will be.

    There are, however similar tools for other types of databases, so I suppose it may happen one day. https://www.mongodb.com/docs/realm/sdk/flutter/ https://firebase.google.com/docs/database/flutter/offline-capabilities

    My team isn't exactly solving for this exact problem, because we aren't really at a point where we're thinking about offline functionality, so I apologize if this question isn't a perfect match. But what we do is use GraphQL to interface with our Neo4j database. By doing so, we have an opportunity to model our local data however we need to on the client and easily convert to JSON objects to interface with our API in a graph-like structure.

    Unfortunately, given the complexities of syncing offline/online in realtime, and especially because neo4j/graphql doesn't really have good subscription functionality yet, you may find yourself having to either roll out some very challenging custom solutions, lean on something like the libraries referenced above, or making compromises on your functionality.

    Alternatively, if realtime sync isn't the point, I would argue that your client database really doesn't need to use the same tools as your server db (that's what apis are for) and that you should consider using sqlite, one of the above db tools, or one of the many other mobile client databases available. You can find many of them here: https://pub.dev/packages?q=database

    updating to add: Depending on your goals and experience level you may also want to consider the question of if you actually even need a database on the client at all.