Skip to content

Commit 44249af

Browse files
authored
Merge pull request #132 from CS3219-AY2425S1/development
Milestone D7
2 parents 0cd61d5 + 015d195 commit 44249af

File tree

256 files changed

+40131
-951
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

256 files changed

+40131
-951
lines changed

.github/workflows/ci.yml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,22 @@ jobs:
2929
run: npm run lint
3030
- name: Test
3131
run: docker compose -f docker-compose-test.yml run --rm test-frontend
32+
# - name: Build
33+
# run: docker compose -f docker-compose-prod.yml build frontend
3234
backend-ci:
3335
runs-on: ubuntu-latest
3436
strategy:
3537
matrix:
36-
service: [question-service, user-service, matching-service]
38+
service:
39+
[
40+
question-service,
41+
user-service,
42+
matching-service,
43+
collab-service,
44+
code-execution-service,
45+
communication-service,
46+
qn-history-service,
47+
]
3748
steps:
3849
- name: Checkout code
3950
uses: actions/checkout@v4
@@ -54,4 +65,7 @@ jobs:
5465
FIREBASE_CLIENT_EMAIL: ${{ secrets.FIREBASE_CLIENT_EMAIL }}
5566
FIREBASE_STORAGE_BUCKET: ${{ secrets.FIREBASE_STORAGE_BUCKET }}
5667
JWT_SECRET: ${{ secrets.JWT_SECRET }}
68+
ONE_COMPILER_KEY: ${{ secrets.ONE_COMPILER_KEY }}
5769
run: docker compose -f docker-compose-test.yml run --rm test-${{ matrix.service }}
70+
# - name: Build
71+
# run: docker compose -f docker-compose-prod.yml build ${{ matrix.service }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ node_modules
1111
dist
1212
dist-ssr
1313
*.local
14+
*.tsbuildinfo
1415

1516
# Coverage
1617
coverage

README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# CS3219 Project (PeerPrep) - AY2425S1 Group 28
22

3+
## Deployment
4+
5+
We deployed PeerPrep on AWS ECS. It is accessible [here](http://peerprep-frontend-alb-1935920115.ap-southeast-1.elb.amazonaws.com/).
6+
37
## Setting up
48

59
We will be using Docker to set up PeerPrep. Install Docker [here](https://docs.docker.com/get-started/get-docker).
@@ -24,9 +28,40 @@ To stop all the services, use the following command:
2428
docker-compose down
2529
```
2630

31+
## Running in Production Mode
32+
33+
1. Build all the services (without using cache).
34+
35+
```
36+
docker-compose -f docker-compose-prod.yml build --no-cache
37+
```
38+
39+
2. Run all the services (in detached mode).
40+
41+
```
42+
docker-compose -f docker-compose-prod.yml up -d
43+
```
44+
45+
To stop all the services, use the following command:
46+
47+
```
48+
docker-compose -f docker-compose-prod.yml down
49+
```
50+
2751
## Useful links
2852

2953
- User Service: http://localhost:3001
54+
3055
- Question Service: http://localhost:3000
56+
3157
- Matching Service: http://localhost:3002
58+
59+
- Collab Service: http://localhost:3003
60+
61+
- Code Execution Service: http://localhost:3004
62+
63+
- Communication Service: http://localhost:3005
64+
65+
- Question History Service: http://localhost:3006
66+
3267
- Frontend: http://localhost:5173

backend/README.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,23 @@
22

33
> Before proceeding to each microservice for more instructions:
44
5-
1. Set up cloud MongoDB if 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. Else, if you are using docker-compose.yml to run PeerPrep, check out the READMEs in the different backend microservices to set up the env for the local MongoDB instances.
5+
1. 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.
66

77
2. Set up Firebase.
88

9-
3. Follow the instructions [here](https://nodejs.org/en/download/package-manager) to set up Node v20.
9+
3. For the microservices that use Redis, to view the contents stored:
10+
11+
1. Go to [http://localhost:5540](http://localhost:5540).
12+
13+
2. Click on "Add Redis Database".
14+
15+
3. Enter `host.docker.internal` as the Host.
16+
17+
4. Enter the port used by the respective service:
18+
- User Service: `6379`
19+
- Collab Service: `6380`
20+
21+
4. Follow the instructions [here](https://nodejs.org/en/download/package-manager) to set up Node v20.
1022

1123
## Setting-up cloud MongoDB (in production)
1224

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
coverage
2+
node_modules
3+
tests
4+
.env*
5+
*.md
6+
dist
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
NODE_ENV=development
2+
SERVICE_PORT=3004
3+
4+
# Origins for cors
5+
ORIGINS=http://localhost:5173,http://127.0.0.1:5173
6+
7+
# Other service APIs
8+
QUESTION_SERVICE_URL=http://question-service:3000/api/questions
9+
10+
# One Compiler configuration
11+
ONE_COMPILER_URL=https://onecompiler-apis.p.rapidapi.com/api/v1/run
12+
ONE_COMPILER_KEY=<ONE_COMPILER_KEY>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
FROM node:20-alpine AS base
2+
3+
WORKDIR /code-execution-service
4+
5+
COPY package*.json .
6+
7+
RUN npm ci
8+
9+
COPY . .
10+
11+
EXPOSE 3004
12+
13+
# DEV
14+
15+
FROM base AS dev
16+
17+
CMD ["npm", "run", "dev"]
18+
19+
# PROD
20+
21+
FROM base AS prod
22+
23+
RUN npm run build
24+
25+
CMD ["npm", "start"]
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Code Execution Service Guide
2+
3+
## Setting-up Code Execution Service
4+
5+
1. In the `code-execution-service` directory, create a copy of the `.env.sample` file and name it `.env`.
6+
7+
2. Sign up for a free OneCompiler API [here](https://rapidapi.com/onecompiler-onecompiler-default/api/onecompiler-apis).
8+
9+
3. Update `ONE_COMPILER_KEY` in the `.env` file with the value of `x-rapidapi-key`.
10+
11+
## Running Code Execution Service Locally
12+
13+
1. Open Command Line/Terminal and navigate into the `code-execution-service` directory.
14+
15+
2. Run the command: `npm install`. This will install all the necessary dependencies.
16+
17+
3. Run the command `npm start` to start the Code Execution Service in production mode, or use `npm run dev` for development mode, which includes features like automatic server restart when you make code changes.
18+
19+
## Running Code Execution Service with Docker
20+
21+
1. Open the Command Line/Terminal.
22+
23+
2. Run the command `docker compose run code-execution-service` to start up the Code Execution Service and its dependencies.
24+
25+
## After running
26+
27+
1. To view Code Execution Service documentation, go to http://localhost:3004/docs.
28+
29+
2. Using applications like Postman, you can interact with the Code Execution Service on port 3004. If you wish to change this, please update the `.env` file.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import globals from "globals";
2+
import pluginJs from "@eslint/js";
3+
import tseslint from "typescript-eslint";
4+
5+
export default [
6+
{ files: ["**/*.{js,mjs,cjs,ts}"] },
7+
{ languageOptions: { globals: globals.node } },
8+
pluginJs.configs.recommended,
9+
...tseslint.configs.recommended,
10+
];

0 commit comments

Comments
 (0)