Case Study 02 // Public TypeScript Multi-Screen SaaS

BeeNight — Live Spelling Bee

A real-time, multi-screen interactive game-show platform built in TypeScript 5.5 & React 18 that brings the energy and responsiveness of Kahoot! to live, in-person spelling bees. Born as a custom game show for our apartment housewarming party with my wife, then re-architected into a Local-First, Ephemeral Multi-Room SaaS where anyone can host a live spelling bee with zero account sign-up, zero database cost, and complete tenant privacy.

Tab-to-TV Sync < 5ms

Intra-browser BroadcastChannel (`beenight_sync_v1`) stays instant even if party Wi-Fi drops.

Avatar Compression > 99%

HTML5 Canvas downscales 3–8MB guest photos into ~15–25KB (256×256 JPEG at 0.82 quality).

Audio Asset Payload 0 KB

100% procedural Web Audio API synthesis (dual-oscillator chimes, buzzers, ticks, drumrolls & fanfare).

Multi-Tenant Capacity 500 Rooms

Concurrent isolated rooms (room:BEE-XXXX) in RAM with 12h TTL eviction and $0/mo DB overhead.

01 // Origin, Surfaces & Stage State Machine

Three Coordinated Screens for Live Verbal Performance

Open Live App ↗
ORIGIN STORY // HOUSEWARMING PARTY → PUBLIC SAAS

Why Existing Trivia Apps Fell Short

When my wife and I moved into our new apartment together, we decided to host an interactive spelling bee for our housewarming party. Existing party trivia tools were designed around multiple-choice phone quizzes rather than live verbal stage performance—where an emcee judges spoken spelling in real time while a living-room TV drives crowd engagement. After the housewarming party became a hit with our friends, I re-architected BeeNight from a single-household LAN build into a public, multi-room SaaS platform with 5 live-switchable broadcast themes, platform-locked branding (PLATFORM_BRANDING separated from mutable GameConfig), and progressive disclosure separating essential setup (Rules & Theme) from power-user modifiers (Advanced Features).

01 // /tv BROADCAST STAGE

Living-Room 10-Foot Display

Cinematic TV display featuring contestant spotlight cards, countdown timers, progressive hint reveals, animated leaderboards, synthesized game-show audio, and canvas-confetti celebrations. Decluttered on Lobby, Ranks, and Podium views with a presence-aware Pair Host QR button that collapses into a subtle status badge once a Host connects.

02 // /host TELEPROMPTER

Mobile Emcee Remote Control

Smartphone remote giving the host private phonetic pronunciations, definitions, example sentences, window.speechSynthesis audio playback, one-tap judgment controls (Correct, Wrong, Skip), and stage-contextual presentation controls over LAN or public HTTPS.

03 // /admin PRODUCTION STUDIO

Pre-Show Roster & Word Bank Suite

Zero-login production desk for importing contestant rosters via sanitized CSV, non-destructively framing guest portraits, curating tiered word banks, configuring streak multipliers and sudden-death finals, stepping through a 25-action undo stack, and exporting/importing JSON backups.

Game Stage (gameState.stage) Host Controller Projection (HostView.tsx) TV Broadcast Behavior (TvView.tsx)
LOBBY Renders exclusively LobbyPresentationCard.tsx so the emcee can step through pre-game contestant bios and portraits without exposing active round buttons. Full-bleed contestant introduction spotlight and presence-aware QR pairing modal with human-readable passphrase (e.g., HONEY-CROWN-42).
ACTIVE_TURN Renders the active speller card, private teleprompter (phonetics, definition, example sentence), progressive hint triggers, and sticky bottom judgment bar (Correct, Wrong, Skip). 10-foot speller spotlight, live countdown timer, masked letter slots with progressive hint reveals, and procedural Web Audio chimes/buzzers.
LEADERBOARD Renders HostLeaderboardCard.tsx with live survival statistics, elimination counts, and one-tap round transition controls. Animated standings table with streak indicators, survival badges, and clean footer-free broadcast framing.
PODIUM Renders HostPodiumCard.tsx (Winners Podium Controller) with remote TV confetti and victory fanfare triggers. 1st/2nd/3rd place championship podium with canvas-confetti bursts and synthesized fanfare.
02 // System Architecture

Local-First Isomorphic Reducer & Dual-Transport Relay

Zero-DB Multi-Tenant SaaS

To transition BeeNight from a private housewarming prototype into a public multi-tenant SaaS without paying for database hosting or storing personally identifiable guest photos on a server, all game rules live in a single zero-dependency TypeScript engine (src/domain/gameEngine.ts) shared isomorphically between the React client and the stateless Node.js Socket.IO relay.

Host Laptop Browser (Source of Truth)

Admin (/admin) + TV (/tv)

Persists state in localStorage (beenight.gameState.v1) and syncs across tabs in <5ms via BroadcastChannel (beenight_sync_v1).

Isomorphic Domain Core

Pure TS Engine (gameEngine.ts)

Scoring formulas, streak multipliers, sudden-death finals, 25-step undo snapshots, CSV sanitization, and strict config whitelisting.

Stateless Node.js Relay

Ephemeral Room Map (stateStore.ts)

Scoped rooms (room:BEE-XXXX) held in RAM with a 12-hour TTL and 500-room LRU cap. Re-hydrates via state:push on reconnect.

Mobile Devices (LAN / Web)

Host Remote (/host?room=BEE-XXXX)

Capability-token QR pairing (&auth=<sha256>) authenticates the emcee's phone instantly with zero cross-talk between concurrent parties.

03 // Key Technical Highlights & Code Deep Dives

Four Production TypeScript Modules Under the Hood

Zero External Crypto / Audio Deps
HIGHLIGHT 01 // src/domain/gameEngine.ts

Isomorphic Config Whitelisting & Schema Self-Healing

Because BeeNight hydrates state from browser localStorage, imported JSON backup files, and untrusted WebSocket payloads, schema drift or legacy keys could corrupt runtime state or overwrite platform-owned branding. Using DEFAULT_GAME_CONFIG as the single runtime source of truth eliminates manual validation boilerplate while guaranteeing that deprecated or unauthorized fields (such as legacy eventTitle / eventSubtitle) are stripped during both hydration (normalizeHydratedGameState) and live admin:updateConfig events.

HIGHLIGHT 02 // src/utils/crypto.ts

Pure-TypeScript FIPS 180-4 SHA-256 & QR Capability Pairing

When a Host scans the TV's QR code over a local Wi-Fi network (http://192.168.x.x:5173), browsers treat non-HTTPS LAN origins as insecure contexts and disable window.crypto.subtle. I implemented a zero-dependency FIPS 180-4 SHA-256 engine in pure TypeScript. Each session generates a memorable passphrase (e.g., HONEY-CROWN-42), stores only passphraseSalt and passphraseHash, and embeds the capability hash in the QR URL (?room=BEE-XXXX&auth=<hash>) for instant one-scan authentication.

HIGHLIGHT 03 // src/components/ParticipantAvatar.tsx

Non-Destructive Face Focal Framing for Contestant Avatars

Party guests submit portraits in wildly different aspect ratios (vertical selfies, group shots, off-center crops). Re-encoding images on every pan/zoom adjustment would degrade JPEG quality and bloat localStorage. Instead, ParticipantAvatar.tsx pairs a single 256×256 compressed JPEG data URL with three focal coordinates (photoFocusX, photoFocusY, photoScale). Binding both objectPosition and transformOrigin to the same percentage coordinates scales directly around the contestant's face across circular badges and 16:9 TV spotlight cards.

HIGHLIGHT 04 // src/utils/audio.ts

Procedural Web Audio API Game-Show Synthesizer

To give the living-room TV broadcast authentic game-show feedback with zero external MP3/WAV assets or network preloading delays, audio.ts synthesizes all sound effects (correct chimes, wrong buzzers, countdown ticks, drumrolls, and podium fanfare) procedurally in real time. Layering a fundamental triangle wave with an octave-doubled sine harmonic (freq * 2) and shaping the envelope via exponentialRampToValueAtTime produces a warm, click-free C5→C6 major 7th chime while passive pointerdown / keydown listeners automatically unlock suspended browser AudioContext instances.

04 // Architectural Challenges & Outcomes

Hard Problems Solved in the SaaS Migration

01

Migrating from Single-Instance Disk Persistence to Multi-Tenant Public SaaS

The Problem: The initial housewarming party build persisted state to a single data/gameState.json file and /uploads folder on the Node.js server. Launching that architecture publicly would cause every concurrent party to overwrite the same game state and expose personal guest photos across tenants.
The Solution: Extracted the reducer into a pure isomorphic engine (src/domain/gameEngine.ts), moved durable persistence to the organizer's browser via src/services/localStorageRepo.ts, and refactored server/stateStore.ts into a stateless, room-scoped (room:BEE-XXXX) in-memory relay with automatic state:push re-hydration if the relay server restarts mid-party.

02

Fitting High-Resolution Guest Photos Inside Browser localStorage Quotas

The Problem: Browser localStorage enforces a strict ~5MB origin limit. Uploading raw smartphone photos (3–8MB each) for 20+ party contestants immediately throws a QuotaExceededError.
The Solution: Built an HTML5 Canvas image compression pipeline (src/utils/imageCompressor.ts) that center-crops and downscales uploaded portraits client-side into 256×256 JPEG data URLs (quality: 0.82), reducing each photo from ~5MB to ~15–25KB (>99% reduction). Even a 50-contestant roster with custom photos and a 25-action undo stack consumes less than 1.5MB of localStorage.

03

Preventing Host Cognitive Overload During Live Stage Transitions

The Problem: During a fast-paced party, showing lobby presentation controls, word teleprompter cards, and round-reset buttons simultaneously on a small phone screen made it easy for the emcee to tap the wrong control.
The Solution: Redesigned HostView.tsx around strict stage-contextual component projection (LobbyPresentationCard, active turn teleprompter, HostLeaderboardCard, and HostPodiumCard) and decluttered TvView.tsx by removing persistent footers on Lobby, Ranks, and Podium views.

Public Live Application

Spin up a live spelling bee room in under two minutes

BeeNight is live and open to the public—import guests via CSV, pair your phone via QR code, and test the multi-screen broadcast stage directly on Render.