Persistent Global Esports
The Internet Throne
Persistent real-time global competitive entertainment platform where exactly one person rules the internet at any second, featuring CAS concurrency locks, Ably WebSocket broadcasting, deterministic mini-game engines, and immutable historical archives.

Executive Summary & Core Concept
01The Internet Throne is a persistent, real-time, global competitive platform centered around a single, scarce digital status object: The Throne.
• At any given second in time, exactly one person rules the internet. • Any visitor (guest or registered user) can step up and challenge the sitting King or Queen to a real-time, skill-based mini-game (Typing, Reaction Speed, or Memory). • If the Challenger wins, the incumbent ruler is instantly dethroned, the Challenger is crowned, and the event is broadcast globally in real time. • If the Defender prevails, their defense count increments, their reign continues, and their legacy grows. • Every reign, defense, score, and dethroning is archived forever into the Hall of Kings.
Core psychological pillars center on absolute scarcity (one global throne that cannot be duplicated or split), skill-based legitimacy (power earned strictly through human skill, zero pay-to-win), immediate curiosity ("Who rules the internet right now?"), and permanent historical immortality.
System Architecture & Golden Engineering Tenets
02The platform is built as a high-performance, edge-ready monolith adhering to Five Golden Engineering Tenets:
1. Server Authority (Zero-Trust Client): Clients submit raw inputs and millisecond timestamps; the server computes scores, validates accuracy, checks physics, and declares outcomes. 2. MongoDB Decides, Ably Distributes: Database transactions are the authoritative single source of truth. Real-time messages are published strictly after database ACID commits succeed. 3. Compare-And-Swap (CAS) Concurrency: The Throne document uses a strict monotonically increasing version counter and activeBattleId lock to guarantee zero race conditions or dual-monarch splits. 4. Permanent Historical Immutability: Ended reigns, historical battles, and audit logs are append-only and immutable. 5. Seamless Guest-to-User Identity Conversion: First-time players can battle immediately as Guests without signup barriers, retaining the ability to claim and merge their prestige into a permanent Auth.js account later.
The application layers cleanly decouple UI controllers (/api/v1/battles, /api/v1/throne, /api/v1/hall), Application Services (ThroneService, BattleService, AntiCheatEngine, ProgressionService), and MongoDB Repositories.
Database Architecture & Data Models
03The persistence layer is modeled in MongoDB using multi-document ACID transactions:
• thrones Collection (Singleton Document): _id: "global", state (OCCUPIED, VACANT, MAINTENANCE), currentRulerId, currentReignId, activeBattleId (mutex lock for ongoing battles), defenseCount, bountyPoints, seasonId, and version (CAS lock counter). • reigns Collection (Immutable Reign Archive): _id, throneId, rulerId, rulerType (user | guest), startedAt, endedAt, endReason (DETHRONED | ADMIN | MAINTENANCE_RESET), defenseCount snapshot, bountyPointsSnapshot, and endedByBattleId. • battles Collection (Battle State Engine): _id, target, challengeType (typing | reaction | memory), state (CREATED through COMPLETED/CANCELLED/DISPUTED), challengerId, defenderId, throneVersionAtCreate, cryptographic seeds, participant submissions/scores, outcome, and server-enforced playDeadlineAt. • Supporting Collections: users (credentials & OAuth bindings), guest_identities (cookie-hashed sessions), profiles, audit_logs (security and anti-cheat trail), creator_thrones, and world_kingdoms.
Throne Concurrency, CAS State Machine & Rulebook
04Throne state transitions are governed by strict mathematical and concurrency rules:
• TR-010 (Cardinality): Exactly one global Throne singleton document (_id: "global"). • TR-040 (Concurrency & Single-Contender Lock): At most one active Throne Battle can occur at any time. Any concurrent challenge requests receive 409 CONFLICT ("Throne is Contested"). • TR-050 (Cooldowns): After a battle completes, the challenger must wait 60,000ms before challenging the same ruler again. • TR-070 (Defense Count): Increments atomically by +1 on each successful defense; resets to 0 when a new ruler takes the Throne. • TR-080 (Bounty Prestige): Bounty Points = ⌊Reign Duration (ms) / 60000⌋ + (Defense Count × 10). • TR-090 (Defender Fatigue Tier): Fatigue Tier = min(3, ⌊Defense Count / 5⌋), adding +15s challenger cooldown per tier to prevent monarch burnout. • TR-120 (Incumbent Advantage in Ties): If challenger and defender post identical validated scores, the Defender wins. • TR-160 (Atomic Dethroning): Crown handoff occurs in a single multi-document ACID transaction verifying expected version.
Competitive Mini-Game Disciplines & Scoring Engines
05Power is contested across 3 server-authoritative skill disciplines:
1. Typing Arena (typing): Server provides a deterministic prompt seed (promptId). Both players type against a 60-second play window. The server parses raw keystroke transcripts, validates accuracy (minimum 85% threshold), and computes official WPM (client-reported WPM is ignored). 2. Reaction Chamber (reaction): 5 randomized stimulus trials within a 45-second window. The server validates cryptographic trigger nonces. Responses earlier than stimulus triggers are flagged as false starts. Valid latency window is 80ms - 1500ms, and lowest mean reaction time wins. 3. Memory Matrix (memory): Server generates an 8-symbol random sequence. A timed encode phase is followed by a timed recall phase (90-second play window). The server validates exact position matches; ties are broken by submission speed, followed by incumbent advantage.
Security, Anti-Cheat Shield & Resilience
06A multi-layered defense shield ensures competitive integrity:
• Cryptographic Challenge Nonces: Seeds and stimulus sequences are generated server-side during the STARTING countdown and emitted exclusively to active participants. • Physics & Biometrics Sanity Checks: Input velocities (WPM < 250, Reaction Time > 80ms) are validated to eliminate bots and macros. • Deterministic Re-Simulation: Server re-executes player inputs against the puzzle rules to verify claimed scores. • Server-Enforced Timeouts: Strict playDeadlineAt timestamps prevent offline manipulation. • Rate-Limiting & Dispute Isolation: Token bucket rate limiters protect API gates, while suspicious runs are routed to DISPUTED status for audit. • Resilient Fallback: If Ably WebSocket connectivity drops, clients automatically fall back to REST polling (/api/v1/throne).
Identity Lifecycle & Growth Roadmap
07The platform features a frictionless user onboarding and progression model:
• Dual Identity: Players can jump directly into battles as Guests via cookie-hashed sessions. Upon registration or OAuth sign-in (GitHub, Google, Discord via Auth.js), players can merge their full match history, reign archives, defense tallies, and trophies into a permanent verified account. • Product Roadmap: - Phase 1 (MVP Core — Complete): Single Throne architecture, 3 mini-game disciplines, CAS concurrency locks, Ably real-time broadcast mesh, and guest identity flow. - Phase 2 (Growth & Community): Hall of Kings historical viewer, Profile claiming, Achievements, and automated seasonal soft resets. - Phase 3 (Creator & Scale): Creator custom thrones, regional territory conquest (World Map), and cosmetic throne customizations.
Testing, Quality Assurance & Engineering Standards
08The codebase enforces comprehensive quality gates across all layers:
• Vitest: Unit tests for domain state machine transitions, CAS version counters, fatigue tier math, and anti-cheat verification. • Integration Tests: Repository transactions verifying atomic MongoDB multi-document commits during simultaneous challenge requests. • Playwright: End-to-end multi-browser test suites simulating concurrent challenger queues, real-time battle play, and dethroning broadcasts.
Highlights
09Absolute Global Scarcity
Exactly one global Throne document across the entire internet; zero duplicate shards or pay-to-win shields.
Atomic CAS Concurrency
Monotonically increasing version counter with single-contender lock preventing race conditions during viral traffic spikes.
Server
Authoritative Anti-Cheat: Deterministic re-simulation, cryptographic nonces, and biometric threshold validation (WPM < 250, Reaction > 80ms).
3 Skill Mini
Game Disciplines: Typing Arena, Reaction Chamber, and Memory Matrix with authoritative server evaluation and tie-breaker mechanics.
Real
Time Broadcast Mesh: Sub-second global event notifications via Ably WebSockets for dethroning events, live battle states, and spectator feeds.
Immutable Hall of Kings
Permanent append-only digital archive recording every reign, duration, defense tally, and dethroning challenger.
Outcome & Status
010Shipped a production-grade high-concurrency competitive platform featuring sub-100ms real-time battle distribution, zero-collision CAS state transitions, and permanent historical reign archives.