SIMLYFE: AI-Assisted 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 JavaScript simulation core and an AI narrative layer that receives a bounded game-state projection and returns schema-validated events. A Supabase Edge Function verifies Firebase identity and request origin, applies durable quotas, owns the OpenAI prompt and model configuration, and keeps provider credentials off the client. Firebase Auth and Firestore provide identity and cloud saves.
Architecture
Metrics
| Metric | Baseline | Achieved |
|---|---|---|
| Automated test cases | CI checked Oct 27, 2026 | 795 Vitest cases across 39 files |
| Provider credential boundary | Direct browser calls avoided | Authenticated proxy with server-owned OpenAI credentials |
| Live acceptance | Historical v19 repair check retained | Current v20 event resolved; same-browser reload passed |
Product Impact
A publicly hosted game demonstrating tested LLM integration boundaries: bounded game-state prompting, server-side key management, schema validation, and separation of deterministic and generative layers. After diagnosing a too-small Nano completion ceiling, five consecutive generated events at ages 6–10 resolved successfully and the same life returned after reload. A subsequent current v20 event resolved and restored age 1/history/stats after reload. These bounded checks do not establish a reliability SLO, broad narrative quality, cost or cross-device recovery.