Demo Mode (Guest Access)
A one-click way to explore the app without signing up — the visitor gets a throwaway guest account pre-filled with sample decks and documented matches, so the recommendation engine and battle-log analysis are immediately demonstrable. Crucially, it does not spend the owner’s LLM token.
How it works
Section titled “How it works”WelcomeScreen "Ohne Anmeldung testen" → authClient.signIn.anonymous() (Better Auth `anonymous` plugin → isAnonymous user) → localStorage['tcg-player-name'] = 'Gtmap' (so the parser pins "me") → POST /api/demo/seed (guest-only, idempotent → seeds decks + matches) → dashboardStore.refresh() (repopulate the now-seeded dashboard)- Guest accounts use Better Auth’s
anonymousplugin. Theuser.is_anonymouscolumn (migration0004_kind_surge.sql) flags them;SessionUser.isAnonymouscarries it into the API, and the client derives demo mode from the live session (lib/demo.ts→isAnonymousUser). - Seeding lives in
apps/api/src/lib/demoSeed.tsand runs server-side viaPOST /api/demo/seed(routes/demo.ts). It is restricted to anonymous users and is idempotent (no-op if the account already owns a deck), so the call is safe to retry.
What gets seeded
Section titled “What gets seeded”Three decks for player Gtmap (from the user’s real example log):
| Deck | Role | Data |
|---|---|---|
| Mega Kangaskhan ex (Ogerpon Toolbox) | primary, default-active | 2 snapshots (League Cup → Regional), 14 matches, 5 with full German battle logs + pre-baked analyses |
| N’s Zoroark ex | secondary | 6 result-only matches |
| Dragapult ex (Dusknoir) | active archetype of the archetype-first UI (Spec 7, decision E9) | 60-card display list (not rules-validated until Spec 2), 6 result-only matches vs opponents outside Deck A’s triggers |
Preferences: the seed also writes user_preferences (activeArchetypeId: 'dragapult-ex',
remembered active deck = the Dragapult deck), so the archetype-first UI
(archetypeCoachUi flag) opens on Dragapult ex without onboarding. The old layout
still defaults to Deck A (lowest id). Battle logs and pre-baked analyses stay on
Deck A for now, so Coaching in the new UI is thin in the demo until Spec 7 Scheibe 7
re-seeds them.
The matchup distribution is engineered to fire the heuristics in
apps/web/src/hooks/useRecommendations.ts:
- Tech suggestions — Dragapult ex (2W-4L) → Eri, N’s Zoroark (2W-3L) → Briar (≥5 encounters, ≤50 % win rate, tech card absent from the deck).
- Version comparison — both bad matchups improve from 0 % (v1) to ~67 % (v2).
- Missing Boss’s Orders — Deck A intentionally omits it.
- Prize-dominated — two logged blow-out losses where Gtmap takes ≤1 prize.
- Battle-log performance — ≥3 logged games feed the per-card / tempo / brick stats.
The invariants above are guarded by apps/api/src/lib/demoSeed.test.ts, which also
runs every seeded log through parseBattleLog + validateAnalysis so a format/quote
drift fails the build instead of silently shipping an empty analysis.
AI analysis without spending tokens
Section titled “AI analysis without spending tokens”Battle-Log Analysis
Section titled “Battle-Log Analysis”- Pre-baked analyses — every logged demo match ships with a stored
analysisJSON (evidence-grounded), so the Match Detail → Analyse tab shows a real analysis with zero API calls. - Optional own token — a guest may paste their own GitHub Models token. In
demo mode it is kept only in
localStorage(pokekon-demo-ai-token) and sent per request;POST /api/analysis/logaccepts an ephemeralapiKeyin the body that is used once and never stored server-side. Regular users keep the existing server-side encrypted-key flow.
Deck Synthesis
Section titled “Deck Synthesis”The demo seed includes pre-computed deck syntheses in the deck_synthesis table for both demo decks, seeded with source: 'demo-seed'. The Mega Kangaskhan ex deck (primary, with field data) has syntheses in both DE and EN; the Zoroark deck is intentionally left without (shows the cold-start state: “No synthesis available — click Synthesize”). This demonstrates the feature without spending tokens on demo-mode visits.
Try it locally
Section titled “Try it locally”The fastest way to see the flow before deploying (single-origin, so the auth cookie stays first-party):
./scripts/demo-local.shIt ensures the dev database exists, applies migrations, builds shared → web → api,
generates local secrets (once, into the gitignored .env.demo.local), and serves
everything on http://localhost:8080. Open it and click “Ohne Anmeldung
testen”. Override the database with DATABASE_URL="…" ./scripts/demo-local.sh.
The API does not read
.envfiles — when starting things by hand, exportDATABASE_URLin the shell, and in two-terminal dev mode start the web withVITE_API_PROXY_TARGET=http://localhost:8080(otherwise/apicalls go nowhere and the demo button appears to do nothing). See getting-started.md.
Caveats
Section titled “Caveats”- Lowercase player names aren’t pinned. The parser’s player heuristic only
accepts names starting with an uppercase letter/digit
(
battleLogParser.ts), so the demo player isGtmap(capitalised), not the original lowercasegtmap. - Account linking drops demo data. Better Auth deletes the anonymous user when a guest signs up; the in-app demo banner communicates this.
- Guest accounts accumulate in Postgres over time. A periodic cleanup of stale anonymous users is a sensible follow-up (not yet implemented).