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:
- 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.
- 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. - Dynamic branching — instead of fixed paths, the model produces the next situation based on prior choices. State is kept in
Session+Messagetables.
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) andschreibdran-rest(PostgREST with RLS). Traefik routes/auth/v1and/rest/v1to the services. - Kilo Gateway — Anthropic-compatible endpoint instead of Vercel AI Gateway: model
z-ai/glm-5.3-flash,authToken(Bearer) instead ofapiKey, andmax_tokens ≥ 4000— GLM "thinking" otherwise eats the budget before the text block.NEXT_PUBLIC_SUPABASE_URL/ANON_KEYare 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