Skip to content

Commit d99ffbc

Browse files
authored
Merge pull request #82 from CS3219-AY2425S1/staging
feat: D5 to D7
2 parents 217dc99 + 60f044f commit d99ffbc

File tree

193 files changed

+15830
-1441
lines changed

Some content is hidden

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

193 files changed

+15830
-1441
lines changed

.github/workflows/test.yml

Lines changed: 159 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,82 @@ on:
1010
branches:
1111
- main
1212
- staging
13+
workflow_dispatch:
1314

1415
jobs:
15-
test:
16+
question-service-tests:
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v2
22+
23+
- name: Set up .env
24+
env:
25+
QUESTION_FIREBASE_CREDENTIAL_PATH: ${{ vars.QUESTION_SERVICE_FIREBASE_CREDENTIAL_PATH }}
26+
JWT_SECRET: ${{ secrets.JWT_SECRET }}
27+
EXECUTION_SERVICE_URL: ${{ vars.EXECUTION_SERVICE_URL }}
28+
run: |
29+
cd ./apps/question-service
30+
echo "FIREBASE_CREDENTIAL_PATH=$QUESTION_FIREBASE_CREDENTIAL_PATH" >> .env
31+
echo "JWT_SECRET=$JWT_SECRET" >> .env
32+
echo "EXECUTION_SERVICE_URL=$EXECUTION_SERVICE_URL" >> .env
33+
34+
- name: Set up credentials
35+
env:
36+
QUESTION_FIREBASE_JSON: ${{ secrets.QUESTION_SERVICE_FIREBASE_CREDENTIAL }}
37+
QUESTION_FIREBASE_CREDENTIAL_PATH: ${{ vars.QUESTION_SERVICE_FIREBASE_CREDENTIAL_PATH }}
38+
run: |
39+
cd ./apps/question-service
40+
echo "$QUESTION_FIREBASE_JSON" > "./$QUESTION_FIREBASE_CREDENTIAL_PATH"
41+
42+
- name: Setup Go
43+
uses: actions/setup-go@v5
44+
with:
45+
go-version: '1.23.x'
46+
47+
- name: Install Go dependencies
48+
run: |
49+
cd ./apps/question-service
50+
go mod tidy
51+
52+
- name: Install firebase tools
53+
run: curl -sL firebase.tools | bash
54+
55+
- name: Run Go tests with Firebase emulator
56+
run: firebase emulators:exec --only firestore 'cd ./apps/question-service; go test -v ./tests'
57+
58+
frontend-unit-tests:
59+
runs-on: ubuntu-latest
60+
61+
steps:
62+
- name: Checkout repository
63+
uses: actions/checkout@v2
64+
65+
- name: Setup .env
66+
run: |
67+
cd ./apps/frontend
68+
cp .env.example .env
69+
70+
- name: Set up Node.js
71+
uses: actions/setup-node@v2
72+
with:
73+
node-version: '22'
74+
75+
- name: Install pnpm
76+
run: npm i -g pnpm
77+
78+
- name: Install dependencies
79+
run: |
80+
cd ./apps/frontend
81+
pnpm i
82+
83+
- name: Run tests
84+
run: |
85+
cd ./apps/frontend
86+
pnpm unit-test
87+
88+
test-docker-compose:
1689
runs-on: ubuntu-latest
1790

1891
steps:
@@ -29,22 +102,36 @@ jobs:
29102
QUESTION_SERVICE_URL: ${{ vars.QUESTION_SERVICE_URL }}
30103
USER_SERVICE_URL: ${{ vars.USER_SERVICE_URL }}
31104
MATCHING_SERVICE_URL: ${{ vars.MATCHING_SERVICE_URL }}
105+
HISTORY_SERVICE_URL: ${{ vars.HISTORY_SERVICE_URL }}
106+
SIGNALLING_SERVICE_URL: ${{ vars.SIGNALLING_SERVICE_URL }}
107+
EXECUTION_SERVICE_URL: ${{ vars.EXECUTION_SERVICE_URL }}
32108
JWT_SECRET: ${{ secrets.JWT_SECRET }}
33-
FIREBASE_CREDENTIAL_PATH: ${{ vars.QUESTION_SERVICE_FIREBASE_CREDENTIAL_PATH }}
109+
QUESTION_FIREBASE_CREDENTIAL_PATH: ${{ vars.QUESTION_SERVICE_FIREBASE_CREDENTIAL_PATH }}
110+
HISTORY_FIREBASE_CREDENTIAL_PATH: ${{ vars.HISTORY_SERVICE_FIREBASE_CREDENTIAL_PATH }}
111+
EXECUTION_FIREBASE_CREDENTIAL_PATH: ${{ vars.EXECUTION_SERVICE_FIREBASE_CREDENTIAL_PATH }}
34112
DB_CLOUD_URI: ${{ secrets.USER_SERVICE_DB_CLOUD_URI }}
35113
USER_SERVICE_PORT: ${{ vars.USER_SERVICE_PORT }}
36114
MATCHING_SERVICE_PORT: ${{ vars.MATCHING_SERVICE_PORT }}
115+
HISTORY_SERVICE_PORT: ${{ vars.HISTORY_SERVICE_PORT }}
116+
SIGNALLING_SERVICE_PORT: ${{ vars.SIGNALLING_SERVICE_PORT }}
117+
EXECUTION_SERVICE_PORT: ${{ vars.EXECUTION_SERVICE_PORT }}
37118
MATCHING_SERVICE_TIMEOUT: ${{ vars.MATCHING_SERVICE_TIMEOUT }}
38119
REDIS_URL: ${{ vars.REDIS_URL }}
120+
RABBITMQ_URL: ${{ vars.RABBITMQ_URL }}
121+
QUESTION_SERVICE_GRPC_URL: ${{ vars.QUESTION_SERVICE_GPRC_URL }}
39122
run: |
40123
cd ./apps/frontend
41124
echo "NEXT_PUBLIC_QUESTION_SERVICE_URL=$QUESTION_SERVICE_URL" >> .env
42125
echo "NEXT_PUBLIC_USER_SERVICE_URL=$USER_SERVICE_URL" >> .env
43126
echo "NEXT_PUBLIC_MATCHING_SERVICE_URL=$MATCHING_SERVICE_URL" >> .env
127+
echo "NEXT_PUBLIC_HISTORY_SERVICE_URL=$HISTORY_SERVICE_URL" >> .env
128+
echo "NEXT_PUBLIC_SIGNALLING_SERVICE_URL=$SIGNALLING_SERVICE_URL" >> .env
129+
echo "NEXT_PUBLIC_EXECUTION_SERVICE_URL=EXECUTION_SERVICE_URL" >> .env
44130
45131
cd ../question-service
46-
echo "FIREBASE_CREDENTIAL_PATH=$FIREBASE_CREDENTIAL_PATH" >> .env
132+
echo "FIREBASE_CREDENTIAL_PATH=$QUESTION_FIREBASE_CREDENTIAL_PATH" >> .env
47133
echo "JWT_SECRET=$JWT_SECRET" >> .env
134+
echo "EXECUTION_SERVICE_URL=$EXECUTION_SERVICE_URL" >> .env
48135
49136
cd ../user-service
50137
echo "DB_CLOUD_URI=$DB_CLOUD_URI" >> .env
@@ -56,14 +143,39 @@ jobs:
56143
echo "MATCH_TIMEOUT=$MATCHING_SERVICE_TIMEOUT" >> .env
57144
echo "JWT_SECRET=$JWT_SECRET" >> .env
58145
echo "REDIS_URL=$REDIS_URL" >> .env
146+
echo "QUESTION_SERVICE_GRPC_URL=$QUESTION_SERVICE_GRPC_URL" >> .env
147+
148+
cd ../history-service
149+
echo "FIREBASE_CREDENTIAL_PATH=$HISTORY_FIREBASE_CREDENTIAL_PATH" >> .env
150+
echo "PORT=$HISTORY_SERVICE_PORT" >> .env
151+
echo "RABBMITMQ_URL=$RABBITMQ_URL" >> .env
152+
153+
cd ../execution-service
154+
echo "FIREBASE_CREDENTIAL_PATH=$EXECUTION_FIREBASE_CREDENTIAL_PATH" >> .env
155+
echo "PORT=$EXECUTION_SERVICE_PORT" >> .env
156+
echo "HISTORY_SERVICE_URL=$HISTORY_SERVICE_URL" >> .env
157+
echo "RABBMITMQ_URL=$RABBITMQ_URL" >> .env
158+
159+
cd ../signalling-service
160+
echo "PORT=$SIGNALLING_SERVICE_PORT" >> .env
59161
60162
- name: Create Database Credential Files
61163
env:
62-
FIREBASE_JSON: ${{ secrets.QUESTION_SERVICE_FIREBASE_CREDENTIAL }}
63-
FIREBASE_CREDENTIAL_PATH: ${{ vars.QUESTION_SERVICE_FIREBASE_CREDENTIAL_PATH }}
164+
QUESTION_FIREBASE_JSON: ${{ secrets.QUESTION_SERVICE_FIREBASE_CREDENTIAL }}
165+
QUESTION_FIREBASE_CREDENTIAL_PATH: ${{ vars.QUESTION_SERVICE_FIREBASE_CREDENTIAL_PATH }}
166+
HISTORY_FIREBASE_JSON: ${{ secrets.HISTORY_SERVICE_FIREBASE_CREDENTIAL }}
167+
HISTORY_FIREBASE_CREDENTIAL_PATH: ${{ vars.HISTORY_SERVICE_FIREBASE_CREDENTIAL_PATH }}
168+
EXECUTION_FIREBASE_JSON: ${{ secrets.EXECUTION_SERVICE_FIREBASE_CREDENTIAL }}
169+
EXECUTION_FIREBASE_CREDENTIAL_PATH: ${{ vars.EXECUTION_SERVICE_FIREBASE_CREDENTIAL_PATH }}
64170
run: |
65171
cd ./apps/question-service
66-
echo "$FIREBASE_JSON" > "./$FIREBASE_CREDENTIAL_PATH"
172+
echo "$QUESTION_FIREBASE_JSON" > "./$QUESTION_FIREBASE_CREDENTIAL_PATH"
173+
174+
cd ../history-service
175+
echo "$HISTORY_FIREBASE_JSON" > "./$HISTORY_FIREBASE_CREDENTIAL_PATH"
176+
177+
cd ../execution-service
178+
echo "$EXECUTION_FIREBASE_JSON" > "./$EXECUTION_FIREBASE_CREDENTIAL_PATH"
67179
68180
- name: Build and Run Services
69181
run: |
@@ -85,19 +197,59 @@ jobs:
85197
USER_SERVICE_URL: ${{ vars.USER_SERVICE_URL }}
86198
QUESTION_SERVICE_URL: ${{ vars.QUESTION_SERVICE_URL }}
87199
MATCHING_SERVICE_URL: ${{ vars.MATCHING_SERVICE_URL }}
200+
HISTORY_SERVICE_URL: ${{ vars.HISTORY_SERVICE_URL }}
201+
SIGNALLING_SERVICE_URL: ${{ vars.SIGNALLING_SERVICE_URL }}
202+
EXECUTION_SERVICE_URL: ${{ vars.EXECUTION_SERVICE_URL }}
88203
run: |
204+
docker ps -a
89205
echo "Testing Question Service..."
90206
curl -sSL -o /dev/null $QUESTION_SERVICE_URL && echo "Question Service is up"
91207
echo "Testing User Service..."
92208
curl -fsSL -o /dev/null $USER_SERVICE_URL && echo "User Service is up"
93209
echo "Testing Frontend..."
94210
curl -fsSL -o /dev/null $FRONTEND_URL && echo "Frontend is up"
211+
echo "Testing History Service..."
212+
curl -fsSL -o /dev/null $HISTORY_SERVICE_URL && echo "History Service is up"
213+
echo "Testing Execution Service..."
214+
curl -fsSL -o /dev/null $EXECUTION_SERVICE_URL && echo "Execution Service is up"
95215
echo "Testing Matching Service..."
96216
if ! (echo "Hello" | websocat $MATCHING_SERVICE_URL); then
97217
echo "WebSocket for Matching Service is not live"
98218
else
99219
echo "WebSocket for Matching Service is live"
100220
fi
101221
# Add in test for matching service in the future
102-
222+
echo "Testing Signalling Service..."
223+
if ! (echo "Hello" | websocat $SIGNALLING_SERVICE_URL); then
224+
echo "WebSocket for Signalling Service is not live"
225+
else
226+
echo "WebSocket for Signalling Service is live"
227+
fi
103228
# We can add more tests here
229+
230+
- name: Install pnpm
231+
uses: pnpm/action-setup@v4
232+
with:
233+
version: 9.1.4
234+
235+
- name: Install dependencies
236+
run: |
237+
cd ./apps/frontend
238+
pnpm i
239+
240+
- name: Install Chrome WebDriver
241+
uses: nanasess/setup-chromedriver@v2
242+
with:
243+
chromedriver-version: '130.0.6723.116'
244+
- name: Install Edge
245+
uses: browser-actions/setup-edge@v1
246+
with:
247+
edge-version: stable
248+
249+
- name: Install Geckodriver
250+
uses: browser-actions/setup-geckodriver@latest
251+
252+
- name: Run Browser Test
253+
run: |
254+
cd ./apps/frontend
255+
pnpm browser-test

README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,38 @@
99
- You can choose to develop individual microservices within separate folders within this repository **OR** use individual repositories (all public) for each microservice.
1010
- In the latter scenario, you should enable sub-modules on this GitHub classroom repository to manage the development/deployment **AND** add your mentor to the individual repositories as a collaborator.
1111
- The teaching team should be given access to the repositories as we may require viewing the history of the repository in case of any disputes or disagreements.
12+
13+
---
14+
15+
## Architecture Diagram
16+
17+
![Overall Architecture Diagram](./docs/architecture_diagram.png)
18+
19+
The overall architecture of PeerPrep follows a microservices architecture. The client acts as an orchestrator for the interaction between the different services.
20+
21+
## Screenshots
22+
23+
![Home Page](./docs/home_page.png)
24+
25+
![Collaboration Page](./docs/collab_page_1.png)
26+
27+
![Collaboration Page](./docs/collab_page_2.png)
28+
29+
![Question Page](./docs/question_page.png)
30+
31+
![Question Page](./docs/indiv_question_page.png)
32+
33+
![History Page](./docs/submission_history_page.png)
34+
35+
## More details
36+
37+
- [Frontend](./apps/frontend/README.md)
38+
- [User Service](./apps/user-service/README.md)
39+
- [Question Service](./apps/question-service/README.md)
40+
- [Matching Service](./apps/matching-service/README.md)
41+
- [Signalling Service](./apps/signalling-service/README.md)
42+
- [History Service](./apps/history-service/README.md)
43+
- [Execution Service](./apps/execution-service/README.md)
44+
- [CI/CD Guide](./docs/cicid.md)
45+
- [Docker Compose Guide](./apps/README.md)
46+
- [Set Up Guide](./docs/setup.md)

apps/README.md

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
This project uses Docker Compose to manage multiple services such as a frontend, backend, and a database. The configuration is defined in the `docker-compose.yml` file, and environment variables can be stored in environment files for different environments (e.g., development, production).
44

5+
More details on how to set up Docker Compose can be found [here](../docs/setup.md)
6+
57
## Prerequisites
68

79
Before you begin, ensure you have the following installed on your machine:
@@ -30,11 +32,25 @@ In the `./apps` directory:
3032
├── user-service
3133
│ ├── Dockerfile # Dockerfile for user-service
3234
│ └── ... (other user-service files)
33-
35+
├── execution-service
36+
│ ├── Dockerfile # Dockerfile for execution-service
37+
│ └── ... (other execution-service files)
38+
├── signalling-service
39+
│ ├── Dockerfile # Dockerfile for signalling-service
40+
│ └── ... (other signalling-service files)
41+
├── history-service
42+
│ ├── Dockerfile # Dockerfile for history-service
43+
│ └── ... (other history-service files)
3444
```
3545

3646
## Docker Compose Setup
3747

48+
Ensure that you are currently using **Docker Compose v2** in your local Docker Desktop.
49+
- Launch your local Docker Desktop application
50+
- Click on settings button at the top right hand corner (beside the name)
51+
- Under the General tab, scroll down until you see a checkbox that says Use Docker Compose V2, ensure that the box is checked then apply and restart (refer to the image below)
52+
![Docker Compose V2](https://github.com/user-attachments/assets/3b8d47c2-c488-4fc1-804d-418ffebbdd9c)
53+
3854
By using multiple Dockerfiles in Docker Compose, we can manage complex multi-container applications where each service has its own environment and build process.
3955

4056
1. Build and Start the Application
@@ -54,11 +70,15 @@ This will:
5470

5571
Once running, you can access:
5672

57-
- The **frontend** at http://localhost:3000
58-
- The **user service** at http://localhost:3001
59-
- The **question service** at http://localhost:8080
60-
- The **matching service** at http://localhost:8081
61-
- The **redis service** at http://localhost:6379
73+
- The [**frontend**](./frontend/README.md) at http://localhost:3000
74+
- The [**user-service**](./user-service/README.md) at http://localhost:3001
75+
- The [**question-service**](./question-service/README.md) at http://localhost:8080 (REST) and http://localhost:50051 (gRPC)
76+
- The [**matching-service**](./matching-service/README.md) at http://localhost:8081
77+
- The [**history-service**](./history-service/README.md) at http://localhost:8082
78+
- The [**execution-service**](./execution-service/README.md) at http://localhost:8083
79+
- The [**signalling-service**](./signalling-service/README.md) at http://localhost:4444
80+
- The **redis** at http://localhost:6379
81+
- The **rabbitmq** at http://localhost:5672
6282

6383
3. Stopping Services
6484

@@ -76,6 +96,11 @@ This command will stop and remove the containers, networks, and volumes created
7696

7797
- **Port Conflicts**: If you encounter port conflicts, ensure the host ports specified in docker-compose.yml (e.g., 3000:3000) are not in use by other applications.
7898
- **Environment Variables Not Loaded**: Ensure the `.env` files are in the correct directories as found in the `docker-compose.yml` file.
99+
- **Command execution failed**: When you try running test cases or submitting the code in the collaborative environment, if you encounter the following error message:
100+
```bash
101+
Command execution failed: Unable to find image 'apps-python-sandbox:latest' locally docker: Error response from daemon: pull access denied for apps-python-sandbox, repository does not exist or may require 'docker login': denied: requested access to the resource is denied. See 'docker run --help'. : exit status 125
102+
```
103+
Ensure that you have **Docker Compose V2** enabled for your Docker Desktop application. Please refer to the Docker Compose setup guide above to enable it locally.
79104

80105
### Known Issues
81106

0 commit comments

Comments
 (0)