Bet Builder
Prices a multi-selection bet with correlation — fifteen queries and a model chain over them, and the deepest data graph in the product.
/bet-builder · src/composed/bet-builder
The chain
A fixture selects a squad, which selects lineups, which select minutes, which
scale each player's expected value, which is finally priced against the book's
line. Every step is a useMemo whose input is the step before it.
Fifteen queries, and none of it is markup — but all 640 lines of it used to sit directly above the 880 lines that render it.
Why the split matters here more than elsewhere
The view can now be handed a slip and a set of prices without a network. That is the difference between a model you can test and a model you can only observe: the correlation maths is checkable against fixed inputs, in a test, rather than by loading the board and reading numbers off it.
The queries were already keyed properly and were left alone. What changed was the boundary, not the fetching.
Correlation
Selections in one match are not independent — a player scoring makes his team
winning more likely — so the joint price is not the product of the legs. The
correlation model lives in src/lib beside the other pure helpers, and
src/lib/__tests__ is where it is checked.