ctfrancia / ajedrez-be

back-end code for chess website
MIT License
0 stars 0 forks source link

ajedrez-be

back-end code for chess website

Project setup

TODO: add more setup instructions for Linux and Windows

DB Column Explanations

NOTE this is currently changing frequently as the project is in development

clubs

Description

TODO

    Column    |            Type             | Collation | Nullable |                Default
--------------+-----------------------------+-----------+----------+----------------------------------------
 club_id      | bigint                      |           | not null | nextval('clubs_club_id_seq'::regclass)
 is_active    | boolean                     |           | not null | true
 is_verified  | boolean                     |           | not null | false
 created_at   | timestamp(0) with time zone |           | not null | now()
 updated_at   | timestamp(0) with time zone |           | not null | now()
 deleted_at   | timestamp(0) with time zone |           |          |
 code         | text                        |           | not null |
 name         | text                        |           | not null |
 address      | text                        |           | not null |
 observations | text                        |           |          |
 city         | text                        |           | not null |
 country      | text                        |           | not null | 'Spain'::text
Indexes:
    "clubs_pkey" PRIMARY KEY, btree (club_id)
Referenced by:
    TABLE "users" CONSTRAINT "fk_admin_of" FOREIGN KEY (club_admin_of) REFERENCES clubs(club_id) ON DELETE CASCADE
    TABLE "users" CONSTRAINT "fk_user_club" FOREIGN KEY (club_id) REFERENCES clubs(club_id) ON DELETE CASCADE

Definitions and descriptions

users

Description

                                                Table "public.users"
        Column         |            Type             | Collation | Nullable |                Default
-----------------------+-----------------------------+-----------+----------+----------------------------------------
 user_id               | bigint                      |           | not null | nextval('users_user_id_seq'::regclass)
 is_active             | boolean                     |           | not null | false
 is_verified           | boolean                     |           | not null | false
 is_admin_of_club      | boolean                     |           | not null | false
 club_admin_of         | bigint                      |           |          |
 created_at            | timestamp(0) with time zone |           | not null | now()
 updated_at            | timestamp(0) with time zone |           | not null | now()
 deleted_at            | timestamp(0) with time zone |           |          |
 first_name            | text                        |           | not null |
 last_name             | text                        |           | not null |
 dob                   | date                        |           |          |
 sex                   | text                        |           |          |
 username              | text                        |           |          |
 email                 | text                        |           |          |
 password              | text                        |           |          |
 password_reset_token  | text                        |           |          |
 avatar                | text                        |           |          |
 club_id               | bigint                      |           |          |
 club_role_id          | bigint                      |           |          |
 about_me              | text                        |           |          |
 is_arbiter            | boolean                     |           | not null | false
 is_coach              | boolean                     |           | not null | false
 price_per_hour        | integer                     |           | not null | 0
 chess_com_username    | text                        |           | not null | ''::text
 lichess_username      | text                        |           | not null | ''::text
 chess24_username      | text                        |           | not null | ''::text
 country               | text                        |           | not null | 'SPAIN'::text
 province              | text                        |           | not null | ''::text
 city                  | text                        |           | not null | ''::text
 neighborhood          | text                        |           | not null | ''::text
 elo_fide_standard     | integer                     |           |          |
 elo_fide_rapid        | integer                     |           |          |
 elo_national_standard | integer                     |           |          |
 elo_national_rapid    | integer                     |           |          |
 elo_regional_standard | integer                     |           |          |
 club_user_code        | text                        |           |          |
 chess_age_category    | text                        |           |          |
 elo_regional_rapid    | integer                     |           |          |
 Indexes:
    "users_pkey" PRIMARY KEY, btree (user_id)
    "users_club_user_code_unique" UNIQUE CONSTRAINT, btree (club_user_code)
Foreign-key constraints:
    "fk_admin_of" FOREIGN KEY (club_admin_of) REFERENCES clubs(club_id) ON DELETE CASCADE
    "fk_user_club" FOREIGN KEY (club_id) REFERENCES clubs(club_id) ON DELETE CASCADE

Definitions and descriptions

notes

In order for the person to be able to have an active account, they need to sign up for the website.

tournaments

Description

Tournaments represent the parent of the games table and will define the rules and regulations of the subsequent games of the child games.

Definitions and descriptions

CREATE TABLE IF NOT EXISTS tournaments (
    tournament_id bigserial PRIMARY KEY,  
    is_active boolean NOT NULL DEFAULT TRUE,
    created_at timestamp(0) with time zone NOT NULL DEFAULT NOW(),
    updated_at timestamp(0) with time zone NOT NULL DEFAULT NOW(),
    deleted_at timestamp(0) with time zone,
    name text NOT NULL,
    description text,
    start_date timestamp(0) with time zone NOT NULL,
    end_date timestamp(0) with time zone NOT NULL,
    no_of_rounds integer NOT NULL DEFAULT 0,
    time_control text NOT NULL, -- create fk to time_control table
    clock_type text NOT NULL,
    clock_rhythm text NOT NULL,
    aribiters bigint[] NOT NULL DEFAULT '{}', -- create fk
    location text,
    organizer_id bigint,
);

games

Description

A game is also considered a round or a match. For example a tournament can be composed of 9 rounds. Those 9 rounds can be considered 9 games and will thus be stored in the games table.

Definitions and descriptions

CREATE TABLE IF NOT EXISTS games (
    game_id bigserial PRIMARY KEY,  
    is_active boolean NOT NULL DEFAULT TRUE,
    created_at timestamp(0) with time zone NOT NULL DEFAULT NOW(),
    updated_at timestamp(0) with time zone NOT NULL DEFAULT NOW(),
    deleted_at timestamp(0) with time zone,
    start_at timestamp(0) with time zone NOT NULL,
    end_at timestamp(0) with time zone,
    location text,
    fide_valid boolean NOT NULL DEFAULT FALSE,
    national_valid boolean NOT NULL DEFAULT FALSE,
    regional_valid boolean NOT NULL DEFAULT FALSE,
    organizer_id bigint,
    organizer_email text NOT NULL,
    organizer_phone text NOT NULL,
    players_attending integer[] NOT NULL DEFAULT '{}',
    club_member_price integer NOT NULL DEFAULT 0,
    club_non_member_price integer NOT NULL DEFAULT 0,
    qr_code text,
    description text,
    additional_info text,
    tournament_id bigint,
);

club_roles

Description

TODO

Definitions and descriptions

TODO

API Endpoints

Users