Skip to content

About

Self-hosted tabletop RPG session manager for your local network: combat tracker, 5e character sheets, compendium and live shared notes.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

gm-session-manager

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 in GitHub Codespaces

Quick start (from a release)

  1. Download the archive for your system from the Releases page and unpack it into its own folder.
  2. Copy .env.example to .env in that folder and set ADMIN_USERNAME and ADMIN_PASSWORD (the server refuses to start without them).
  3. Run gm-session-manager (gm-session-manager.exe on Windows) from that folder. .env and data/ are looked up in the current directory.
  4. Open https://localhost:8080 on the host PC. Localhost is always the GM. The page shows the join address and a QR code for players.

First visit on each device

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.

Windows firewall

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=private

go run builds a new temporary executable each time, so Windows may ask again; a built binary keeps its permission.

Other systems

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.

Player app

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.

GM on another device

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.

Configuration

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.

Compendium (2024 SRD)

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.

Development

Prerequisites

  • 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: run go run ./cmd/vendorjs and go tool shadcn-templ bundle once after cloning.
  • Task for the dev commands (go install github.com/go-task/task/v3/cmd/task@latest). task setup runs the two commands above and sets git config core.hooksPath .githooks, so every commit is linted (.githooks/pre-commit runs task 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).
    • templ and shadcn-templ are Go tool dependencies (go tool …), no install needed.
  • No node or npm. Browser libraries are vendored by cmd/vendorjs.

Run from source

cp .env.example .env    # then set ADMIN_USERNAME and ADMIN_PASSWORD
task run                # or: go run ./cmd/gm-session-manager

task 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).

Project layout

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)

After changing sources

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.

Knowledge graph (graphify)

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.

  1. Install uv, then graphify at the version in .claude/skills/graphify/.graphify_version:

    uv tool install graphifyy==<version>   # e.g. graphifyy==0.9.95
  2. After changing code, refresh the graph and commit it with your change (AST only, no API cost):

    graphify update .
  3. For a full rebuild (including the Markdown docs), run /graphify . in Claude Code.

To update graphify:

  1. Upgrade the tool: uv tool upgrade graphifyy.

  2. Refresh the project's skill, CLAUDE.md section and hooks:

    graphify claude install --project
  3. Review git diff: it rewrites .claude/skills/graphify/ (including .graphify_version), the ## graphify section of CLAUDE.md and the hooks in .claude/settings.json. A locally edited SKILL.md is kept as SKILL.md.bak; delete it once reviewed.

  4. Rebuild the graph with the new version (graphify update .) and commit everything together.

See the graphify README for everything else (queries, hooks, exports).

Releasing on GitHub

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.

Each release

  1. If sources changed, regenerate (go generate ./internal/db ./internal/web) and commit.

  2. Check: go build ./..., go test ./..., task lint.

  3. 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
  4. Watch the run on the repository's Actions tab (gh run watch); the release appears under Releases when it finishes.

Manual fallback

Build and upload it yourself:

VERSION=v0.1.0 task build:release
gh release create v0.1.0 dist/* --generate-notes

About

Self-hosted tabletop RPG session manager for your local network: combat tracker, 5e character sheets, compendium and live shared notes.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages