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.
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 Blazor | Rust | Improvement |
|---|---|---|---|
| /soccer payload | 1,470,340 B | 2,033 B | 723× smaller |
| /soccer latency | 7,641 ms | 10 ms | 764× faster |
| /nfl payload | 46,559 B | 1,432 B | 32× smaller |
| /nfl latency | 2,093 ms | 6 ms | 349× faster |
| / latency | 3,961 ms | 3 ms | 1,320× faster |
| /health latency | 388 ms | 1 ms | 388× faster |
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.
| Sport | Interval while live | Why |
|---|---|---|
| Soccer, NBA, WNBA, NCAAB | 5 s | Continuous clock, frequent scoring — 30 s is visibly wrong |
| NFL, NCAAF, MLB, NCAA Baseball, NCAA Softball | 10 s | Discrete plays with long gaps; 10 s is already ahead of the feed |
| Anything idle | 2 min | Keeps 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:
| Sports | Stage | Driven by |
|---|---|---|
| NFL, NCAAF | 100-yard field | Play start and end yard line |
| NBA, WNBA, NCAAB | Half court | Shot release coordinates |
| MLB, NCAA Baseball, NCAA Softball | Diamond | Bases, outs, and count per at-bat |
| Soccer | 105×68 pitch | Play position in metres |
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.
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.
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.
- 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
| Layer | Choice | Why |
|---|---|---|
| HTTP | axum 0.8 | Built on tokio + hyper, tower middleware for free |
| Runtime | tokio 1 | The async runtime everything else already assumes |
| Middleware | tower-http | Compression, timeouts, tracing, security headers, static files |
| Database | sqlx 0.8 | Async Postgres, one pool, PgBouncer-safe, compile-time checked |
| Time | chrono + chrono-tz | Real IANA time zones, DST-correct week windows |
| Upstream | reqwest | rustls, 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.
/healthreturns only{"status":"ok"}— no version or build info./diag/*routes are dev-only and absent in release builds.- The config
Debugimpl redacts the database URL; the container runs as a non-root user. cargo auditandcargo denyrun in CI alongside clippy, fmt, and 596 tests.
Railway runs two environments from one repo, each with its own Postgres and a /health probe:
| Environment | Branch | URL |
|---|---|---|
| test | test | web-test-002a.up.railway.app |
| production | main | web-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.