Skip to content

Commit b5f084a

Browse files
committed
Shift firebase set up to backend directory readme
1 parent 57b1da9 commit b5f084a

File tree

3 files changed

+42
-36
lines changed

3 files changed

+42
-36
lines changed

backend/README.md

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
# PeerPrep Backend
22

3-
> Set-up either a local or cloud MongoDB first, before proceeding to each microservice for more instructions.
3+
> Before proceeding to each microservice for more instructions:
4+
5+
1. Set-up either a local or cloud MongoDB.
6+
7+
2. Set-up Firebase.
48

59
## Setting-up local MongoDB (only if you are using Docker)
610

711
1. In the `backend` directory, create a copy of the `.env.sample` file and name it `.env`.
812

913
2. To set up credentials for the MongoDB database, update `MONGO_INITDB_ROOT_USERNAME`, `MONGO_INITDB_ROOT_PASSWORD` of the `.env` file.
1014

11-
3. Your local Mongo URI will be `mongodb://<MONGO_INITDB_ROOT_USERNAME>:<MONGO_INITDB_ROOT_PASSWORD>@mongo:27017/`. Take note of it as we will be using in the `.env` file in the various microservices later on.
15+
3. Your local Mongo URI will be `mongodb://<MONGO_INITDB_ROOT_USERNAME>:<MONGO_INITDB_ROOT_PASSWORD>@mongo:27017/`. Take note of it as we will be using in the `.env` files in the various microservices later on.
1216

1317
4. You can view the MongoDB collections locally using Mongo Express. To set up Mongo Express, update `ME_CONFIG_BASICAUTH_USERNAME` and `ME_CONFIG_BASICAUTH_PASSWORD`. The username and password will be the login credentials when you access Mongo Express at http://localhost:8081.
1418

@@ -87,4 +91,36 @@
8791

8892
![alt text](GuideAssets/ConnectionString.png)
8993

90-
13. Your cloud Mongo URI will be the string you copied earlier. Take note of it as we will be using in the `.env` file in the various microservices later on.
94+
13. Your cloud Mongo URI will be the string you copied earlier. Take note of it as we will be using in the `.env` files in the various microservices later on.
95+
96+
## Setting-up Firebase
97+
98+
1. Go to https://console.firebase.google.com/u/0/.
99+
100+
2. Create a project and choose a project name. Navigate to `Storage` and click on it to activate it.
101+
102+
3. Select `Start in production mode` and your preferred cloud storage region.
103+
104+
4. After Storage is created, go to `Rules` section and set rule to:
105+
106+
```
107+
rules_version = '2';
108+
service firebase.storage {
109+
match /b/{bucket}/o {
110+
match /{allPaths=**} {
111+
allow read: if true;
112+
allow write: if request.auth != null;
113+
}
114+
}
115+
}
116+
```
117+
118+
This rule ensures that only verified users can upload images while ensuring that URLs of images are public. Remember to click `Publish` to save changes.
119+
120+
5. Go to `Settings`, `Project settings`, `Service accounts` and click `Generate new private key`. This will download a `.json` file, which will contain your credentials.
121+
122+
6. You will need to update the following variables in the `.env` files of the various microservices later on.
123+
- `FIREBASE_PROJECT_ID` is the value of `project_id` found in the downloaded json file.
124+
- `FIREBASE_PRIVATE_KEY` is the value of `private_key` found in the downloaded json file.
125+
- `FIREBASE_CLIENT_EMAIL` is the value of `client_email` found in the downloaded json file.
126+
- `FIREBASE_STORAGE_BUCKET` is the folder path of the Storage. It should look something like `gs://<appname>.appspot.com`.

backend/question-service/README.md

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,6 @@
11
# Question Service
22

3-
> If you have not set-up either a local or cloud MongoDB, go [here](../README.md) first before proceding.
4-
5-
## Setting-up Firebase
6-
7-
1. Go to https://console.firebase.google.com/u/0/.
8-
9-
2. Create a project and choose a project name. Navigate to `Storage` and click on it to activate it.
10-
11-
3. Select `Start in production mode` and your preferred cloud storage region.
12-
13-
4. After Storage is created, go to `Rules` section and set rule to:
14-
15-
```
16-
rules_version = '2';
17-
service firebase.storage {
18-
match /b/{bucket}/o {
19-
match /{allPaths=**} {
20-
allow read: if true;
21-
allow write: if request.auth != null;
22-
}
23-
}
24-
}
25-
```
26-
27-
This rule ensures that only verified users can upload images while ensuring that URLs of images are public. Remember to click `Publish` to save changes.
28-
29-
5. Go to `Settings`, `Project settings`, `Service accounts` and click `Generate new private key`. This will download a `.json` file, which will contain your credentials.
3+
> If you have not set-up either a local or cloud MongoDB, as well as Firebase, visit [this](../README.md) before proceeding.
304
315
## Setting-up Question Service
326

@@ -35,10 +9,6 @@
359
2. To connect to your cloud MongoDB instead of your local MongoDB, set the `NODE_ENV` to `production` instead of `development`.
3610

3711
3. Update `MONGO_CLOUD_URI`, `MONGO_LOCAL_URI`, `FIREBASE_PROJECT_ID`, `FIREBASE_PRIVATE_KEY`, `FIREBASE_CLIENT_EMAIL`, `FIREBASE_STORAGE_BUCKET`.
38-
- `FIREBASE_PROJECT_ID` is the value of `project_id` found in the downloaded json file.
39-
- `FIREBASE_PRIVATE_KEY` is the value of `private_key` found in the downloaded json file.
40-
- `FIREBASE_CLIENT_EMAIL` is the value of `client_email` found in the downloaded json file.
41-
- `FIREBASE_STORAGE_BUCKET` is the folder path of the Storage. It should look something like `gs://<appname>.appspot.com`.
4212

4313
## Running Question Service without Docker
4414

backend/user-service/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# User Service Guide
22

3-
> If you have not set-up either a local or cloud MongoDB, as well as Firebase, go [here](../README.md) first before proceding.
3+
> If you have not set-up either a local or cloud MongoDB, as well as Firebase, visit [this](../README.md) before proceeding.
44
5-
## Setting-up
5+
## Setting-up User Service
66

77
1. In the `user-service` directory, create a copy of the `.env.sample` file and name it `.env`.
88

0 commit comments

Comments
 (0)