This file contains instructions on how to build and run all microservices, as well as the client. Do follow the instructions strictly to ensure that the applications are started successfully.
We will be using Docker to containerise our applications.
If you don't already have Docker installed, download the right version of Docker corresponding to the machine you are using and complete the Docker installation.
After you have successfully downloaded and installed Docker, run the Docker Desktop application.
Before running the application in any environment, please follow the steps mentioned below to set up our application on your machine of choice. You will need accounts with ElephantSQL, MongoDB, CloudAMPQ, and RapidAPI to set up our project locally.
- Inside the
./client
folder, create a file called .env which contains the following variables (make sure you add the . in front of “env”)
VITE_USER_BASE_PATH=http://localhost:8000/api
VITE_QUESTION_BASE_PATH=http://localhost:3000/api/questions
VITE_MATCHING_ENDPOINT=http://localhost:5001
VITE_HISTORY_BASE_PATH=http://localhost:3001/api
VITE_CODE_EXECUTION_BASE_PATH=http://localhost:5002/api
VITE_COLLABORATION_BASE_PATH=http://localhost:8001
VITE_COLLABORATION_WS_ORIGIN=ws://localhost:8002
In the ./src/user-service folder
, create 2 files called
.env.local
which contain the following variables
PORT=8000
PSQL_HOST=rain.db.elephantsql.com
PSQL_PASSWORD=<Elephant SQL account password>
PSQL_USER=<Elephant SQL account>
PSQL_DATABASE=<Elephant SQL database name>
ACCESS_TOKEN_SECRET=<your own access token secret>
.env.docker
which contain the following variables
PORT=8000
PSQL_HOST=rain.db.elephantsql.com
PSQL_PASSWORD=<Elephant SQL account password>
PSQL_USER=<Elephant SQL account>
PSQL_DATABASE=<Elephant SQL database name>
ACCESS_TOKEN_SECRET=<your own access token secret>
In the ./src/question-service
folder, create 2 files called
.env.local
which contain the following variables
PORT=3000
QUESTION_DATABASE_URL=<A MongoDB URL>
USER_BASE_PATH=http://localhost:8000/api
.env.docker
which contains the following variables
PORT=3000
QUESTION_DATABASE_URL=<A MongoDB URL>
USER_BASE_PATH=http://user-service:8000/api
In the ./src/matching-service
folder, create 2 files called
.env.local
which contain the following variables
PORT=5001
AMPQ_HOST=<A CloudAMPQ instance URL>
.env.docker
which contains the following variables
PORT=5001
AMPQ_HOST=<A CloudAMPQ instance URL>
In the ./src/collaboration-service
folder, create 2 files called
.env.local
which contain the following variables
PORT=8001
COLLABORATION_DATABASE_URL=<A MongoDB URL>
USER_BASE_PATH=http://localhost:8000/api
.env.docker
which contains the following variables
PORT=8001
COLLABORATION_DATABASE_URL=<A MongoDB URL>
USER_BASE_PATH=http://user-service:8000/api
In the ./src/history-service
folder, create 2 files called
.env.local
which contains the following variables
PORT=3001
HISTORY_DATABASE_URL=<A MongoDB URL>
USER_BASE_PATH=http://localhost:8000/api
.env.docker
which contains the following variables
PORT=3001
HISTORY_DATABASE_URL=<A MongoDB URL>
USER_BASE_PATH=http://user-service:8000/api
In the ./src/code-execution-service
folder, create 2 files called
.env.local
which contain the following variables
REACT_APP_RAPID_API_HOST="judge0-ce.p.rapidapi.com"
REACT_APP_RAPID_API_KEY=<Rapid API Key> // TODO
REACT_APP_RAPID_API_URL="https://judge0-ce.p.rapidapi.com"
USER_BASE_PATH=http://localhost:8000/api
.env.docker
which contain the following variables
REACT_APP_RAPID_API_HOST="judge0-ce.p.rapidapi.com"
REACT_APP_RAPID_API_KEY=<Rapid API Key>
REACT_APP_RAPID_API_URL="https://judge0-ce.p.rapidapi.com"
USER_BASE_PATH=http://user-service:8000/api
-
Open Docker and ensure that the Docker Engine is up and running.
-
Ensure that you are in the root folder of our application.
-
Run the commands below depending on your OS. You should see all the microservices running in their individual containers on the Docker Desktop and you are good to go!
-
Windows (Powershell):
$env:PEERPREP_ENV="docker"; docker compose up
. -
Unix:
PEERPREP_ENV=docker docker compose up
-
Do the same checks for the URLs mentioned above. This time, everything supposed to be set to using localhost.
-
Ensure that you are in the root folder of our application.
-
Run
npm i concurrently
if you don't have Concurrently installed. -
Run
npm run install-all
which will runnpm i
in each individual microservice. -
Run the commands below depending on your OS, which will run
npm run dev
in each individual microservice.-
Windows (Powershell):
$env:PEERPREP_ENV="local"; npm run dev-all
. -
Unix:
PEERPREP_ENV=local npm run dev-all
-
That's it! Happy coding!