A LAN host for a tabletop RPG table. The GM's PC runs one binary; players
join from phones on the same network by address or QR code. All data stays
on the host in SQLite. GMs manage campaigns, combat, NPCs and the
compendium; players manage their characters; everyone shares real-time
collaborative notes. See CLAUDE.md for the architecture, rules and
conventions.
My first project made with claude
-
Open the tabs from the Ports panel (globe icon next to the port), if the browser does not open them on its own.
-
The GM tab (port 8443) is the app as the GM, with a sample campaign.
-
The Player tab (port 8444) is the same app as a player on the network sees it.
-
Keep both ports private: a public player port would be remote play.
-
The player app (a character taken home) starts on demand:
task run:playerin the terminal opens port 8042. Download a take-home file in the GM tab, open it in the player app, then bring it back in the GM tab. The phone handoff needs a shared network, so it does not work in a Codespace. -
The Codespace starts a prebuilt server that does not watch the code, to save the 2-core machine's compute. After editing code, run
task run:test: it stops that server, rebuilds and serves the GM tab again. It does not watch either, so run it again after each change, or useWATCH=1 task run:testto rebuild and restart on every save (compute you opt into). A rebuild takes about 2 minutes on the 2-core machine; the old server keeps serving until the new one is up.
- Download the archive for your system from the Releases page and unpack it into its own folder.
- Copy
.env.exampleto.envin that folder and setADMIN_USERNAMEandADMIN_PASSWORD(the server refuses to start without them). - Run
gm-session-manager(gm-session-manager.exeon Windows) from that folder..envanddata/are looked up in the current directory. - Open
https://localhost:8080on the host PC. Localhost is always the GM. The page shows the join address and a QR code for players.
The host uses a self-signed certificate (in DATA_DIR/tls, renewed when a
network address changes or it nears expiry). Each browser shows a warning
once per certificate: choose "Advanced" and continue. The GM page shows the
certificate's SHA-256 fingerprint if you want to compare it with what the
browser shows.
To run on an always-on Debian server in Docker instead, see deploy/README.md.
The first time the host listens, Windows asks whether to allow
gm-session-manager.exe on networks. Allow Private networks (your home
Wi-Fi). If you dismissed the prompt, players cannot connect: open
"Windows Defender Firewall → Allow an app through firewall" and tick
Private for gm-session-manager, or run once as administrator:
netsh advfirewall firewall add rule name="gm-session-manager" dir=in action=allow protocol=TCP localport=8080 profile=privatego run builds a new temporary executable each time, so Windows may ask
again; a built binary keeps its permission.
Releases ship for Windows and Linux on x86-64. On macOS or ARM, build from
source (see Development): task build builds for the
machine it runs on.
gm-session-manager --player runs the player app for one person: it
listens on 127.0.0.1 only over plain HTTP, needs no login, reads no .env
(only the flags --port, default 8042, --data, default data-player/, and
--no-browser, none valid without --player) and opens the browser itself
unless given --no-browser. The
archive ships Player app.bat (Windows) or player-app.sh (Linux) to start it
with a double-click.
Log in at /admin/login with the .env credentials. A device holds one
role: to switch between player and GM, log out and log in again.
Settings come from .env in the working directory; real environment
variables override it.
| Variable | Default | Notes |
|---|---|---|
ADMIN_USERNAME |
— | required |
ADMIN_PASSWORD |
— | required |
PORT |
8080 |
HTTPS port |
DATA_DIR |
data |
everything the app stores |
DATA_DIR holds the database (gm-session-manager.db), the certificate
(tls/), uploaded files (attachments/) and compendium sources
(compendium/), and unfinished image CSV imports (imports/, kept 3 days
so a restart does not lose them). Back up this folder to keep your campaigns; stop the
server first, or copy the -wal and -shm files with the database.
The server also hands out the files in DATA_DIR/downloads/ to the GM and
players (/downloads/<name>). The update job runs task build:release and
copies dist/* there (the release build needs Task and zip, on Debian too).
App-wide settings changed in the app (not per campaign) are kept in DATA_DIR/settings.json.
The importer reads data folders from DATA_DIR/compendium/<source>/. For
the 2024 SRD, download the JSON files of
open5e-api data/v2/wizards-of-the-coast/srd-2024
into data/compendium/srd-2024/. They are imported at start-up and from the
Compendium page ("Import now"); unchanged folders are skipped. The SRD 5.2
is licensed CC-BY-4.0 and every entry shows its attribution. While the
compendium is empty, the GM's Browse tab offers a few starting sets to import
in one click.
The GM can also fill the compendium from the 5etools data: the Import >
5etools tab lists the books (core, supplements, adventures, Unearthed Arcana,
third party), downloads the checked ones from the 5etools GitHub mirror into
DATA_DIR/compendium/5etools-<id>/ (that folder is the cache) and imports
them; "Remove" deletes a book and its entries. Where several sources hold the
same entry, the Source priority list beside the import tabs decides which copy
is shown and linked; the others are listed as "Also in" on the entry page.
Each source in that list shows how many of its entries are shown among the
sources the campaign allows; one that shares entries with another source links
to them, and each opens every copy side by side.
This content is for private use at your own table and is not redistributed
with the app.
Homebrew is written in the Compendium page and is shared by all campaigns.
- Go at the version in
go.mod. That is all you need to build and run: generated code and built assets are committed, except the browser libraries and the component script bundle: rungo run ./cmd/vendorjsandgo tool shadcn-templ bundleonce after cloning. - Task for the dev
commands (
go install github.com/go-task/task/v3/cmd/task@latest).task setupruns the two commands above and setsgit config core.hooksPath .githooks, so every commit is linted (.githooks/pre-commitrunstask lint, which needs the tools below). - Only for changing sources:
- sqlc on PATH (migrations and queries),
- the Tailwind standalone CLI
on PATH as
tailwindcss(templates and classes), - golangci-lint,
- gopls on PATH (
go install golang.org/x/tools/gopls@latest; VS Code's Go extension installs it). templandshadcn-templare Go tool dependencies (go tool …), no install needed.
- No node or npm. Browser libraries are vendored by
cmd/vendorjs.
cp .env.example .env # then set ADMIN_USERNAME and ADMIN_PASSWORD
task run # or: go run ./cmd/gm-session-managertask run rebuilds and restarts when sources change (a failed build keeps the
old server). A changed migration pauses reloading until touch build/restart;
touch build/stop quits. task --list lists the other tasks (run:player,
run:test, seed, before, run:before, lint, build, release).
cmd/gm-session-manager/ main: config, DB, hub, HTTPS server
cmd/vendorjs/ downloads pinned browser JS into internal/web/assets/vendor
Taskfile.yml dev, lint, build and release tasks (task --list); the run modes are env there
deploy/ the Debian server install: Docker, backup and update scripts, systemd timer (deploy/README.md)
scripts/ the longer tasks (run loop, lint, build, release tag), run in Task's shell
internal/ every package below; not importable outside this module
config/ .env loading and fail-fast validation
enum/ typed values of every SQL CHECK list (wired through sqlc overrides)
db/ migrations/, queries/ (sqlc input), sqlc/ (generated), Open, Migrate, Store.InTx
auth/ session tokens, cookie, middleware, admin and loopback checks
perm/ every permission and visibility rule (characters, combatants, note blocks, entities)
hub/ websocket hub: (epoch, seq) events, catch-up ring, live-view patches, pending join requests
dnd5e/ 5e sheet, commands (Parse/Apply), slots, level-up
compendium/ importers (Open5e, 5etools, AideDD, Wikidot, web pages), search, homebrew
export/ campaign zip (notes as Markdown, characters as JSON)
join/ LAN addresses, TLS certificate, HTTP→HTTPS redirect on the same port, QR code
web/ router, *_handlers.go, render.go (view models), live.go (live views, /live); sheet5e*.go is 5e
web/core/ App (deps, hub) and the request/response helpers every handler uses; no game feature
web/views/ neutral templ pages and components; live.go holds live-view keys and binds; sheet5e.go is the door to 5e
web/views/sheet5e/ the 5e views (sheet, wizard, builder, level-up, sources, compendium); imports views, never the reverse
web/components/, utils/ shadcn-templ CLI output: never edit by hand
web/assets/ js/ (app.js, live.js, notes.js, fields.js, wikilink.js), css/ (globals.css → output.css), vendor/
data/ local instances, not code: dev (task run), test (browser checks), player (task run:player)| Change | Command |
|---|---|
internal/db/migrations, internal/db/queries |
go generate ./internal/db (sqlc) |
*.templ, Tailwind classes |
go generate ./internal/web (script bundle + templ fmt + templ + Tailwind) |
| Go formatting | golangci-lint fmt |
| shadcn-templ components | go tool shadcn-templ add <name>, then go generate ./internal/web |
| browser JS versions | go run ./cmd/vendorjs -check lists newer releases; edit cmd/vendorjs/main.go, then go run ./cmd/vendorjs -update and commit cmd/vendorjs/vendor.sum (every other run refuses files that differ from it) |
Then go build ./..., go test ./... and task lint (golangci-lint, gopls check on changed Go files,
then stale Tailwind classes; task lint -- --all checks every Go file).
GSM_COMPENDIUM_DIR=data/dev/compendium go test ./internal/compendium -run TestRealSource -v
checks the importer against a real data download.
Claude Code uses graphify to
query the codebase (see CLAUDE.md). The graph is committed
(graphify-out/graph.json, GRAPH_REPORT.md, graph.html); the rest of
graphify-out/ is a local cache. Optional; not needed to build or run.
-
Install uv, then graphify at the version in
.claude/skills/graphify/.graphify_version:uv tool install graphifyy==<version> # e.g. graphifyy==0.9.95
-
After changing code, refresh the graph and commit it with your change (AST only, no API cost):
graphify update . -
For a full rebuild (including the Markdown docs), run
/graphify .in Claude Code.
To update graphify:
-
Upgrade the tool:
uv tool upgrade graphifyy. -
Refresh the project's skill,
CLAUDE.mdsection and hooks:graphify claude install --project
-
Review
git diff: it rewrites.claude/skills/graphify/(including.graphify_version), the## graphifysection ofCLAUDE.mdand the hooks in.claude/settings.json. A locally editedSKILL.mdis kept asSKILL.md.bak; delete it once reviewed. -
Rebuild the graph with the new version (
graphify update .) and commit everything together.
See the graphify README for everything else (queries, hooks, exports).
The build and build:release tasks in Taskfile.yml are the one build process, for you and CI. They fetch the vendored
JS, build the shadcn-templ script bundle (both are gitignored), run
task lint (build only) and the tests and stamp the version
(git describe, or $VERSION) into the binary:
task build # this machine → dist/gm-session-manager[.exe]
task build:release # every target → dist/ archives + SHA256SUMS (Linux; needs zip)Pushing a v* tag runs .github/workflows/release.yml: it runs
golangci-lint, then task build:release (Windows and Linux x86-64 binaries,
no CGO, so every target builds from one runner, each packed with
README.md, .env.example and a player-app launcher), and publishes a GitHub release with
generated notes. .env and data/ are git-ignored and never shipped.
-
If sources changed, regenerate (
go generate ./internal/db ./internal/web) and commit. -
Check:
go build ./...,go test ./...,task lint. -
Tag and push (from a clean, pushed
main; it refuses a version that isn't newer than the latest tag unless you add--force):task release -- 0.2.0
-
Watch the run on the repository's Actions tab (
gh run watch); the release appears under Releases when it finishes.
Build and upload it yourself:
VERSION=v0.1.0 task build:release
gh release create v0.1.0 dist/* --generate-notes