Before proceeding to each microservice for more instructions:
-
Set up cloud MongoDB if you are not using Docker. We recommend this if you are just testing out each microservice separately to avoid needing to manually set up multiple instances of local MongoDB. Otherwise, if you are using
docker-compose.yml
to run PeerPrep, check out the READMEs in the different backend microservices to set up the.env
files for the local MongoDB instances. -
Set up Firebase.
-
For the microservices that use Redis, to view the contents stored:
-
Go to http://localhost:5540.
-
Click on "Add Redis Database".
-
Enter
host.docker.internal
as the Host. -
Enter the port used by the respective service:
- User Service:
6379
- Collab Service:
6380
- User Service:
-
-
Follow the instructions here to set up Node v20.
This guide references the user-service README in the PeerPrep-UserService repository
-
Visit the MongoDB Atlas Site https://www.mongodb.com/atlas and click on "Try Free".
-
Sign Up/Sign In with your preferred method.
-
You will be greeted with welcome screens. Feel free to skip them till you reach the Dashboard page.
-
Create a Database Deployment by clicking on the green
+ Create
Button:
- Make selections as followings:
- Select Shared Cluster
- Select
aws
as Provider
- Select
Singapore
for Region
- Select
M0 Sandbox
Cluster (Free Forever - No Card Required)
Ensure to select M0 Sandbox, else you may be prompted to enter card details and may be charged!
-
Leave
Additional Settings
as it is -
Provide a suitable name to the Cluster
- Next, click on
Add my Current IP Address
. This will whitelist your IP address and allow you to connect to the MongoDB Database.
-
Click
Finish and Close
and the MongoDB Instance should be up and running. -
[Optional] Whitelisting All IP's
-
After setting up, go to the Database Deployment Page. You would see a list of the Databases you have set up. Select
Connect
on the cluster you just created earlier. -
Select the
Drivers
option. -
Select
Node.js
in theDriver
pull-down menu, and copy the connection string.Notice, you may see
<password>
in this connection string. We will be replacing this with the admin account password that we created earlier on when setting up the Shared Cluster. -
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.
For ease of testing, you can set up just one firebase to use across all the microservices that need it.
-
Create a project and choose a project name. Navigate to
Storage
and click on it to activate it. -
Select
Start in production mode
and your preferred cloud storage region. -
After Storage is created, go to
Rules
section and set rule to:rules_version = '2'; service firebase.storage { match /b/{bucket}/o { match /{allPaths=**} { allow read: if true; allow write: if request.auth != null; } } }
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. -
Go to
Settings
,Project settings
,Service accounts
and clickGenerate new private key
. This will download a.json
file, which will contain your credentials. -
You will need to update the following variables in the
.env
files of the various microservices later on.FIREBASE_PROJECT_ID
is the value ofproject_id
found in the downloaded json file.FIREBASE_PRIVATE_KEY
is the value ofprivate_key
found in the downloaded json file.FIREBASE_CLIENT_EMAIL
is the value ofclient_email
found in the downloaded json file.FIREBASE_STORAGE_BUCKET
is the folder path of the Storage. It should look something likegs://<appname>.appspot.com
.