- Clone this repository to your local machine.
- Ensure you have Docker installed.
- (Optional) Sign up for a MongoDB Atlas account
- The docker compose file is configured to use a local MongoDB instance by default. If you would like to use a remote MongoDB instance, you can follow the instructions in the "Remote DB Setup" section below.
-
Open a terminal and navigate to the root directory of the project.
-
Duplicate the .env.sample file and rename it to .env
- If you wish to, you can modify the values in the .env file
Variable Description Default Value NEXT_PUBLIC_USER_SERVICE_URL URL of the user service http://localhost:8004 NEXT_PUBLIC_QUESTION_SERVICE_URL URL of the question service http://localhost:8003 NEXT_PUBLIC_QUESTION_SERVICE_URL URL of the question service http://localhost:8003 NEXT_PUBLIC_IMAGE_UPLOAD_KEY AuthToken for image upload None, you can get this from https://www.portive.com FRONTEND_PORT Port to run the frontend service 3000 USER_MONGODB_URI MongoDB URI for the user service None, commented out. If you are using a remote MongoDB instance, you can key in your connection string here USER_MONGO_INITDB_ROOT_USERNAME MongoDB root username for the user service userroot USER_MONGO_INITDB_ROOT_PASSWORD MongoDB root password for the user service userpassword USER_PORT Port to run the user service 8004 JWT_SECRET Secret for creating JWT signature you-can-replace-this-with-your-own-secret QUESTION_MONGODB_URI MongoDB URI for the question service None, commented out. If you are using a remote MongoDB instance, you can key in your connection string here QUESTION_MONGO_INITDB_ROOT_USERNAME MongoDB root username for the question service questionroot QUESTION_MONGO_INITDB_ROOT_PASSWORD MongoDB root password for the question service questionpassword QUESTION_PORT Port to run the question service 8003 MATCHING_PORT Port to run the matching service 8002 USER_SERVICE_URL URL of the user service (for matching) http://g38-user-service:8004 REDIS_URL URL of the Redis instance redis://redis:6379 MATCHING_SERVICE_LOGS_DIR Directory to store logs for the matching service ./logs MATCHING_TIMEOUT Timeout for matching in milliseconds 10000
- If you wish to, you can modify the values in the .env file
-
Run
docker-compose up
to start the services.- If you keyed in remote MongoDB URIs in the .env file, the MongoDB containers will not be started. The services will connect to the remote MongoDB instances instead.
-
Once the services are up and running, you can access the frontend at
http://localhost:<FRONTEND_PORT>
(default: http://localhost:3000)
If the services are to be run individually (e.g. for deployment on different platforms), you can follow the instructions below.
-
cd into the matching-service directory
-
Duplicate the .env.sample file and rename it to .env
-
If you wish to, you can modify the values in the .env file
Variable Description Default Value MATCHING_PORT Port to run the service 8002 USER_SERVICE_URL URL of the user service http://localhost:8004 REDIS_URL URL of the Redis instance redis://redis:6379 MATCHING_SERVICE_LOGS_DIR Directory to store logs for the matching service ./logs MATCHING_TIMEOUT Timeout for matching in milliseconds 10000
-
-
Run
docker-compose up
to start the matching service.
-
cd into the question-service directory
-
Duplicate the .env.sample file and rename it to .env
-
If you wish to, you can modify the values in the .env file
Variable Description Default Value QUESTION_MONGODB_URI MongoDB URI None, commented out. If you are using a remote MongoDB instance, you can key in your connection string here QUESTION_PORT Port to run the service 8003 MONGO_INITDB_ROOT_USERNAME MongoDB root username root MONGO_INITDB_ROOT_PASSWORD MongoDB root password password
-
-
Run
docker-compose up
to start the question service.- If you keyed in a remote MongoDB URI in the .env file, the MongoDB container will not be started. The question service will connect to the remote MongoDB instance instead.
Common Issue and Troubleshooting
Issue: MongoParseError: URI malformed
- Solution: Ensure that the MONGODB_URI in your .env file is correctly formatted with the right username, password, and database name.
- cd into the user-service directory
- Duplicate the .env.sample file and rename it to .env
-
If you wish to, modify the values in the .env file to change the port that the service is hosted on.
Variable Description Default Value USER_MONGODB_URI MongoDB URI None, commented out. If you are using a remote MongoDB instance, you can key in your connection string here MONGO_INITDB_ROOT_USERNAME MongoDB root username root MONGO_INITDB_ROOT_PASSWORD MongoDB root password password USER_PORT Port to run the service 8004 JWT_SECRET Secret for creating JWT signature you-can-replace-this-with-your-own-secret
-
- Run
docker-compose up
to start the user service.- If you keyed in a remote MongoDB URI in the .env file, the MongoDB container will not be started. The user service will connect to the remote MongoDB instance instead.
- Navigate to the frontend directory: cd frontend/peerprep
- Duplicate the .env.sample file and rename it to .env
-
If you wish to, you can modify the values in the .env file
Variable Description Default Value NEXT_PUBLIC_QUESTION_SERVICE_URL URL of the question service http://localhost:8003 NEXT_PUBLIC_IMAGE_UPLOAD_KEY AuthToken for image upload None, you can get this from https://www.portive.com FRONTEND_PORT Port to run the frontend service 3000
-
- Run
docker-compose up
to start the frontend service.
- cd into the any of the service directories (question-service, user-service, frontend/peerprep)
- Run
docker build -t "<image-name>" .
to build the Docker image.
The matching service API can be found here: Matching Service API
User Service API Endpoints
The user service API can be found here: User Service API
Question Service API Endpoints
The question service API can be found here: Question Service API
-
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
- You will be prompted to set up Security for the database by providing
Username and Password
. Select that option and enterUsername
andPassword
. Please keep this safe as it will be used in User Service later on.
- Next, click on
Add my Current IP Address
. This will whiteliste 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. -
The connection string can be found by clicking on the
Connect
button on the Cluster Overview Page. followed byDrivers
.
- Select
Network Access
from the left side pane on Dashboard.
- Click on the
Add IP Address
Button
- Select the
ALLOW ACCESS FROM ANYWHERE
Button and ClickConfirm
Now, any IP Address can access this Database.