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 273 commits into
base: feedback
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
273 commits
Select commit Hold shift + click to select a range
61f8c0f
Question service/ Connect frontend to backend for create questions
Kevin-Liusx Sep 23, 2024
62eda6b
Question Service/Fix minor bug
Kevin-Liusx Sep 23, 2024
9fafddb
Merge pull request #9 from Kevin-Liusx/milestone-2
jibtaf Sep 23, 2024
ef18a2f
Add the list UI
Kevin-Liusx Sep 23, 2024
f3aae22
Merge pull request #10 from Kevin-Liusx/milestone-2
jibtaf Sep 23, 2024
6cd37fc
Question frontend/ Fix category selection design
jibtaf Sep 23, 2024
d73dad5
Question frontend/ Update dependency
jibtaf Sep 23, 2024
d40d509
Merge pull request #11 from jibtaf/milestone-2
Leb14 Sep 23, 2024
90bd88c
Change categories field to drop down
Leb14 Sep 23, 2024
ea4b5fd
Organise file structure
Leb14 Sep 23, 2024
3ba8a3f
Integrate questions delete API
Leb14 Sep 23, 2024
af36fb3
Merge pull request #12 from Leb14/Edit-Question-API
adammangzijun Sep 23, 2024
eb6a0a4
Frontend API integration
Leb14 Sep 24, 2024
c4e5199
Merge pull request #13 from Leb14/Edit-Question-API
IamZhenHong Sep 24, 2024
798bbcd
Implement search function logic
IamZhenHong Sep 24, 2024
dbc5567
Revert "Implement search function logic"
IamZhenHong Sep 24, 2024
48e7113
Implement search function logic Beta
IamZhenHong Sep 24, 2024
c4a998f
Revert "Implement search function logic Beta"
IamZhenHong Sep 24, 2024
30d471a
Update Questions.js
IamZhenHong Sep 24, 2024
6ad0e17
Revert "Update Questions.js"
IamZhenHong Sep 24, 2024
a4f1708
Question backend/ Update controller and image field
jibtaf Sep 24, 2024
bfa96f8
Merge pull request #15 from jibtaf/milestone-2
Kevin-Liusx Sep 24, 2024
0ac5e23
Implement search question logic
IamZhenHong Sep 28, 2024
b327466
Question service: Add check for duplicate title
jibtaf Sep 28, 2024
988fad0
Question service: Add View Question page
jibtaf Sep 28, 2024
72943dc
Merge pull request #16 from IamZhenHong/milestone-2
jibtaf Sep 28, 2024
5488ad4
Merge pull request #17 from jibtaf/milestone-2
Kevin-Liusx Sep 28, 2024
fe1c352
Updated Styling for Side Bar as well as Search Bar
adammangzijun Sep 29, 2024
aaa59b3
Merge branch 'milestone-2' into milestone-2-1
adammangzijun Sep 29, 2024
262ebe1
Merge pull request #18 from adammangzijun/milestone-2-1
jibtaf Sep 29, 2024
306387d
Question service: Fix dependency bugs
jibtaf Sep 29, 2024
2392a8e
Question service: Remove node_modules
jibtaf Sep 29, 2024
535c6d5
Merge pull request #19 from jibtaf/milestone-2
Kevin-Liusx Sep 29, 2024
c725f1a
Remove the question mark in Add and Edit Page
Kevin-Liusx Sep 29, 2024
062fbf8
Merge pull request #20 from Kevin-Liusx/milestone-2
jibtaf Sep 29, 2024
84979b2
Move index.js and package.json to QuestionService Directory
Leb14 Oct 1, 2024
0112aa9
Add user service
Leb14 Oct 1, 2024
6d78c6a
Add AuthApi.js to frontend
Leb14 Oct 1, 2024
b0211b5
Add Login page
Leb14 Oct 1, 2024
a1b0bdd
Add page navigation
Leb14 Oct 1, 2024
12c0d34
Update dependencies
Leb14 Oct 1, 2024
db5f90e
Add admin login functionality
Leb14 Oct 1, 2024
4adc306
Add concurrently start for backend services
Leb14 Oct 2, 2024
ec4c9e0
Implement session storage to store the authenticated state
Leb14 Oct 2, 2024
486d8d5
Store isAuthenticated and isAdmin to session storage
Leb14 Oct 2, 2024
9f7fe40
Store accessToken to session storage
Leb14 Oct 2, 2024
5dedadb
Remove isAdmin field to pass back to route
Leb14 Oct 2, 2024
1439283
Change form function to button onclick
Leb14 Oct 2, 2024
efba730
Add confirmation dialog box before deleting a question
Leb14 Oct 2, 2024
61fa697
Adjust alignment
Leb14 Oct 2, 2024
91293cf
Add logout functionality at Admin SPA
Leb14 Oct 2, 2024
18fd182
Add password visibility toggle
Leb14 Oct 2, 2024
3a8faea
Update confirmation dialog text
Leb14 Oct 2, 2024
cb779cb
Add register functionality
Leb14 Oct 2, 2024
5e95b54
Remove redundant parameters
Leb14 Oct 2, 2024
da758fc
Add cancel button to question services
Leb14 Oct 2, 2024
95ac177
Organise frontend folder structure
Leb14 Oct 2, 2024
055ca32
Merge pull request #23 from Leb14/Add-User-Service
Kevin-Liusx Oct 2, 2024
dad9c41
Add transition when changing auth route
Leb14 Oct 2, 2024
b35b760
Fix logout navigating bug
Leb14 Oct 3, 2024
d661950
Add users tab at admin panel
Leb14 Oct 3, 2024
510a39f
Add update user privilege funtionality
Leb14 Oct 3, 2024
c010f74
Update alignment and UI for AddQuestion.js and EditUser.js
Leb14 Oct 3, 2024
42c153d
Add delete user funcitonality at admin panel
Leb14 Oct 3, 2024
0eba734
Add access token check for question API
Leb14 Oct 3, 2024
3eca5be
Fix scroll bar glitch at auth pages
Leb14 Oct 3, 2024
4dd1133
Add token check to all questions-related route
Leb14 Oct 3, 2024
e71cfb3
Add status code check for QuestionApi.js
Leb14 Oct 3, 2024
1959a5e
Update frontend pages UI
Leb14 Oct 4, 2024
1905f46
Change alignment
Leb14 Oct 4, 2024
335ac00
Add duplicate check for edit question
jibtaf Oct 5, 2024
5f32050
Containerize questions service
jibtaf Oct 5, 2024
4793056
Containerize user service
jibtaf Oct 5, 2024
f984df8
Containerize frontend
jibtaf Oct 5, 2024
6748ff4
Compose all services
jibtaf Oct 5, 2024
10c5375
Add scripts to start all services
jibtaf Oct 5, 2024
5a1199b
Add npm install fro the script
jibtaf Oct 5, 2024
9dcabc6
Update readme
jibtaf Oct 5, 2024
6eb6a3f
Merge pull request #24 from Leb14/Add-User-Service
jibtaf Oct 5, 2024
c5bfb80
Merge branch 'milestone-3' into milestone-3
jibtaf Oct 5, 2024
eae352d
Merge pull request #25 from jibtaf/milestone-3
Kevin-Liusx Oct 5, 2024
040a59c
Fix backend axios call error when using docker
jibtaf Oct 5, 2024
ba89224
Update readme
jibtaf Oct 5, 2024
6d2d663
Merge pull request #26 from jibtaf/milestone-3
Kevin-Liusx Oct 5, 2024
941347a
Update readme
jibtaf Oct 6, 2024
3c06c58
Merge pull request #27 from jibtaf/milestone-3
jibtaf Oct 6, 2024
f1ea59d
Merge pull request #28 from CS3219-AY2425S1/milestone-3
jibtaf Oct 6, 2024
0d61d09
Fix isAdmin default value
jibtaf Oct 6, 2024
5a62777
Merge pull request #29 from jibtaf/milestone-3
jibtaf Oct 6, 2024
79d40fb
Merge pull request #30 from CS3219-AY2425S1/milestone-3
jibtaf Oct 6, 2024
39127fb
Add the layout for student page
Kevin-Liusx Oct 18, 2024
55ad9f5
Add the sidebar for student page
Kevin-Liusx Oct 18, 2024
fdc5010
Add the header for the user page
Kevin-Liusx Oct 18, 2024
dba114d
Add the content section for user page
Kevin-Liusx Oct 18, 2024
3001439
Fix minor errors
Kevin-Liusx Oct 18, 2024
5af38d9
Remove unnecessary files
Kevin-Liusx Oct 18, 2024
967e5fe
Add pie chart
Kevin-Liusx Oct 19, 2024
6c16ff2
Merge pull request #31 from Kevin-Liusx/milestone-3
jibtaf Oct 19, 2024
ee5ce74
Fix the pie chart so that it is aligned
Kevin-Liusx Oct 19, 2024
677e2ab
Merge pull request #32 from Kevin-Liusx/milestone-3
jibtaf Oct 19, 2024
c20002c
Add matching service backend
jibtaf Oct 19, 2024
55de221
Add matching service frontend
jibtaf Oct 19, 2024
b0fbbdb
Add new api endpoint for fetching user info
jibtaf Oct 19, 2024
eec327d
Fix minor bug
jibtaf Oct 19, 2024
143ea35
Remove console.log statement
jibtaf Oct 19, 2024
0ed3cb8
Fix undefined user id bug
jibtaf Oct 19, 2024
d9195db
Fix matching criteria bug
jibtaf Oct 19, 2024
9fcf73f
Merge pull request #33 from jibtaf/milestone-4
Kevin-Liusx Oct 19, 2024
75fc5b5
Fix countdown not stopping at backend bug
jibtaf Oct 19, 2024
16d4e1f
Fix user info unreachable after refreshing bug
jibtaf Oct 19, 2024
f306bec
Merge pull request #34 from jibtaf/milestone-4
Kevin-Liusx Oct 19, 2024
1ea5b93
Fix the position of the matching button
Kevin-Liusx Oct 19, 2024
9c16884
Merge pull request #35 from Kevin-Liusx/milestone-4
jibtaf Oct 19, 2024
8126aff
Add cloud raabitmq
jibtaf Oct 19, 2024
efe0f02
Containerise matching service
jibtaf Oct 19, 2024
6d0af49
Merge pull request #36 from jibtaf/milestone-4
Kevin-Liusx Oct 19, 2024
979f462
Add start script on alt port for demo
jibtaf Oct 20, 2024
ebe902d
Change website icon and title
jibtaf Oct 20, 2024
a1b4a9a
Update readme
jibtaf Oct 20, 2024
9444b6b
Merge pull request #37 from jibtaf/milestone-4
Kevin-Liusx Oct 20, 2024
d9aa804
Update matching logic
jibtaf Oct 20, 2024
472b4e9
Merge pull request #38 from jibtaf/milestone-4
jibtaf Oct 20, 2024
7a12efc
Merge pull request #39 from CS3219-AY2425S1/milestone-4
jibtaf Oct 20, 2024
cc44090
Updated UI for matching page
adammangzijun Oct 20, 2024
458d79e
Add collaboration backend
jibtaf Oct 28, 2024
1362a03
Update gitignore
jibtaf Oct 28, 2024
c60a208
Update frontend for collaboration
jibtaf Oct 28, 2024
0f10808
Update script
jibtaf Oct 28, 2024
137a7c7
Merge pull request #41 from jibtaf/milestone-5
Leb14 Oct 30, 2024
6625850
Add API for matching cancellation
IamZhenHong Nov 3, 2024
6390409
Revert "Add API for matching cancellation"
IamZhenHong Nov 3, 2024
baf8d5e
Add WebSocket-based cancel matching functionality
IamZhenHong Nov 4, 2024
64df675
Fix persist matching after matching cancellation
IamZhenHong Nov 4, 2024
2020d6e
Buggy collab services integration
Leb14 Nov 5, 2024
54e347a
Merge pull request #44 from Leb14/milestone-five
jibtaf Nov 5, 2024
dbb5632
Fix websocket closed error
jibtaf Nov 5, 2024
2aa5b5b
Merge pull request #45 from jibtaf/Collab-bug
Leb14 Nov 5, 2024
64c7439
Updated main page UI
adammangzijun Nov 5, 2024
64f75f7
Merge branch 'milestone-5' of https://github.com/CS3219-AY2425S1/cs32…
adammangzijun Nov 5, 2024
bd136d3
Merge pull request #43 from IamZhenHong/milestone-5
adammangzijun Nov 5, 2024
74e6436
Merge branch 'milestone-5' of https://github.com/CS3219-AY2425S1/cs32…
adammangzijun Nov 5, 2024
d4461ed
Merge remote-tracking branch 'upstream/milestone-5' into milestone-five
Leb14 Nov 5, 2024
6cdc410
Add code collaboration
Leb14 Nov 5, 2024
aa1920a
Add basic functions for chat system
Kevin-Liusx Nov 5, 2024
b110ae5
Fix the roomManager so that it does not overwrite the current users
Kevin-Liusx Nov 5, 2024
bcd77db
fix minor issues
Kevin-Liusx Nov 5, 2024
ff1a728
Add language change fucntionality
Leb14 Nov 6, 2024
972ebdb
Merge pull request #46 from Leb14/milestone-five
IamZhenHong Nov 6, 2024
d2675d1
Small code change to ws.js file
Kevin-Liusx Nov 6, 2024
f34af7d
Remove strict mode to avoid double rendering
jibtaf Nov 6, 2024
9daf0fa
Change userId
jibtaf Nov 6, 2024
3e36c66
Fix connected users undefined issue
jibtaf Nov 6, 2024
990b5be
Merge branch 'Collab-bug' into Collab-bug
Kevin-Liusx Nov 6, 2024
c648d5b
Merge pull request #47 from Kevin-Liusx/Collab-bug
jibtaf Nov 6, 2024
c190344
Merge branch 'Collab-bug' into Collab-bug
jibtaf Nov 6, 2024
530fbd5
Merge pull request #48 from jibtaf/Collab-bug
Kevin-Liusx Nov 6, 2024
674f826
Fix minor bug
Kevin-Liusx Nov 6, 2024
3a5368c
Merge pull request #49 from Kevin-Liusx/Collab-bug
Kevin-Liusx Nov 6, 2024
49cf874
Merge pull request #50 from CS3219-AY2425S1/Collab-bug
Kevin-Liusx Nov 6, 2024
516f46a
Modify collaboration room layout
Kevin-Liusx Nov 6, 2024
cbd6caf
Merge pull request #51 from Kevin-Liusx/Collab-bug
Kevin-Liusx Nov 6, 2024
a84b60a
UI update for the chat box
Kevin-Liusx Nov 6, 2024
5e469bc
Fix match cancelling
IamZhenHong Nov 6, 2024
578d65f
Merge branch 'milestone-5' of https://github.com/CS3219-AY2425S1/cs32…
IamZhenHong Nov 6, 2024
07cf983
Updated main page UI design
adammangzijun Nov 6, 2024
6a14aa6
Merge branch 'milestone-5' of https://github.com/CS3219-AY2425S1/cs32…
adammangzijun Nov 6, 2024
ef392bf
Use localhost rabbitmq instead of CloudAMQP to avoid error
jibtaf Nov 6, 2024
a947530
Containerise collaboration sevice
jibtaf Nov 6, 2024
58767ce
Update backend script
jibtaf Nov 6, 2024
238c591
Update README
jibtaf Nov 6, 2024
4879ddb
Merge pull request #52 from IamZhenHong/milestone-5
jibtaf Nov 6, 2024
f8cb9d5
Merge pull request #53 from jibtaf/milestone-5
Kevin-Liusx Nov 6, 2024
c9c3e9e
Fix mq connection string
jibtaf Nov 6, 2024
08e922d
Merge pull request #54 from jibtaf/milestone-5
jibtaf Nov 6, 2024
9de08a3
Implement the chat function
Kevin-Liusx Nov 6, 2024
d3d81a2
Fix bug for chat function
Kevin-Liusx Nov 6, 2024
ebca756
Change the css for code editor
Kevin-Liusx Nov 6, 2024
8e07c0f
Proposed Final Design for Main Page
adammangzijun Nov 6, 2024
2eb811d
Add css to textContent
Kevin-Liusx Nov 6, 2024
6c7853d
Merge pull request #55 from Kevin-Liusx/milestone-5
jibtaf Nov 6, 2024
e192ef5
Updated Modal for Main Page
adammangzijun Nov 6, 2024
95962be
Merge branch 'milestone-5' of https://github.com/CS3219-AY2425S1/cs32…
adammangzijun Nov 6, 2024
3b47848
Created functions for session history as well as updated fields in
adammangzijun Nov 6, 2024
7ba7d7e
Created HistoryCard, updated history page, edited fields for
adammangzijun Nov 6, 2024
8fc6a12
Add yaml files for deployment
jibtaf Nov 7, 2024
0076909
Update urls for deployment
jibtaf Nov 7, 2024
94c84d8
Implement AI Copilot for collab
IamZhenHong Nov 7, 2024
eddef72
Update deployment
jibtaf Nov 7, 2024
6282aaf
Committing for error in Match History
adammangzijun Nov 7, 2024
75eb581
Merge pull request #56 from jibtaf/milestone-5
IamZhenHong Nov 7, 2024
1078107
Implement AI Copilot for collab
IamZhenHong Nov 7, 2024
9c21372
Merge branch 'milestone-5' into ai-copilot2
IamZhenHong Nov 7, 2024
db0c107
Merge pull request #61 from IamZhenHong/ai-copilot2
Kevin-Liusx Nov 7, 2024
86fc7ec
resolve conflicts
Kevin-Liusx Nov 7, 2024
2385ca1
Fix some errors
Kevin-Liusx Nov 7, 2024
a616dac
Merge pull request #62 from Kevin-Liusx/milestone-5
Kevin-Liusx Nov 7, 2024
df9c2f0
Update deployment
jibtaf Nov 7, 2024
3502153
Merge pull request #63 from jibtaf/milestone-5
jibtaf Nov 7, 2024
0c3b470
Updated user api and route
adammangzijun Nov 7, 2024
f8a5423
Updated API for addSessionToUser
adammangzijun Nov 7, 2024
f658734
Updated History Function, working fine now.
adammangzijun Nov 7, 2024
013deeb
Merge branch 'milestone-5' of https://github.com/CS3219-AY2425S1/cs32…
adammangzijun Nov 7, 2024
95481f9
Add to assign question functionality
Leb14 Nov 8, 2024
3f53ee3
Merge pull request #65 from Leb14/milestone-five
jibtaf Nov 8, 2024
997772c
Change color
Leb14 Nov 8, 2024
f383648
Delete node_modules/.package-lock.json
adammangzijun Nov 8, 2024
4e9da00
Delete node_modules/debug/.jshintrc
adammangzijun Nov 8, 2024
e49f290
Merge pull request #66 from Leb14/milestone-five
jibtaf Nov 8, 2024
2d1f1cc
Delete node_modules/debug/.npmignore
adammangzijun Nov 8, 2024
b77e9c1
Delete node_modules/debug/History.md
adammangzijun Nov 8, 2024
9065da1
Delete node_modules/debug/Makefile
adammangzijun Nov 8, 2024
c72f6e2
Delete node_modules/debug/Readme.md
adammangzijun Nov 8, 2024
b99b16f
Delete node_modules/debug/browser.js
adammangzijun Nov 8, 2024
741afec
Delete node_modules/debug/component.json
adammangzijun Nov 8, 2024
7155b5c
Delete node_modules/debug/debug.js
adammangzijun Nov 8, 2024
3db16b4
Delete node_modules/debug/node.js
adammangzijun Nov 8, 2024
a9ce799
Delete node_modules/debug/package.json
adammangzijun Nov 8, 2024
9e5bb1d
Delete node_modules/erlang/.npmignore
adammangzijun Nov 8, 2024
b77ebcb
Delete node_modules/erlang/LICENSE
adammangzijun Nov 8, 2024
2a341aa
Delete node_modules/erlang/README.md
adammangzijun Nov 8, 2024
06847b9
Delete node_modules/erlang/decode.js
adammangzijun Nov 8, 2024
291a01c
Update for containerisation
jibtaf Nov 8, 2024
944c9ad
Merge branch 'milestone-5' into milestone-5
jibtaf Nov 8, 2024
35a048c
Merge pull request #64 from adammangzijun/milestone-5
jibtaf Nov 8, 2024
5db8dbb
Merge pull request #68 from jibtaf/milestone-5
jibtaf Nov 8, 2024
d31f91b
Delete node_modules
jibtaf Nov 8, 2024
50e28cd
Merge pull request #69 from jibtaf/milestone-5
jibtaf Nov 8, 2024
7db4a8b
Fix some bug
Kevin-Liusx Nov 8, 2024
cfaf039
Merge pull request #70 from Kevin-Liusx/milestone-5
Kevin-Liusx Nov 8, 2024
5f2b85f
Merge pull request #72 from CS3219-AY2425S1/milestone-5
jibtaf Nov 10, 2024
3c6edba
Fix question assigning bug
Leb14 Nov 12, 2024
815dac6
Fix language change bug
Leb14 Nov 12, 2024
e22e958
Add modal to notify user left room
Leb14 Nov 12, 2024
7a35ab2
Merge pull request #73 from Leb14/milestone-five
adammangzijun Nov 12, 2024
f8efd0a
Update containerisation
jibtaf Nov 12, 2024
3eaee39
Merge pull request #74 from jibtaf/milestone-5
jibtaf Nov 12, 2024
5cc56a1
Update containerisation
jibtaf Nov 12, 2024
6fa1898
Merge pull request #76 from jibtaf/post-ms7
jibtaf Nov 12, 2024
e21fcb4
Updated the function of saveSessionData, still not working
adammangzijun Nov 12, 2024
67b8e05
Created UI Design for Settings Page
adammangzijun Nov 13, 2024
5bbb26e
Updated history logic
adammangzijun Nov 13, 2024
84b647c
Merge pull request #77 from adammangzijun/post-ms7
Leb14 Nov 13, 2024
b7f1763
Updated loading for copilot response
adammangzijun Nov 13, 2024
5602b09
Add edit profile functionality
Leb14 Nov 13, 2024
aa2e560
Fixed code saving
adammangzijun Nov 13, 2024
a42057e
Merge pull request #78 from adammangzijun/post-ms7
Leb14 Nov 13, 2024
8d34215
Merge remote-tracking branch 'upstream/require-fixing-savesession' in…
Leb14 Nov 13, 2024
64d7aaa
Merge pull request #79 from Leb14/fix-save-bug
adammangzijun Nov 13, 2024
143b2a3
Update History Card
adammangzijun Nov 13, 2024
9be4d13
Merge pull request #81 from adammangzijun/post-ms7
jibtaf Nov 14, 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
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.env
.history

node_modules/

kubernetes/secrets.env
112 changes: 107 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,109 @@
[![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: G19

### 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.
### Quickstart:
There are two ways to run our application:
1. Using Docker
2. Using `npm`

Fisrt download or `git clone` our code.

#### Using Docker:
1. Make sure Docker is running
2. Add a file named `.env` to current directory (i.e., project root directory), with the following content:

```
JWT_SECRET=
DB_CLOUD_URI=
DB_LOCAL_URI=
MONGO_URL=
```
Fill in it with your own environment variable values.
3.
- If you are using running on MacOS or Linux, run the bash script:
`./run_all_containerized_services.sh`

If an error

`permission denied: ./run_all_containerized_services.sh`

occurs, please run

`chmod a+x run_all_containerized_services.sh`

before running the script.

- If you are using running on Windows, run:
```
docker-compose build --no-cache
docker-compose up -d
```
4. To stop all services, run:

`docker compose down` or `docker-compose down`(for Windows)

#### Using `npm`:
1. Add a file named `.env` to user_service directory (i.e., `./backend/user-service`), with the following content:

```
DB_CLOUD_URI=
DB_LOCAL_URI=
PORT=8000
ENV=PROD
JWT_SECRET=
```
Fill in it with your own environment variable values.
2. Add a file named `.env` to questions_service directory (i.e., `./backend/questions_service`), with the following content:

```
PORT=8001
MONGO_URL=
```
Fill in it with your own environment variable values.
3. Add a file named `.env` to matching-service directory (i.e., `./backend/matching-service`), with the following content:

```
PORT=8002
```
Fill in it with your own environment variable values.
4. Add a file named `.env` to collaboration-service directory (i.e., `./backend/collaboration-service`), with the following content:

```
PORT=8003
```
Fill in it with your own environment variable values.
5. **Make sure RabbitMQ is running on port `5672`.**
6.
- If you are running on MacOS or Linux, change back to the project root directory and run the script:

`./run_all_services.sh`

If an error

`permission denied: ./run_all_services.sh`

occurs, please run

`chmod a+x run_all_services.sh`

before running the script.

To stop all services, press `Ctrl + C`.

- If you are running on Windows:
1. run `npm install` for all backend services.

2. Change to the `/backend` directory, and run:
`npm start`.

3. Then change to the `/frontend` directory and run:

```
npm install
npm start
```
4. To stop all services, press `Ctrl + C` in all service directories.


**Now the frontend can be viewed at `http://localhost:3000`.**
3 changes: 3 additions & 0 deletions backend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.env
node_modules
*.rest
2 changes: 2 additions & 0 deletions backend/collaboration-service/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/
.env
13 changes: 13 additions & 0 deletions backend/collaboration-service/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM node:20-alpine

WORKDIR /app

COPY package*.json ./

RUN npm install

COPY . .

EXPOSE 8003

CMD ["npm", "start"]
140 changes: 140 additions & 0 deletions backend/collaboration-service/consumer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
const { Mistral } = require('@mistralai/mistralai');

const amqp = require('amqplib/callback_api');
const { sendWsMessage, broadcastToRoom } = require('./ws');
const axios = require('axios');
const dotenv = require('dotenv');
dotenv.config();

const CLOUDAMQP_URL = process.env.CLOUDAMQP_URL;
const LOCAL_RABBITMQ_URL = process.env.LOCAL_RABBITMQ_URL || "amqp://localhost:5672";
const COLLAB_SERVICE_URL = process.env.COLLAB_SERVICE_URL || "http://localhost:8003";

function arrayEquals(a, b) {
return Array.isArray(a) &&
Array.isArray(b) &&
a.length === b.length &&
a.every((val, index) => val === b[index]);
}

function checkSubset(parentArray, subsetArray) {
return subsetArray.every((el) => {
return parentArray.includes(el)
});
}

// In-memory store to track unmatched users
let unmatchedUsers = [];

// Function to set up RabbitMQ consumer
const setupConsumer = () => {
amqp.connect(LOCAL_RABBITMQ_URL, (err, conn) => {
if (err) {
console.error('Connection error in consumer.js:', err);
return;
}

conn.createChannel((err, ch) => {
if (err) throw err;
const queue = 'collab_queue';
ch.assertQueue(queue, { durable: false });

console.log('Listening for messages in RabbitMQ queue for collab...');
ch.consume(queue, async (msg) => {
const userRequest = JSON.parse(msg.content.toString());
console.log('Received user request:', userRequest);
console.log('User request type:', userRequest.type);
if (userRequest.status === 'cancel') {
// Handle cancel request
const userIndex = unmatchedUsers.findIndex(u => u.userId === userRequest.userId);
if (userIndex !== -1) {
console.log(`Cancelling request for user ${userRequest.userId}`);
clearTimeout(unmatchedUsers[userIndex].timeoutId); // Clear any pending timeout
unmatchedUsers.splice(userIndex, 1); // Remove user from unmatched list
sendWsMessage(userRequest.userId, { status: 'CANCELLED' });
console.log(`Cancelled matching request for user ${userRequest.userId}`);
} else {
console.log(`No unmatched request found for user ${userRequest.userId}`);
}
sendWsMessage(userRequest.userId, { status: 'CANCELLED' });
console.log(`Cancelled matching request for user ${userRequest.userId}`);
} else if (userRequest.type === 'ASK_COPILOT') {
// Function to make the API call with retry logic

try {
const apiKey = process.env.MISTRAL_API_KEY;
const client = new Mistral({ apiKey: apiKey });
prompt = userRequest.prompt;
currentCode = userRequest.code;

const chatResponse = await client.chat.complete({
model: 'mistral-large-latest',
messages: [{ role: 'user', content: currentCode + '\n' + prompt }],
});
console.log('Asking Copilot:', chatResponse);

broadcastToRoom(userRequest.roomId, { type: 'ASK_COPILOT', response: chatResponse.choices[0].message.content });
} catch (error) {
console.error("Failed to fetch chat response:", error);
broadcastToRoom(userRequest.roomId, { type: 'ASK_COPILOT', response: "Error fetching response from assistant." });
}
}
else {
// Handle match request
const match = unmatchedUsers.find(u =>
checkSubset(u.category, userRequest.category) ||
checkSubset(userRequest.category, u.category)
) || unmatchedUsers.find(u => u.difficulty === userRequest.difficulty);

if (match) {
try {
console.log(`Matched user ${userRequest.userId} with user ${match.userId}`);

// Create room in collaboration service
const response = await axios.post(`${COLLAB_SERVICE_URL}/rooms/create`, {
users: [userRequest.userId, match.userId],
difficulty: userRequest.difficulty,
category: userRequest.category
});
console.log(response.data);
const { roomId } = response.data;

// Notify both users
[userRequest, match].forEach(user => {
sendWsMessage(user.userId, {
status: 'MATCH_FOUND',
roomId,
matchedUserId: user === userRequest ? match.userId : userRequest.userId,
difficulty: userRequest.difficulty,
category: userRequest.category
});
});

// Clear the timeouts for both users
clearTimeout(match.timeoutId);

// Remove matched user from unmatchedUsers
unmatchedUsers = unmatchedUsers.filter(u => u.userId !== match.userId);
} catch (error) {
console.error('Error creating room:', error);
}
} else {
// Set a timeout to remove unmatched users after 30 seconds
const timeoutId = setTimeout(() => {
unmatchedUsers = unmatchedUsers.filter(u => u.userId !== userRequest.userId);
sendWsMessage(userRequest.userId, { status: 'timeout' });
}, 30000); // 30 seconds timeout

// Add the new user with their timeout ID
unmatchedUsers.push({ ...userRequest, timeoutId });
}
}

ch.ack(msg); // Acknowledge message processing
});
});
});
};


module.exports = { setupConsumer };
16 changes: 16 additions & 0 deletions backend/collaboration-service/controllers/copilotControllers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const { sendToQueue } = require("../mq");

const askCopilot = async (req, res) => {

const { code, prompt, type, roomId } = req.body;
console.log(`Received request to ask Copilot for prompt: ${prompt}`);

sendToQueue({ code, prompt, type, roomId });

res.status(200).send({ status: 'Request received. Waiting for Copilot response.' });

};

module.exports = {
askCopilot,
};
Loading