Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feedback #1

Open
wants to merge 484 commits into
base: feedback
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
484 commits
Select commit Hold shift + click to select a range
71effb2
Update package files for frontend
tsulim Oct 20, 2024
bb834c9
Print the number of users in the queue when cancelling the match
Oct 20, 2024
8065040
Merge pull request #55 from AndrewOng2066/matching_final
AndrewOng2066 Oct 20, 2024
be63996
Add api to get a random question for specified fields
tsulim Oct 20, 2024
25e1e9e
Add question service to fetch random question
tsulim Oct 20, 2024
8d439fe
Add temporary match controller
tsulim Oct 20, 2024
2f91192
Add `index.js` for collaboration service
tsulim Oct 20, 2024
cfe5893
Update package files for collaboration service
tsulim Oct 20, 2024
9990ef4
Add `socketHandler` for collaboration service
tsulim Oct 20, 2024
a7411bd
Remove controller for collaboration service
tsulim Oct 20, 2024
abb7724
Add `.env.sample` for all services and frontend
tsulim Oct 20, 2024
e32c2ab
Remove route for collaboration service
tsulim Oct 20, 2024
fd98887
Shift `TempMatchPage` from `collaboration` to `matching` folder
tsulim Oct 20, 2024
0287ed8
Modify indentations to 2 spaces
tsulim Oct 20, 2024
da0d49d
Change logging messages
Oct 20, 2024
b87fb13
Merge pull request #56 from AndrewOng2066/matching_final
AndrewOng2066 Oct 20, 2024
8013e2b
Fix finding match refresh bug
iynixil Oct 20, 2024
f010142
Merge remote-tracking branch 'upstream/matching_Andrew' into matching…
iynixil Oct 20, 2024
9f0d88b
Edit page refresh return string on match found page
iynixil Oct 20, 2024
156423a
Remove clear queue function in queueController
iynixil Oct 20, 2024
80ac158
Update matching service dockerfile comment
iynixil Oct 20, 2024
4380ab1
Update removal of clear queue function in socketHandler
iynixil Oct 20, 2024
555291d
Update queueController to remove clear queue function
iynixil Oct 20, 2024
4a6e591
Remove unnecessary code in queueController
iynixil Oct 20, 2024
ac25b05
Merge pull request #54 from CS3219-AY2425S1/matching-service-xy
xuelinglow Oct 20, 2024
8691d28
Merge branch 'matching-service-xy' into collaboration-service-tsu
tsulim Oct 20, 2024
d1f06ed
Remove duplicate route
tsulim Oct 20, 2024
2fe269c
Merge pull request #20 from CS3219-AY2425S1/main
AndrewOng2066 Oct 20, 2024
9a155f7
Change the sequence of values for the hostname
Oct 20, 2024
405c16d
Implement code editor into collaboration service
xuelinglow Oct 21, 2024
9291136
Implement tabs to change between code editor and content editor
xuelinglow Oct 21, 2024
d12cfec
Handle different coding languages in code editor
xuelinglow Oct 21, 2024
ff93c6e
Remove unused rabbitmq
tsulim Oct 23, 2024
f0dd450
Remove temporary match files used for collab
tsulim Oct 23, 2024
4be9e35
Merge pull request #57 from CS3219-AY2425S1/collaboration-service-tsu
tsulim Oct 23, 2024
b73c52c
Combine `socket.js` contents
tsulim Oct 23, 2024
8adc9c3
Update `.env.sample` files
tsulim Oct 23, 2024
4692a56
Rename `HOSTNAME` to `RABBIT_HOSTNAME` in `rabbitMQ.js`
tsulim Oct 23, 2024
25e7379
Add `useSessionStorage`
tsulim Oct 23, 2024
81a11bf
Combine `usePersistState` into `useLocalStorage`
tsulim Oct 23, 2024
51134b9
Integrate `collaboration-service` with `matching-service`
tsulim Oct 23, 2024
3c21438
Merge pull request #60 from CS3219-AY2425S1/collaboration-service-tsu
tsulim Oct 23, 2024
746e2bf
Update `docker-compose`
tsulim Oct 23, 2024
6d722c5
Merge pull request #68 from CS3219-AY2425S1/collaboration-service-tsu
tsulim Oct 23, 2024
8982f0d
send updates to databse
whitesnowx Oct 24, 2024
164aab1
store latest content to database
whitesnowx Oct 24, 2024
3b23b9b
only upstate when there is content to update
whitesnowx Oct 24, 2024
0689506
fix update content for each room seperately
whitesnowx Oct 24, 2024
863371b
remove excess db firebase
whitesnowx Oct 24, 2024
0d9fb17
Merge branch 'collaboration-service' of https://github.com/CS3219-AY2…
xuelinglow Oct 24, 2024
b6f6bf3
Make changes to collab service css
xuelinglow Oct 24, 2024
7a66ff0
Make changes according to req
xuelinglow Oct 24, 2024
a737bfd
Remove package files
xuelinglow Oct 24, 2024
b0775dc
Merge pull request #73 from CS3219-AY2425S1/collab-service-xl
tsulim Oct 24, 2024
71432f6
Merge branch 'collaboration-service' of https://github.com/CS3219-AY2…
whitesnowx Oct 24, 2024
d3352a8
store language, code
whitesnowx Oct 24, 2024
76e05c1
added comments lines
whitesnowx Oct 24, 2024
c1ff695
Make category field array
xuelinglow Oct 24, 2024
661b201
missing from previous commit, frontend files who did not leave
whitesnowx Oct 24, 2024
1e758f3
Adjust Question Panel css
xuelinglow Oct 24, 2024
7981ae9
Fix bug in updating question
xuelinglow Oct 24, 2024
0e61ecb
Merge remote-tracking branch 'upstream/collaboration-service' into co…
tsulim Oct 25, 2024
577c4f6
move user removal to disconnect listioner and segment useEffect for init
whitesnowx Oct 25, 2024
b579207
useEffect and depdencies in contenteditor
whitesnowx Oct 25, 2024
69a5a6c
Fix display of different question in same collaboration
tsulim Oct 25, 2024
ad0d77e
Merge pull request #75 from whitesnowx/58-collabdata
tsulim Oct 25, 2024
c3d1e27
Merge pull request #74 from CS3219-AY2425S1/collab-service-xl
tsulim Oct 25, 2024
0a033a0
Merge remote-tracking branch 'upstream/collaboration-service' into co…
tsulim Oct 25, 2024
93dc0ee
Merge branch 'collaboration-service' into 76-different-question-in-co…
tsulim Oct 25, 2024
35718ad
use id instead of roomId
whitesnowx Oct 25, 2024
2039103
id not accessible in disconnect, use socket.roomid instead
whitesnowx Oct 25, 2024
0a7d668
Merge pull request #78 from whitesnowx/58-collabdata
tsulim Oct 28, 2024
5ff2c33
Merge remote-tracking branch 'upstream/collaboration-service' into co…
tsulim Oct 29, 2024
d957326
Merge branch 'collaboration-service' into 76-different-question-in-co…
tsulim Oct 29, 2024
bab5d36
Shift setting of interval
tsulim Oct 29, 2024
99aaa96
Merge pull request #77 from CS3219-AY2425S1/76-different-question-in-…
whitesnowx Oct 29, 2024
655c1e3
Merge remote-tracking branch 'upstream/collaboration-service' into 79…
whitesnowx Oct 29, 2024
293dbb2
conflict revolve -- no crash but pending fix on deleting residue data…
whitesnowx Oct 29, 2024
bcbe6aa
deleting residue when no more users are in the room
whitesnowx Oct 29, 2024
e95bb82
Merge branch 'checking_branch_2' into collaboration-service
AndrewOng2066 Nov 1, 2024
64dd08d
Merge pull request #22 from CS3219-AY2425S1/collaboration-service
AndrewOng2066 Nov 1, 2024
1039719
Create a simple user profile
Nov 1, 2024
dba5900
FindingMatch back-navigation revert back
whitesnowx Nov 1, 2024
68db6fb
remove rabbit sample in env sample of collab-service
whitesnowx Nov 1, 2024
54a3d90
Merge pull request #80 from whitesnowx/79_mergeconflict
tsulim Nov 1, 2024
b8ed228
Merge remote-tracking branch 'upstream/main' into 81_deletingSocketRe…
whitesnowx Nov 1, 2024
8ff3220
= to ==
whitesnowx Nov 1, 2024
d4ae6f4
Merge remote-tracking branch 'upstream/main'
tsulim Nov 1, 2024
942bba8
Create a function to display the user's reviews from firebase
Nov 1, 2024
78510be
attached roomId to socket and add some logging message
whitesnowx Nov 1, 2024
495f7b6
Create a 5 stars rating component
Nov 1, 2024
4ece972
Create user feedback form
Nov 1, 2024
1c94cb6
Fix issue: After refresh, User can reconnect
tsulim Nov 1, 2024
357e7d8
Merge pull request #82 from whitesnowx/81_deletingSocketResidue
tsulim Nov 1, 2024
549a16c
Merge remote-tracking branch 'upstream/main'
tsulim Nov 1, 2024
44a79f8
Merge branch 'main' into 72-refresh-rejoin-room
tsulim Nov 1, 2024
1dae9c3
Add code for leaving socket room
tsulim Nov 1, 2024
bd4d4bd
Modify code for leaving socket room
tsulim Nov 1, 2024
91e2176
Add restricted collaboration route
tsulim Nov 1, 2024
f37ba28
Add navbar to PageNotFound
tsulim Nov 1, 2024
cb5d258
Create reviewCard to display the reviews nicely
Nov 2, 2024
5c16c1d
Create avatar profile image
Nov 2, 2024
88e26eb
Update the signup process to include a null image
Nov 2, 2024
57b38be
Implement the profile's avatar image fully
Nov 2, 2024
627e89e
Change the designs of profile and NavBar
Nov 2, 2024
fa5792e
Create function for website feedback
Nov 2, 2024
7082662
Add a status message when pressing the submit button for the website
Nov 2, 2024
7f0ef31
Add Code Execution functionality with judge0
xuelinglow Nov 2, 2024
1b7ca3c
Fix language id problem
xuelinglow Nov 2, 2024
18cf88d
Merge branch 'main' of https://github.com/CS3219-AY2425S1/cs3219-ay24…
xuelinglow Nov 3, 2024
d8cbf51
Remove unnecessary lines
Nov 4, 2024
92966fe
Add message feedback to userfeedback
Nov 4, 2024
1cfe44a
Extracted all the feedback functions to feedback-service microservice
Nov 4, 2024
b3c863d
Extracted feedback functions to feedback-microservice
Nov 4, 2024
a8b50b4
Modify functionality of restricted collaboration route
tsulim Nov 4, 2024
0e599e0
Merge pull request #83 from tsulim/72-refresh-rejoin-room
tsulim Nov 4, 2024
74b2274
Merge remote-tracking branch 'upstream/main'
tsulim Nov 4, 2024
ee034f7
Merge branch 'main' into restricted-collab-route
tsulim Nov 4, 2024
15353d0
Modify to check for `location.state.data.id` if exists
tsulim Nov 4, 2024
e3a4368
Remove irrelevant imports
tsulim Nov 4, 2024
cdc2eb5
Remove old `PageNotFound`
tsulim Nov 4, 2024
c58fb22
Merge pull request #85 from tsulim/restricted-collab-route
tsulim Nov 4, 2024
999f46e
Merge remote-tracking branch 'upstream/collaboration-service-tsu' int…
tsulim Nov 4, 2024
95a4d9b
Modify css
tsulim Nov 4, 2024
1fed22e
Merge pull request #86 from tsulim/modify-css
tsulim Nov 4, 2024
ccfe056
Merge remote-tracking branch 'upstream/collaboration-service-tsu' int…
tsulim Nov 4, 2024
adc42b4
Add timestamp to the review
Nov 4, 2024
00a8a36
Add new buttons in the profile page
Nov 4, 2024
e4a4d55
Provide function for users to change password
Nov 4, 2024
5611263
Change the name
Nov 4, 2024
b70e985
Fix inconsistent email bug
Nov 4, 2024
cd8b313
Add submit button to collab service
xuelinglow Nov 4, 2024
8230428
Add matching history
Nov 5, 2024
eb57d25
Merge branch 'nth_Andrew' into Extract_feedback_branch
AndrewOng2066 Nov 5, 2024
58cc19f
Merge pull request #88 from AndrewOng2066/Extract_feedback_branch
AndrewOng2066 Nov 5, 2024
e74ea05
Provide userfeedback on the matching history page
Nov 5, 2024
0a8eee7
Fix the bug in matching history
Nov 5, 2024
19c0291
Update docker-compose to include feedback-service
Nov 5, 2024
787c02f
Merge pull request #89 from AndrewOng2066/nth_branch
AndrewOng2066 Nov 5, 2024
998584a
change to read database only after if have new data
whitesnowx Nov 5, 2024
b3182cd
Include the user's email in the feedback's email
Nov 5, 2024
1b677a0
Merge pull request #90 from AndrewOng2066/nth_branch
AndrewOng2066 Nov 5, 2024
812fa8b
Fix spacing issue
Nov 5, 2024
0cae7bd
Merge pull request #91 from AndrewOng2066/nth_branch
AndrewOng2066 Nov 5, 2024
d18436f
add chatbox, local message only
whitesnowx Nov 5, 2024
f22d658
Merge branch 'checking_branch_2' of https://github.com/AndrewOng2066/…
Nov 5, 2024
8f601bc
Merge branch 'checking_branch_2' into collab-service-xl
AndrewOng2066 Nov 5, 2024
980f138
broading chat but to everyone in the socket :(
whitesnowx Nov 5, 2024
faf9faa
Merge branch 'nth_branch_testing' into collab-service-xl
AndrewOng2066 Nov 5, 2024
ffdd209
Merge pull request #26 from CS3219-AY2425S1/collab-service-xl
AndrewOng2066 Nov 5, 2024
c7dad89
Create `API-Gateway`
tsulim Nov 5, 2024
c7f7621
Add `apiGatewayRoute` and `userRoute` and `userService`
tsulim Nov 5, 2024
ce532c8
working but catching an asynchronous reponse error:
whitesnowx Nov 5, 2024
c3de1a9
Show the userfeedback page after the collaboration part
Nov 5, 2024
f896811
Merge branch 'nth_Andrew' into nth_branch_testing
AndrewOng2066 Nov 5, 2024
9c4e10d
Merge pull request #92 from AndrewOng2066/nth_branch_testing
AndrewOng2066 Nov 5, 2024
06ed620
Remove the submit button once the user pressed it
Nov 5, 2024
915236c
Merge branch 'nth_branch_testing' of https://github.com/AndrewOng2066…
Nov 5, 2024
c7c8db5
Merge pull request #93 from AndrewOng2066/nth_branch_testing
AndrewOng2066 Nov 5, 2024
da41cb3
Remove unnecessary lines
Nov 5, 2024
acd4eb8
Merge pull request #94 from AndrewOng2066/nth_branch_testing
AndrewOng2066 Nov 5, 2024
848f931
Fix bugs and ui changes
xuelinglow Nov 5, 2024
0ddf59d
Merge branch 'collab-service-xl' of https://github.com/CS3219-AY2425S…
xuelinglow Nov 5, 2024
d94db86
scroll to bottom of the message box
whitesnowx Nov 5, 2024
e38176c
Merge pull request #95 from whitesnowx/62_communciation_chat
whitesnowx Nov 5, 2024
cfaa329
docker the collab service
whitesnowx Nov 5, 2024
be19896
Update `.env.sample`
tsulim Nov 5, 2024
8222852
Add `questionRoute` and `questionService`, along with the updates of …
tsulim Nov 5, 2024
c19cdc2
3
whitesnowx Nov 5, 2024
9d5ae4f
Allow refresh of tab, fix bugs related to collab submission
xuelinglow Nov 5, 2024
f1478f8
remove unnessary health check
whitesnowx Nov 5, 2024
dce965d
Update docker-compose
Nov 5, 2024
e3c84a8
add express to package.json
whitesnowx Nov 5, 2024
ac459fa
Merge pull request #98 from AndrewOng2066/nth_branch_testing
AndrewOng2066 Nov 5, 2024
7a59d8e
Merge pull request #97 from whitesnowx/40_container_collab
whitesnowx Nov 5, 2024
7d8a6c8
Merge branch 'main' into nth_Andrew
AndrewOng2066 Nov 5, 2024
1a1f6d4
Merge branch 'main' of https://github.com/CS3219-AY2425S1/cs3219-ay24…
xuelinglow Nov 5, 2024
15d1c9e
Merge branch 'main' into collab-service-xl
xuelinglow Nov 5, 2024
8d67603
Merge pull request #100 from CS3219-AY2425S1/nth_Andrew
whitesnowx Nov 5, 2024
ca3f851
Merge branch 'main' into collab-service-xl
xuelinglow Nov 5, 2024
824ebf1
make some changes to fix bugs from merging
xuelinglow Nov 6, 2024
af08188
Merge pull request #101 from CS3219-AY2425S1/collab-service-xl
whitesnowx Nov 6, 2024
9c16af8
merge changes
whitesnowx Nov 6, 2024
7b5aee7
Merge pull request #102 from whitesnowx/62_communciation_chat
whitesnowx Nov 6, 2024
9ba6df8
Merge pull request #96 from CS3219-AY2425S1/communcation_cal
tsulim Nov 6, 2024
1374fb3
Merge remote-tracking branch 'upstream/main'
tsulim Nov 6, 2024
586f627
Merge branch 'main' into 87-api-gateway
tsulim Nov 6, 2024
1562aac
Add `collaborationRoute` and `collaborationService`, along with the u…
tsulim Nov 6, 2024
d0d882e
Modify `questionRoute` and `questionService`, along with the updates …
tsulim Nov 6, 2024
70ac2c6
Add `feedbackRoute` and `feedbackService`, along with the updates of …
tsulim Nov 6, 2024
9a96fb1
Add more user routes and services
tsulim Nov 6, 2024
c5e505c
Update `.env.sample` for `api-gateway` and `collaboration-service`
tsulim Nov 6, 2024
bebfb52
trying to implemented colored
whitesnowx Nov 6, 2024
ab658bf
Merge pull request #28 from CS3219-AY2425S1/main
AndrewOng2066 Nov 7, 2024
ddcf654
Change from sessionStorage to useSessionStorage.
Nov 7, 2024
c26b687
Include an overall rating score in the profile.js
Nov 8, 2024
1b959d7
Update the context code and text in the historyIndividual (Firebase) …
Nov 8, 2024
a0b9377
Update so that a review can only be given once for each match
Nov 8, 2024
13e57dd
Fix review bugs
Nov 8, 2024
0cbcb93
Copy and paste from feedback-service to user-service
Nov 8, 2024
36140fb
Remove all the feedback-service components
Nov 8, 2024
830c5a3
Update the matching history page to show the user text and code
Nov 8, 2024
c30281c
Update the History Code to display the code nicely
Nov 8, 2024
ef3073c
Merge pull request #106 from AndrewOng2066/combining_user_feedback
AndrewOng2066 Nov 8, 2024
2593695
Add `socketHandler` for `matching-service` and update its usage
tsulim Nov 8, 2024
1c4f289
Add `socketHandler` for `collaboration-service` and update its usage
tsulim Nov 8, 2024
b18771a
Merge remote-tracking branch 'upstream/nth_Andrew_2' into 87-api-gateway
tsulim Nov 8, 2024
7d01364
Merge `feedbackRoute` and `feedbackService` with `userRoute` and `use…
tsulim Nov 8, 2024
51de287
Remove remnants of `feedback-service`
tsulim Nov 8, 2024
ee14948
Fix bugs
tsulim Nov 8, 2024
e5b554e
Standardize page css
tsulim Nov 8, 2024
d8d7181
show username instead of email
whitesnowx Nov 8, 2024
6c60d03
Remove redundant stuff
tsulim Nov 8, 2024
028095b
Update dependencies for `matching-service`
tsulim Nov 8, 2024
74f1a33
Update `.env.sample` for `api-gateway`
tsulim Nov 8, 2024
32dae53
Containerize `api-gateway`
tsulim Nov 8, 2024
173e313
Rename folder
tsulim Nov 8, 2024
7cfba81
Modify to use variable in `socket.js`
tsulim Nov 9, 2024
78f9ee1
Fix matching any
tsulim Nov 9, 2024
d8d1ae4
Merge pull request #107 from tsulim/87-api-gateway
iynixil Nov 9, 2024
edb6bdb
admin
whitesnowx Nov 9, 2024
b5b6985
merge complete
whitesnowx Nov 9, 2024
384ff73
Merge pull request #108 from whitesnowx/105_coloredusernames
iynixil Nov 9, 2024
d4baacc
merge complete
whitesnowx Nov 9, 2024
1d619f5
Fix multiple refresh bug
xuelinglow Nov 9, 2024
90a1e2e
Merge pull request #109 from whitesnowx/admin_branch
iynixil Nov 9, 2024
0a5a1b3
Fix refresh bug
xuelinglow Nov 9, 2024
1a53cfa
remove feedback service folder
xuelinglow Nov 9, 2024
732c986
Merge pull request #110 from CS3219-AY2425S1/testBranch_xl
whitesnowx Nov 9, 2024
34e5d2c
Merge remote-tracking branch 'upstream/main'
tsulim Nov 9, 2024
d73c881
Modify sequence of pages for match to collaboration
tsulim Nov 10, 2024
e6b2e86
Merge pull request #112 from tsulim/buffer-page-match-found
iynixil Nov 10, 2024
5b41375
Add rate limiter to `api-gateway`
tsulim Nov 10, 2024
cc832c9
Merge remote-tracking branch 'upstream/main' into rate-limit-api-gateway
tsulim Nov 10, 2024
62d47f4
Merge pull request #113 from tsulim/rate-limit-api-gateway
whitesnowx Nov 10, 2024
5fc9729
Update docker-compose file, Add containerization of frontend
iynixil Nov 11, 2024
84fb26c
Update README.md to include docker-compose instructions and info abou…
iynixil Nov 11, 2024
77411e3
Remove unnecessary lines in frontend Dockerfile
iynixil Nov 13, 2024
1fbd405
Merge branch 'main' into update-docker
iynixil Nov 13, 2024
1f96d32
Make changes to output window
xuelinglow Nov 13, 2024
84aa032
Remove console logs for testing
xuelinglow Nov 13, 2024
66a178d
Merge pull request #114 from iynixil/update-docker
xuelinglow Nov 13, 2024
73d1319
Merge remote-tracking branch 'upstream/main' into update-docker
iynixil Nov 13, 2024
d4deb25
Make changes to outputWindow css
xuelinglow Nov 13, 2024
e67c43e
Merge pull request #115 from CS3219-AY2425S1/apiTest_XL
iynixil Nov 13, 2024
43d27fc
Merge branch 'main' into update-docker
iynixil Nov 13, 2024
43e07c3
Remove network external config in docker compose
iynixil Nov 13, 2024
5566552
Update password change error message
iynixil Nov 13, 2024
aade200
Update debugging message in match history retrieval
iynixil Nov 13, 2024
cf4d7a9
Merge pull request #116 from iynixil/update-docker
AndrewOng2066 Nov 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules/
.env
.vscode/
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
[![Review Assignment Due Date](https://classroom.github.com/assets/deadline-readme-button-22041afd0340ce965d47ae6ef1cefeee28c7c493a6346c4f15d667ab976d596c.svg)](https://classroom.github.com/a/bzPrOe11)
# CS3219 Project (PeerPrep) - AY2425S1
## Group: Gxx
## Group: G46

### Note:
- You can choose to develop individual microservices within separate folders within this repository **OR** use individual repositories (all public) for each microservice.
- 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.
- 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.

### Run PeerPrep with docker-compose:
Prerequisite: Ensure that Docker is installed and running.
1. Clone the repository.
2. Ensure that the respective `.env` files for all microservices, and the frontend, have been added in.
3. In any IDE or terminal, `cd` to the project root directory, and run the following commands:
- `docker-compose build --no-cache` to build the images
- `docker-compose up -d` to run the web app on `localhost:3000`
- `docker-compose down` to stop running the containers

### Production Deployment of PeerPrep
- The production build and deployment of PeerPrep is located under the `deployment` branch.
- Deployment link: http://g46-peerprep-env.eba-u9cm3q7g.ap-southeast-1.elasticbeanstalk.com/
2 changes: 2 additions & 0 deletions backend/api-gateway/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
npm-debug.log
5 changes: 5 additions & 0 deletions backend/api-gateway/.env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
PORT=8000

QUESTION_SERVICE_URL=
USER_SERVICE_URL=
COLLABORATION_SERVICE_URL=
20 changes: 20 additions & 0 deletions backend/api-gateway/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Use an official Node.js runtime as a parent image
FROM node:20-alpine

# Set the working directory in the container
WORKDIR /app

# Copy package.json and package-lock.json
COPY package*.json ./

# Install any dependencies
RUN npm install

# Bundle app source inside the Docker image
COPY . .

# Make port 8000 available to the world outside this container
EXPOSE 8000

# Define the command to run your app
CMD ["npm", "start"]
199 changes: 199 additions & 0 deletions backend/api-gateway/handler/socketHandler.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
let socketMap = {};
let matchingService, collaborationService;

const handleSocketIO = (io) => {
io.on("connection", (socket) => {
console.log(`A user connected with socket ID: ${socket.id}`);

socket.on("matchingService", () => {
console.log(`matching service connected with socket ID: ${socket.id}`);
matchingService = socket.id;
});

socket.on("collaborationService", () => {
console.log(`collaboration service connected with socket ID: ${socket.id}`);
collaborationService = socket.id;
});

// Listen for the join_matching_queue event from the client
socket.on("join_matching_queue", async (data) => {
console.log(`New request for matching:`, data);
const { email } = data;

// Store the socket ID for the user
socketMap[email] = socket.id;

io.to(matchingService).emit("join_matching_queue", data);
});

// Listen for cancel_matching event from client
socket.on("cancel_matching", async (data) => {
console.log(`Cancelling matching for user:`, data.email);
const { email } = data;

// Store the socket ID for the user
socketMap[email] = socket.id;

io.to(matchingService).emit("cancel_matching", data);
});

socket.on("match_found", (data) => {
const { user1, user2, matchData, id } = data;

console.log("data", matchData);

// Notify both users about the match
io.to(socketMap[user1]).emit("match_found", {
data: matchData,
id,
});

io.to(socketMap[user2]).emit("match_found", {
data: matchData,
id,
});
});

socket.on("createSocketRoom", async ({ data, id, currentUser }) => {
console.log("create socket room");
// Store the socket id for the user
socketMap[currentUser] = socket.id;
socket.roomId = id;

socket.join(id);
console.log(`User with socket ID ${socket.id} joined room with ID ${id}`);

const room = io.sockets.adapter.rooms.get(id);
console.log("room", room.size);

io.to(collaborationService).emit("createSocketRoom", { data: data, id: id, roomSize: room.size });
});

socket.on("readyForCollab", async (data) => {
console.log("ready for collab");
const { id, questionData } = data;

io.in(id).emit("readyForCollab", data);

console.log(
`Room ${id} is ready. Collaboration question sent: ${questionData}`
);
});

socket.on("reconnecting", ({ id, currentUser }) => {
socketMap[currentUser] = socket.id;
socket.join(id);
console.log(
`User with socket ID ${socket.id} reconnected to room with ID ${id}`
);
});

socket.on("sendContent", (data) => {
io.to(collaborationService).emit("sendContent", data);
});

socket.on("receiveContent", ({ id, content }) => {
io.to(id).emit("receiveContent", { content: content });
});

socket.on("sendCode", (data) => {
io.to(collaborationService).emit("sendCode", data);
});

socket.on("receiveCode", ({ id, code }) => {
io.to(id).emit("receiveCode", { code: code });
});

socket.on("languageChange", (data) => {
io.to(collaborationService).emit("sendLanguageChange", data);
});

socket.on("receivelanguageChange", ({ id, language }) => {
io.to(id).emit("receivelanguageChange", { language: language });
});

socket.on("sendMessage", (data) => {
console.log("send chat message", data);
io.to(collaborationService).emit("sendMessage", data);
});

socket.on("receiveMessage", ({ id, message }) => {
io.to(id).emit("receiveMessage", { message: message });
});

socket.on("endSession", ({ id }) => {
console.log("endSession");
io.to(collaborationService).emit("endSession", { id: id });
});

socket.on("sessionEnded", ({ user1Email, user2Email, roomId }) => {
io.in(roomId).emit("sessionEnded", { user1Email: user1Email, user2Email: user2Email, roomId: roomId });

const user1 = socketMap[user1Email];
const user2 = socketMap[user2Email];
const user1Socket = io.sockets.sockets.get(user1);
const user2Socket = io.sockets.sockets.get(user2);
if (user1Socket) {
user1Socket.disconnect();
}
if (user2Socket) {
user2Socket.disconnect();
}
});

socket.on("submissionCount", ({ id, count, totalUsers }) => {
io.in(id).emit("submissionCount", { count, totalUsers });
});

socket.on("cancelendSession", ({ id }) => {
io.to(collaborationService).emit("cancelendSession", { id: id });
});

socket.on("userDisconnect", ({ id }) => {
io.to(collaborationService).emit("userDisconnect", { id: id });
});

socket.on("sendUserDisconnect", ({ id }) => {
io.in(id).emit("userDisconnect", { id: id });
});

socket.on("userReconnect", ({ id }) => {
io.to(collaborationService).emit("userReconnect", { id: id });
});

socket.on("sendUserReconnect", ({ id }) => {
io.in(id).emit("userReconnect", { id: id });
});

socket.on("reloadSession", ({ id }) => {
socket.join(id);
console.log(`Reloaded - User with socket ID ${socket.id} joined room with ID ${id}`);

io.to(collaborationService).emit("reloadSession", { id: id });
});

socket.on("receiveCount", ({ id }) => {
io.to(id).emit("receiveCount", { id: id });
});

// Handle disconnection
socket.on("disconnect", () => {
console.log(`User with socket ID ${socket.id} disconnected`);
io.to(collaborationService).emit("socketDisconnect", { roomId: socket.roomId });

socketMap = Object.fromEntries(
Object.entries(socketMap).filter(([key]) => key !== socket.id)
);

if (socket.roomId) {
socket.leave(socket.roomId);
console.log(`User with socket ID ${socket.id} disconnected, leaving ${socket.roomId}`);
} else {
console.log(`User with socket ID ${socket.id} disconnected`);
}
});
});
};

// Export user functions
module.exports = { handleSocketIO };
57 changes: 57 additions & 0 deletions backend/api-gateway/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// Author(s): Xiu Jia
require("dotenv").config();

const express = require("express");
const cors = require("cors");
const rateLimit = require('express-rate-limit');
const http = require("http");
const { Server } = require("socket.io");
const { handleSocketIO } = require("./handler/socketHandler.js");
const apiRoute = require("./routes/apiGatewayRoute.js");

const port = process.env.PORT || 8000;

// Create an instance of Express app
const app = express();
const server = http.createServer(app);

// Initialize the Socket.IO server
const io = new Server(server, {
cors: {
origin: "*", // Allow all origins, adjust as needed
methods: ["GET", "POST"],
},
});

handleSocketIO(io);

app.use(express.json());
app.use(cors());

// Define a rate limiter with options
const apiLimiter = rateLimit({
windowMs: 15 * 60 * 1000, // 15 minutes
max: 100, // limit each IP to 100 requests per windowMs
message: 'Too many requests from this IP, please try again later.',

// Custom handler function for rate limit errors
handler: (req, res) => {
res.status(429).send({
error: 'You have exceeded the maximum allowed requests. Please wait a while and try again.',
});
},
});

app.use(apiLimiter);

// default API from expressJS
app.get("/", (req, res) => {
res.send("Welcome to the Express server!");
});

// Route
app.use("/api", apiRoute);

server.listen(port, () => {
console.log(`Server listening on port ${port}`);
});
Loading