Offline / local device sync and online cloud replication with Realm and Mongo

Hello everyone,

I would like to realize a POS Retail system with the following requirements:

  • no desktop-like hardware
  • local first approach
  • data replication in cloud
  • mobile apps developed with Flutter
  • all the involved devices must be able to share data even when the Internet is down

Among other solutions (Ditto, ObjectBox, …) I am evaluating the usage of Mongo technologies, in order to realize this POS system in a smooth but yet reliable fashion.

Please be aware that the question might sound similar to the following: Any known issues with manually syncing offline devices through a physical server?
We indeed have something in common, but unfortunately the solution “approved” by the OP there is not suiting all my needs.

I try to list what I have in mind, it would be nice to hear your opinion about that:

  • main-app: it has a “central” Realm DB, in Sync with an Atlas Mongo DB
  • children-apps: they use a local-only Realm DB (not synced or anything) simply to store certain data
  • the main-app and the various children applications would be communicating via a socket-based connection, over the local network
  • the main-app would work as some sort of event emitter and receiver, f.e. broadcasting messages to all the connected clients when needed, receiving specific requests from a child and sending a response to it, and so on.

Whenever the Internet is off, the whole environment would still be operational, because all the children-apps running on devices would access the main-app over LAN.
The main-app would naturally store any change in its local Realm DB.
Once Internet connection is re-established, thanks to Atlas Device Sync, the local Realm DB will sync up with the Atlas Mongo DB.

My main concern here is the actual implementation of the two-way communication between children and main-app.
For sure I will not use a REST server, but rather a socket-based solution as I said.
However I feel like that’s kind of a gimmick (maybe too complicated to realize?), just to go around the fact that Realm App sync only works over the Internet.

I am aware about the existence of Realm legacy Platform that would handle the sync over LAN just fine, thanks to the Realm Obj Server. However the idea of starting a brand new project using a so called “legacy” technology is not really appealing. Moreover, that wouldn’t satisfy the need of data replication in cloud as smoothly as Atlas device Sync.

What do you guys think, am I on a right path with Mongo, with that caveat of implementing the socket-communicaton? Does it sound too complicated, should I search elsewhere?

Thank you for your time.

1 Like