What the player experiences, what the implementation actually owns, and where production responsibilities would begin.
01
Game background
Keno is a draw game in which a player selects numbers from a larger field and receives a return according to how many selections appear in the draw. The engineering interest is the combination of sampling without replacement, combinatorial probabilities, and selection-specific paytables.
02
How the game works
Select 2–10 numbers from an 80-number board.
Choose a virtual stake and submit the selection to the service.
The backend draws 20 unique numbers, counts intersections, and reads the matching paytable multiplier.
The browser applies the returned payout to demo-only credits after the result arrives.
03
Backend architecture
A NestJS service stores one AmericanKenoGame in an in-memory map keyed by a cryptographic UUID. The service validates bet and selection commands, while the game object owns the draw, hit count, and payout calculation.
Presentation, input, accessibility, and demo-credit display.
REST API
Request validation and routing into one isolated game session.
Game Session
Ephemeral configuration and the previous authoritative result.
Game Engine / RNG
Outcome generation, game rules, win evaluation, and result contracts.
Paytable
Selection-count and hit-count multiplier lookup.
05
Critical engineering decisions
Keep the draw server-authoritative so the browser cannot choose numbers after seeing the outcome.
Sample without replacement so every draw contains 20 unique values.
Separate selection validation from draw execution.
Expose theoretical probability helpers rather than treating a short demo sample as evidence of RTP.
06
Failure handling
An invalid or unknown gameId returns a failed result rather than a new draw.
If the response times out after a draw, the client should query the known session before requesting another outcome; durable command replay is not implemented.
Refreshing the page loses local demo credits even if the short-lived backend session still exists.
A production wallet timeout would require reconciliation, but this demo has no wallet integration.
07
Fairness / RNG
The draw runs on the backend and uses Node.js cryptographic randomness with Fisher–Yates sampling. This is not a provably-fair commitment scheme and is not presented as certified gambling infrastructure.