Skip to content

Commit

Permalink
Merge pull request #132 from CS3219-AY2425S1/development
Browse files Browse the repository at this point in the history
Milestone D7
  • Loading branch information
jolynloh authored Nov 13, 2024
2 parents 0cd61d5 + 015d195 commit 44249af
Show file tree
Hide file tree
Showing 256 changed files with 40,131 additions and 951 deletions.
16 changes: 15 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,22 @@ jobs:
run: npm run lint
- name: Test
run: docker compose -f docker-compose-test.yml run --rm test-frontend
# - name: Build
# run: docker compose -f docker-compose-prod.yml build frontend
backend-ci:
runs-on: ubuntu-latest
strategy:
matrix:
service: [question-service, user-service, matching-service]
service:
[
question-service,
user-service,
matching-service,
collab-service,
code-execution-service,
communication-service,
qn-history-service,
]
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -54,4 +65,7 @@ jobs:
FIREBASE_CLIENT_EMAIL: ${{ secrets.FIREBASE_CLIENT_EMAIL }}
FIREBASE_STORAGE_BUCKET: ${{ secrets.FIREBASE_STORAGE_BUCKET }}
JWT_SECRET: ${{ secrets.JWT_SECRET }}
ONE_COMPILER_KEY: ${{ secrets.ONE_COMPILER_KEY }}
run: docker compose -f docker-compose-test.yml run --rm test-${{ matrix.service }}
# - name: Build
# run: docker compose -f docker-compose-prod.yml build ${{ matrix.service }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ node_modules
dist
dist-ssr
*.local
*.tsbuildinfo

# Coverage
coverage
Expand Down
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CS3219 Project (PeerPrep) - AY2425S1 Group 28

## Deployment

We deployed PeerPrep on AWS ECS. It is accessible [here](http://peerprep-frontend-alb-1935920115.ap-southeast-1.elb.amazonaws.com/).

## Setting up

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

## Running in Production Mode

1. Build all the services (without using cache).

```
docker-compose -f docker-compose-prod.yml build --no-cache
```

2. Run all the services (in detached mode).

```
docker-compose -f docker-compose-prod.yml up -d
```

To stop all the services, use the following command:

```
docker-compose -f docker-compose-prod.yml down
```

## Useful links

- User Service: http://localhost:3001

- Question Service: http://localhost:3000

- Matching Service: http://localhost:3002

- Collab Service: http://localhost:3003

- Code Execution Service: http://localhost:3004

- Communication Service: http://localhost:3005

- Question History Service: http://localhost:3006

- Frontend: http://localhost:5173
16 changes: 14 additions & 2 deletions backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,23 @@

> Before proceeding to each microservice for more instructions:
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.
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.

2. Set up Firebase.

3. Follow the instructions [here](https://nodejs.org/en/download/package-manager) to set up Node v20.
3. For the microservices that use Redis, to view the contents stored:

1. Go to [http://localhost:5540](http://localhost:5540).

2. Click on "Add Redis Database".

3. Enter `host.docker.internal` as the Host.

4. Enter the port used by the respective service:
- User Service: `6379`
- Collab Service: `6380`

4. Follow the instructions [here](https://nodejs.org/en/download/package-manager) to set up Node v20.

## Setting-up cloud MongoDB (in production)

Expand Down
6 changes: 6 additions & 0 deletions backend/code-execution-service/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
coverage
node_modules
tests
.env*
*.md
dist
12 changes: 12 additions & 0 deletions backend/code-execution-service/.env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
NODE_ENV=development
SERVICE_PORT=3004

# Origins for cors
ORIGINS=http://localhost:5173,http://127.0.0.1:5173

# Other service APIs
QUESTION_SERVICE_URL=http://question-service:3000/api/questions

# One Compiler configuration
ONE_COMPILER_URL=https://onecompiler-apis.p.rapidapi.com/api/v1/run
ONE_COMPILER_KEY=<ONE_COMPILER_KEY>
25 changes: 25 additions & 0 deletions backend/code-execution-service/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
FROM node:20-alpine AS base

WORKDIR /code-execution-service

COPY package*.json .

RUN npm ci

COPY . .

EXPOSE 3004

# DEV

FROM base AS dev

CMD ["npm", "run", "dev"]

# PROD

FROM base AS prod

RUN npm run build

CMD ["npm", "start"]
29 changes: 29 additions & 0 deletions backend/code-execution-service/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Code Execution Service Guide

## Setting-up Code Execution Service

1. In the `code-execution-service` directory, create a copy of the `.env.sample` file and name it `.env`.

2. Sign up for a free OneCompiler API [here](https://rapidapi.com/onecompiler-onecompiler-default/api/onecompiler-apis).

3. Update `ONE_COMPILER_KEY` in the `.env` file with the value of `x-rapidapi-key`.

## Running Code Execution Service Locally

1. Open Command Line/Terminal and navigate into the `code-execution-service` directory.

2. Run the command: `npm install`. This will install all the necessary dependencies.

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.

## Running Code Execution Service with Docker

1. Open the Command Line/Terminal.

2. Run the command `docker compose run code-execution-service` to start up the Code Execution Service and its dependencies.

## After running

1. To view Code Execution Service documentation, go to http://localhost:3004/docs.

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.
10 changes: 10 additions & 0 deletions backend/code-execution-service/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import globals from "globals";
import pluginJs from "@eslint/js";
import tseslint from "typescript-eslint";

export default [
{ files: ["**/*.{js,mjs,cjs,ts}"] },
{ languageOptions: { globals: globals.node } },
pluginJs.configs.recommended,
...tseslint.configs.recommended,
];
Loading

0 comments on commit 44249af

Please sign in to comment.