Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
669c11e
removed dockerfile from database, added to backend
nsmzoneli May 11, 2026
5ca31e0
changed the entry point directory in dockerfile, commented out Judge0…
nsmzoneli May 11, 2026
a5fa432
added math problems schema
morganthegirlboss May 11, 2026
a3082ab
added comp sci problems schema
morganthegirlboss May 11, 2026
95eafe5
Adding virtual table and problem category type to be compatible with …
morganthegirlboss May 12, 2026
429a218
Providing categories to children tables
morganthegirlboss May 12, 2026
0060055
removed comments
morganthegirlboss May 12, 2026
bf03ee0
added sql tables for matches, match log and elo
nsmzoneli May 12, 2026
48e0208
removing function signature and equation in child tables, changed imp…
morganthegirlboss May 12, 2026
c662811
fixed id reference for match_problem table
nsmzoneli May 12, 2026
caf15a4
Merge branch 'nosandiso/docker-test-schema' into fixing_the_docker_file
morganthegirlboss May 15, 2026
417e400
use cases and functional requirements
Apr 30, 2026
3cdaf9f
initial use case diagram
Apr 30, 2026
ce31a7f
outlined inital use cases
Apr 30, 2026
3865d5e
organised use cases by actor
Apr 30, 2026
18b91ce
updated use cases and use case diagram
Apr 30, 2026
5fe4e7a
Updated functional requirements and use cases
May 1, 2026
0a83827
started changing our setup from JS to TS
May 13, 2026
8e9e980
updated backend files to use typescript
May 13, 2026
d93e486
updated backend for sonarQube safety checks
May 14, 2026
8177920
Commented out default pages because they were failing quality checks
May 14, 2026
b6ea37c
removed commented out code and unused imports
May 14, 2026
acb6e82
Merge branch 'dev' into fixing_the_docker_file
nsmzoneli May 16, 2026
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
12 changes: 12 additions & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM node:18-alpine

WORKDIR /app

COPY package*.json ./
RUN npm install

COPY . .

EXPOSE 3000

CMD ["node", "src/server.js"]
8 changes: 0 additions & 8 deletions database/Dockerfile

This file was deleted.

100 changes: 85 additions & 15 deletions database/init.sql
Original file line number Diff line number Diff line change
@@ -1,16 +1,86 @@
--very generic tables that can be changed later, just trying not to keep the file empty
CREATE TABLE IF NOT EXISTS users (
user_id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
username VARCHAR(50) UNIQUE NOT NULL,
email VARCHAR(100) UNIQUE NOT NULL,
password_hash VARCHAR(255) NOT NULL,
created_at TIMESTAMP DEFAULT NOW()
);

CREATE TABLE IF NOT EXISTS elo_ratings (
elo_id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
user_id UUID REFERENCES users(user_id),
game_mode VARCHAR(20) NOT NULL,
rating INTEGER DEFAULT 600,
updated_at TIMESTAMP DEFAULT NOW()
--very generic tables that can be changed later, just trying not to keep the file empty
CREATE TABLE IF NOT EXISTS users (
user_id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
username VARCHAR(50) UNIQUE NOT NULL,
email VARCHAR(100) UNIQUE NOT NULL,
password_hash VARCHAR(255) NOT NULL,
created_at TIMESTAMP DEFAULT NOW()
);

CREATE TABLE IF NOT EXISTS match_problems(
match_problems_id PRIMARY KEY DEFAULT gen_random_uuid(),
question1 UUID REFERENCES problems(id) NOT NULL,
question2 UUID REFERENCES problems(id) NOT NULL,
question3 UUID REFERENCES problems(id) NOT NULL, --every match has a minimum of 3 questions, i.e. difficult mode
question4 UUID REFERENCES problems(id),
question5 UUID REFERENCES problems(id)
);

CREATE TABLE IF NOT EXISTS matches(
match_id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
player1_id UUID REFERENCES users(user_id),
player2_id UUID REFERENCES users(user_id),
match_problems_id UUID REFERENCES match_problems(match_problems_id),
mode VARCHAR(10) CHECK (mode IN ('ranked', 'casual')) NOT NULL,
queue_start TIMESTAMP DEFAULT NOW() NOT NULL,
match_start TIMESTAMP,
status VARCHAR(20) CHECK (status IN ('waiting', 'in_progress', 'completed', 'abandoned')) DEFAULT 'waiting'
);

CREATE TABLE IF NOT EXISTS match_log(
log_id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
match_id UUID REFERENCES matches(match_id),
winner_id UUID REFERENCES users(user_id),
loser_id UUID REFERENCES users(user_id),
elo_gained INTEGER, --can be null incase it's a casual match
elo_lost INTEGER
);

CREATE TYPE problem_category AS ENUM ('math', 'programming');

CREATE TABLE IF NOT EXISTS problems (
id SERIAL PRIMARY KEY,
type problem_category NOT NULL,
difficulty_level ENUM('Easy', 'Medium', 'Difficult') NOT NULL,
title VARCHAR(20) NOT NULL,
description VARCHAR(40) NOT NULL,
time_limit TIME(2) NOT NULL
);

CREATE TABLE IF NOT EXISTS elo_ratings (
elo_id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
user_id UUID REFERENCES users(user_id),
rating INTEGER DEFAULT 600,
updated_at TIMESTAMP DEFAULT NOW(),

);


CREATE TABLE IF NOT EXISTS math_problems (
id SERIAL PRIMARY KEY,
problem_id INT NOT NULL REFERENCES problems(id) ON DELETE CASCADE,
--equation VARCHAR(20) NOT NULL,
solution_formula VARCHAR(20) NOT NULL,
CONSTRAINT math_category_check CHECK (
(SELECT type FROM problems WHERE id = problem_id) = 'math'
)
);

CREATE TABLE IF NOT EXISTS programming_problems (
id SERIAL PRIMARY KEY,
problem_id INT NOT NULL REFERENCES problems(id) ON DELETE CASCADE,
--function_signature VARCHAR(25) NOT NULL,
supported_languages ENUM('java', 'c++') NOT NULL,
CONSTRAINT programming_category_check CHECK (
(SELECT type FROM problems WHERE id = problem_id) = 'programming'
)
);

CREATE TABLE IF NOT EXISTS elo_history (
history_id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
user_id UUID REFERENCES users(user_id),
match_id UUID REFERENCES matches(match_id),
old_rating INTEGER,
new_rating INTEGER,
changed_at TIMESTAMP DEFAULT NOW()
);
Loading
Loading