Skip to content

Commit

Permalink
Milestone 6: Nice-to-Haves (#121)
Browse files Browse the repository at this point in the history
* Add base code for collaboration service

* Added additional services for collaboration and code improvements

* Add basic collab page with resizeable panels

* Add collab-test page component for real-time collaboration

* Add capturing of selection in onInputCapture function

* Add matching history

* Integrate ide in collaboration page

* Fix lint errors for collaboration page

* Add server.js for Socket.io and YJS integration

* Basic collab editor function done

* Remove unecessary dep in useCallback

* Add monaco editor and y-websocket dependencies

* Add MonacoEditor component for collaborative code editing

* Add cursor indicators for collaboration ide

* Add dracula theme for monaco ide

* Collab-test (to be removed)

* Add todo

* Add subscribe button

* Refactor async function to fetch and display question (temp)

* Add CollaborativeEditor and InjectableCursorStyles components

* Get user and add todo

* Refactor matching logic (#104)

* Implement y-websocket and host it as a separate gateway (#101)

* Refactor code structure for collab to maintain consistency

* Adding a new yjs ws gateway

* Update merge error

* Attempt to create yjs gateway

* Remove yjs in nestjs

* Implement y-websocket as service

* Ms5 jared/refactor matching (#102)

* Add base code for collaboration service

* Added additional services for collaboration and code improvements

* Add matching history

* Refactor matching logic

---------

Co-authored-by: Evan Yan <103996156+evanyan13@users.noreply.github.com>

* Revert "Ms5 jared/refactor matching (#102)" (#103)

This reverts commit ef07356.

---------

Co-authored-by: Jajabonks <84561814+Jajared@users.noreply.github.com>

* Add new features and update layout in collaboration page

* Improve error handling for question creation/editing

* Update UI components in Chatbox and DescriptionTabContent

* Add y-utility package dependency

* Add useYjsStore custom hook for syncing with Yjs store

* Update CollaborativeWhiteboard to use our own yjs backend

* Refactor cursor styles and WebSocket connection in Editor

* Fix build errors

* Update default socket URLs in collaborative editor and whiteboard components

* Add cursorColors.ts with array of colors and getRandomColor() function

* Use random color for the cursors

* Implement get collab session (#105)

* Implement get collab session

* Remove unused schema

* Check session status before returning session details

* Patch: Connect collab message with gateway

* Add get question by ID endpoint

* Fix get question by id endpoint

* Reorder setupWSConnection to fix sync issues

* Update collaboration page to fetch session info before rendering

* Refactor code for passing sessionId to editor components

* Create SessionInfo schema for storing session details

* Add getSessionInfo function to collaborationService

* Add redirect user to collaboration page

* Setup y-mongo db provider (#106)

* Patch import error
:

* fix get question by id endpoint

* Update CreateQuestionModal.tsx with quill editor

* Update EditQuestionModal.tsx to include quill functionalities

* Update DescriptionTabContent.tsx to display updated description format

* Update pages to display correct question for collab session

* Add QuestionSchema parsing and update DescriptionTabContent

* Quill (#109)

* Update CreateQuestionModal.tsx with quill editor

* Update EditQuestionModal.tsx to include quill functionalities

* Update DescriptionTabContent.tsx to display updated description format

* Update pages to display correct question for collab session

* Add QuestionSchema parsing and update DescriptionTabContent

---------

Co-authored-by: shavonneg <>

* Fix build errors and eslint errors

* Remove test server file

* Remove duplicate QuestionTabPanel component

* Refactor collaboration frontend and add additional endpoints for code review

* Integrate code review

* Remove unnecessary changes

* Resolve conflicts

* Resolve extra linting

* Add syntax highlighting and markdown support in code review (#111)

* Refactor to use animation context to persist code review (#112)

* Refactor code to use context

* Add code execution service

* Update default language to Python in CollaborativeEditor

* Update

* Standardise result object

* Fix prettier errors

* Add test case field to question schema and service

* Add user collab history endpoint

* Add update question test cases functionality

* Add update question test cases endpoint

* Update

* Add executionTime

* Add functionality to manage test cases in questions

* Implement collab-service websocket in gateway

* Implement test cases tab to display actual test cases

* Improve UI

* Change theme to use cloudsMidnight

* Temp test result tab content

* Collaboration socket integration draft

* Add 'submit' functionality for code execution and testing

* Implement basic chat

* Update backend collab socket to handle chat

* Chat feature now shows profile details

* Chat feature now persists profile details even if not in session

* Add question feature and test result submission handling

* Update TestResultDto and CollaborationGateway for code execution

* Chat now persisted via redis

* Polish chat ui to auto scroll

* Update CollaborativeEditor and TabPanel components styling

* Remove unnecessary console log statements in CollaborationGateway

* Fix build errors

* MS6 DevOps: Cloud Deployment using K8s (#115)

* Push image up aws cloud

* Attempt to bring up question service

* Update Dockerfile for k8

* Setup local k8 deployment

* Revert "Setup local k8 deployment"

This reverts commit 95c6775.

* Reapply "Setup local k8 deployment"

This reverts commit a7fef30.

* Update config

* Remove non essential yml

* Deployed to GKE

* Initialise CI workflow (#117)

* Initialise ci (#118)

* Initialise CI workflow

* Add CI for both repos

* Fix ci (#119)

* Initialise CI workflow

* Fix CI pipeline

* Add ci (#120)

* Initialise CI workflow

* Amend CI workflow

* Fix linting and add backend CI workflow

* Reconfigure for local dev

* Update deployment options

---------

Co-authored-by: Jajabonks <84561814+Jajared@users.noreply.github.com>

* MS6 Code Execution, P2P Chat, Session History (#122)

* Merged with ms6-rick/code-execution

* Refactor code-runner to use sourceFileName for Java class

* Fix toast position issue and remove recharts

* Change avatar in find match modal to use displayName

* Update input file name with random number suffix

* Implement change language functionality

* Implement change language functionality

* Add join session error handling

* Fix lint issues

* Add session history schemas and types

* Add user session history retrieval function

* Add functionality to rejoin active collaboration sessions

* Add handling of session ending in collaboration service

* Implement end session functionality

* Implement rejoin and end session

* Change source file name to Solution

---------

Co-authored-by: jmsandiegoo <jmsandiego0710@gmail.com>

* Update Backend CICD Github Action (#123)

* Push image up aws cloud

* Attempt to bring up question service

* Update Dockerfile for k8

* Setup local k8 deployment

* Revert "Setup local k8 deployment"

This reverts commit 95c6775.

* Reapply "Setup local k8 deployment"

This reverts commit a7fef30.

* Update config

* Remove non essential yml

* Deployed to GKE

* Initialise CI workflow (#117)

* Initialise ci (#118)

* Initialise CI workflow

* Add CI for both repos

* Fix ci (#119)

* Initialise CI workflow

* Fix CI pipeline

* Add ci (#120)

* Initialise CI workflow

* Amend CI workflow

* Fix linting and add backend CI workflow

* Reconfigure for local dev

* Update deployment options

* Update backend cd workflow

* Update syntax

* Update backend ci action version

---------

Co-authored-by: Jajabonks <84561814+Jajared@users.noreply.github.com>

---------

Co-authored-by: Jajared <jajawong09@gmail.com>
Co-authored-by: jmsandiegoo <jmsandiego0710@gmail.com>
Co-authored-by: Rick <rick.kohjiaxuan@gmail.com>
Co-authored-by: Jajabonks <84561814+Jajared@users.noreply.github.com>
Co-authored-by: shavonneg <>
  • Loading branch information
5 people authored Nov 12, 2024
1 parent 95cbc6f commit ac068b5
Show file tree
Hide file tree
Showing 156 changed files with 10,222 additions and 1,021 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/backend-ci-workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: '18'
node-version: "18"

- name: Install Dependencies for Each Service
run: |
Expand Down
46 changes: 46 additions & 0 deletions .github/workflows/docker-build-push-gcloud.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Build and Push Docker Images to Google Cloud

on:
pull_request:
branches:
- main
push:
branches:
- main

jobs:
build-and-push:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Google Cloud CLI
uses: google-github-actions/setup-gcloud@v0.2.0
with:
project_id: ${{ secrets.GCP_PROJECT_ID }}
service_account_key: ${{ secrets.GCP_SERVICE_ACCOUNT_KEY }}
export_default_credentials: true

- name: Authenticate Docker to Google Artifact Registry
run: gcloud auth configure-docker ${{ secrets.GCP_REGION }}-docker.pkg.dev

- name: Build and Push Docker Images for Each Service
env:
GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
GCP_REGION: ${{ secrets.GCP_REGION }}
SERVICES: ${{ vars.SERVICES }}
run: |
# Convert the comma-separated SERVICES string to an array
IFS=',' read -ra services <<< "$SERVICES"
# Loop over each service, build and push its Docker image
for service in "${services[@]}"; do
# Define the Docker image path
IMAGE_NAME="${GCP_REGION}-docker.pkg.dev/${GCP_PROJECT_ID}/peerprep/$service:${GITHUB_SHA}"
# Build and push the Docker image
echo "Building and pushing image for $service..."
docker buildx build --platform linux/amd64 -t $IMAGE_NAME -f ./$service/Dockerfile ./backend/$service --push
done
40 changes: 3 additions & 37 deletions backend/auth-service/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,47 +1,13 @@
#################
## DEVELOPMENT ##
#################
FROM node:18-alpine AS development
FROM node:18

# Set the working directory in the container
WORKDIR /app

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

# Install dependencies
RUN npm install

# Copy the rest of the application code
COPY . .

# Built the app to /dist folder
RUN npm run build
EXPOSE 3003

# Expose the port the app runs on
EXPOSE 4000

################
## PRODUCTION ##
################
FROM node:18-alpine AS production

# Set node environment to production
ARG NODE_ENV=production
ENV NODE_ENV=${NODE_ENV}

# Set the working directory in the container
WORKDIR /app

# Copy only the necessary files from the previous build stage
COPY --from=development /peerprep/app/dist ./dist
COPY package*.json ./

# Install production dependencies only
RUN npm ci --only=production

# Expose the port the app runs on
EXPOSE 4000

# Run the main file
CMD ["node", "dist/main"]
CMD ["node", "dist/main.js"]
1 change: 1 addition & 0 deletions backend/code-execution-service/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
56 changes: 56 additions & 0 deletions backend/code-execution-service/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# compiled output
/dist
/node_modules
/build

# Logs
logs
*.log
npm-debug.log*
pnpm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# OS
.DS_Store

# Tests
/coverage
/.nyc_output

# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json

# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# temp directory
.temp
.tmp

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
4 changes: 4 additions & 0 deletions backend/code-execution-service/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"singleQuote": true,
"trailingComma": "all"
}
38 changes: 38 additions & 0 deletions backend/code-execution-service/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Use a single stage for both development and production
FROM ubuntu:20.04

# Set environment variables to prevent interactive prompts
ENV DEBIAN_FRONTEND=noninteractive

# Update package list and install Python 3, pip, Java, and Node.js
RUN apt-get update && \
apt-get install -y \
python3 python3-pip openjdk-11-jdk curl gnupg && \
curl -fsSL https://deb.nodesource.com/setup_18.x | bash - && \
apt-get install -y nodejs && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

# Verify installations
RUN python3 --version && java -version && node --version

# Set the working directory in the container
WORKDIR /app

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

# Install dependencies
RUN npm install

# Copy the rest of the application code
COPY . .

# Build the app
RUN npm run build

# Expose the port the app runs on
EXPOSE 4000

# Set the command to run the application
CMD ["node", "dist/main.js"]
76 changes: 76 additions & 0 deletions backend/code-execution-service/Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#################
## DEVELOPMENT ##
#################
FROM ubuntu:20.04 AS development

# Set environment variables to prevent interactive prompts
ENV DEBIAN_FRONTEND=noninteractive

# Update package list and install Python 3, pip, Java, and Node.js
RUN apt-get update && \
apt-get install -y \
python3 python3-pip openjdk-11-jdk curl gnupg && \
curl -fsSL https://deb.nodesource.com/setup_18.x | bash - && \
apt-get install -y nodejs && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

# Verify installations
RUN python3 --version && java -version && node --version

# Set the working directory in the container
WORKDIR /app

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

# Install dependencies
RUN npm install

# Copy the rest of the application code
COPY . .

# Build the app to the /dist folder
RUN npm run build

# Expose the port the app runs on
EXPOSE 4000

# Run the application in development mode
CMD ["npm", "run", "start:dev"]


################
## PRODUCTION ##
################
FROM ubuntu:20.04 AS production

# Set environment variables to prevent interactive prompts
ENV DEBIAN_FRONTEND=noninteractive
ARG NODE_ENV=production
ENV NODE_ENV=${NODE_ENV}

# Install only runtime dependencies (Node.js, Python, and Java)
RUN apt-get update && \
apt-get install -y \
python3 openjdk-11-jdk curl gnupg && \
curl -fsSL https://deb.nodesource.com/setup_18.x | bash - && \
apt-get install -y nodejs && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

# Set the working directory in the container
WORKDIR /app

# Copy the build artifacts from the development stage
COPY --from=development /app/dist ./dist
COPY package*.json ./

# Install production dependencies only
RUN npm ci --only=production

# Expose the port the app runs on
EXPOSE 4000

# Run the main application
CMD ["node", "dist/main"]
85 changes: 85 additions & 0 deletions backend/code-execution-service/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<p align="center">
<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="120" alt="Nest Logo" /></a>
</p>

[circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456
[circleci-url]: https://circleci.com/gh/nestjs/nest

<p align="center">A progressive <a href="http://nodejs.org" target="_blank">Node.js</a> framework for building efficient and scalable server-side applications.</p>
<p align="center">
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/dm/@nestjs/common.svg" alt="NPM Downloads" /></a>
<a href="https://circleci.com/gh/nestjs/nest" target="_blank"><img src="https://img.shields.io/circleci/build/github/nestjs/nest/master" alt="CircleCI" /></a>
<a href="https://coveralls.io/github/nestjs/nest?branch=master" target="_blank"><img src="https://coveralls.io/repos/github/nestjs/nest/badge.svg?branch=master#9" alt="Coverage" /></a>
<a href="https://discord.gg/G7Qnnhy" target="_blank"><img src="https://img.shields.io/badge/discord-online-brightgreen.svg" alt="Discord"/></a>
<a href="https://opencollective.com/nest#backer" target="_blank"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a>
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://opencollective.com/nest/sponsors/badge.svg" alt="Sponsors on Open Collective" /></a>
<a href="https://paypal.me/kamilmysliwiec" target="_blank"><img src="https://img.shields.io/badge/Donate-PayPal-ff3f59.svg" alt="Donate us"/></a>
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://img.shields.io/badge/Support%20us-Open%20Collective-41B883.svg" alt="Support us"></a>
<a href="https://twitter.com/nestframework" target="_blank"><img src="https://img.shields.io/twitter/follow/nestframework.svg?style=social&label=Follow" alt="Follow us on Twitter"></a>
</p>
<!--[![Backers on Open Collective](https://opencollective.com/nest/backers/badge.svg)](https://opencollective.com/nest#backer)
[![Sponsors on Open Collective](https://opencollective.com/nest/sponsors/badge.svg)](https://opencollective.com/nest#sponsor)-->

## Description

[Nest](https://github.com/nestjs/nest) framework TypeScript starter repository.

## Project setup

```bash
$ npm install
```

## Compile and run the project

```bash
# development
$ npm run start

# watch mode
$ npm run start:dev

# production mode
$ npm run start:prod
```

## Run tests

```bash
# unit tests
$ npm run test

# e2e tests
$ npm run test:e2e

# test coverage
$ npm run test:cov
```

## Resources

Check out a few resources that may come in handy when working with NestJS:

- Visit the [NestJS Documentation](https://docs.nestjs.com) to learn more about the framework.
- For questions and support, please visit our [Discord channel](https://discord.gg/G7Qnnhy).
- To dive deeper and get more hands-on experience, check out our official video [courses](https://courses.nestjs.com/).
- Visualize your application graph and interact with the NestJS application in real-time using [NestJS Devtools](https://devtools.nestjs.com).
- Need help with your project (part-time to full-time)? Check out our official [enterprise support](https://enterprise.nestjs.com).
- To stay in the loop and get updates, follow us on [X](https://x.com/nestframework) and [LinkedIn](https://linkedin.com/company/nestjs).
- Looking for a job, or have a job to offer? Check out our official [Jobs board](https://jobs.nestjs.com).

## Support

Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://docs.nestjs.com/support).

## Stay in touch

- Author - [Kamil Myśliwiec](https://twitter.com/kammysliwiec)
- Website - [https://nestjs.com](https://nestjs.com/)
- Twitter - [@nestframework](https://twitter.com/nestframework)

## License

Nest is [MIT licensed](https://github.com/nestjs/nest/blob/master/LICENSE).
8 changes: 8 additions & 0 deletions backend/code-execution-service/nest-cli.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"$schema": "https://json.schemastore.org/nest-cli",
"collection": "@nestjs/schematics",
"sourceRoot": "src",
"compilerOptions": {
"deleteOutDir": true
}
}
Loading

0 comments on commit ac068b5

Please sign in to comment.