Engineering Blog
Deep dives on how Code Arena is built.
- Catching Copied Code: Structural Plagiarism Detection with Winnowing — How Code Arena flags copied contest submissions with a MOSS-style pipeline — tokenizing away formatting and variable names, hashing k-grams, winnowing to a compact fingerprint, and scoring with containment so padding doesn't hide a copy.
- Designing a Fair Elo System for Coding Contests — Classic Elo is built for two players. Here's how Code Arena generalizes it to rate N-player coding contests and real-time matches fairly — using expected rank, geometric-mean targeting, damping, and a zero-sum correction.
- One Emit, Every Node: Fanning Out WebSockets Across a Cluster — Scaling Code Arena's real-time layer past a single API process — routing every WebSocket event through a Redis bus so a socket on node A receives an event emitted on node B, and using a SET NX claim to make judge side-effects fire exactly once cluster-wide.
- Generating Prisma Migrations Offline, Without a Database — How to generate Prisma migration SQL with no database connection using migrate diff and --from-schema-datamodel — why it beats --from-migrations, and a subtle gotcha that can silently corrupt a migration file and break production.
- Making a Desktop Coding Arena Work on Phones — Code Arena was built desktop-first — two-pane solve screens and a wide nav bar that fell apart on a phone. Retrofitting it for mobile with one small media-query hook, a tabbed layout, a hamburger menu, and a screenshot-driven way to actually verify it.
- Measuring a Program's True Peak Memory with cgroups — How to get the exact peak memory a program used — not an estimate — by reading the Linux kernel's own cgroup high-water mark (memory.peak), with fallbacks for cgroup v1, from inside a Docker sandbox.
- Playing to an Empty Arena — Every competitive game has the same cold-start problem: it's only fun with a crowd, and you only get a crowd by being fun. A day spent making the arena feel alive for one person — bots that walk on when the lobby is empty, matches that stop repeating themselves, and a way to react without a keyboard.
- Polishing Game Feel in a Coding Arena — The small, no-new-logic changes that make a real-time coding match feel good to play: editor keyboard shortcuts (and the stale-closure trap they hide), a verdict flash, an auto-scrolling console, and telling the player why a button is disabled.
- Putting an AI in the Arena — and Making It Play Fair — Code Arena now lets you duel an AI that writes real code, judged on the same hidden tests you get, on the same clock. Here's exactly how it works — the prompt, the sandbox, the full-effort race — and why 'can you beat the AI?' is an honest question and not a party trick.
- Building Code Arena: Scaling WebSockets & Docker Sandboxes for a Battle Royale — A deep dive into Code Arena's architecture: decoupling submission spikes with BullMQ, sandboxing untrusted code with Docker and cgroups, streaming verdicts over Redis pub/sub and per-user WebSockets, and orchestrating a real-time coding Battle Royale.
- Shipping a Platform One Small PR at a Time — The development workflow behind Code Arena: small, single-purpose pull requests, an always-deployable main, verify-before-merge, and strict branch discipline — how a whole platform got built in slices that each ship on their own.
- Sizing a 100-Player Battle Royale: Scale the Judge, Not the Sockets — Scaling a real-time coding Battle Royale from 6 players to 100 isn't a networking problem — it's a judging problem. Working from Code Arena's real sandbox limits (2s, 256MB, one core per container) to judge-seconds per submission, round-1 load, and a concrete server spec.
- The Dependency Diet: Building Features Without the Bloat — A running theme in Code Arena's development: reach for a new npm package last, not first. Real examples — canvas share cards, email over fetch, kernel memory accounting, no CSS framework — and when we did add a dependency anyway.