Skip to content

Commit d0659e0

Browse files
docs: start SQL diagrams and thinking about season implementation
1 parent 0272d79 commit d0659e0

4 files changed

Lines changed: 96 additions & 14 deletions

File tree

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
title: Concepts and Vocabulary
3+
---
4+
5+
# Disambiguation
6+
7+
## Match/Set
8+
When we refer to the games played between players, which are reported to Grindcord, we use the term "match" over "set". Despite "set" being more common to refer to a past game, it shadows the term "set", which is a reserved word in programming (the data structure).

apps/docsite/docs/Internal/database.md

Lines changed: 75 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,80 @@
22
title: Database Design
33
---
44

5-
This file outlines the structure of the entities stored by Grindcord, and the rationale in their design.
5+
This file outlines the structure of the entities stored by Grindcord, and the rationale in their design. An emphasis is placed on database entities in their role as storage, rather than their function.
6+
7+
In an effort to support compatibility with every database management system (DBMS) supported by Knex.js, we avoid the use of arrays and enums.
8+
9+
Matches are reported to the backend. These reports contain the data:
10+
11+
- The Discord server in which the match was played
12+
- The users who played
13+
- Match count (3-0)
14+
- The fighters used by each respective user
15+
16+
##### External Dependencies
17+
18+
A user of Grindcord SHOULD NOT be stored explicitly in our database. A [`GuildMember`](https://discord.com/developers/docs/resources/guild#get-guild-member) is an external dependency provided by Discord. A [`GuildMember`](https://discord.com/developers/docs/resources/guild#get-guild-member)'s `user_id` on the [`user`](https://discord.com/developers/docs/resources/user#user-object) field SHOULD be considered a primary key for our purposes.
19+
20+
A guild SHOULD NOT be stored explicitly in our database. A [`Guild`](https://discord.com/developers/docs/resources/guild#get-guild) is an external dependency provided by Discord. A `Guild`'s `guild_id` SHOULD be considered a primary key for our purposes.
21+
22+
```mermaid
23+
erDiagram
24+
direction LR
25+
Guild
26+
GuildMember
27+
```
28+
29+
We split this into three tables.
630

731
```mermaid
8-
```
32+
erDiagram
33+
direction LR
34+
Match {
35+
int match_id PK
36+
int season_id PK
37+
datetime created_at
38+
}
39+
MatchPlayer {
40+
int match_id FK,PK
41+
string user_id PK
42+
int win_count
43+
}
44+
MatchCharacter {
45+
int match_id FK,PK
46+
string user_id
47+
int fighter_number
48+
}
49+
Match ||--|{ MatchPlayer: "is played by"
50+
MatchPlayer ||..|{ MatchCharacter: "uses"
51+
```
52+
53+
##### Entity Relation Diagram for Matches, storing the data that would be reported by a user.
54+
55+
The winner of the match can be inferred by selecting the `MatchPlayer` record with the highest `win_count` among records with the same `match_id`.
56+
57+
Note that `guild_id` is not stored by the `Match` table. When a match is reported for a particular `guild_id` (a unique ID assigned by Discord for a particular Discord server), the match is reported for that "guild's" current season (see below).
58+
59+
```mermaid
60+
erDiagram
61+
direction LR
62+
Match {
63+
int match_id
64+
int season_id
65+
datetime created_at
66+
}
67+
Season {
68+
int season_id
69+
string guild_id
70+
datetime start_at
71+
datetime end_at
72+
}
73+
Match }|--|| Season: "was played during"
74+
Guild ||--o{ Season: "has a current or past"
75+
```
76+
77+
##### Entity Relation Diagram for Seasons.
78+
79+
A guild's "current" season is a `Season` record for which the `guild_id` matches, and the system datetime is between `start_at` and `end_at`.
80+
81+
In addition, a `Season` in which participants will be designated an individual tier. Participants in a `Season` are `GuildMember` who report having participated in a `Match` during a `Season`.

apps/docsite/src/components/HomepageFeatures/index.tsx

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,32 +11,33 @@ type FeatureItem = {
1111

1212
const FeatureList: FeatureItem[] = [
1313
{
14-
title: 'Easy to Use',
14+
title: 'Handle the boring stuff',
1515
Svg: require('@site/static/img/undraw_docusaurus_mountain.svg').default,
1616
description: (
1717
<>
18-
Docusaurus was designed from the ground up to be easily installed and
19-
used to get your website up and running quickly.
18+
Grindcord is designed to assist in all the bureaucracy of running a leaderboard
19+
so that you can get right back to the fun part of engaging in competition.
2020
</>
2121
),
2222
},
2323
{
24-
title: 'Focus on What Matters',
24+
title: 'Easy, Simple, and Extensible',
2525
Svg: require('@site/static/img/undraw_docusaurus_tree.svg').default,
2626
description: (
2727
<>
28-
Docusaurus lets you focus on your docs, and we&apos;ll do the chores. Go
29-
ahead and move your docs into the <code>docs</code> directory.
28+
Grindcord is accessible to anyone from competitors, to server admins, to TOs,
29+
whether or not they have technical experience, and especially supports those with
30+
experience to use Grindcord to its full potential.
3031
</>
3132
),
3233
},
3334
{
34-
title: 'Powered by React',
35+
title: 'Open-source, self-hostable',
3536
Svg: require('@site/static/img/undraw_docusaurus_react.svg').default,
3637
description: (
3738
<>
38-
Extend or customize your website layout by reusing React. Docusaurus can
39-
be extended while reusing the same header and footer.
39+
Grindcord is created by competitors, for competitors. We invite anyone,
40+
regardless of experience, to use Grindcord for their own purposes.
4041
</>
4142
),
4243
},

apps/docsite/src/pages/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ function HomepageHeader() {
2121
<Link
2222
className="button button--secondary button--lg"
2323
to="/docs/intro">
24-
Docusaurus Tutorial - 5min ⏱️
24+
Get started with Grindcord
2525
</Link>
2626
</div>
2727
</div>
@@ -33,8 +33,8 @@ export default function Home(): ReactNode {
3333
const {siteConfig} = useDocusaurusContext();
3434
return (
3535
<Layout
36-
title={`Hello from ${siteConfig.title}`}
37-
description="Description will go into a meta tag in <head />">
36+
title={`Welcome to ${siteConfig.title}`}
37+
description="Tools for competitive Smash communities">
3838
<HomepageHeader />
3939
<main>
4040
<HomepageFeatures />

0 commit comments

Comments
 (0)