Jonas Krauss

Portfolio

Schreibdran Adventure

AI-powered text adventure set in the fantasy world of “When the Gods Froze” — Next.js, a minimal self-hosted Supabase stack, and LLM integration via the Kilo Gateway. A creative hobby project.

Challenge

Building an interactive text adventure that does not rely on pre-written story trees but generates each scene dynamically from a language model. The goal: tell a believable fantasy world, react to players' choices and stay consistent — without writing every branch by hand. And to run it without expensive cloud services.

Approach

The adventure is a standalone Next.js frontend (schreibdran3, a Turborepo with shared + web) against a slim self-hosted Supabase instance:

  1. Character setup — players set name, gender, profession, background, motivation and strengths/weaknesses. The profile is baked into the prompts as game context and shapes the narrative tone.
  2. LLM-driven scenes — the story is generated from the LLM. Every choice is saved as a guest via char_auth_key (anon key); registering keeps the character permanently.
  3. Dynamic branching — instead of fixed paths, the model produces the next situation based on prior choices. State is kept in Session + Message tables.

Self-hosted instead of cloud

Originally the adventure ran against Supabase Cloud and the Vercel AI Gateway. Both were migrated to own infrastructure:

  • Supabase minimal stack (/opt/prod/schreibdran-supabase): schreibdran-db (Postgres 15.8), schreibdran-auth (GoTrue, anon sign-ins, GOTRUE_DB_NAMESPACE=auth) and schreibdran-rest (PostgREST with RLS). Traefik routes /auth/v1 and /rest/v1 to the services.
  • Kilo Gateway — Anthropic-compatible endpoint instead of Vercel AI Gateway: model z-ai/glm-5.3-flash, authToken (Bearer) instead of apiKey, and max_tokens ≥ 4000 — GLM "thinking" otherwise eats the budget before the text block. NEXT_PUBLIC_SUPABASE_URL/ANON_KEY are build args (baked into the client bundle at build time).

Results

  • Fully functional text adventure at adventure.jonaskrauss.de
  • Consistent, dynamic scenes — every playthrough is different
  • Instant guest play, optional registration for persistent characters
  • Completely self-hosted: no Supabase Cloud, no Vercel AI Gateway — full control over data and cost

Tech Stack

  • Frontend: Next.js (App Router), React, TypeScript, Tailwind CSS
  • Backend/DB: Supabase minimal stack (Postgres 15.8, GoTrue, PostgREST)
  • AI: Kilo Gateway (Anthropic-compatible), model z-ai/glm-5.3-flash
  • Tooling: Turborepo, pnpm, Docker, Traefik (Let's Encrypt), Docker Compose