Live on Railway · Rust rewrite

AllGameTimes (Rust)

Every game, every league, every second — rebuilt in Rust. Nine sports, live scores, play-by-play, animated viewers, and a 3D globe of today's games from one binary.

Role
Architect & sole developer
Stack
Rust · axum · sqlx · PostgreSQL
Domain
Multi-league sports schedules
Platform
Railway · test + production
AllGameTimes home page in dark theme showing featured games and today's schedule
The Rust rewrite's home page — featured games and the day's full schedule, dark by default.
9 sports, first-class
596 tests passing
3 ms home page latency
1 binary, one Postgres pool

What it is

AllGameTimes is a sports schedule and live-score site covering NFL, NCAA Football, NBA, WNBA, NCAA Basketball, MLB, NCAA Baseball, NCAA Softball, and Soccer — built as a ground-up Rust rewrite of the .NET 8 Blazor app that came before it.

The rewrite is not a port of the same mistakes. It is a different shape: server-rendered HTML with hand-written escaping, one Postgres pool, one worker loop, and a stubborn refusal to ship a 1.4 MB page.

Why rewrite at all

The original app was slow for reasons that were bugs, not limits. The database query behind the worst page always ran in 37 ms; the other 7.6 seconds were redundant upstream fetching and HTML assembly. The rewrite fixed the shape of the problem rather than the language of it:

Route.NET 8 BlazorRustImprovement
/soccer payload1,470,340 B2,033 B723× smaller
/soccer latency7,641 ms10 ms764× faster
/nfl payload46,559 B1,432 B32× smaller
/nfl latency2,093 ms6 ms349× faster
/ latency3,961 ms3 ms1,320× faster
/health latency388 ms1 ms388× faster
The measurement is the point

A benchmark harness measures every route and writes diffable JSON. The committed baseline-*.json files are the evidence every phase gate is judged against — not a claim in a README.

Live scores that actually feel live

The live poller does not use one cadence. Each sport — and each soccer league, since ESPN serves one scoreboard per league — carries its own next-due time in a process-wide schedule, and a pass polls only the keys whose interval has elapsed.

SportInterval while liveWhy
Soccer, NBA, WNBA, NCAAB5 sContinuous clock, frequent scoring — 30 s is visibly wrong
NFL, NCAAF, MLB, NCAA Baseball, NCAA Softball10 sDiscrete plays with long gaps; 10 s is already ahead of the feed
Anything idle2 minKeeps an empty slate cheap without hiding a kickoff

Every flow request is also a presence heartbeat. An in-memory viewer registry counts who is watching which game, and the poller spends its finite upstream budget on the games people are actually watching — most-watched first. Unwatched games fall back to the slower cadence, and a stale-row sweep still runs unconditionally so a game nobody watches gets its final score eventually.

Animated matchup viewers

Each matchup page returns the game's live state plus every stored play in chronological order, and the client renders it as an SVG stage chosen by sport:

SportsStageDriven by
NFL, NCAAF100-yard fieldPlay start and end yard line
NBA, WNBA, NCAABHalf courtShot release coordinates
MLB, NCAA Baseball, NCAA SoftballDiamondBases, outs, and count per at-bat
Soccer105×68 pitchPlay position in metres
Animated NFL field view replaying stored plays
Field view — every stored play replayed on a sport-true stage.
Animated soccer pitch view with the ball placed by real play coordinates
Pitch view — 105×68 m, ball placed by real play coordinates.
Animated basketball half-court view with shots placed by release coordinates
Court view — half court, shots placed by release coordinates.

Each viewer supports play/pause, prev/next, scrubbing, a Live button, keyboard control, and a 10 s refresh while the game is in progress. The refresh cadence is a server decision — written into the section as a data attribute — so tuning the rate never needs a JavaScript change. A backgrounded tab skips its polls and refreshes immediately on return.

Schedules, teams, and themes

Schedule pages use DST-correct week windows, so a Sunday slate doesn't shift by an hour when the clocks change. Each row carries records, odds, venues, and broadcast. The teams index groups every team by conference and division, ranked by its own feed's seed.

NFL schedule page with week windows, records, odds, venues, and broadcast
NFL schedule — DST-correct week windows, records, odds, venues, broadcast.
Teams index grouped by conference and division
Teams index — every team, grouped by conference and division.
Soccer schedule page with 12 leagues, hemisphere split, odds, and broadcast
Soccer — 12 leagues, hemisphere split, odds and broadcast per match.

Dark is the default theme; light applies either from an explicit choice or from the OS preference when no choice has been made. A small script runs synchronously in the head and writes the theme attribute before first paint, so there is no flash of the wrong palette, and the choice survives navigation.

AllGameTimes home page in light theme
Two themes, one token set — dark by default, light on request or OS preference, no flash.

The Global globe

/global renders today's games on an interactive 3D globe with a server-rendered hub list beside it. The page works without JavaScript — the list is real HTML — and the globe layers on top.

3D globe of today's games grouped by region with local kickoff times
Today's games pinned to a real 3D earth, grouped by region with local kickoff times.
  • No arcs between venues — animated lines hopping between cities carried no information and read as visual noise. Only the ping rings remain.
  • Both teams on every label and row — BUF 17–21 KC, never just the home side, because "who is playing whom" is the question the page answers.
  • One camera tween at a time — a hub click interpolates from wherever the camera currently is; the 30 s live poll never moves the view.

The library and texture are vendored rather than loaded from a CDN, because the CSP is script-src 'self' and img-src 'self'. A verification script then proves in a real browser that the page still paints, fires zero CSP violations, keeps its rings, labels both teams, and tweens rather than jumps.

Stack and structure

LayerChoiceWhy
HTTPaxum 0.8Built on tokio + hyper, tower middleware for free
Runtimetokio 1The async runtime everything else already assumes
Middlewaretower-httpCompression, timeouts, tracing, security headers, static files
Databasesqlx 0.8Async Postgres, one pool, PgBouncer-safe, compile-time checked
Timechrono + chrono-tzReal IANA time zones, DST-correct week windows
Upstreamreqwestrustls, gzip/brotli, one client with retry and a rate gate

Templates are hand-written functions rather than a template engine: the pages are a handful of repeated shapes, and one auditable esc() beats trusting a template engine's auto-escaping rules per syntax.

Sixteen background workers share one loop. Each supplies a name, a cadence, and a tick function; cancellation, error isolation, exponential backoff from 5 s to 5 min, and startup jitter are shared. Ingest runs from 5 minutes (soccer, 12 leagues) to 24 hours (team colours, logos, and venue coordinates), with the live poller adapting between 5 s, 10 s, and 2 min.

Security and deployment

  • #![forbid(unsafe_code)] at the crate root.
  • CSP, HSTS, nosniff, frame options, referrer policy, and permissions policy on every response.
  • /health returns only {"status":"ok"} — no version or build info.
  • /diag/* routes are dev-only and absent in release builds.
  • The config Debug impl redacts the database URL; the container runs as a non-root user.
  • cargo audit and cargo deny run in CI alongside clippy, fmt, and 596 tests.

Railway runs two environments from one repo, each with its own Postgres and a /health probe:

EnvironmentBranchURL
testtestweb-test-002a.up.railway.app
productionmainweb-prod-production-f624.up.railway.app

Because the branches are independent, nothing reaches production until a push to main — that push is the promotion step. Each service's database URL is a Railway reference variable rather than a copied literal, so the two environments cannot drift onto the same database.

The repo is a git subtree split of the allgametimes-rs/ directory in the parent AllGameTimes repository, so the Rust port and the original Blazor app live side by side in history.

Related projects