This site uses one functional cookie to keep feature rollouts consistent for you. Nothing is set until you choose. See the privacy notice.
Dev notes
The idea is sports betting with the loss taken out. You lock a deposit for a term, bet it freely on real lines, and at the end you get the original deposit back no matter your record. What you keep forever is the record — every bet, every swing, a bankroll curve, a profile you can show off. The catch is that holding people's deposits and investing the float is the legally hard part, so the first cut draws a hard line: the ledger is real, the dollars are simulated. Every deposit, stake, payout and refund is a real double-entry row, and "deposit $100" is a button, not a charge. This is what I built into the API behind this site, and why I built it in that order.
The first decision was the one I could not take back later, so I spent the most time on it: money is never a number in a column. It is derived from a ledger, and every movement is a set of lines that sum to zero across three accounts — the user's bankroll, an escrow that holds the locked principal, and the house. A wallet's balance is the running total of its user-account lines, computed on read, never stored.
It is more code than a balance column, and it is the whole reason the fake-money version can become the real-money version without a rewrite. Placing a bet moves the stake from the user to escrow; settling it pays out or sweeps to the house; the term ends and the principal comes back — and every one of those is a pair that nets to zero, checked by a pure function before it ever reaches Postgres.
// a $25 win at +122, in ledger lines that sum to 0 user payout +2500 // stake returned from escrow escrow payout -2500 user payout +3050 // profit paid by the house house payout -3050
The refund at the end is the part that makes it "no-loss": it returns exactly the principal, whatever the record. A wallet up 40% and a wallet that went to zero both get the same deposit back. The paper profit was always a stat, not cash — which is the honest version of what a real book's screenshot never tells you.
Anyone can buy the same odds API I did; the inputs are a commodity. The thing that compounds and cannot be bootstrapped is the output of play — a record of decisions made at a frozen line with a known outcome. Real books know whether you won money. They do not know whether you were good, because variance hides skill. The public proxy that cuts through it is closing-line value: did the price you took beat where the line closed.
So the odds worker snapshots every pull instead of overwriting, and at settlement I read the last snapshot before kickoff and stamp the closing odds and the CLV onto the bet. It is unrecoverable if you don't capture it live, which is exactly why it was in the first cut and not a "later." A bet at -110 that closes at -130 beat the market, and the number says so:
computeClv(-110, -130) → +7.91 // took 1.909, closed 1.769 computeClv(-130, -110) → -7.33 // the other side of the same move
Roll CLV up with ROI and volume over a few hundred bets and you get a sharp score — a single number a competitor can't fake on day one and that gets more accurate the longer someone plays. It is also the targeting signal for the one revenue line that needs no licensing: refer the provably-sharp users to a real book and take the affiliate fee. The moat and the first dollar are the same asset.
I built it as a stack, not a big bang: ledger and wallets, then odds ingestion, then placing a bet, then settlement, then the term-end unlock, then the profile and leaderboard, then the house view and referrals. Each one is a clean break — it has its own migration, its own tests, and it deploys on its own — so I could ship and check a stage before the next one built on it, and so a reviewer reads one idea at a time instead of a wall.
The settler is the piece I was most careful with, because the failure mode is paying twice. It is idempotent: it only grades open bets and skips events already marked final, so running it again over the same results is a no-op. The messy tail — pushes, voids, an exact spread cover, a postponed game — is graded first-class and tested first, because that is where settlement disputes actually live.
Odds and results both sit behind one interface, with three implementations: the real API, a fixtures provider that replays a captured slate for zero credits, and — for results — the quota-free scores endpoint. Dev, test and seeding never spend a credit, and the provider is chosen explicitly by an environment variable rather than guessed.
The rule I held to there was to fail loud, not fall back quietly. A dead vendor or an exhausted quota throws — it does not return an empty slate that reads as "no games today," which is the kind of silent default that becomes a 2am mystery. User traffic never touches the vendor at all: the events feed serves from the database, so quota is a worker's problem, not a scaling one.
Update — September 3, 2026
The API shipped as eight stacked backend PRs, and the front end is following the same discipline: small, stacked, each one deployable. The first slice is the part that can't go wrong, because it can't do anything — a read-only lobby.
The lobby at /zeroproof renders the public events board — upcoming games with their latest moneyline, spread and total lines — straight from the same DB-backed endpoint the settler reads, so no vendor call rides on a visitor. Under it sits the sharp leaderboard: players ranked by closing-line value rolled up with return and volume. There is nothing to click that spends anything, which is exactly why it's the honest first thing to ship.
The leaderboard endpoint returns the Auth0 sub per row, which is a user identifier and has no business on a public page. The front end derives a stable, opaque handle from it instead — the same player always reads the same token, and the token can't be walked back — and a test asserts the sub string never appears in the rendered DOM.
playerHandle("auth0|abc123") → "P-1F9K2" // stable, opaque
board.textContent → never contains "auth0|"Update — September 3, 2026
With the lobby merged and real odds flowing from The Odds API on a cron, two things surfaced that only a live product does: the first bet you try to place fails, and a weekly sport makes the board look empty.
Opening a Season wallet returned Validation failed. The body looked right from the browser, so I chased the schema first — wrong. The frontend proxies the write through a BFF route, and that route forwarded the body to the API with only an Authorization header. Express's express.json() only parses when the content-type says JSON, so the API received an empty body and the first required field failed. Every integration test passed because supertest sets the header for you — the gap was in the one seam the tests mocked.
headers: buildHeaders(token, null) // Authorization only, no Content-Type
// → express.json() skips the body → req.body = {} → "mode is required"
headers: buildHeaders(token, null, { "Content-Type": "application/json" }) // fixedOne more layer down: the Season button posted a bare { mode } with no amount, which the backend rejects because a Season wallet needs a deposit. It defaults to $500 now; a real deposit-amount input is the follow-up.
MLB is a daily slate, but NFL is weekly — point the odds cron at football and the board shows a wall of games a week out, or nothing for days. So the board defaults to the next three days and grows from there: a load-more that adds three days, a toggle to auto-load as you scroll instead, and a collapse back to three. The window is a client filter over the same served-from-DB list — the endpoint already returns every upcoming game in kickoff order, so "load more" costs no fetch and no vendor credit.
cutoff = now + daysAhead * ONE_DAY // daysAhead starts at 3 visible = events.filter(e => e.commenceTime <= cutoff) // load more → daysAhead += 3 ; collapse → daysAhead = 3
The lobby had grown three jobs on one page — the board you bet from, the leaderboard you compare on, and your own record — and they read as one long scroll. They're tabs now: Board, Leaderboard, Your record. All three panels stay mounted so their data preloads and a switch is instant; the inactive ones are hidden, which also drops them out of the accessibility tree, so a screen reader and the keyboard only ever see the panel you're on. The tablist is a proper ARIA one — arrow keys move between tabs, and the selected tab is the only one in the tab order.
Update — September 4, 2026
Two board refinements once real football lines were flowing, both about not losing the game you care about in a list.
A weekend NFL slate is a lot of games at once. The board groups them by day under a heading each — the events already arrive sorted by kickoff, so it's a grouping over the same list, no new fetch.
Any fixture the caller already has a bet on gets a Your bet badge, and stays on the board even when it's past the day-horizon — so a game you're in can't scroll off behind the three-day default. The board reuses the profile's bets query and shows nothing extra when you're signed out.
visible = events.filter(e => e.commenceTime <= cutoff || betOn.has(e.id)) // bet-on fixtures are always in, horizon or not
Update — September 8, 2026
People wanted to run their own contests — set the bankroll, the size, how you win — and compete on a private board. The temptation was a whole second system. It didn't need one.
Every member bets from a league-scoped wallet — a new mode='league' row tagged with a league_id. Placement, the ledger and the settler never learned the word "league"; a league only decides which wallet you bet from and whose bankroll your standing compares against. The board ranks by balance, ROI breaking ties — the same pure ranking the global leaderboard already used.
League wallets belong to you, so they'd have quietly leaked into the global sharp leaderboard and your /me stats — a for-fun contest inflating the record that's the actual product. So the global scans are scoped to season and challenge play only, and because a user can now hold an active wallet in many leagues at once, the one-active-wallet index had to split.
-- season/challenge: still one active wallet per mode CREATE UNIQUE INDEX ... ON (user_sub, mode) WHERE status='active' AND mode <> 'league'; -- league wallets: unique per league instead CREATE UNIQUE INDEX ... ON (user_sub, league_id) WHERE status='active' AND mode='league';
A cron settles finished leagues — threshold once a member crosses the target, timeline once the deadline passes — stamps the winner and freezes the final board. The winner is the leader the moment a crossing is first seen rather than strictly the first to cross: a deliberate simplification that keeps settlement a decoupled sweep instead of logic threaded into every bet's settlement.
Update — September 8, 2026
The ask was betting on ESPN fantasy weekly matchups, and binding a league so its members only bet one ESPN league. The surprise was how little new machinery it needed.
The matchup feed has projected and actual scores and a winner, but no odds — so there's no line to normalise. v1 prices every matchup as a pick'em (both sides -110); a projected-score moneyline is the next step. There's also no kickoff timestamp, so the commence time is synthesised and betting stays open until the matchup settles.
{ "matchupPeriodId": 1, "winner": "UNDECIDED",
"home": { "teamId": 5, "totalPoints": 0 },
"away": { "teamId": 4, "totalPoints": 0 } }The provider writes each matchup as an event with a stable key — espn:{game}:{season}:{leagueId}:… — so a bet, the ledger and settlement never learned the word "fantasy." Binding a league to one ESPN league is then just a prefix match at placement: a bound league's wallet may only bet events whose key names that game, season and league, and anything else is refused. No new state, no new settlement path — the weekly score grades it like any other result.
Update — September 8, 2026
A day after shipping the ESPN binding, I changed the shape of it. The first version tied a league to one ESPN league and refused everything else — and that turned out to be the wrong instinct.
A league locked to one ESPN league is a narrower product than the one it's inside. The point of a contest is a shared bankroll and a leaderboard; forcing every bet to be one fantasy league's weekly matchup makes it thinner, not more focused. What a commissioner actually wants is to add their league's matchups to the board their members already bet — a shelf you put things on, not a cage you lock them in.
The restriction lived in exactly one place — a check at placement that refused a league wallet betting outside its bound key. Taking it out is the core of the change:
- if (wallet.mode === 'league' && wallet.leagueId) {
- const binding = espnBindingOf(await getLeagueById(wallet.leagueId));
- if (binding && !isEventInEspnLeague(event.providerKey, binding))
- throw new ForbiddenError('This league only bets its bound ESPN matchups');
- }What replaces it is additive: a per-league table of ESPN leagues a commissioner has added, whose keys are unioned into the ingest list so their matchups show up on the board — and nothing stops a member betting anything else. The single-bind columns are still there, unused; the new many-to-many is the real model. Managing it moved off the create form and onto the league page, where only the commissioner sees the add and remove controls.
Update — September 9, 2026
The ESPN settle cron went red in staging. The reflex read was "no bets to settle" — but that's a clean no-op. It took three passes to get the real shape of it, and the first fix created the problem the third one solved.
The provider looped its configured leagues and awaited each fetch with no isolation. One league returning a non-2xx — a private league, a wrong id, an off-season season — threw, and the throw aborted the loop, so nothing settled, not just the bad one.
ESPN fantasy returned 401 for fba:449389534:2027 → getResults() threw → settle() threw → cron exit 1 (nothing graded)
The fix was to skip a league that won't fetch and settle the rest. Correct — but now a commissioner's misconfigured league just silently never appears, with nothing on the page to say why. Resilience without observability is a worse bug wearing a calmer face. So the skip had to become something you can see.
The same ESPN league can sit in the registry, in several contests, and in an env fallback — its reachability is identical everywhere, so storing a status per row would duplicate it. It's one health record per key (game:leagueId:season), written by the sync as it fetches (an observer on the fetch, so no extra call), and left-joined onto the league detail. The page now says which league it can't reach and when it last worked, instead of quietly dropping it.
Once I'd named the shape, it was obvious the odds-vendor providers did it too: one sport's quota blip threw and sank the whole board sync and settle. Same fix — isolate per sport, log and skip, let the reachable ones through. No per-league page there to surface it on, so that one stays in the logs, where the operator who set the sport list can see it.
Update — September 9, 2026
I sat someone new in front of the ZeroProof lobby and watched them not know where to start. Board, Leagues, Leaderboard, Your record — obvious to me, who built it, and a wall of tabs to anyone else. So the lobby now offers to walk you through itself, one coach-mark at a time.
A tour that just seizes the page on arrival is a tour you resent. The first step is a plain question — take a quick tour, yes or no — and "No thanks" closes it for good. Only "Show me around" starts spotlighting things. It auto-opens on a first visit and never again once you've seen or dismissed it, and a "Take the tour" button in the header brings it back whenever you want it.
Each step highlights a real element — a tab, the intro — by measuring its box with getBoundingClientRect() and cutting a hole in a dimmed backdrop over it. The obvious place to measure is an effect, and the obvious place to store the result is state. That is exactly the shape the hooks lint refuses:
error Do not call setState synchronously in an effect
react-hooks/set-state-in-effectThe fix is to measure inside a requestAnimationFrame callback — which runs after the tab switch has re-rendered the lobby, so the element is where it will actually sit — and set the rect from there. Switching tabs happens in the Next handler, an event, not an effect; and rendering the tour only while it's open means it mounts fresh at the consent step every time, so there is no reset effect to trip over either.
The theme menu in the page header opened behind the board's sticky "Auto-load as I scroll" bar. Both sat at z-20, and the board bar comes later in the DOM, so it won — the menu's own z-50 meant nothing, capped inside the header's stacking context. Lifting just the ZeroProof header to z-30 puts the dropdown back on top.
Update — September 9, 2026
The ZeroProof tour did its job, and the obvious next thought was that every dense page on the site has the same cold-start problem. So I pulled the tour out of ZeroProof and made it a thing any page can wear.
The coach-mark overlay, the consent-first flow, the measure-in-a-frame spotlight and the auto-open-once logic all moved into a shared GuidedTour engine — a component, a useGuidedTour hook, and a FeatureTour drop-in that a page wires up with a label, a storage key, and its own steps. ZeroProof now uses it too, so there is one implementation, not two. Fantasy, the Pokémon TCG browser, the operator and vitals dashboards, and the design-system gallery each got a tour built from a few lines of step config.
A tour that opens itself on a first visit is a modal that covers the page — and the E2E suite lands on every page as a first-time visitor. The operator dashboard's a11y scan started measuring the tour instead of the page, and the restock and card-browser flows had a backdrop over the thing they were trying to click.
// e2e/helpers/tours.ts — pin every tour "seen" before the page runs, // the same way the theme is pinned, so a coach-mark can't cover a scan. await disableTours(page);
The fix was the same shape as the theme-pinning the a11y scans already do: a shared helper that marks every tour seen before the page's scripts run. The tours' own behaviour — and the overlay's accessibility — stay covered by the unit suite instead.
The 3D world is the exception. Its HUD is a set of corner panels, some of them keyboard-only, over a WebGL canvas that doesn't render in jsdom — so a coach-mark tour there wants more than a step config and a couple of ids, and I left it for its own pass. The engine is ready when the world's HUD is.
Update — September 10, 2026
I'd pulled the tour into a reusable GuidedTour in @paul-portfolio/react. The obvious next step was to stop maintaining a second copy here and consume the published one — dogfood my own primitive.
Fantasy, the Pokémon TCG browser, and the operator, vitals and design-system tours are just coach-marks — spotlight a thing, describe it, move on. Those now render the package's GuidedTour straight off, with FeatureTour mapping the app's step shape to the package's. The tour's CSS rode in for free — it lives in the same components.css the app already imports.
The lobby tour switches tabs as it walks them, and I'd deliberately shipped the design-system primitive without a per-step side effect — a coach-mark library shouldn't assume its host has tabs. So the first published version literally couldn't drive ZeroProof's tab-switching. As a stopgap while the primitive caught up, FeatureTour kept any tour with an onEnter step on the local engine and routed the rest to the package:
const needsLocalEngine = steps.some((step) => step.onEnter); // stopgap: ZeroProof -> local engine; the rest -> @paul-portfolio/react
Then I added the missing piece upstream — a per-step onEnter hook on the design-system GuidedTour, shipped in @paul-portfolio/react@0.8.0. With that published, the stopgap branch came out: every tour, ZeroProof included, now maps its steps straight onto the package and the local GuidedTour.tsx overlay is deleted. One tour engine, the design system's. The right shape for the primitive turned out to be the one the hardest consumer needed, which is exactly what dogfooding is for.
Update — September 14, 2026
The leaderboard names players by an opaque handle on purpose — nobody browsing the board sees who's who. But I'm the one running this, and I wanted to see the whole book: who bet what, which bets are still live, how everyone's record actually shakes out. So there's now an admin-only page that does exactly what the rest of the site refuses to.
Every other bet query is scoped to the caller's own wallets. The god's view needs the opposite — all wallets, joined back to the person — so it's a single new endpoint that leaves the anonymized ones alone. It joins bets to wallets to the user, left-joining the profile so a bet never drops out just because its bettor hasn't set a display name yet:
select bet.*, wallet.user_sub, wallet.mode,
users.email, up.username, up.display_name
from zeroproof_bets bet
join zeroproof_wallets wallet on wallet.id = bet.wallet_id
left join users on users.sub = wallet.user_sub
left join user_profiles up on up.user_sub = wallet.user_sub
where q ilike any(email, username, display_name, selection, market)
order by bet.placed_at desc"Everyone's record" sounds like a second endpoint — a de-anonymized leaderboard. But a win-loss-push record is just a count over the bets I'm already returning, so the page groups them by player on the client and tallies wins, losses, pushes and how many are still open. Search is server-side, so it can key off the database; the live/resolved split is a client toggle over what's loaded. ROI and the sharp score still live on the anonymized leaderboard — de-anonymizing those is a later problem I didn't need to solve to answer "how is everyone doing."
The page and its API sit behind the same allowlist gate the other admin surfaces use, and a signed-in non-admin gets a 404, not a 403 — the page reads as absent rather than as a locked door with something behind it. The public leaderboard's anonymity is intact for everyone; this is the one door only I have.
const isAdmin = isAllowedEmail({ email, emailVerified, allowlist });
if (!isAdmin) notFound(); // reads as absent, not forbiddenUpdate — September 15, 2026
Someone put money on a basketball matchup a month before the season. The board was offering week-1 fantasy matchups the moment a league existed — before the draft, before anyone had a roster, a coin-flip nobody could handicap. Three things were wrong at once: the matchups showed too early, they were priced as flat pick'ems, and real stakes had already gone down on them.
The sync bet the earliest undecided week. Reasonable, until you learn ESPN publishes the entire season pre-season — every matchup undecided, every side on zero points. So "earliest undecided week" was week 1, in August, with no draft done.
// before: the earliest undecided week, whenever that happens to be const week = currentBettableWeek(league); // → 1, in the preseason
A league opens now only once it has drafted AND its season is within a week of starting. And "season start" isn't ESPN's fantasy calendar — I read the pro schedule and take the earliest real game across the league's teams, so a week out means a week from a ball actually being tipped.
if (!league.draftDetail?.drafted) return false; if (seasonStart) return now >= seasonStart - ONE_WEEK; return (league.status?.latestScoringPeriod ?? 0) >= 1; // fallback if the schedule won't load
Every matchup shipped as both sides -110. But ESPN publishes a per-side win probability, and a projected score — so a matchup is priced off the probability when it has one, and off the projection gap otherwise (a logistic on the margin). A real favourite and a real underdog, still no vig.
The gate stops new bad bets, but people had already staked the pre-season ones. I didn't want to grade them when the games eventually played — the bet was invalid at placement, on a roster that didn't exist yet. The settler already had a void grade that refunds the stake and keeps the bet out of the win-loss record, so the job was to apply it. The realization that made it safe: a league only ever goes closed → open, never back, so an open bet on a currently-closed league is always a pre-open one. The sync voids them as it runs.
// a closed league shouldn't carry open bets — refund the ones it does
for (const spec of closedLeagues) {
for (const bet of await openBetsFor(spec)) {
await settleBet({ bet, grade: "void" }); // stake back, record untouched
}
}Building the god's view last week, I said it joined a bet to a name and an email. It did — but only for people who'd used the parts of the site that capture your email into the users table. A ZeroProof-only bettor never had. Every other module runs an upsertUser middleware after auth; ZeroProof didn't, so betting never wrote the row, and those players showed a P-XXXXX handle and a blank email.
router.post("/bets", checkJwt, upsertUser, ...) // the middleware that was missingWired in now. The catch is there's no backfill: a verified email only reaches the server inside that person's own token, so it fills in the next time they place a bet, not retroactively.
Update — September 18, 2026
The ledger was correct and the record was accurate and opening a bet that won felt like reading a bank statement. A no-loss book should at least let you enjoy the wins, so the record now celebrates them.
The trick is “first time seeing it,” not “every visit.” A device-local set holds the ids of wins I’ve already been shown; the celebration keys off the wins that aren’t in it, and dismissing adds them. So a fresh win pops, and the same win never pops again.
const { ids, count, totalCents } = unseenWins(bets, seen);
if (count === 0) return null; // nothing new to cheer
// "Nice!" → setSeen(prev => [...prev, ...ids])The big figure counts up in whole dollars for the pop, but that animated number is aria-hidden — the real total is plain static text a screen reader reads, and the whole card is a polite live region. Ask for reduced motion and the count-up jumps straight to the total and the sparkles don’t render. The maths (win rate, net profit, recent form, the unseen-wins total) is a pure module I could unit-test without any of the animation.
Update — September 18, 2026
The leaderboard says who’s on top; it doesn’t say how I measure up against one particular player. A Compare tab does — pick someone from the board and our records line up side by side, each measure flagged for who leads, with where I’d rank by ROI.
What I actually wanted was “which bets did we agree or disagree on,” and I deliberately didn’t ship it. The board is anonymised on purpose (a handle that can’t be walked back to a person) and everyone’s picks are private, so surfacing another player’s individual bets to me would undo that. It needs a consented, opt-in surface on the backend, not a clever client — so this compares how we’ve each done, not what we each took.
The “who leads” and “where do I rank” logic is a pure module I could unit-test on its own, with null scores sinking below any real number so an ungraded player doesn’t top the board. The panel reads the leaderboard and profile the lobby had already fetched, so the tab costs no new request.
Update — September 18, 2026
The board only ever showed upcoming games, and I wanted to glance back at how a line moved or a matchup I’d missed. Two things had to be true: the backend had to serve finished games, and the board had to stop pretending time only runs forward.
The board’s day-horizon filter was time ≤ now + daysAhead — no lower bound at all. So the moment the backend returned a past game, it would have shown, with no way to limit how far back. The fix is symmetry: a daysBack that mirrors daysAhead, defaulting to 0 so the everyday board is unchanged, and growing as you load earlier — up to a 3-month cap the backend enforces.
time <= now + daysAhead * dayMs && time >= now - daysBack * dayMs
Past fixtures render read-only — badged Final, their closing lines shown as plain text instead of the pickable price buttons, so there’s no way to try to bet a game that already happened. The backend serves finished games behind an opt-in ?include=past&pastDays=N, reusing the same latest-line join as the upcoming query. The board fetches only the window it shows — a couple of weeks at first, widened as you load earlier up to the 3-month cap — rather than pulling all 90 days at once.
Update — September 18, 2026
The board worked but read as a grey list. I wanted highlight cards for the games worth a glance, team colour on every fixture, some motion when you place a bet, and for the bet to land the instant I hit place. Most of that was straightforward. The team colours were not.
I wanted Lakers purple and Celtics green, but the board spans NBA, NFL, MLB and fantasy, and the events carry team names, not ids — no logo URL or brand-colour table I could key off across all of them. So the first cut hashed the name to a hue in the app’s tone band: not the real colour, but a stable one, and an hsl()so it stayed inside the palette guard with no hard-coded hex.
// the fallback: stable, distinct, palette-safe
return `hsl(${hueFromName(name)} 52% 48%)`;A hash is fine, but Lakers purple is better, so I wrote the brand colours out after all. The catch is that a nickname isn’t unique: the NFL and MLB both have a Cardinals and a Giants, and they don’t share a palette. So the table is keyed by league — derived from the sport — and the lookup matches either the exact nickname or the tail of the vendor’s full name (Boston Red Sox). Fantasy teams have no brand colour and fall back to the hash.
const league = leagueFromSport(sport); // nba | nfl | mlb | null
for (const [nickname, color] of Object.entries(BRAND[league])) {
if (lower === nickname || lower.endsWith(` ${nickname}`)) return color;
}I liked effects from ReactBits and OriginKit and the iOS “Liquid Glass” look, but I didn’t want their libraries in the bundle. So I rebuilt the ones I wanted — a click spark, a blur reveal, a spinning conic border, a specular shine, a frosted glass surface — as small components on my own tokens, in src/components/motion (the cursor-follow spotlight was already there, so I left it), with the keyframes in globals.css. Each one stands down when the device asks for reduced motion, so nothing on the board depends on movement.
Placing a bet used to wait on the round-trip before the fixture showed it. Now the mutation writes the bet into the bets cache first, so the “Your bet” flag appears the moment I hit place; a failure rolls it back, and the settler’s real bet replaces it on the next refetch.
onMutate: async () => {
await queryClient.cancelQueries({ queryKey: bets });
const previous = queryClient.getQueryData(bets);
queryClient.setQueryData(bets, (old) => [...(old ?? []), optimistic]);
return { previous };
},Update — September 21, 2026
I sat down to place real bets on the live board and hit five things in a row. Four were small. The first was the one that mattered: I could still bet a fantasy matchup that had already tipped off.
The backend closes a matchup the moment points hit the board, and the board hides anything not upcoming. But a fixture I’ve already bet on is pinned to the board on purpose — and there my read-only check was only catching final or a kickoff in the past. A fantasy matchup keeps a synthetic commence time about 48 hours out, so the kickoff clause never fires; only its started status closes it, and the board wasn’t looking at that. So it kept showing live outcome buttons on a game already underway. I mirrored the backend’s exact rule instead:
export function isEventBettable(event, now) {
if (event.status !== "upcoming") return false;
const time = new Date(event.commenceTime).getTime();
return !Number.isNaN(time) && time > now;
}
// board: readOnly={!isEventBettable(event, now)} — badged "Live" or "Final"A totals or spread pick in my record and in the god’s view read as a bare “Over Total” with no teams attached, because the bet row only carried the selection and market. The event has the teams; the bet just wasn’t joined to it. I joined zeroproof_events onto both bet reads and carried home/away/sport through, so a bet finally names the matchup:
Heat @ Celtics Over Total 210.5 $25.00 -110
The Compare tab listed every leaderboard row to stack myself against — including me, so I could compare myself to myself and land an even “0 apiece”. The frontend never knew its own subject to drop it, so /me returns it now and the field is everyone but me, for both the picker and the rank.
const others = entries.filter((e) => e.userSub !== myUserSub);
The proxy route was dropping the pastDays window, so “load earlier” never actually widened the backend query. And the backend hands back upcoming ascending, then past descending — so once revealed, finished games piled up at the very bottom in reverse order rather than slotting in where they belong. I forwarded the window and sorted the visible board by kickoff before grouping, so a game from Tuesday sits above tonight’s.
The two board toggles were bare checkboxes. They’re the design system’s SquishSwitch now — the springy one whose thumb squishes as it slides — a real role="switch" button that still flips cleanly under reduced motion.
Update — September 22, 2026
Betting the board, three things nagged at me: I could only line up one pick at a time, the slip scrolled away the moment I looked for a second game, and once I’d scrolled I’d lost track of which day I was on.
The slip was a single SelectedBet | null, so picking a new outcome replaced the old one. Making it a list — keyed by event/market/selection so a tap toggles a leg on or off — was most of the work; the rest was giving each leg its own stake and placing them in a loop, dropping each off the slip as it lands.
for (const { leg, cents } of staked) {
await placeLeg.mutateAsync({ leg, stakeCents: cents });
onRemove(betLegKey(leg)); // it's placed — take it off the slip
}I wanted the slip always in view and the day header always in view. The slip was easy — dock it to the bottom with sticky bottom-4, an edge nothing else competes for. The day header wanted the top, where the filter bar already sticks at top-14; stacking both there just overlaps them. There’s no pure-CSS way to offset one sticky element by another’s height, so I measure the bar and hand the headers the number:
section.style.setProperty(
"--zp-day-top",
`calc(3.5rem + ${bar.offsetHeight}px)`,
);
// h3: style={{ top: "var(--zp-day-top)" }}Imperative on purpose — writing a CSS variable in a ResizeObserver sets no React state, so it never triggers a re-render and the lint rule against state-in-effect stays happy. And the left colour bar became a thick bottom border while I was in there, which reads better under the sticky header.
Update — September 29, 2026
Prepping for a senior front-end interview, the honest answer to “how did your analytics SDK batch?” was: it didn’t. It sent each event on its own, no queue, no flush on tab-close — so anything in flight when someone left was silently lost, at exactly the moment you most want it measured. I kept describing the layer I’d build instead. So I built it, and pointed it at ZeroProof.
track() is not allowed to cost a click.The rule I started from: analytics must never show up in INP. So track() stamps the event with a UUID and a per-session sequence, pushes it onto an in-memory queue, and returns. Everything expensive — deciding whether to send, serializing, persisting — happens off the caller’s path. The flush decision is a pure function so I could unit-test every threshold without a browser: flush on whichever comes first.
if (state.count >= limits.maxEvents) return "size"; // ~20 events if (state.bytes >= limits.maxBytes) return "bytes"; // near the ~64KB cap if (now - state.oldestEnqueuedAt >= limits.maxAgeMs) return "time"; // ~5s
A normal fetch gets killed when a backgrounded mobile tab is reaped; unload never fires there and also breaks the back/forward cache. The last event you can rely on is visibilitychange to hidden, so that’s where the flush goes, via sendBeacon — sending a plain string, not a Blob typed application/json, because that content type isn’t CORS-safelisted and would force a preflight the beacon can’t survive.
The subtle part: sendBeacon returning true means the browser queued the request, not that it arrived. So I don’t delete the persisted copy when I beacon — it’s kept and resent on the next load, and the duplicate gets absorbed downstream.
if (opts?.beacon) {
transport.beacon(batch); // fire, but keep the persisted copy
return; // "queued" != "delivered"
}Retries and beacons will manufacture duplicates, and exactly-once isn’t achievable from a browser. So delivery is at-least-once: events leave the queue only after a 2xx, transient failures (network, 5xx, 429) retry with exponential backoff plus jitter, and a 4xx is dropped rather than retried forever — a malformed event is a poison pill that would block everything behind it. The backend makes it safe by deduping on the client’s event UUID:
INSERT INTO zeroproof_analytics_events (event_uuid, ...) VALUES ... ON CONFLICT (event_uuid) DO NOTHING; -- a resend is a no-op
Every event carries a per-session sequence, so the backend can spot a hole — 1, 2, 4, where’s 3? — and know events were lost in flight rather than never sent. That’s the difference between “we think delivery is fine” and measuring it. The whole thing is gated on the site’s existing cookie consent and keyed by a hashed, non-reversible device id: no consent, no id, no tracking.
Update — October 2, 2026
The biggest-underdog and closest-game cards had no kickoff on them, and that hid a worse problem: they pick from every fixture the board has loaded, while the date sections only show the next three days. The longest shot is usually a week or more out, so the card advertised a game you couldn’t find below it without clicking load-more and guessing how many times.
Both cards show their kickoff now, in the same format as the board, and a Go to date button. It widens the horizon in the same three-day steps load-more takes, just far enough to reach the fixture, so every day in between shows too. It resets the filters only if they’d hide the fixture. Then it scrolls to the card and moves focus onto it, so a keyboard or screen-reader user lands where a sighted one looks.
revealEvent(event, filters, horizon, step = 3) 10.75 days out -> daysAhead = ceil(10.75 / 3) * 3 = 12 filters hide it -> DEFAULT_BOARD_FILTERS already shown -> unchanged
The jump is a fresh { eventId, seq }object per click. Clicking the same card twice is still a new jump, and the effect that scrolls only reads state, never sets it, which is what the set-state-in-effect lint rule wants.
Load-more could keep going as long as the vendor had lines, and the backend sent every upcoming fixture on the first request whether the board ever showed it or not. The board now stops a month out and says so: “Come back later for more.” The events endpoint gained anaheadDays parameter, clamped to 1–30 (portfolio_api#261), so the request stops there as well. The board also caps what it receives, which means the two can ship in either order.
Earlier on this page I wrote that a fixture you’ve bet on is never hidden, horizon or not. The month cap breaks that for anything more than 30 days out: the backend no longer returns it, so there is nothing for the board to pin. I kept the cap anyway. Only bets placed before it shipped can sit that far out, they come back on their own as the date gets closer, and Your record lists them the whole time.
Update — November 18, 2026
A codebase audit flagged that signed-out visitors were asking for bets they could never have. Every visit to the board without a session fired a request that came back 401.
// The caller's bets, so a fixture they've already bet on is flagged on the
// board — and always shown, even past the horizon. Reuses the profile's query
// and returns [] when signed out.
const betsQuery = useQuery({
queryKey: queryKeys.zeroproof.bets(),
queryFn: fetchBets,
staleTime: 30 * 1000,
});“Reuses the profile’s query” was true in the sense that it shared a cache key. But the board, the bet history, the record trend, the profile and the Compare tab each declared their own copy of this query, and only some of them waited for a session. The board’s copy didn’t, so it fetched for everyone. Sharing a key shares the cached answer. It doesn’t share the rule about when to ask.
All five now call useMyBets, which reads the profile query and only fetches once it says there’s a session. The bet history keeps its 30-second poll through an option. The test renders the page signed out and fails if a bets request goes out at all, which is the claim the comment had been making on its own.