I recently went on holiday in Australia because I was speaking at NDC Sydney, one of the global NDC developer conferences. It was my first time speaking at an NDC event, and the entire experience was fantastic. I gave two talks: one focused on building AI agents and another on active-active multi-region architecture on Azure. Naturally, I needed a demo project substantial enough to support both presentations. That requirement ultimately evolved into a full multiplayer game platform called The Last Republic.

The Last Republic is a social deduction game for five to nine players centered on the fragility of free government and the courage required to defend it. The game draws clear inspiration from Secret Hitler, but the goal was never to simply clone an existing board game. I wanted to explore what would happen if modern AI systems could actively participate in highly social, deceptive, psychologically driven multiplayer gameplay. The result became part distributed systems experiment, part AI orchestration platform, and part fully playable online game.

The real outcome was pretty hilarious…and a little frightening. Especially as I watch the AI player chat as they attempt to deceive the other players into voting against their self interest by abandoning democracy and putting a totalitarian ruler into power.

In the words of my generation: “That’s heavy, man.”

A Personal Touch

One of my favorite additions to the game was the Animal Farm theme. George Orwell’s Animal Farm has always been one of my favorite books because it manages to condense political idealism, corruption, propaganda, authoritarianism, and the gradual collapse of democratic principles into something deceptively simple and approachable. Underneath the talking animals and farm setting is an incredibly sharp exploration of how power structures evolve and how easily fear, manipulation, and groupthink can reshape a society.

Since The Last Republic is fundamentally a game about fragile democracies and hidden authoritarian movements, the thematic overlap felt almost perfect. Eventually I decided to build an entire alternate game theme inspired by Orwell’s world.

Instead of traditional political roles, players can enter matches as iconic farm animals from the book or take on the roles of the more sinister figures like the intimidating Napoleon or the relentlessly manipulative Squealer. The policy tracks, role labels, cards, win screens, and overall presentation were all adapted to fit the tone of the novel while still preserving the underlying mechanics of social deduction and hidden allegiance.

What made the theme particularly entertaining was watching the AI agents inhabit those personalities during gameplay. Accusations, political maneuvering, strategic deception, and shifting alliances somehow become even more amusing when they are delivered through the lens of paranoid revolutionary farm animals trying to consolidate power. There is something uniquely entertaining about watching an AI-controlled Napoleon confidently manipulate a room full of suspicious livestock while another player desperately attempts to convince everyone that Squealer is lying again.

Thematically, the Animal Farm variant ended up reinforcing one of the central ideas behind the entire project: social systems are fragile, narratives are powerful, and people — or apparently farm animals — are surprisingly susceptible to persuasion, fear, and coordinated misinformation.

One of the recurring problems with social deduction games is player count. Technically, five people is enough to make the mechanics function, but anyone who has played these kinds of games knows the experience improves dramatically with larger groups. Seven players creates a completely different social atmosphere. The conversations become more chaotic, alliances become unstable, and suspicion becomes far harder to manage. Unfortunately, organizing seven humans at the same time is difficult. My solution was straightforward: allow AI agents to fill empty seats dynamically so that games could always reach their ideal size.

What began as a conference demo escalated quickly. My first commit was on April 15th. One month later, on May 15th, the platform was effectively complete. In that time, the project evolved into a production-grade online multiplayer game system combining real-time gameplay, AI agents, monetization, operational tooling, analytics, and cloud-native distributed architecture.

What did I build?

The platform supports real-time multiplayer gameplay through SignalR with automatic reconnection, live game updates, chat, and lobby subscriptions. The full Secret Hitler ruleset was implemented, including elections, policy decks, executive powers, investigations, executions, special elections, and victory conditions. Beyond that, the system introduced AI-powered players driven by Azure OpenAI with persistent memory, personality archetypes, contextual reasoning, deception strategies, and evolving suspicion analysis.

The AI players are not simple scripted bots. Each maintains a running understanding of the game, remembers prior rounds, tracks voting behavior, forms suspicions, and adapts strategically based on role and context. They lobby other players, accuse opponents, react to chat messages, deliberate during executive decisions, and continuously update their internal models of who they trust. The goal was not merely to automate gameplay but to create AI participants capable of contributing to the social dynamics that make deduction games interesting in the first place.

To make the experience more flexible, the platform also supports multiple thematic variants beyond the traditional setting. Themes include Classic, Animal Farm, Imperial, Care Bears, Startup, and Culture War, each with custom roles, cards, policy tracks, labels, and win screens. This gave the game a level of replayability that extended well beyond the original mechanics.

The project also grew far beyond gameplay itself. Authentication is handled through Auth0 with automatic onboarding and persistent player profiles. Monetization is implemented through a coin economy backed by Stripe Checkout integration, allowing players to purchase AI participation. Human players collectively vote on whether coins should be spent to add AI players into active games, which creates an interesting layer of social consensus even around monetization itself.

Player analytics became another major area of focus. The platform tracks ELO ratings, role-specific statistics, vote accuracy, lies told, and long-term player performance. Post-game analysis tools expose AI reasoning, suspicion graphs, scorecards, and round histories, effectively allowing players to replay the psychological evolution of an entire match after it concludes.

Operational tooling became necessary surprisingly quickly. Administrative systems were added for recovering stalled games, monitoring AI usage, tracking token consumption, moderating users, and cleaning up cascading game failures. Since AI inference costs can spiral rapidly, several layers of cost control were introduced, including concurrent AI caps, token accounting, probabilistic AI chat throttling, and configurable response budgets.

Underneath all of this sits a heavily cloud-native Azure architecture. The platform uses Cosmos DB, Event Grid, Storage Queues, Azure OpenAI, SignalR, Key Vault, OpenTelemetry, managed identities, and Azure Container Apps. Infrastructure is provisioned entirely through Terraform. The architecture intentionally emphasizes scalability, resiliency, operational simplicity, and asynchronous processing patterns.

Building the Architecture

The technical architecture separates responsibilities into two independently scalable services: an API layer and a Worker layer. The API handles HTTP requests, authentication, SignalR communication, game-state mutations, and all real-time interactions with human players. The Worker asynchronously processes AI gameplay events and Azure OpenAI completions.

This separation solves several problems simultaneously. Long-running AI requests never block real-time gameplay responsiveness. Human traffic and AI workloads can scale independently. Failures inside AI processing pipelines remain isolated from the primary multiplayer experience. In practice, this architecture made the platform dramatically more resilient under load while also simplifying operational reasoning about the system.

Both services share a common core library containing the domain models, rules engine, orchestration logic, persistence models, and validation systems. This shared-core design guarantees that AI and human players operate under identical game rules. There is no separate “AI path” through the system. Every action flows through the same validation engine and state machine.

The AI orchestration model itself is fully event-driven. Human actions mutate game state synchronously through the API. Whenever an AI participant needs to act, the system emits a CloudEvent through Event Grid. The event routes into Azure Storage Queues where Worker instances consume it asynchronously. The Worker invokes Azure OpenAI, generates the AI decision, and feeds the resulting action back through the shared game engine.

This architecture creates a surprisingly elegant gameplay pipeline. AI actions become durable asynchronous workflows that tolerate retries safely and scale horizontally without interfering with the real-time multiplayer loop. The game remains responsive for humans even while multiple AI agents are simultaneously reasoning about strategy, deception, and voting behavior.

AI System

AI players are powered by Azure OpenAI and are implemented as persistent contextual agents rather than simple stateless bots. Each AI player maintains personality archetypes, role-based strategic behavior, prior-round memory, conflict analysis, voting history, and persistent reasoning continuity across the game. Prompt construction dynamically incorporates current game state, historical actions, social interactions, and previous AI thoughts to create sophisticated deception, deduction, persuasion, and coordination behavior that mimics human social deduction gameplay.

AI gameplay is implemented using an event-driven orchestration model built on Azure EventGrid and Azure Storage Queues. Human actions mutate game state synchronously through the API service, and whenever an AI player must act, the system publishes a CloudEvent into EventGrid. That event is routed into a Storage Queue where the Worker service consumes it asynchronously, invokes Azure OpenAI to generate the AI decision, and then calls back into the shared game engine to apply the result. This architecture allows AI gameplay to scale horizontally, tolerate retries safely, and process multiple AI actions concurrently without blocking the core gameplay loop.

The system includes multiple layers of AI governance and cost-control mechanisms to prevent runaway token consumption and operational instability. Features include configurable concurrent AI-player caps, detailed token accounting, probabilistic AI chat throttling, response-length budgeting, and monetized AI participation through an in-game coin economy. These controls allow the platform to maintain sustainable operational costs while still delivering rich AI-driven gameplay experiences.

Cosmos DB Design

Persistence is handled through Azure Cosmos DB using multiple purpose-specific containers for games, users, rounds, analytics, chat, AI decisions, and coin transactions. The design relies heavily on partition-scoped queries, ETags, and atomic patch operations for high-contention scenarios such as updating balances or synchronizing game state.

The game itself is modeled as a document-centric aggregate. That approach maps naturally onto multiplayer game state because the system needs to persist deeply nested, rapidly evolving structures while maintaining horizontal scalability and low-latency access patterns.

One particularly interesting design decision was the filter-on-read security model. Instead of storing multiple versions of game state tailored for each player, the system stores a single authoritative document containing all hidden information, including secret roles, policy decks, AI reasoning metadata, and investigation results. Whenever a player requests game state, the backend dynamically constructs a role-aware filtered DTO containing only the information that player is allowed to see.

That means rules such as:

  • “Can this player see fascist teammates?”
  • “Can the Tyrant see the authoritarian team at this player count?”
  • “Should spectators see hidden roles?”
  • “Should dead players retain visibility?”

are enforced dynamically at read time rather than through duplicated storage models.

Deployment

Infrastructure for The Last Republic is provisioned entirely through Terraform using a multi-stack, multi-provider infrastructure architecture spanning Azure, Auth0, Cloudflare, Stripe integration infrastructure, and supporting platform services. Rather than manually configuring cloud resources through portals or ad-hoc scripts, the entire environment is declaratively orchestrated through infrastructure-as-code, allowing the platform to be reproducible, versioned, environment-aware, and fully automatable from end to end.

Terraform stacks coordinate the provisioning of Azure Container Apps, Cosmos DB, Azure Front Door, Event Grid, Storage Queues, Key Vault, managed identities, monitoring infrastructure, networking, DNS configuration, TLS routing, and identity configuration alongside Auth0 tenants and Cloudflare-managed edge services. This creates a unified deployment model where infrastructure, identity systems, networking, security boundaries, and application runtime environments evolve together as a single coherent platform rather than as disconnected operational silos.

The infrastructure design intentionally mirrors the architecture of the application itself: distributed, event-driven, independently scalable, and operationally resilient. API and Worker services are deployed separately through Azure Container Apps so human gameplay traffic and AI orchestration workloads can scale independently. This prevents expensive or long-running AI operations from degrading realtime gameplay responsiveness while also simplifying operational tuning and fault isolation.

Managed identities and Key Vault eliminate the need for shared secrets throughout the runtime environment, while Cloudflare and Front Door collectively provide edge routing, DNS management, TLS termination, and global traffic handling. The result is an architecture where the majority of operational concerns — networking, security, routing, secret distribution, scaling, and environment consistency — are codified directly into Terraform rather than managed manually through operational processes.

One Developer, 30 Days

One of the strangest parts of this project is not necessarily the architecture or even the AI systems. It is the timeline. The first commit was on April 15th. By May 15th, the platform was effectively complete. Not prototype complete. Operationally complete. Multiplayer gameplay worked, AI orchestration worked, monetization worked, realtime infrastructure worked, analytics worked, and the deployment pipeline was fully automated.

There is absolutely no scenario where I could have built a platform of this scope in that timeframe using traditional development approaches alone. Most of the work was done while on holiday and even while I sat on a mini-bus on a day trip to the Blue Mountains, the Twelve Apostles or Phillip Island!

The project was built using a hybrid development model combining local Claude-assisted development, GitHub Copilot remote agents running tasks in parallel, and continuous human architectural oversight. Rather than treating AI as a code generator operating in isolation, I treated it more like an asynchronous team of extremely fast junior-to-mid-level engineers that required direction, correction, validation, and occasionally intervention when things drifted off course.

A large amount of the implementation work happened through parallel task execution. While I worked locally on architecture, system design, debugging, or feature refinement, I would simultaneously dispatch isolated implementation tasks to GitHub Copilot agents. Entire feature branches could be generated in parallel while I focused on higher-level coordination and integration work. This dramatically compressed iteration cycles because multiple streams of development could progress simultaneously instead of serially.

Claude was particularly useful for deeper implementation reasoning, refactoring, architectural refinement, debugging assistance, and helping evolve larger systems coherently over time. Copilot agents were extremely effective for parallelized feature implementation, boilerplate-heavy work, repetitive integration tasks, and rapidly scaffolding infrastructure or API surfaces. The combination worked surprisingly well because each tool compensated for the weaknesses of the other.

That does not mean the process was automatic or effortless. Quite the opposite. AI dramatically accelerated implementation velocity, but it also introduced a new category of engineering work centered around orchestration, validation, and correction.

A significant amount of time was spent course-correcting generated implementations, refining abstractions, fixing edge cases, and steering the system back toward architectural consistency whenever generated code began to drift. Runtime debugging became a core part of the workflow. I frequently had to inspect Application Insights telemetry, analyze distributed traces, review runtime exceptions, and pull detailed logs out of live systems in order to understand failures occurring across asynchronous workflows, SignalR events, queue processing, AI orchestration pipelines, or distributed state transitions.

Testing the actual gameplay loop became equally important. Social deduction games are filled with strange edge cases because the system is driven by combinations of hidden information, player roles, asynchronous timing, disconnects, voting states, executive powers, deaths, reconnections, AI actions, and realtime synchronization. Many bugs only surfaced through repeatedly playing the game itself and intentionally trying to break it in unusual ways.

When failures occurred, the workflow became highly iterative. I would reproduce the issue, gather telemetry and logs, isolate the failing behavior, and then feed the problem back into either Claude or GitHub Copilot as a highly specific corrective task. In many cases, the AI systems were far more effective when supplied with concrete runtime evidence rather than abstract descriptions of bugs. Application Insights effectively became part of the prompt engineering workflow.

What emerged from the experience was not “AI replaces developers,” but something much more interesting: AI dramatically increases the implementation bandwidth of a developer who already understands architecture, distributed systems, operational concerns, and software design. The bottleneck shifts away from typing code and toward system thinking, validation, debugging, prioritization, and architectural judgment.

The result is a very different style of software engineering than traditional development. Instead of manually implementing every line of code, the process becomes one of orchestrating parallel implementation streams, continuously validating outcomes, steering architectural direction, refining generated systems, and using operational telemetry as feedback loops for iterative correction. In many ways, the development process itself started to resemble the distributed systems architecture the platform was built upon: asynchronous, parallelized, event-driven, and heavily dependent on observability and coordination.

Summary

At its core, The Last Republic became far more than a multiplayer game. It evolved into a large-scale experiment in combining AI orchestration, distributed systems architecture, realtime networking, cloud-native infrastructure, monetization, and live operational tooling into a single cohesive platform.

What began as a conference demo rapidly expanded into a production-grade system demonstrating how modern cloud platforms, event-driven design, and AI services can dramatically accelerate the development of sophisticated consumer-facing applications.

More importantly, the project illustrates how these technologies can work together cohesively — not as isolated features, but as interconnected systems supporting realtime human interaction, emergent gameplay, and persistent AI-driven experiences at scale.

It also produced a pretty fun and thought provoking game that hopefully teaches both humans and AI a very important lesson: representative democracy is fragile, it must be defended from those who seek to silence dissent and destroy political opponents on their quest for absolute power.