Instructions to run PeerPrep on local environment
Pre-requisites
- Install Docker and Docker Compose
- You may want to refer to the installation documemtation on Docker Docs
Steps
- Change endpoints on frontend to local deployments
- Open
./frontend/src/configs.js
- Change deployment URL to
localhost:***
- NOTE: Try not to change the ports, if you must, you will need to update the exposed docker ports in
./docker-compose.yml
as well.
- NOTE: Try not to change the ports, if you must, you will need to update the exposed docker ports in
- Open
- Go to Project Root run
docker compose build --no-cache
docker compose up
- Access local staging application at
localhost:8081
- NOTE: If you changed the ports for frontend, the deployed port will match that port.
- Install Node.js and npm
- You may want to refer to the installation documemtation on npm Docs
- Frontend
- Navigate to frontend directory
cd ./frontend
- Install dependencies
npm install --force
- Change endpoints on frontend to local deployments
- Open
./frontend/src/configs.js
- Change deployment URL to
localhost:***
- Open
- Build
npm run build
- Start frontend
npm start
- Navigate to frontend directory
- User Service
- Navigate to User Service directory
cd ./user-service
- Install dependencies
npm install
- Configure environment variables using
./user-service/.env
file- Refer to
./docker-compose.yml
for environment variables that should be present in./user-service/.env
- Refer to
- Start Service
npm start
- Navigate to User Service directory
- Question Service
- Navigate to Question Service directory
cd ./question-service
- Install dependencies
npm install
- Configure environment variables using
./question-service/.env
file- Refer to
./docker-compose.yml
for environment variables that should be present in./question-service/.env
- Refer to
- Start Service
npm start
- Navigate to Question Service directory
- Matching Service
- Navigate to Matching Service directory
cd ./matching-service
- Install dependencies
npm install
- Configure environment variables using
./matching-service/.env
file- Refer to
./docker-compose.yml
for environment variables that should be present in./matching-service/.env
- Refer to
- Start Service
npm start
- Navigate to Matching Service directory
- Collaboration Service
- Navigate to Collaboration Service directory
cd ./collaboration-service
- Install dependencies
npm install
- Configure environment variables using
./collaboration-service/.env
file- Refer to
./docker-compose.yml
for environment variables that should be present in./collaboration-service/.env
- Refer to
- Start Service
npm start
- Navigate to Collaboration Service directory
- Chat Service
- Navigate to Chat Service directory
cd ./chat-service
- Install dependencies
npm install
- Configure environment variables using
./chat-service/.env
file- Refer to
./docker-compose.yml
for environment variables that should be present in./chat-service/.env
- Refer to
- Start Service
npm start
- Navigate to Chat Service directory
Access the application at http://localhost:8081
or click here
By default, the frontend is pre-configured to connect to the various deployed microservices hosted on AWS. Even if you run the frontend locally, it will connect to the deployed microservices and not the local ones. If you wish to change the deployment endpoints to local instances of the various microservice, here are the steps:
- Locate the frontend configuration file at:
./frontend/src/config.js
- For each service that you wish to change the endpoint,
- Replace the export const variable with the endpoint of your deployed microservice
- e.g. Change
export const USER_SVC_URI_HOSTNAME ="http://cs3219g49-user-service.eba-gsqyhcuy.ap-southeast-1.elasticbeanstalk.com";
toexport const USER_SVC_URI_HOSTNAME = "http://localhost:8000";
- The default endpoints of the microservices have been pre-defined and commented out for your convienence, you may choose to toggle between them using by commenting them instead of redefining
- Please double check the ports of your local endpoints. If you wish to change the ports, please refer to the Ports Reconfiguration section.
Currently, the application is pre-configured for the individual services to be hosted at:
- Frontend-
localhost:8081
- User Service:
localhost:8000
- Question Service:
localhost:3004
- Matching Service:
localhost:3001
- Collaboration Service:
localhost:3002
- Chat Service:
localhost:3003
These ports can be changed, but do require configuration on the users' end.
-
If you are using docker compose:
-
Locate the docker compose file at
./docker-compose.yml
-
Locate the relavant service that you wish to reconfigure
-
Look for the line that maps the container's port to your host OS port
ports: - "3004:3004"
-
Change the first value to the port of your choice
-
-
If you are using a
.env
file:- Set the
PORT
environment variable to that of your choise
- Set the
-
If you are not using a
.env
file:- Locate the startup file in the relavant microservice
server.js
orindex.js
- Locate the line in which the application port is set
- e.g.
const port = process.env.PORT || 3002
- e.g.
- Replace the default port with the port number of your choice
- Locate the startup file in the relavant microservice
-
Lastly, you will need to reconfigure the frontend if you wish to connect to them from the frontend. Refer to the Configuring Frontend section.
Unit tests can be run on the relavant microservices. To do so:
- Change directory to the microservice
- e.g.
cd user-service
- e.g.
- Install dependencies
npm install
- Run tests
npm test
The results of the tests will be displayed in the console.