You can view the live project here: https://peerprep.delishad.com
- Ensure that you have a Kubernetes cluster set up.
- Ensure that you have kubectl installed and configured to point to your Kubernetes cluster.
- Set up environemnt variables under the config-map.yaml files and secrets.yaml files in the kubernetes directory. Each service also has its own config-map and secret file. Template files have been provided in the kubernetes directory.
- Run
kubectl apply -f kubernetes/ --recursive
to deploy all services to your Kubernetes cluster.
- 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.
- 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_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_MATCHING_SERVICE_URL URL of the matching service http://localhost:8002 NEXT_PUBLIC_COLLAB_SERVICE_URL URL of the collab service http://localhost:8010 NEXT_PUBLIC_COLLAB_SOCKET_URL URL of the collab socket service http://localhost:8010 NEXT_PUBLIC_MATCHING_SOCKET_URL URL of the matching socket service http://localhost:8002 NEXT_PUBLIC_IMAGE_UPLOAD_KEY AuthToken for image upload None, you can get this from https://www.portive.com, you need this for image uploads to work with the question editor. FRONTEND_PORT Port to run the frontend service 3000 JWT_SECRET Secret for creating JWT signature, make sure this is the same as your user service you-can-replace-this-with-your-own-secret
- if you wish to, you can modify the values in the .env file
- do
npm install
to install the required dependencies - do
npm run build
to build the frontend - do
npm run start
to start the frontend - Access the frontend at
http://localhost:3000
-
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 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 GMAIL_USER Gmail account for verification emails None, you can key in your Gmail account here GMAIL_PASS Gmail password for verification emails None, you can key in your Gmail password here USER_PORT Port to run the user service 8004 JWT_SECRET Secret for creating JWT signature you-can-replace-this-with-your-own-secret FRONTEND_URL URL of the frontend service (Do not change this, its fixed due to NextJS) http://localhost:3000 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_SERVICE_PORT Port to run the matching service 8002 REDIS_URL URL of the Redis instance for internal access redis://redis:6379 MATCHING_SERVICE_LOGS_DIR Directory to store logs for the matching service ./logs MATCHING_TIMEOUT Timeout for matching in milliseconds 10000 USER_SERVICE_URL URL of the user service for internal access http://g38-user-service:8004 COLLAB_SERVICE_URL URL of the collab service for internal access http://g38-collab-service:8010 QUESTION_SERVICE_URL URL of the question service for internal access http://g38-question-service:8003 COLLAB_API_KEY API key for the collab service ( used by matching-service for initialising sessions) collab-api-key
- 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_SERVICE_PORT Port to run the service 8002 USER_SERVICE_URL URL of the user service http://localhost:8004 QUESTION_SERVICE_URL URL of the question service http://localhost:8003 COLLAB_SERVICE_URL URL of the collab service http://localhost:8010 COLLAB_API_KEY API key for the collab service ( used by matching-service for initialising sessions) collab-api-key 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 USER_SERVICE_URL URL of the user service http://localhost:8004
-
-
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 GMAIL_USER Gmail account for verification emails None, you can key in your Gmail account here GMAIL_PASS Gmail password for verification emails None, you can key in your Gmail password here USER_PORT Port to run the service 8004 ENV Environment - determines if secure cookies should be used PROD 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.
- cd into the collab-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 COLLAB_MONGODB_URI MongoDB URI None, commented out. If you are using a remote MongoDB instance, you can key in your connection string here COLLAB_MONGO_INITDB_ROOT_USERNAME MongoDB root username root COLLAB_MONGO_INITDB_ROOT_PASSWORD MongoDB root password password COLLAB_SERVICE_PORT Port to run the service 8010 USER_SERVICE_URL URL of the user service http://localhost:8004 QUESTION_SERVICE_URL URL of the question service http://localhost:8003 COLLAB_REDIS_URL URL of the Redis instance redis://collab-redis:6379 COLLAB_API_KEY API key for the collab service collab-api-key
-
- 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.
Alternatively, you can use the build_and_push_services.sh
or build_and_push_services_dev.sh
script to build and push all services to the Docker image to Docker Hub.
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
Matching Service API
The matching service API can be found here: Matching Service API
Collaboration Service API
The collaboration service API can be found here: Collaboration 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.