Under the hood

How the realm is built.

For the curious and the technical: the engine, the tools I build the world with, the database, why the only way in is a browser, and how one developer and a set of AI tools build all of it.

Dark Realms began as a SMAUG MUD. Like a lot of MUDs, it kept falling into the same trap: the vision was always bigger than what the code could do and the time there was to build it. This version is written from scratch, and no line of Merc, Diku or SMAUG code is in it. That gave me the chance to make a few big decisions early and stick to them. This page is about those decisions and why I made them.

By the numbers

2,400+commits since work began in August 2026
~450,000lines of C# in the server and engine
~300,000lines of C# tests, over 8,100 of them
~116,000lines of TypeScript in the client and World Studio
250+design documents, and 130 architecture decision records
147areas, with about 4,900 rooms and 2,460 kinds of NPC

All of that was built by one person in about three months. That pace isn't normal, and I won't pretend it is: it comes from building with AI tools, which I describe at the end of this page.

Figures as of December 2026.

The stack

Game server and engineC# 14 on .NET 10, hosted in ASP.NET Core
Realtime connectionSignalR over WebSockets, with my own versioned protocol on top
Game client and World StudioReact and TypeScript, built with Vite
DatabasePostgreSQL, through Entity Framework Core
WebsiteAstro, built to static pages
WikiWiki.js, with pages kept as Markdown in git

Why .NET rather than C, the language of the old MUDs? Dark Realms isn't limited by raw CPU. It's a large, long-lived set of rules that have to keep working with each other for years. Strong types, mature async networking, good testing and diagnostics, and no manual memory management are worth far more to me than squeezing out the last cycle. One platform also covers the engine, the web APIs and the World Studio back end.

The engine: one writer, one order

The old MUD engines kept the whole world in global variables that any piece of code could change at any time. It's fast to write and very hard to reason about. My engine works the other way: exactly one part of the program changes the live world.

Everything else asks. The web connection, the timers, NPC behaviors, World Studio publishing and staff tools all put a request in one queue. The engine takes one item at a time, applies the rules, and emits structured events that describe what happened. Here's the path of a single command:

  1. 1
    You type

    cast fireball brute in the client, or click the same thing on a panel.

  2. 2
    Translate

    The server turns the line into a typed action. Raw text stops here: the engine never sees it.

  3. 3
    Queue

    The action joins the single queue of work for the world, together with timers that are due.

  4. 4
    Resolve

    The engine checks the rules, changes the world and records what happened as structured events.

  5. 5
    Deliver

    Each event goes to everyone who could perceive it, in order.

  6. 6
    Show

    Your client draws the combat line, moves the health bar and updates the target panel from the same event.

  7. 7
    Save

    Writers outside the game loop save what changed to the database, a moment later.

Determinism

The engine has its own simulation clock. Game rules never read the computer's clock, never sleep and never use timers that fire on their own thread. Anything due at the same instant runs in an explicit order, and randomness comes from a seeded source. Real time is measured outside the engine and fed in as "this much time has passed."

That makes a bug reproducible: the same starting world, the same commands and the same passage of time always give the same events, in the same order. Tests can run a day of game time in milliseconds without sleeping. A few "golden" tests compare a whole run, line by line, against a trace checked into the repository. Here's a piece of the engine's first one: a rejected command, then two timers due at the same instant, which run in the order they were scheduled.

seq=05 time=0000ms audience=session:…0002 type=CommandRejected command=…0003 code=fixture.denied
seq=06 time=0010ms audience=broadcast type=ScheduledDeltaApplied label=alpha delta=2 value=7  scheduled-seq=1
seq=07 time=0010ms audience=broadcast type=ScheduledDeltaApplied label=beta  delta=3 value=10 scheduled-seq=2
seq=08 time=0010ms audience=session:…0001 type=SessionDisconnectRequested
seq=09 time=0010ms audience=broadcast type=EntitySurvivedDisconnect value=10
From the engine's kernel trace. IDs shortened.

Architecture tests in the build fail if engine code reaches for the wall clock, a database or the web layer.

Meaning before words

Mechanics never depend on English text. A combat round is an event with an attacker, a target, a damage type, an amount and anything special about it: a critical, a chain of hits, a stun. The sentence you read is made from that event at the very end. The same event can fill a panel, update a health bar and become a line of text, and changing the wording can never break a rule.

One combat round: You utter the words, 'fireball'. You use Fireball against war-ogre brute. Your fireball roasts war-ogre brute (196) dmg. Your fireball FLATTENS war-ogre brute (215) dmg, Chain x 2.
One round: a level 50 Elementalist casts Fireball at a war-ogre brute. The spell, the damage word, the amount and the chain are all fields of the event, and the colors come from the theme.

Content is data

Areas, NPCs, items, abilities, classes, quests and behaviors are data with stable IDs, not code. When a builder wants a greeting when you enter, a reward for handing over an item, or a guard who shouts for help, that's a behavior rule: a trigger, conditions and actions, authored in World Studio. This one belongs to the guards of a bonded warehouse at the docks, which players can rob:

{
  "name": "Defense: call the guards",
  "trigger": { "kind": "attacked", "arguments": { "byCharacter": "true" } },
  "conditions": [],
  "actions": [
    { "kind": "say", "arguments": { "text": "Thieves in the bond! Watch, to me!", "to": "room" } },
    { "kind": "call-for-help", "arguments": { "group": "ports-warehouse", "radius": "2" } }
  ],
  "cooldownSeconds": 20,
  "chancePercent": 100
}
A behavior rule. It's validated, versioned and published with the rest of the world.

When I need something the engine can't do yet, I write that new piece in C#, test it, and then expose it to World Studio so it can be combined with everything else.

Lua, when data isn't enough

I also designed a sandboxed Lua layer for the rare cases a rule can't express. A Lua script will be able to watch events, read what it's allowed to read and ask the engine to act. It won't be able to touch files, the network, the database or the game's internals, and it runs under strict limits on time, actions and spawns. So far I haven't needed it. Some places I expect it to earn its keep:

  • Puzzles with memory. A riddle chamber where the right answer depends on what the party did in the last three rooms.
  • Games inside the game. A dice or card game in a tavern, with its own rules and turns.
  • Encounters with unusual phases. A boss that swaps bodies with a player, or rewrites the room around the fight.
  • Generated places. A maze laid out fresh for each group that enters a private realm.

World Studio

World Studio is my building tool, a separate web app with its own sign-in. Old MUDs edited the live world in place, with online creation commands. A typo could take an area down, and nothing kept a history. In World Studio, everything that makes up the world is a record with its own editor:

The worldareas on a map canvas with floors, rooms, exits, doors and locks, the overland map, planes, continents, climates and weather
Who lives there2,460 kinds of NPC with stats, combat doctrine, behavior rules, shops, daily routines and spawns
What they carryobjects, loot tables, recipes, materials, currencies, vehicles, ferry lines and text styles
Who you arespecies, races and classes, nearly 1,900 abilities and 2,100 effects, reactions and portraits
What you doquests, achievements, deeds, Legendary talents, events, organizations, housing plots and the store
How it readshelp pages, socials, channels, noteboards, and the colors and styles of every kind of text

Every editor also shows where a record is used, what's wrong with it and what changed in the current draft, and a search reaches every record in the world.

World Studio showing the Cathedral Graveyard area: a map canvas of linked rooms on two floors, a list of locations, and an inspector editing The Ruined Chapel's name and description.
The Cathedral Graveyard on the map canvas, with the Ruined Chapel open in the inspector. This is the read-only view of the published world. Edits happen in a change set.
World Studio's ability editor for Lightning Kick: key, name, description, electric and blunt domains, tags, type Skill, activation Active, difficulty Exceptional, targeting an enemy actor.
An ability: Lightning Kick, a monk skill, with tabs for who can learn it and what it does.
World Studio's NPC editor for the Rat Queen, on the Behavior tab: how it fights, with flee threshold, assist group rat-court, abilities bite, poison and trip, ability chance and control resistance.
An NPC: how the Rat Queen fights. Her assist group decides which NPCs join her fights.
World Studio's text style library: Black Flame, Blood Curse, Carved Faces, Flame, Frost, Gaea's Wrath Signature, Gilt, Harvest Bubbles, Ice Wreath and Illusion, each with a live sample, key, item count, labels and whether it animates.
The text style library, with a live sample of each style and the items that wear it.

World Studio works more like source control for the world:

  • Change sets. A builder opens a change set, which is a private draft copy of the whole world taken from the live revision. Nothing in a draft touches the live game.
  • Validate. The draft is checked as a whole: every exit leads somewhere, every reference exists, every piece of markup is well formed. A failed check stops the publish. It never skips a broken record and hopes.
  • Preview. A draft can run in its own isolated copy of the engine, with no link to the live world or its players.
  • Publish. A valid draft becomes a new, immutable revision. The engine installs it into the running world as one ordered step, and refuses if, for example, it would remove a room a player is standing in. No restart.
  • Roll back. Every published revision is kept. Rolling back publishes an older one through the same checks.

With more than one change set open, there was a catch. Each draft starts as a full copy of the world, so the last publish used to win. One day an import of 53 new races was published, and then an older draft that still had only 4 was published on top of it. The 53 races vanished from the live game. Now a change set that is out of date can't be published. It has to pull in what changed in production first, with a three-way merge between the original copy, the draft and the live world, and conflicts show up field by field.

Staff permissions are narrow capabilities, not the old numbered immortal levels. Reviewing, publishing, taking over or closing someone else's change set are separate permissions, and each of those actions is audited with a reason. Staff work happens on staff accounts kept apart from anyone's personal characters.

World Studio is also an API. Scripts can create and revise areas through the same change sets, validation and publishing that the editors use. The guard rule above was written by one. That's also how I bring old areas forward: read the original for its rooms, prose and ideas, then rebuild it natively, rather than porting vnums and mudprogs as they were.

The database

Durable data lives in PostgreSQL: accounts, characters, items, organizations, the world revisions, audit trails and statistics. The most important rule about it is a negative one: the database is not the game. The engine never waits on a query in the middle of a fight. It keeps the live world in memory and reports what changed.

  • Write-behind. After each unit of work the engine reports a character's state as one complete snapshot: level, experience, attributes, classes, location. A writer outside the game loop saves only the newest one per character, a quarter of a second later, so a burst of changes becomes one write. Because each snapshot is complete, a retry or a replay does no harm.
  • Items have one owner. Every item that has moved, changed or been made has a row, held by exactly one room, character or container. Item changes from one unit of work are saved in order in a single transaction. An item can't be duplicated by a restart, and one that was destroyed can't come back.
  • The database enforces what matters. Unique names, who owns which character, one open transfer per character. Trades between two accounts lock both in a fixed order, so two at once can't deadlock or both succeed.
  • Statistics are facts. Raw events are kept for 13 months and rolled into daily and lifetime totals kept forever. That's what feeds The Realm and the hiscores.

Why PostgreSQL? Most of what I store is relational and needs real integrity: ownership, uniqueness, transactions that span two accounts. PostgreSQL gives me that, plus JSON for the world-revision documents, and it's dependable and open source.

Hotboot: updates without goodbyes

Old MUDs had the copyover: the server handed its open Telnet sockets to a new copy of itself. A WebSocket can't outlive the process that holds it, so I couldn't do that. Instead a hotboot is a fast, announced restart that saves everything a player would miss.

I sort every change by how much it has to disturb. Content from World Studio goes in live, with no restart. A hotboot starts a new server on the same database. It restores a snapshot of the soft state: open doors, lit torches, weather, groups, who was sitting or sleeping. Your client pauses, reconnects on its own with a one-time resume ticket, and puts you back where you were. Only real maintenance, such as a database change the old state can't survive, needs a cold start.

The web client, and why there's no Telnet

The client is a web app. A classic command line sits in the middle, and around it are panels you can show, hide, collapse, move and resize: your character, vitals, the room and who's in it, your target, the map, quests, inventory, channels. The layout presets go from Classic (just the text and the command line) to Expanded, and room descriptions can sit in a banner above the chronicle or flow in the chronicle like a classic MUD. You can keep two characters open in tabs. A panel never invents state. Everything it shows comes from events the server sent, and if your character didn't perceive something, the panel doesn't know it either.

The game client with a custom layout: minimap, collapsed quick actions, character and target panels on the left; the Yew Walk and the Lychgate described in the chronicle in the center, above health, stamina and experience bars, the action bar and the command line; on the right the Quests panel showing A Newcomer's Road: First Lessons with its objective, the Entities panel, and a collapsed Inventory.
A custom layout: room descriptions in the chronicle, Quick actions and Inventory collapsed, and a newcomer's first quest open in the Quests panel.

The connection speaks a versioned protocol. The client and server agree on a version and a set of capabilities when they connect, so a new feature can ship without breaking a client that's a release behind.

Here's the decision I get asked about most. Dark Realms doesn't support Telnet, and won't. That means no MUD clients like Mudlet or MUSHclient, no ANSI color, no VT100 screens. I actually built a Telnet connection early on, with GMCP. I retired it, for these reasons:

A game of data, not a stream of bytes

Telnet delivers a stream of characters. Everything I show in a panel (a health bar, a map, a target, a list of who's in the room) would have to be squeezed into that stream, either as text for client scripts to scrape or as GMCP side messages that each MUD client supports differently. Every feature would need two presentations and two sets of tests. When I kept the two paths in step, the terminal path slowed every new feature down and limited what I would let myself design. With one client I know exactly what every player sees.

Color that means something

ANSI color is 16 colors, or 256 at best, written into the text as codes like the old &R. The color is baked in at the moment the line is sent. My text uses meaning instead: this is fire damage, this is a god speaking, this is an epic item. Builders write it with a small markup language that has a closed set of tokens, so there's no way to slip raw HTML or styles into the game:

The bell rope hangs <bold>perfectly still</>. Under the floor,
something <damage.necrotic>cold</> is waiting. (A literal << stays a "<".)
Markup in a room description. Player names and speech are never read as markup.

The browser applies a theme to that meaning. The theme is published with the world, so it can restyle old lines as well as new ones. It's checked for contrast, and it can never make text blink. A terminal can't do any of that.

World Studio's live preview of the text styles: a room title, NPC and player names, exits, fire damage, a critical hit, vitals, speech and tells, warnings, rewards and an epic announcement, each in its own color.
The text-style editor's live preview in World Studio. Change a style here, publish, and every line that carries that meaning changes with it.

The best items go further, with text styles of their own: real CSS, checked and scoped so it only ever reaches inside the item's name, and players can turn animation or styles off. Here's a level 200 Legendary monk looking at themself:

The output of look self for Valcopy, a level 200 Kharvek Legendary Drunken Master: a list of worn equipment colored by quality, with the Phantasm Belt in a shifting prism style and Gungnir, a spear with a golden head, glowing in the gold Gilt style.
look self. Item names are colored by quality, and two carry text styles: the Phantasm Belt in Prism and Gungnir in Gilt.

Accounts that stay safe

Telnet sends everything as plain text, including your password, and few MUD clients support encryption well. In the browser everything runs over HTTPS. Sign-in uses secure, HTTP-only cookies, and two-step authentication works the same everywhere you sign in. That includes confirming a character transfer or deletion, which in Telnet would be a password typed in the clear.

Nothing to install, nothing to configure

Anyone with a browser can play in a few seconds, on any computer. A new player doesn't have to learn a MUD client before learning the game, and I don't have to support a dozen clients with different quirks. Quick-action buttons and the action bar cover the commands you use most, and anything the client provides is within the rules.

I know this decision costs me some players who've spent decades in a favorite client, and I don't make it lightly. But one client, done properly, is how one developer can make a world this deep feel good to play.

The APIs

Everything the client does goes through the same public paths, with nothing special for my own front end:

  • Gameplay runs over one realtime hub. A connection says hello, agrees on a protocol version, and then starts or resumes a session. The server assigns every session ID itself and never accepts one from a client.
  • Accounts and characters are ordinary web APIs: sign-in, two-step setup, the character roster, transfers, friends, messages and profiles. Writes are rate limited, and anything sensitive asks for your password again.
  • Public pages like profiles and hiscores have small anonymous, rate-limited endpoints that show only what players have chosen to make public.
  • World Studio has its own API and its own sign-in, separate from playing, and every route checks a specific staff capability.
  • The game data API serves the website and wiki. It needs an API key, which is stored hashed, limited to the data it may read and locked to known hosts. It reads the published world and a public snapshot refreshed every 30 seconds, never the live game loop.

The game is also connected to Discord. You can link your account, show a character card if you choose to, get private channels for your organization that follow in-game membership, and see announcements as they happen.

The website and the wiki

This site is built from the game's own data. The race and class pages come from the published world when the site is built, so they can't drift from what's in the game. Live figures (who's online, Tidings, the Chronicle, hiscores) are fetched by a small service on the server, which holds the API key and writes plain files for the site to show. Your browser never sees a key.

What's new is written from the changes I merge, rewritten for players and published an hour after release. In-game help builds an entry for every class, race, ability and area from the world itself. The wiki goes deeper, with guides I keep in git and sync to the wiki, and the site's build fails if it links to a wiki page that doesn't exist. The spoiler rule is overviews, not specifics. The wiki will tell you a boss exists and what it can drop. It won't tell you the drop rates or the answer to a riddle.

Staging, production and tests

There are two realms on the server: a test realm where new content and code are tried first, and the live one. Content is built and played on staging, then promoted to production as one checksummed world file and published through the same World Studio checks. A code release goes into its own folder with its database migrations, and a hotboot switches to it.

Behind it all are more than 8,100 automated tests: engine rules, deterministic replays, database migrations against a real PostgreSQL, the World Studio publish path, and the client's panels and protocol.

Built with AI, directed by a person

Dark Realms has one developer. A game this size, with an engine, a client, a building tool, a website and 147 areas, isn't something one person can finish alone, let alone in three months. So I'll say it plainly: Dark Realms is built with AI tools, in both its design and its code.

That doesn't mean typing "build me a MUD, make it good, no mistakes" and shipping whatever comes back. It's a workflow with checks at every step, and a human decision at the start and the end of each feature:

  1. 1
    An idea

    It starts with something I want: a system, a fix from a playtest, a feeling the game is missing.

  2. 2
    A proposal

    The idea becomes a written design: what it is, how it fits, what it touches, and every question that has more than one good answer. Those questions come to me, and my answers are recorded with the design.

  3. 3
    Vetting

    The design is checked against the code and the other designs for accuracy and fit. Does it contradict something? Does the engine already do half of it? Is a number off?

  4. 4
    Small slices

    The work is cut into pieces that can each be built, tested and reviewed on their own.

  5. 5
    Build and test

    Each slice is written with its tests. The full test suite and the architecture tests have to pass, and a separate review looks for bugs before anything is merged.

  6. 6
    Agent playtests

    AI helpers play the feature as players would, on a local copy of the game, and report what broke, what read badly and what made no sense.

  7. 7
    Handoff

    A short document says what was built, what was decided along the way and what is still open.

  8. 8
    My playtest

    I play it. If it's right, it ships to the test realm and then the live one. If it isn't, we go around again.

It's a collaboration, and it runs both ways. When the tools aren't sure about something, a rule that could be read two ways or a number that seems off, they stop and ask before building. When I don't know exactly what I want until I see it working, I play it, and we change course. Those 250-odd design documents and 130 decision records are largely that conversation, written down. A lot of the engine's discipline (one writer, determinism, golden traces, architecture tests) exists because it lets both me and the tools change a large system without breaking it.

Some people won't like that the game is built this way. Some will feel it cheapens the craft. That's a fair thing to feel, and I'm not going to hide how the game is made. But I think what counts is the result: whether the world is worth exploring, whether the systems hold together, whether it's fun. If it is, I don't think the tools should matter.