# Completed A tracker for a video game collection: what you own, which platform it's on, your score for it, and whether (and when) you finished it. ## Status Each account has its own private game list, but all accounts share one platform list (only an admin can add/rename/delete a platform - the first account ever registered becomes an admin automatically). The API is usable. There are three small-base clients: a terminal UI, a desktop GUI (Fyne), and a web app (Angular) — each can log in and show your games, with more to come. ## Running it ```sh just docker-up # starts Postgres and the API on :8080 just docker-down # stops them ``` Or against a Postgres you already have running locally: ```sh export DATABASE_URL="postgres://postgres:password@localhost:5432/gamedb?sslmode=disable" just run-api ``` The API creates its database and runs migrations on startup if needed. Browse `http://localhost:8080/docs` for the generated API docs. ## Using the API ```sh # Register (also logs you in; the first account ever registered becomes # an admin, which is required to create platforms - see Status above) curl -X POST localhost:8080/api/auth/register -H 'Content-Type: application/json' \ -d '{"email":"you@example.com","password":"a long password","name":"You"}' # -> {"token": "...", "user": {...}} TOKEN=... # the token from above curl -X POST localhost:8080/api/platforms -H "Authorization: Bearer $TOKEN" \ -H 'Content-Type: application/json' -d '{"name":"PC"}' curl localhost:8080/api/games -H "Authorization: Bearer $TOKEN" ``` A browser-based client can skip the `Authorization` header: register/login also set an httpOnly `session` cookie. ## Clients - `just run-tui` — a terminal UI (Bubble Tea). Log in, see your games in a scrollable table, `r` to refresh. - `just run-gui` — a desktop GUI (Fyne). Log in, see your games in a table, refresh. - `just web-dev` — a web app (Angular + Material) at `http://localhost:4200`, proxying nothing itself; it talks directly to the API at `localhost:8080` (CORS is permissive enough for local dev as-is). Log in, see your games. All three point at `http://localhost:8080` by default. The TUI and GUI read `COMPLETED_API_URL` to use a different API; the web app's URL is a build-time constant in `web/src/app/app.config.ts`. Each client is a small base - listing is there, but adding/editing a game or managing platforms isn't yet. ## Development ```sh just test # go test ./... just sqlc # regenerate internal/db after changing db/query.sql or a migration just openapi # regenerate api/openapi.json after changing a route just web-test # web app unit tests (Vitest) just web-build # production build of the web app ``` Schema changes go in `db/migrations` as a new `_.up.sql` / `.down.sql` pair; `sqlc.yaml` reads the schema from that directory directly, so there's no separate schema file to keep in sync. The TUI and GUI share `internal/client`, a typed Go HTTP client for the API. The web app's API client (`web/src/app/api/`) is generated from `api/openapi.json` by `ng-openapi-gen` (`cd web && npx ng-openapi-gen`) and shouldn't be hand-edited. ## CI/CD `.gitea/workflows/ci.yml` builds and tests everything (Go + web) on every push to `main` or `develop`. `.gitea/workflows/release.yml` builds all three clients and attaches them to a Gitea release when a `vX.Y.Z` tag is pushed; see that file's comments for its one real limitation (the desktop GUI is only built for linux/amd64, since it needs cgo and this repo has no registered macOS/Windows runner to cross-build it on).