Skip to content
GetUsernameFromDatabasePublic

About

Shared-household app: chat, expenses, shopping lists, notes and files. Built with Go + htmx.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Roommates

Project structure

roommates/
├─ Taskfile.yml         task entry point (includes app/Taskfile.yml), plus update, logs, backup
├─ docker-compose.yml   db, rustfs, backup, mailpit and app services
├─ deploy/              PostgreSQL, RustFS, backup, Mailpit and app images
└─ app/                 Go module (run go commands from here; task works from here or the root)
   ├─ cmd/server/       entry point (main.go) and routes
   ├─ internal/         application code
   │  ├─ config/        env, routes, cookie/header keys
   │  ├─ db/            migrations, queries/, sqlc output (dbqueries/)
   │  ├─ handlers/      HTTP layer
   │  ├─ services/      business logic used by handlers
   │  ├─ storage/       file contents in an S3 API (RustFS)
   │  ├─ mailer/        SMTP email (Mailpit in development)
   │  ├─ push/          web push notifications
   │  ├─ events/ images/ middleware/ models/ validators/ sessions/ logger/ utils/
   │  └─ locales/       translations (en, et) and generated keys
   ├─ web/
   │  ├─ components/    shared templ components (shadcn-templ ui)
   │  ├─ pages/         full pages (home, chat, expenses, files, notes, shopping, …)
   │  ├─ renderer/      gin <-> templ renderer
   │  └─ assets/        css, favicon, pwa, public/ (embedded static files)
   ├─ tools/            dev and build time programs, see tools/README.md
   ├─ scripts/          dev, format and lint scripts
   └─ certificates/     local mkcert TLS cert/key (not committed)

Quick start

After Setup. task commands work from the repo root or app/, go commands run from app/.

  1. From the repo root: cp .env.example .env, then replace the REPLACE_WITH_* and `openssl …` values
  2. From the repo root: docker compose up -d --wait rustfs, then sh deploy/rustfs/app-key.sh and paste its APP_S3_* lines into .env (the app's own file storage key)
  3. Create the TLS certificate: app/certificates/README.md
  4. From the repo root: task setup runs task vendor, which downloads htmx and the fonts (not committed, task dev does not fetch them, see app/web/assets/README.md), and turns on the pre-commit hook, which runs task fmt and task lint when a commit touches app/
  5. Mailpit gives an inbox at http://127.0.0.1:8025: task dev starts it and sends every email there
  6. task dev starts db + rustfs + mailpit and serves the app with hot reload on https://localhost:8090. The database is migrated on start
  7. task seed adds example users and a household

Whole stack in Docker instead: docker compose up --build from the repo root, app on https://127.0.0.1:8000. That also runs the backup service (db dump + files into ./backups), see deploy/backup/README.md for config and restore.

Running it on a server (Cloudflare Tunnel, upgrades, rollback): deploy/README.md.

Setup

Install golang

https://go.dev/doc/install

Install Docker with compose (PostgreSQL, RustFS and Mailpit run in it)

Install mkcert for the local certificate

Install binaries with go

  • go install github.com/sqlc-dev/sqlc/cmd/sqlc@v1.31.1
    • sqlc
    • generate go code to interact with database
  • go install github.com/go-task/task/v3/cmd/task@latest
  • go install github.com/go-delve/delve/cmd/dlv@latest
    • delve
    • task dev runs the server under it (debugger on 127.0.0.1:2345)
  • go install honnef.co/go/tools/cmd/staticcheck@latest

templ and shadcn-templ need no install: they are pinned as tool in go.mod and run with go tool templ / go tool shadcn-templ

Install tailwindcss at the version pinned as TAILWIND_VERSION in Taskfile.yml so that it is usable with tailwindcss command (task tailwind and task build refuse other versions)

used in Taskfile.yml required by https://shadcn-templ.com/docs/installation#existing-project

Install golangci-lint

Common commands

task works from the repo root or app/ (task --list shows all; in VS Code the recommended Task extension lists them). The rest from app/:

  • task build builds for production → bin/app, the git version is logged at startup
  • task generate regenerates sqlc, locale keys, templ and script bundles
  • task lint / sh scripts/lint.sh runs staticcheck + golangci-lint
  • task fmt / sh scripts/format.sh runs templ fmt + golangci-lint fmt (gofmt + goimports + golines)
  • go test ./... (task test) skips DB tests unless TEST_POSTGRES_DB names a throwaway database (the migration test drops all tables), never the dev database

Code generation (regenerate after editing the source, never edit the output):

  • sqlc generate: internal/db/queries/*.sql → internal/db/dbqueries/
  • go tool templ generate: *.templ → *_templ.go
  • go generate ./tools/...: internal/locales/ yaml → locale keys

About

Shared-household app: chat, expenses, shopping lists, notes and files. Built with Go + htmx.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages