Skip to content

The platform (Phase 3)

Accounts, publishing, a sandboxed player, a catalog, ratings and moderation (3a); the web editor with version history, live preview and the bring-your-own-key AI assistant (3b-1); remote MCP for outside AI tools, social sign-in and more AI providers (3b-2). Decisions: ADRs 0008–0012, 0015, 0019, 0020, 0021.

Without Docker (in-process Postgres, files, builds in the same process):

Terminal window
pnpm platform:dev # http://localhost:3000 · games on http://<game>.play.localhost:3001
ADMIN_EMAILS=you@example.test pnpm platform:dev # that address becomes an admin when it signs up

Emails are not sent: verification links appear at http://localhost:3000/dev/mail. Data lives in .cache/ (delete .cache/platform-db and .cache/platform-blobs to start over).

With Docker (Postgres, SeaweedFS, Mailpit, and the web, play and worker containers):

Terminal window
cp .env.example .env # optional: real secrets and ADMIN_EMAILS
pnpm platform:up # docker compose up --build

Then open http://localhost:3000; mail at http://localhost:8025. The first image build takes a few minutes; a game build takes about 20 seconds in the worker container. Checked on 2026-11-27: sign-up with mail through Mailpit, publishing Sprout through the builder, playing it in the sandbox from Chromium, the builder’s isolation (loopback only: no route to storage, the database or the internet; read-only filesystem; no secrets) and localhost-only ports.

Area Where
Catalog (search, tags, new / top rated / most played) /
Game page: sandboxed player, ratings, report button /games/<slug>
Sign up (13+, terms), sign in, access tokens /sign-up, /sign-in, /account
Creator: new game, start from template, upload a folder, versions, publish/unlist /creator
Editor: files, Monaco with schema checks, save/commit, branches, history and undo, preview, assistant, release /creator/<slug>/edit
AI key (bring your own, stored encrypted) and AI usage /account
Moderation queue: take down or dismiss reports /moderation (moderators/admins)
Terms, privacy, copyright policy (placeholders — need legal review) /legal/*
API reference (OpenAPI 3.1) /api/openapi.json

Open a game on /creator and choose Open editor. The first time, start from the platformer template or from the latest uploaded version.

  • Save (button or Ctrl/Cmd+S) checks every changed JSON document against its schema; with errors nothing is saved and the problems list shows each one with its JSON pointer. The editor checks JSON as you type too.
  • Commit snapshots the branch. History lists every commit (✦ = made by the assistant); click one to see the files it changed, Restore to undo back to it (recorded as a new commit). New branch tries an idea apart.
  • Merge… brings another branch (yours, or an assistant’s ai-… branch) into the open one. Files changed on one side take that change, edits to different lines of the same file are combined, and files changed on both sides in the same place ask you which version to keep. The merge is one commit you can restore away.
  • Levels open in a visual view (switch to JSON any time; both edit the same file). Tools: paint tiles from the tileset, erase, rectangle, fill, Ground (auto-tiled terrain from game/levels/legend.json; shift removes), Entity (a prefab, drawn with its sprite), Trigger (drag an area; it sends an event), Point (a named spot), Select (drag to move, snapped to tiles unless shift is held; edit the JSON of the selection, Delete removes it). Layers can be hidden, added and marked solid; the level can be resized (rows are added at the top) and given a background colour. Undo/redo with Ctrl/Cmd+Z / Shift+Z. Alt- or right-drag pans, Ctrl+wheel zooms. Play here: click a spot and the preview starts the level’s scene with the player there (it rebuilds first if files changed). The view draws data only (tileset images and prefab sprites); no game code runs on the site’s origin. The AI tools make the same edits (read_level, edit_level).
  • Preview builds the branch in the sandbox and plays it next to the editor (saves stay in memory).
  • Release builds the branch head as the next version (live once built; public if the game is published).
  • Assistant: describe a change; Claude works on a copy of your files with the agent tools, tests the game in the sandbox, and saves the result as one commit you can restore away. It uses your own Anthropic key (/account); you choose the model (Claude Opus 5.5 by default; the editor remembers your choice, so pick Sonnet 5.5 for cheaper runs). OpenAI, any OpenAI-compatible server and Ollama work too: set them up on /account (key, server URL, model); they appear in the editor’s model menu. Server URLs must be public https unless the operator allows private addresses (PLATFORM_AI_ALLOW_PRIVATE_URLS, on in local mode). Without a key, local mode offers a test assistant that calls no model. A run cut off by a server restart shows Ask again.

Content packs, forks and remixes (Phase 4b)

Section titled “Content packs, forks and remixes (Phase 4b)”

Games whose owner allows it (permissions in game.json) get Make a pack and Fork/Remix buttons on their page.

  • Packs are data and media only, built in the editor under pack/. The level editor shows the game’s tilesets and prefabs.
  • Releasing a pack checks it against the game’s live release and puts it in the owner’s Pack queue, where the owner can try it, then approve or reject it.
  • Players turn approved packs on, one by one, on the game page. Packs show up in the game’s Expansions menu, and the loader gives pack ids a <pack>: prefix so they never clash with the game’s.
  • Forks copy the live release with credit; private forks cannot be published.

See guides/content-packs.md.

Work on your games from AI tools (remote MCP)

Section titled “Work on your games from AI tools (remote MCP)”

The server speaks MCP at /mcp, so Claude Code, Claude Desktop and other MCP clients can work on your games:

Terminal window
claude mcp add --transport http ludrel http://localhost:3000/mcp

The tool opens a browser to sign in and asks you to allow it (read only, or read and change your games). Its tools are the editor assistant’s (read and write files, prefabs, scenes, levels, validate, run headless in the sandbox, search docs) plus list_games, create_game, commit, list_commits and restore. Changes are checked and saved to the branch draft (default main), like the editor’s Save; commit them to make an undo point. Connected apps on /account lists the tools you allowed; Remove access ends it at once. A tool that cannot open a browser can send a personal access token instead (--header "Authorization: Bearer pn_...").

Set a provider’s *_CLIENT_ID and *_CLIENT_SECRET (callback URL <web origin>/api/auth/callback/<provider>) and its button appears on the sign-in and sign-up pages. Providers give no birth date, so a new account first goes through the age step at /welcome (date of birth, handle, terms): until then it can do nothing else; under 13 it is deleted. As with email sign-up, only the age group is kept.

Create a token on /account, then:

Terminal window
PLATFORM_TOKEN=pn_... pnpm platform publish games/sprout --slug sprout --publish

Several folders upload one after another, each under its folder name. Games made by the AI evals (games/eval-*, ignored by git) can be uploaded this way for live testing, then opened in the editor with Start from version …:

Terminal window
PLATFORM_TOKEN=pn_... pnpm platform publish games/eval-*

The typed SDK (@ludrel/sdk) is generated from the OpenAPI document: pnpm --filter @ludrel/sdk generate after changing API routes (a test fails if you forget).

browser ──> web (React Router pages + /api, one process) ──> Postgres (Drizzle)
│ │ upload → validate → store source → job └─ pg-boss jobs
│ └──────────────> worker (internal network: database + storage only)
│ ⇅ shared folder └──> storage: builds/<version>/
│ builder (no network, read-only, no secrets): type-check + Vite build
│ └─ assistant (agent tools on a scratch copy) ──> Claude API with the creator's key
│ └─ run_headless / type-check ──> sandbox (builder container, via /work)
└─ iframe sandbox="allow-scripts" ──> play origin <game>.play.…: serves builds with strict CSP
⇅ postMessage bridge (only channel): ready, cloud saves, pause/resume
  • Uploads may contain only game/** (documents and assets) and src/**/*.ts; documents are validated with exact JSON pointers before anything is stored; limits: 2000 files, 8 MB per file, 40 MB total.

    Pack uploads may contain only pack/** (JSON, PNG, WebP, OGG, MP3, WAV, WOFF2). Their JSON is stored normalized, under packs/<versionId>/.

    The play server serves /p/<versionId>/ only on the target game’s host. It serves only versions that are approved or waiting for review; version ids are unguessable, and pending ones are shown only to the owner and the creator.

  • Builds use the platform’s own page and entry file (framework + game behaviors + bridge + touch controls). In Docker, uploaded code is compiled only in the builder container, which has no network at all; the worker hands it folders through a shared volume and uploads the results.

  • Ports are bound to 127.0.0.1: other machines on your network cannot reach the platform or its mail.

  • Player isolation: opaque-origin sandbox, separate site, CSP default-src 'none', only the game’s own files, frame-ancestors = the platform. Games never see tokens; saves go through the bridge as the signed-in player.

  • Moderation: anyone can report (copyright notices need a contact email); moderators take games down (they leave the catalog and the play origin stops serving them) or dismiss; every action is logged in moderation_action.

  • Money: the tables from ADR 0015 exist (products, revenue-share rules, orders, entitlements, double-entry ledger, payouts) and stay unused until Phase 7.

Variable Meaning
DATABASE_URL Postgres; unset = local mode
S3_BUCKET, S3_ENDPOINT, S3_REGION, S3_ACCESS_KEY_ID, S3_SECRET_ACCESS_KEY Blob storage (else BLOB_DIR / .cache)
BETTER_AUTH_SECRET Session signing secret (32+ characters; required outside local mode)
WEB_ORIGIN, PLAY_ORIGIN ({game} placeholder), PLAY_HOST_SUFFIX Public URLs
SMTP_URL, MAIL_FROM Mail (else printed and shown at /dev/mail)
ADMIN_EMAILS Emails that become admins on sign-up
PORT, PLAY_PORT, PLATFORM_DATA_DIR Ports and local data folder
PLATFORM_MASTER_KEY Encrypts users’ AI keys (32 bytes, base64; local mode generates .cache/master.key)
PLATFORM_MASTER_KEY_PREVIOUS Old master keys while rotating (comma-separated); stored keys are re-encrypted at startup
GOOGLE_CLIENT_ID / _SECRET, GITHUB_…, DISCORD_… Social sign-in providers (each on when both are set)
MCP_ENABLED false turns off remote MCP at /mcp (on by default)
PLATFORM_AI_ALLOW_PRIVATE_URLS true: users may point OpenAI-compatible/Ollama at private addresses and http (local mode default)
WORKSPACE_GC_HOURS Hours between deletions of editor file contents nothing uses (default 6; 0 = off)
BUILDER_CONCURRENCY, BUILD_MEMORY_MB Jobs the builder runs at once (default 2) and the heap each gets (default 1024)
PLATFORM_AI_TEST_PROVIDER scripted = test assistant for users without a key (default in local mode; not for production)
BUILD_RUNNER=builder, SANDBOX_WORK_DIR Run assistant checks in the builder container through this shared folder