SIMLYFE: LLM-Driven Life Simulator
Personal Project
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
Metrics
| Metric | Baseline | Achieved |
|---|---|---|
| Automated test assertions | 0 | 350+ (engine, LLM boundary, market) |
| Client-side API key exposure | Common naive pattern | Zero — server-side proxy |
| Deployment | Prototype | Live 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.