Ask HN: Help with mobile app that works offline and sync data

1 points by saurabhnanda ↗ HN
At our startup, our target market is increasingly conducting their business, on-the-go. Therefore, we have to augment our browser-based desktop app with a mobile app.

Therefore, I'm now evaluating what it would take to develop a mobile app that could work completely offline and sync transaction data periodically with the central server.

I've read briefly about Firebase, Parse, Usergrid, BaasBox, master-master replication, and the CAP theorem. As expected, I'm royally confused now!

‎We already have an existing data storage infra, which is using Postgres. And since we're dealing with financial transactions, I'd like to stick with an ACID store and not some new-fangled JSON hotness. Our app also has HTTP/JSON APIs for various read & write operations. I can even consider exposing very fine grained RPC calls over Thrift/Protocol Buffers, which frankly, seem more manageable than the JSON APIs.

Now, my question is, is there a project/service/SDK out there which has already solved this data sync problem? What about conflict resolution when it comes to transaction data? I understand that this is like resolving merge conflicts in git, which basically requires human intervention, but is there an SDK that will reduce dev time for such scenarios? Can said SDK work with a custom backend API?

Also, how should one be storing all this data on the mobile app? SQLite?

This is the first mobile app that we're about to write as a team, and any gyaan from the experienced folks would be appreciated.

3 comments

[ 3.1 ms ] story [ 18.2 ms ] thread
"That could work completely offline and sync transaction data periodically with the central server."

From what I've gathered you want the app to sync data when possible but still work as it should when offline? There are several solutions in the space of this.

A simple solution would be to split or abstract the logic with handling the data versus the functionality of the mobile app itself. In which case you should not be tied down to specific backends.

Anything that works for mongodb or other databases you can usually find something that converts said backend to something working for postgres or whatever for server side.

As for mobile your data backend should be something lightweight and it may be beneficial to use something that is agnostic to mobile like html5. Key players for web data usually are Indexedb and somewhat basket.js : https://addyosmani.github.io/basket.js/ . As the web is usually the way of using what mobile apps are using for storage gathered from a look at angular.js in retrospect.

Some of the other stuff you mentioned:

A more accurate terminology for what you may be looking for in the future for communicating with several distributed systems would be a CRDT key-value(for example; https://github.com/dominictarr/crdt ) if you want it to be purely distributed over many devices completely and provide the same updates to many devices. There is still a lot of on-going research in the area with Riak and Redis having somewhat successful uses in the box at the moment. A newer idea is something called SyncFree: https://github.com/SyncFree

As for resolving git transaction conflicting updates there is a solution that is being developed talked about here: http://the-paper-trail.org/blog/subverting-sinfonia/

A more json version for updates would be something along the lines of: https://github.com/Operational-Transformation