I'm working on a mobile app using Google Flutter that requires accessing a database through JSON requests and API's. Also the database isn't controlled by me so if I want additional features, I would have to pay (a significant amount of money to the database company).
Because accessing the database requires a authentication token that only lasts for 1 hour, I'm thinking that everytime the user logs in or resumes the app, a cloud function is triggered to retrieve information from the third party database and copies it to a collection on Firestore. Then on the app, I would just access the collection from Firebase
I'm already using Firestore because I need it to push and access past push notifications. I have a cloud function that triggers a push notification when a new document is added to my "notifications" collection. Thay way I can access past notifications.
I've never done this before, are there other pros and cons I need to consider? How realistic is this approach?
Pros - Offline data persistence with Firestore - Scalability (since there's a chance I'll be creating a webapp version in the future and different flavours of the app) I can reuse the cloud functions to sync back and forth with the third party database - Ability to add future features at a lower cost (since the database company charges a like $130 an hour for development) - Access to event triggers built into database - Keep data to one database on the app, simplifies data streams
Cons - Having to create seperate cloud functions to sync data across the two seperate databases - Managing data?