super simple minimal chat app for learning
Find a file
2026-03-22 20:58:08 +01:00
docs added ui mockup made in libreoffice draw 2026-03-22 17:02:47 +01:00
pseudocode Update pseudocode/backend.s 2026-03-21 13:02:19 +01:00
public try dynamic viewport height to fix mobile browser window height 2026-03-22 20:58:08 +01:00
.gitignore initial db connection 2026-03-21 14:04:11 +01:00
curl_get.sh added struct fields, enabled basic webserver 2026-03-21 23:24:00 +01:00
curl_send_message.sh implemented new message API endpoint 2026-03-21 23:06:26 +01:00
go.mod switched to sqlx 2026-03-21 22:31:00 +01:00
go.sum switched to sqlx 2026-03-21 22:31:00 +01:00
main.go stop browsers from caching files we are actively changing during dev 2026-03-22 20:48:11 +01:00
README.md Update README.md 2026-03-21 23:46:26 +01:00
sqlite-create-tables.sql added user field to messages - temporary hack 2026-03-22 16:03:02 +01:00

grugchat

super simple minimal chat app for learning

how to run

  • be on linux (for now)
  • ensure dependencies are installed, here for archlinux:
  • go
  • sqlite
  • git (for cloning the repo, sorry no binary releases yet)
  • clone the repo
  • cd into the repo
  • initialize the sqlite db file:
  • sqlite3 messages.sqlite < sqlite-create-tables.sql
  • go mod tidy
  • go build
  • ./grugchat
  • open browser to localhost:8080 or whatever port you configure

Initial scope:

frontend:

  • 1 page, html/css/js. Rooms on the left sidebar, Chatwindow for the rest, chatwindow features a textbox + send button on the bottom.
  • onload: get rooms, populate sidebar. get messages for the first room, populate chatbox.
  • subscribe to sse.
  • on changing room: new page, get that rooms messages, subscribe to that sse

backend:

  • no auth, every user is "anonymous".

GET:

  • /api/rooms to get a list of rooms (can even be hardcoded at first)
  • /api/rooms/:roomID/messages to get the message history of a room
  • /api/rooms/:roomID/sse to "subscribe" to a rooms messages per server-sent events

POST:

  • /api/rooms/:roomID/messages with super simple "content" to send a chat message

database:

  • rooms with id (index) and name
  • messages, proper relation to rooms so each message is matched to the room its in:
id - primary key
room_id - foreign key
content - the text
tiestamp - needed for ordering

Notes on the "backend":
try to keep "business logic" seperated from the communications and storage layers.
We'll try to have a "handler" that converts HTTP requests into the proper Go structs and passes them on.
then we'll have a "service" that implements the actual logic - go structs go in, go structs come out (either to the client or the storage layer).
third, the storage layer accepts Go and saves/loads SQL.