webapp
contains the PWA hosted on S3cloud-functions
is the cloud functions deployed on firebase
- The website if hosted on Amazon S3, behind Cloudflare.
- The user subscribes to Google Cloud Firestore, which is readonly.
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read: if request.auth.uid == resource.data.player1.id || request.auth.uid == resource.data.player2.id || resource.data.player1.id == '' || resource.data.player2.id == '';
allow write: if false;
}
}
}
- When a user is interacting with the application, cloud functions are triggered.
- The cloud functions will update the Firestore database, and the frontend listeners will display the updated object.
With the free tier, with an average of 15 invocations per game, we can do 125000 / 15 = 8333 games
per month for free.
After that, we can do ~60k games
for less a dollar. Which is totally fine, especially with some sort of ads.
The Google Cloud Functions will have a cold boot. This means that if nobody is playing, the first users will suffer a little bit from a slow API. After that, it should become fast again.
Icon:
Icons made by Freepik from www.flaticon.com