Looking for Architecture Advice for leveraging different Firebase

I have a small Ionic app that I have released to the app store and am now working on version 2.0.
Version 1.0 was a single user application. Now with version 2.0 I am thinking about adding some collaborative features.

A good analogy for these features would be like an evite type application. Basically one person can create a party and invite a bunch of people to that party. When the people invited respond, I would like the person organizing the party to get some notification. Ideally it would be like a push notification where the app is launched when the notification is pressed.

One thought I had was to build a server-less Service Layer using Firebase Cloud Functions where the creation of the party and inviting of the people would basically happen by invoking these Firebase cloud functions over HTTPS. That service layer would handle writing to Firestore and any other business logic. Notifications would come back to the party organizer via Firebase Cloud Messages. Having done a lot of SOA type projects during my career this appealed to me because it felt familiar and like a good old 3 tiered architecture.

However perhaps I am being too much of a dinosaur and making things more complicated (and expensive) then they need to be.

One alternative I was thinking of would be to just let the client uses the Firestore Client API directly and then leverage the realtime updates to facilitate the notification part by having the party organizer’s application just listen for updates to the invites sub-collection of the party. Perhaps I could just have a service worker that listens for updates and creates a LocalNotification which would solve the notification problem.

In the middle it seems there could be a hybrid solution where the client uses the Firestore API to read and write. When a person accepts an invite it is written to Firestore. A Cloud function could then be triggered by the update of the subcollection to send an FCM message to the party organizer.

I hope that this question isn’t too hypothetical abstract.
In a way just posting it is a way for me to ask the duck and attempt to reason it out for myself.

However if there are people on this forum who have done one of these approaches before i would be interested in hearing why it was good or bad, what the pitfalls were, etc.
I am trying to strike a balance between having a clean/straightforward solution while also consider the second order consequences like what my Google bill will look like at the end of the month.


I don’t know if anyone has enough experience with Firestore billing to develop a best practices yet. One approach I can recommend is that I built an internal app API, and made that my main database provider. All pages and other providers talk to that. Then, inside that database provider, I inject the provider that actually talks to the backend as a service. (For Firestore as the specific example, you could see here.) So if I want to change the backend, all I have to do is to change which provider I inject into the database service.

That way, 95% of your code is immune to changes, even if you change your database service every month while you shop around.

Firebase Cloud Functions and Notifications sound good to me - but then again I may be a very long in the tooth dinosaur.

Perhaps one solution is allow the party organizer to automatically send out i.e. the cloud function only works if value is true.

@AaronSterling - Thanks for the input/suggestion. As a general rule I always put this type of logic behind a provider rather than at the page level. I saw the post about your npm package and was definitely planning on using it if I go the way of direct connection instead of using the Cloud Function as a fascade.

I may double post to the Firebase google group about this if no-one here has a view on the potential complexity/costs. Although if the moderators are Firebase employees they would probably encourage using as many components as possible.

@JAR19 - I don’t understand your point about the cloud function only works if value is true. Also we shouldn’t worry too much about being Dinosaurs as long as the work is still fun and pays the bills. Experience should count for something.

Thanks again guys.