a mini social media app for small communities
1# database spec
2
3i have a mental map of the databases in use for beep, but that does not mean
4others also do. along with that, having a visual representation is probably
5going to be pretty useful. so with that said, i present to you, the database
6spec for beep:
7
8## `User`
9
10> represents a registered user
11
12| name | type | desc |
13|-----------------|-----------|--------------------------------------------------|
14| `id` | int | identifier this user on the backend |
15| `username` | string | identifier this user on the frontend |
16| `nickname` | ?string | optional nickname for this user on the frontend |
17| `password` | string | hashed and salted password for this user |
18| `password_salt` | string | salt for this user's password |
19| `muted` | bool | controls whether or not this user can make posts |
20| `admin` | bool | controls whether or not this user is an admin |
21| `automated` | bool | controls whether or not this user is automated |
22| `theme` | ?string | controls per-user css themes |
23| `css` | ?string | controls per-user css |
24| `bio` | string | bio for this user |
25| `pronouns` | string | pronouns for this user |
26| `created_at` | time.Time | a timestamp of when this user was made |
27
28## `Post`
29
30> represents a public post
31
32| name | type | desc |
33|---------------|-----------|----------------------------------------------|
34| `id` | int | identifier for this post |
35| `author_id` | int | id of the user that authored this post |
36| `replying_to` | ?int | id of the post that this post is replying to |
37| `title` | string | the title of this post |
38| `body` | string | the body of this post |
39| `pinned` | bool | if this post in globally pinned |
40| `nsfw` | bool | if this post in marked as nsfw |
41| `posted_at` | time.Time | a timestamp of when this post was made |
42
43## `Like`
44
45> represents all likes and dislikes on posts for this beep instance
46
47| name | type | desc |
48|-----------|------|------------------------------------------------|
49| `id` | int | identifier for this (dis)like |
50| `user_id` | int | the user that sent this (dis)like |
51| `post_id` | int | the post this (dis)like is for |
52| `is_like` | bool | `true` if this is a like, `false` if a dislike |
53
54## `LikeCache`
55
56> stores total likes for a post
57
58<!-- todo: implement this -->
59<!-- > a post with no likes nor dislikes will not be in this table -->
60<!-- > the data in this table is cleared and recalculated every
61> `config:post:likes_refresh_minutes` minutes -->
62
63| name | type | desc |
64|-----------|------|---------------------------------------|
65| `id` | int | identifier for this entry |
66| `post_id` | int | the post this entry is for |
67| `likes` | int | the net amount of likes this post has |
68
69## `Site`
70
71> stores mutable, site-wide data. there should only ever be one entry here
72
73| name | type | desc |
74|--------|--------|----------------------------------------------|
75| `id` | int | identifier for this (should always be 0) |
76| `motd` | string | the message of the day displayed on `/index` |
77
78## `Notification`
79
80> represents a notification sent to a user
81
82| name | type | desc |
83|-----------|--------|------------------------------------------|
84| `id` | int | identifier for this notification |
85| `user_id` | int | the user that receives this notification |
86| `summary` | string | the summary for this notification |
87| `body` | string | the full text for this notification |
88
89## `SavedPost`
90
91> a list of saved posts for a user
92
93| name | type | desc |
94|-----------|------|--------------------------------------------------|
95| `id` | int | identifier for this entry, this is mostly unused |
96| `post_id` | int | the id of the post this entry relates to |
97| `user_id` | int | the id of the user that saved this post |
98| `saved` | bool | if this post is saved |
99| `later` | bool | if this post is saved in "read later" |