1. Work
  2. Web and product engineering

Multiplayer garden game: from prototype to realtime serverless rebuild

A multiplayer browser game built twice: first with a server-authoritative economy on plain shared hosting, then rebuilt on a serverless stack with realtime rooms, managed sign-in and scheduled world ticks.

Problem

Social garden and shop games usually live inside closed game platforms. The aim was a browser game anyone could open on a phone or a laptop, with the same depth of collecting, crafting and playing with friends, and nothing to install. The first version then showed its own limits: polling the server and running world ticks from scheduled jobs on shared hosting made trades, chat and multiplayer rounds feel slow, and left a server to look after.

Goal

First, a complete multiplayer browser game with a server-authoritative economy, social features and an immersive interface, on ordinary shared hosting with no framework. Second, a rebuild on a modern serverless stack with realtime multiplayer, managed sign-in, scheduled world ticks and nothing to run by hand.

My role

Sole creator of both versions: game design, backend, database and migrations, frontend, art direction through SVG and CSS, realtime features, admin tooling, deployment and testing, with AI coding assistance on the rebuild.

Solution

Version one is a framework-free PHP API behind a single front controller, a relational database with versioned migrations and a vanilla JavaScript single-page app. Every economic action is validated on the server, and scheduled jobs keep the shared world moving.

Version two is a TypeScript web app with one page per game area and one server route handler per action, backed by managed Postgres with built-in sign-in and realtime channels, and deployed serverless with scheduled functions.

How it works

Version one. Every API call enters one front controller and a router that dispatches to feature controllers. Shared helpers give prepared-statement database access, uniform JSON responses and input validation, and a middleware protects player routes with sessions, hashed passwords and CSRF tokens. Growth is computed from timestamps, so idle growth needs no background process. Every purchase, harvest, craft, gift and trade is checked against the player's real inventory on the server, and a trade runs inside a database transaction so both inventories change together or not at all. Scheduled jobs rotate the weather, cycle weekly events and simulate helpers watering a shared community garden. In the browser, one central state module plus one module per feature, CSS variables for themes, fluid scaling for very small phones, SVG avatars and Web Audio sound make it feel like a game rather than a web page.

Version two. Action routes are designed to resolve the signed-in player on the server before they touch data. Experience points flow through one server helper, introduced after a level-up bug caused by writes scattered across features. Realtime channels carry multiplayer mini-game rooms (join by code, presence, host start, live score and answer broadcasts, and late joiners who still land in a round already running), chat, live trade offers and friends' garden updates. When a trade is accepted, the server checks again that every item and pet is still owned and cancels a stale offer instead of executing it. Scheduled functions handle daily weather, event rotation and clean-up, and computer-controlled shopkeepers enter the weekly fashion contest so it stays lively with few players.

Both versions have an admin console for players, economy tuning, events, weather, characters, configuration and moderation.

Technical challenges

Designing economy rules that are validated on the server rather than trusted from a browser client.

Two-player trades that cannot leave inventories half changed in version one, and offers that are re-verified at accept time in version two.

Timed growth, mutations and weather without a running game loop.

A game-like interface that scales from very small phones to desktops without a UI framework.

Moving from polling to event-driven realtime without letting the client become authoritative.

Room lifecycle and late joiners in live multiplayer rounds.

Centralising progression logic after a real bug, rather than patching each caller.

Porting many interlocking game systems to a typed stack.

Capabilities

  • Plant, grow and harvest with mutation tiers
  • Drink crafting with a customer queue and secret recipes
  • Pets, friends, gifting, garden visits and trading
  • Co-op stand roles and a shared community garden
  • Town map and housing
  • Quests, weekly events, achievements, leaderboards and login rewards
  • Fashion contests with computer-controlled entrants
  • Mini-games, including live multiplayer rooms
  • Realtime chat with stickers
  • Photo mode, themes and sound
  • Managed sign-in
  • Scheduled world ticks
  • Admin and moderation console

Technology

  • PHP 8 without a framework
  • MySQL-family relational database with SQL migrations
  • JavaScript with no framework
  • CSS custom properties and fluid scaling
  • SVG and the Web Audio API
  • Scheduled jobs on shared hosting
  • Static analysis with PHPStan and JSHint
  • Next.js App Router with React and TypeScript
  • Tailwind CSS
  • Supabase with Postgres and SQL migrations
  • Supabase authentication and realtime
  • Vercel hosting and scheduled functions

Impact

A feature-complete playable prototype validated the game design and exposed the limits of polling and shared hosting. The rebuild made the game realtime and fully serverless, with no server to patch and rounds that update instantly for everyone in the room. It shows one product carried from prototype to a modern architecture, with a reason behind each change.

Skills demonstrated

  • Full-stack web development
  • API and database design
  • Session authentication and CSRF protection
  • Transactional integrity
  • Game economy design
  • Responsive, immersive UI without a framework
  • React and Next.js
  • Realtime systems
  • Serverless architecture and scheduled jobs
  • Large-scale migration between stacks

Demo

Planned

A throwaway sandbox seeded with invented players. For the rebuild: two windows side by side join one mini-game room with live scores, then an accepted trade and an instant chat message. For the prototype (optional, or a short recording): a harvest with a visible mutation, a drink served to a queued customer, a theme switch on a phone-sized screen and an admin price change.

Not built yet. A demo here uses only invented names and data.

All work