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| `theme` | ?string | controls per-user css themes |
22| `bio` | string | bio for this user |
23| `pronouns` | string | pronouns for this user |
24| `created_at` | time.Time | a timestamp of when this user was made |
25
26## `Post`
27
28> represents a public post
29
30| name | type | desc |
31|---------------|-----------|----------------------------------------------|
32| `id` | int | identifier for this post |
33| `author_id` | int | id of the user that authored this post |
34| `replying_to` | ?int | id of the post that this post is replying to |
35| `title` | string | the title of this post |
36| `body` | string | the body of this post |
37| `posted_at` | time.Time | a timestamp of when this post was made |
38
39## `Like`
40
41> represents all likes and dislikes on posts for this beep instance
42
43| name | type | desc |
44|-----------|------|------------------------------------------------|
45| `id` | int | identifier for this (dis)like |
46| `user_id` | int | the user that sent this (dis)like |
47| `post_id` | int | the post this (dis)like is for |
48| `is_like` | bool | `true` if this is a like, `false` if a dislike |
49
50## `LikeCache`
51
52> stores total likes for a post
53
54<!-- todo: implement this -->
55<!-- > a post with no likes nor dislikes will not be in this table -->
56<!-- > the data in this table is cleared and recalculated every
57> `config:post:likes_refresh_minutes` minutes -->
58
59| name | type | desc |
60|-----------|------|---------------------------------------|
61| `id` | int | identifier for this entry |
62| `post_id` | int | the post this entry is for |
63| `likes` | int | the net amount of likes this post has |
64
65## `Site`
66
67> stores mutable, site-wide data. there should only ever be one entry here
68
69| name | type | desc |
70|--------|--------|----------------------------------------------|
71| `id` | int | identifier for this (should always be 0) |
72| `motd` | string | the message of the day displayed on `/index` |
73
74## `Notification`
75
76> represents a notification sent to a user
77
78| name | type | desc |
79|-----------|--------|------------------------------------------|
80| `id` | int | identifier for this notification |
81| `user_id` | int | the user that receives this notification |
82| `summary` | string | the summary for this notification |
83| `body` | string | the full text for this notification |
84
85## `SavedPost`
86
87> a list of saved posts for a user
88
89| name | type | desc |
90|-----------|------|--------------------------------------------------|
91| `id` | int | identifier for this entry, this is mostly unused |
92| `post_id` | int | the id of the post this entry relates to |
93| `user_id` | int | the id of the user that saved this post |
94| `saved` | bool | if this post is saved |
95| `later` | bool | if this post is saved in "read later" |