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 77 commits into
base: feedback
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
5e3a5d5
Setting up GitHub Classroom Feedback
github-classroom[bot] Sep 5, 2024
d82512c
add deadline
github-classroom[bot] Sep 5, 2024
b818eef
Initializes backend
brandon-nam Sep 25, 2024
3985ab8
sets up mongodb with mongoose
brandon-nam Sep 26, 2024
acd4746
Add question model, controller, and getQuestions controller function
brandon-nam Sep 26, 2024
e04f030
Add addQuestion controller function and edit api route
brandon-nam Sep 26, 2024
d31fde0
Add getQuestion, updateQuestion, and deleteQuestion
brandon-nam Sep 26, 2024
56f9691
setup react frontend
yuu-chennn Sep 28, 2024
1ac8052
set up routing
yuu-chennn Sep 28, 2024
20b01b6
added login page with mui
yuu-chennn Sep 28, 2024
f4e388e
Add login and signup API
brandon-nam Sep 29, 2024
ec69f75
Add comments regarding API endpoints
brandon-nam Sep 29, 2024
ae434dd
Make changes in backend for axios
brandon-nam Sep 29, 2024
3afe5cb
Add missing dependencies in frontend and set up axios for logging in
brandon-nam Sep 29, 2024
fd185f2
Allow for multiple categories in questionModel
brandon-nam Sep 29, 2024
9962d7b
Make homepage route non-protected and add CRUD operations to homepage
brandon-nam Sep 29, 2024
7f30c35
Disable enums constraints on question complexity
brandon-nam Sep 29, 2024
7efd8a9
Make description viewable after clicking the title
brandon-nam Sep 29, 2024
a4bf9ba
Add a missing jsonwebtoken dependency
brandon-nam Sep 29, 2024
981e7b4
Initial containerisation of frontend and backend components.
Oct 5, 2024
4f51cbc
Containerise microservices and frontend.
Oct 6, 2024
8d77541
Fix docker compose issues with named volume
brandon-nam Oct 6, 2024
2ee86d0
Update README.md
brandon-nam Oct 6, 2024
2d82c84
Edit port variable names in question and user service
brandon-nam Oct 6, 2024
3a1df29
Update README.md
Wyrkx Oct 6, 2024
029a226
Merge pull request #2 from CS3219-AY2425S1/containerization
AkkFiros Oct 6, 2024
2044034
Rename services and pull from given user service
brandon-nam Oct 16, 2024
b131ef8
Initialize rabbitmq
brandon-nam Oct 16, 2024
2c3e9ac
Set up rabbitmq for communication between user service and matching s…
brandon-nam Oct 18, 2024
3729edd
Comment out hot reload to fix missing dependency error
brandon-nam Oct 18, 2024
ed45e5d
Enable enum constraints on complexity
Wyrkx Oct 19, 2024
d8280c4
Implement socket.io notification
brandon-nam Oct 20, 2024
a65156e
Add matching logic
Wyrkx Oct 20, 2024
0c1d6d6
Merge branch 'matching-service' of https://github.com/CS3219-AY2425S1…
Wyrkx Oct 20, 2024
cecb6a7
Fix minor bugs
Wyrkx Oct 20, 2024
1a1392b
Implement cancel matching
Wyrkx Oct 20, 2024
1a57b37
Enable canceling and timeout
brandon-nam Oct 20, 2024
44dfc69
Merge branch 'matching-service' of https://github.com/CS3219-AY2425S1…
brandon-nam Oct 20, 2024
dcf426f
Enable choosing complexity and topic
brandon-nam Oct 20, 2024
512898b
Fix match cancel and env variable uses
brandon-nam Oct 20, 2024
94a4d29
Fix env variable uses
brandon-nam Oct 20, 2024
1558068
added sample questions to matchmaking
yuu-chennn Oct 20, 2024
fb5a23b
Fix timeout error issue
brandon-nam Oct 21, 2024
6b789b9
Change cancel match from synchronous to asynchronous
brandon-nam Oct 29, 2024
438a69e
Add question service message queue
brandon-nam Oct 29, 2024
3367c84
Add random question to match result
brandon-nam Oct 29, 2024
fd425af
Implement collaborative code editing
brandon-nam Oct 31, 2024
32c73a0
Add room creating logic
brandon-nam Nov 4, 2024
17ab1ae
Add leaving room logic
brandon-nam Nov 4, 2024
9d2ce99
Fix issues with leaving room
brandon-nam Nov 5, 2024
dc7eeec
Refactor code for chatting purposes
brandon-nam Nov 5, 2024
3d0f407
Enable chatting
brandon-nam Nov 5, 2024
b5ab15e
Delete messages and code after leaving room
brandon-nam Nov 5, 2024
e7a3cc5
Move urls to .env
Nov 5, 2024
82c66ed
Fix dockerfiles
Nov 5, 2024
ab597d6
Show matched question in collaborative space
brandon-nam Nov 6, 2024
9a951f1
Style collab space
brandon-nam Nov 6, 2024
e346ff9
Protect routes and implement navbar
brandon-nam Nov 6, 2024
1e0430b
add syntax highlighting and language selection
yuu-chennn Nov 6, 2024
01d9967
add helmet to all pages
yuu-chennn Nov 6, 2024
a3755c6
update interface and element positioning
yuu-chennn Nov 6, 2024
638ac9c
added constants for sample questions, categories, complexities, and c…
yuu-chennn Nov 6, 2024
5ed715a
Merge branch 'collaboration-service' into code-syntax
yuu-chennn Nov 6, 2024
580af49
fixed navigation link
yuu-chennn Nov 6, 2024
976b39d
updated home page to use constants import
yuu-chennn Nov 6, 2024
ce5e1d3
Fix chat scrolling issue
brandon-nam Nov 6, 2024
eca1dcc
Add Sandbox service to run code in collab space.
Nov 6, 2024
79aae73
Merge branch 'sandbox-service' into merged-syntax-sandbox
doimoiboi Nov 6, 2024
4f18b80
Fix faulty import.
doimoiboi Nov 6, 2024
19c9bab
Implement sandbox-service with google cloud functions.
doimoiboi Nov 13, 2024
c108e12
Run preview instead of dev
Nov 13, 2024
4d6553b
Fix various bugs
Nov 13, 2024
69f5f45
Merge pull request #3 from CS3219-AY2425S1/merged-syntax-sandbox
Wyrkx Nov 13, 2024
64ea18c
Implement continuous session
brandon-nam Nov 13, 2024
5d39bc9
Merge branch 'collaboration-service-fix'
Nov 13, 2024
35329dd
Update README
Nov 13, 2024
00d338b
remove button
yuu-chennn 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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
.env
42 changes: 21 additions & 21 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
MIT License

Copyright (c) 2024 CS3219-AY2425S1

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
MIT License
Copyright (c) 2024 CS3219-AY2425S1
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# CS3219 Project (PeerPrep) - AY2425S1
## Group: Gxx

### 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.
[![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: G13
### Welcome to Peerprep!
Checkout our project here: http://34.128.119.63:3000/login
23 changes: 23 additions & 0 deletions collaboration-service/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# backend/Dockerfile

# Use a Node.js base image
FROM node:18-alpine

# Set working directory
WORKDIR /usr/src/app/collaboration-service

# Copy package.json and install dependencies
COPY package*.json ./
# Ensure clean dependency install
RUN rm -rf node_modules
RUN npm install -g nodemon
RUN npm install

# Copy the rest of the app's source code
COPY . .

# Expose the backend port
EXPOSE 4444

# Command to run nodemon
CMD ["npm", "start"]
Empty file.
130 changes: 130 additions & 0 deletions collaboration-service/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
// server.js

const express = require('express');
const { createServer } = require('http');
const cors = require('cors');
const { WebSocketServer } = require('ws');
const Y = require('yjs');
const { setupWSConnection } = require('y-websocket/bin/utils');
const { createChannel, sendDeleteRoomRequest } = require('./rabbit/rabbit.js')

const app = express();
app.use(cors());
app.options('*', cors());
app.use(express.json());

const httpServer = createServer(app);
const wss = new WebSocketServer({ server: httpServer });

const docs = new Map();
const rooms = new Map();

wss.on('connection', (ws, req) => {
const urlParams = new URL(req.url, `http://${req.headers.host}`).searchParams;
const roomId = urlParams.get('room');
const isCustom = urlParams.get('custom') === 'true';

if (isCustom) {
// Handle custom WebSocket connection
if (!rooms.has(roomId)) {
rooms.set(roomId, { sockets: new Set(), question: null });
}
const room = rooms.get(roomId);
room.sockets.add(ws);

console.log(`Custom WebSocket client connected to room ${roomId}. Room size: ${room.sockets.size}`);

ws.on('message', (message) => {
try {
const messageString = message.toString('utf8');
const parsedMessage = JSON.parse(messageString);
console.log('Parsed custom message:', parsedMessage);

if (parsedMessage.type === 'SEND_QUESTION') {
room.question = parsedMessage.question;
} else if (parsedMessage.type === 'REQUEST_QUESTION') {
console.log('Request question received');
if (room.question) {
ws.send(
JSON.stringify({ type: 'RECEIVE_QUESTION', question: room.question })
);
}
}
} catch (error) {
console.error('Error parsing custom message:', error);
}
});

ws.on('close', async () => {
room.sockets.delete(ws);
console.log(`Custom WebSocket client disconnected from room ${roomId}. Room size: ${room.sockets.size}`);

if (room.sockets.size === 0) {
const channel = await createChannel();

const payload = { roomId: roomId }
sendDeleteRoomRequest(channel, Buffer.from(JSON.stringify(payload)));
await channel.close();
rooms.delete(roomId);
console.log(`Custom room ${roomId} removed`);
}
});

return;
}

// Yjs synchronization connection
if (!docs.has(roomId)) {
const doc = new Y.Doc();
docs.set(roomId, doc);

// Initialize shared types
doc.getText('monaco');
doc.getArray('chatMessages');
console.log(`Created new Yjs document for room ${roomId}`);
}

setupWSConnection(ws, req, {
docName: roomId,
doc: docs.get(roomId),
gc: true, // Enable garbage collection
});

ws.on('close', () => {
// Yjs WebSocket does not need to manage room sockets; handled internally
const doc = docs.get(roomId);

if (wss.clients.size === 0) {
// No clients connected to the server at all


docs.delete(roomId);
console.log(`Yjs document destroyed for room ${roomId}`);
}
});
});

httpServer.on('error', (error) => {
console.error('Server error:', error);
});

httpServer.on('listening', () => {
console.log(`Listening on port 4444`);
});

process.on('SIGINT', () => {
console.log('Server shutting down...');

docs.forEach((doc, roomId) => {
doc.destroy();
console.log(`Cleaned up Yjs document for room ${roomId}`);
});

docs.clear();
rooms.clear();

process.exit(0);
});

const PORT = process.env.PORT || 4444;
httpServer.listen(PORT);
Loading