Why did we choose to build our own DB Gateway instead of using Google cloud Firestore?

As we discussed in our previous post on how we use our Coral Gateway server instead to keep our Flutter App in sync with our Cloud DB. You can find the details in our previous post.

We build this system for Ordermaster.ca use-case where each restaurant has an app to get order information, menu information and table reservation information from Cloud. The restaurant uses the Tablet also as a POS system to take orders in the restaurant itself which should work with any internet connection. So we keep all the orders in local Sembast DB which we keep in sync with the Cloud.

Since we were using FireStore, we thought it would be easy to just use it in offline mode. But we ran into some of the issues which were related to our use-case.

Below is the list of primary reason we have to build our own Gateway server

  1. Our cloud tables which are in Firestore are multi-tenant where as our App Local DB is single tenant along with our Restaurant
Image for post
Image for post
Coral Gateway keeping local DB and cloud DB in sync

Multi-tenant Cloud DB vs Single Tenant Local DB

In the cloud firestore table we keep the orders from all restaurants. We don’t have per restaurant Order table. But in case of the local DB in the flutter app we keep only orders from the restaurant for which that tablet is registered.

Coral Gateway which keeping the data in sync ensure that it doesn’t put other restaurants data into other than authorised local DB.

Subset of Data

In the cloud table the orders are kept for a period of month whereas in the Local App DB we only keep the orders till 24 hrs period. This keeps the memory requirements low in the app.

Custom State based Sync

Before the order is created its in draft mode and sometimes customer doesn’t finish the creation of Order. Such orders are not shown in the app and hence not pushed to the device local DB.

There are few other small reasons as we are not locked into google firestore. If tomorrow we decide to choose any other DB like MongoDB for cloud we can easily change it without any need to make app changes.

Let us know if you want to know more about Coral Gateway for your flutter app.

Follow us on twitter: https://twitter.com/k8scaleio

Simplifying writing cloud connected Apps.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store