Skip to content
arusadusdgPublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

30 Commits

Folders and files

Repository files navigation

Turf

A territory-map revision game for Elliot and friends. Each subject is a map, and each test topic is a hex tile. Answering a tile's cards builds your mastery; reach the threshold and you claim the tile in your colour. Mastery decays with spaced repetition, so friends can steal tiles back.

  • Live: https://studyturf.bond (once DNS and the server are set up)
  • Stack: Node 22, Fastify, SQLite (better-sqlite3), vanilla JS with no build step, and Caddy for HTTPS.
  • Design: see DESIGN.md.

Run locally

npm install
TURF_DEV=1 ADMIN_INVITE=TEST-ADMN npm run dev

Open http://localhost:3000 and sign up with invite code TEST-ADMN. That first account is the admin. Data goes to ./data/turf.db.

To turn on AI generation and marking locally, put AI_PROVIDER=claude and ANTHROPIC_API_KEY=... (or AI_PROVIDER=gemini and GEMINI_API_KEY=...) in .env. .env is git-ignored. Optional: AI_MODEL= to choose a different model.

Content

Path What
content/subjects/<id>.json Subject, exam date and time, regions (syllabus units) and tiles (topics)
content/seed/<id>*.json Seed card banks. Format: content/CARD_SCHEMA.md
content/mocks/<id>.json Timed practice papers with markschemes
content/text/<id>/*.md Source text the AI marks against (teacher files, notes)
content/tests/<id>.md Official test instructions (from Toddle)

Seeds are upserted on every start, so pushing new content deploys it. Players' own cards live only in the database.

Server (Hetzner, Ubuntu 24.04, 1 GB)

On the server, as root:

apt-get update && apt-get install -y git
ssh-keygen -t ed25519 -N "" -f /root/.ssh/turf_deploy -C turf-server && cat /root/.ssh/turf_deploy.pub

Add the printed key as a read-only deploy key at https://github.com/arusadusdg/turf/settings/keys, then:

GIT_SSH_COMMAND="ssh -i /root/.ssh/turf_deploy -o StrictHostKeyChecking=accept-new" git clone git@github.com:arusadusdg/turf.git /opt/turf && bash /opt/turf/deploy/bootstrap.sh

The bootstrap script:

  • adds 2 GB of swap;
  • installs Node 22, Caddy, poppler and sqlite3;
  • creates the turf service (systemd), the nightly backup timer (03:30, kept 14 days in /var/backups/turf) and the auto-deploy timer (pulls main every 2 minutes and rolls back if the health check fails);
  • sets up ufw to allow only ports 22, 80 and 443;
  • prints the admin invite code.

Secrets live in /etc/turf.env. To add or change the AI key later:

bash /opt/turf/deploy/set-ai-key.sh claude

Useful commands:

journalctl -u turf -f                 # app log
journalctl -u turf-deploy -n 30       # deploys
systemctl list-timers 'turf*'         # timers

DNS at Porkbun: two A records, @ and www, both pointing to the server IP. Delete Porkbun's default parking ALIAS/CNAME records.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages