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