LifeBeta is an idle life simulation built for Reddit's Devvit platform. A shared Express runtime advances a single Snoo through monthly events while the web client visualises stats, emotions, and community influence. Players press Begin to claim the run using their Reddit identity, then watch the story unfold, occasionally steering fate when community control peaks.
- Server-driven life loop – The server tracks age, month, and six stats (Happiness, Health, Wealth, Stress, Energy, Cash) and advances time every 0.5–1s once a player starts their run.
- Dynamic emotions & events – Emotion thresholds affect which events trigger and how positive/negative outcomes are weighted. Events apply clamped stat changes and can shift emotions directly.
- Community influence – Pulse and Control meters decay over time and bias event selection. When Control wins a roll, the server surfaces two community choice events for the player to decide.
- Life timeline – The client renders the 30 most recent event outcomes with animated stat-change bubbles and a collapsible drawer for readability.
- Completion flow – Runs finish when the Snoo reaches age 110 or a stat hits zero. The finale screen summarises results, refreshes the leaderboard, and offers restart & share buttons.
- Leaderboard & sharing – Posting a summary through
/api/sharerecords the score for the current Reddit user and refreshes the local leaderboard preview.
src/client/– Vite-built web client with DOM orchestration inmain.ts, HUD layout inindex.html, and styling instyle.css.src/server/– Express API hosted with@devvit/web/server.index.tsencapsulates the tick loop, Redis persistence, API routes, and leaderboard logic.src/shared/– Shared types, emotion definitions, event data, and stat helpers used by both client and server.tools/– Automation scripts and Devvit configuration helpers.dist/– Build output consumed by the Devvit runtime (generated).
- Install dependencies (Node 22+ recommended):
npm install
- Launch the local dev stack (client build watcher, server watcher, Devvit playtest):
npm run dev
- Point the Devvit playtest UI to the running experience and interact with the app on Reddit.
Useful supporting scripts:
npm run build– Production build for both client and server bundles.npm run type-check– TypeScript project reference check across client, server, and shared packages.npm run deploy/npm run launch– Upload and publish the bundle via the Devvit CLI (requiresdevvit login).
GET /api/initseeds the client with the current state, event history, community snapshot, and leaderboard summary.- The client polls
/api/stateevery 2s for stream messages containing the latestStateEnvelope, pending choices, or finalisation notice. - When Control triggers a choice, the server locks in two candidate events. The selected option is posted via
/api/events/choosebefore the timeout expires. - Sharing the final summary hits
/api/share, which stores the score in a Redis-backed leaderboard and returns updated rankings. POST /api/restartresets the run to a fresh age-18 state while retaining the player’s Reddit display name for continuity.
npm run dev: Starts a development server where you can develop your application live on Reddit.npm run build: Builds your client and server projectsnpm run deploy: Uploads a new version of your appnpm run launch: Publishes your app for reviewnpm run login: Logs your CLI into Redditnpm run check: Type checks, lints, and prettifies your app
Set the following environment variables before running the server to enable AI-generated share drafts:
OPENAI_API_KEY: Required. API key for the OpenAI account.OPENAI_MODEL: Optional. Overrides the defaultgpt-4o-minimodel name.OPENAI_API_URL: Optional. Defaults tohttps://api.openai.com/v1/chat/completions.OPENAI_TIMEOUT_MS: Optional. Request timeout in milliseconds (defaults to8000).
Add these to your local .env file when using npm run dev.