
Ask HN: Best architecture for offline-first, cloud-synced mobile app? - milohoffman
So I&#x27;ve been grappling with a technical design decision for a few days now and wanted to see what HN thinks, since I imagine there are a bunch of people who have run up against this problem and might have opinions&#x2F;experience.<p>I&#x27;ve built an iOS app that uses Rails as a backend, this has worked well as a stack for me in the past, but the wrinkle is that this app now needs to be truly functional offline - I need to persist every object locally for offline use, but then also have that synced to the cloud for backup and to enable other features like sending emails and notifications containing users&#x27; content.<p>There are obviously plenty of straight-forward options to handle the local persistence (CoreData, SQLlite, Realm, etc.), and I&#x27;m happy to use any of them, but there seems to be no great option for persisting&#x2F;syncing the local stuff on the cloud.  Each of the options I&#x27;ve come across has significant drawbacks:<p>Realm Platform - prohibitively expensive (&gt; $2000&#x2F;year) if you want to access the server data to do anything other than communicate with a Realm client, also migrations are a pain<p>iCloud + CoreData - people might not have iCloud space or iCloud enabled<p>Google Cloud Firestore - in beta, some people experiencing issues with locally created objects not getting persisted, locked in to platform<p>Google Firebase Realtime - seems like this is effectively on the way to getting deprecated in favor of Firestore<p>Rolling my own solution where I write a background process to sync the client&#x27;s data with my Rails server - lots of complex code, prone to bugs<p>Any opinions on this problem or things I should consider?  Would be greatly appreciated!
======
xq3000
1) Couchdb

2) AWS AppSync Client (not Amplify) + AWS AppSync service + Cognito + a few
Lambdas + some db

~~~
steve_taylor
CouchDB has the advantage of implementations for mobile (CouchBase Lite for
iOS and Android) and web (PouchDB).

------
spacesarebetter
I just leave this link here. Quip is one of my favorite offline-first cross-
platform app. They use leveldb (realm is also based on leveldb) on the client
and use mysql on the server. Protocol buffers are used for communication
although thats just a communication method.

[https://medium.com/@btaylor/react-with-c-building-the-
quip-m...](https://medium.com/@btaylor/react-with-c-building-the-quip-mac-and-
windows-apps-c63155c1531b)

------
bstahlhood
Have you checked out MongoDB Mobile/Stitch?

[https://www.mongodb.com/cloud/stitch](https://www.mongodb.com/cloud/stitch)

~~~
milohoffman
No, never heard of this option, definitely going to check it out - thanks!

------
aaronbrager
You could use Realm Object Server instead of signing up for Realm Platform.

Another option you can investigate is AWS AppSync.

You also can just configure your data layer to get from the cache if offline,
and get from your Rails app if online. You can use the Reachability framework
to get notifications when an Internet connection comes back online.

~~~
milohoffman
My understanding is that just "using Realm Object Server" means using Realm
Platform Self Hosted, which starts at $2000/year. The hosted Realm Platform
starts at $30 month, but I've read you need to upgrade to a similarly
expensive $1500-2000 enterprise plan if you want to access the data from non-
mobile-Realm clients. That is to say, I'm very open to just using Realm
Database on the client for local persistence, because it's free and really
nice to use, but don't think Realm for sync is viable.

AWS AppSync looks like it's worth investigating, thanks!

Agreed a custom data layer/cache might be the way to go, I think it gets a bit
more complex once you have a bunch of objects being edited and deleted, and
I've also spent some time with iOS background networking in the past and I
know it can be buggy/frustratingly non-deterministic, which is why I'm
reluctant.

