SIMLYFE: LLM-Driven Life Simulator

Personal Project

2025 – 2026

Problem

LLM-generated content is compelling but unreliable: left unconstrained it breaks game-state coherence, and calling it naively from the browser leaks API keys. The challenge was building a playable, shippable game where procedural LLM narrative and deterministic simulation systems reinforce rather than corrupt each other.

Constraints

  • LLM output must respect current game state (age, career, finances, relationships)
  • API keys must never reach the client — all inference server-side
  • Mobile-first performance: playable on mid-range phones in the browser
  • LLM latency and cost per event had to stay low enough for a free-to-play loop
  • Game logic had to remain testable independently of non-deterministic LLM output

Approach

Split the architecture into a deterministic TypeScript simulation core (economy, careers, relationships — pure functions, fully unit-tested) and an LLM narrative layer that receives structured game-state context and returns schema-validated events. All GPT-4o-mini calls route through Supabase Edge Functions acting as a server-side proxy, keeping keys off the client. Firebase handles cloud saves. The boundary between the two layers is contract-tested so LLM misbehavior degrades to fallback events instead of corrupting state.

Architecture

game-state contextschema-validated eventssavesReact 19 Clientmobile-first UIDeterministic Sim Coreeconomy·careers·relationshipsSupabase Edge Fnserver-side key proxyGPT-4o-minievent engineFirebase Cloud Savescross-device persistence
React 19 client → deterministic simulation core ⇄ Supabase Edge Function proxy → GPT-4o-mini event engine; Firebase cloud saves

Metrics

MetricBaselineAchieved
Automated test assertions0350+ (engine, LLM boundary, market)
Client-side API key exposureCommon naive patternZero — server-side proxy
DeploymentPrototypeLive on Vercel with cloud saves

Product Impact

A shipped, publicly playable game demonstrating production LLM integration patterns: structured prompting against live application state, server-side key management, schema validation at the LLM boundary, and a test suite that keeps deterministic and generative layers safely separated.

Tech Stack

React 19
TypeScript
Vite
Supabase Edge Functions
Firebase
OpenAI GPT-4o-mini
Vitest
Vercel

Links