Firebase
Firebase
Firebase is a Platform as a Service owned by Google. Crowde's entire infrastructure is based on Firebase.
Firebase Services
Firebase Auth
Firebase Auth is used for Authentication. Everything resolivng around registering, login, password-resets is done using Firebase Auth.
Firestore
Firestore is used as a realtime database for all of crowde's data. Every topic, question, feedback, etc. is stored in Firestore.
Most Authorization in crowde is done by Firestore Rules. Every read and write is authorized by descriptive rules defined in /firestore.rules
Firebase Storage
Files like Question-Files and Exam-Exports are stored in Firebase Storage.
Authorization regarding these files is defined by /storage.rules
.
Firebase Cloud Functions
Cloud Functions are used for server-side-logic. Most Operations in crowde are done directly from the web-client to firestore, but for some operations the web-client cannot be bothered or trusted. Cloud Functions are mainly used for those Operations, that are computing-intensive or require system-wide permissions. They are mostly triggered by changes in firestore and mostly respond by writing back into firestore. There are a few exceptions, like a function responding to a newly registered user in Firebase Auth. Functions in this project are defined in /functions/
. Learn more
Firebase Hosting
Firebase Hosting is used to serve the Web-Client's static files. This is the only Firebase-Service that can be swapped out easily by any other Hosting Service. Learn more
Configure Firebase
Crowde is linked to a particular firebase in 4 places:
- firebase-cli uses
/.firebaserc
to determine which firebase to deploy to.- crowde.net is set to the default (
firebase use default
) - Other firebase instances can be added to this file and used by the firebase-cli. (for example
firebase use server-dev
) - This configuration does not contain secrets
- crowde.net is set to the default (
- The Web-Client uses the environment files found in
/client/src/environments/
- crowde.net is set to the default for development (
/client/src/environments/environment.ts
) and production (/client/src/environments/environment.prod.ts
) - edit these two files or configure new environments (like
server-dev
) to link different firebase instances. - This configuration does not contain secrets
- crowde.net is set to the default for development (
- Functions need a Service Account to use the firebase-admin SDK.
- Follow the instruction from the firebase docs to get a serviceAccountKey.json
- Place the serviceAccountKey.json at
/functions/serviceAccountKey.json
- Server-Dev needs the same Service Account access as Functions
- Place the serviceAccountKey.json at
/server/serviceAccountKey.json
- Place the serviceAccountKey.json at