1.1. BEFORE YOU BUILD THE CHAT APP
The app utilizes all of these Firebase services, and will require you to set it up, then copy the .env.example in the root folder into .env, and fill in accordingly
.env
VITE_FIREBASE_API_KEY=
VITE_FIREBASE_AUTH_DOMAIN=
VITE_FIREBASE_AUTH_PROJECT_ID=
VITE_FIREBASE_STORAGE_BUCKET=
VITE_FIREBASE_MESSAGING_SENDER_ID=
VITE_FIREBASE_APP_ID=
VITE_FIREBASE_DATABASE_URL=
VITE_VAPID_KEY=
You should find everything but VAPID_KEY under Project Settings -> Your Apps -> SDK setup and configuration
For VAPID_KEY:
Under Cloud Messaging tab, create a new "Web Push certificates". That's your VAPID_KEY
1.2. BUILD THE CHAT APP
Simply
yarn && yarn build
1.3. DEPLOY THE CHAT APP
The project utilizes Firebase Hosting as well. To deploy the app the same way:
- Install Firebase CLI
- firebase deploy
If you're looking it to host it yourself, the app is still at its core a React app bundled with Vite. Plenty of tutorials for that online.
2.1 BEFORE YOU BUILD
Acquire a serviceaccount.json file from the "Generate new private key" button in the Project Settings -> Service Account
Save the file under firebase_functions/functions/src directory
Go into the index.ts file, change databaseURL to your databaseURL (yes I probably should use .env file for this but this is niche and small enough to justify my laziness)
2.1 BUILD AND DEPLOY
With the terminal pointed to the very same directory, run
npm run deploy
Some explanations of the services used
For push notifications. Foreground notifications are set up with Firebase "onMessaging" function, while background notifications are set up with src/firebase-messaging-sw.js file
For the login as google function
For chat function. Data is de normalized to maximize reading capability. Schema is as bellow
For push notifications. Essentially a cron job that runs every x hours/minutes to check for notifiable messages from users.
For deployment