Skip to content

Engine

Six layers, one direction.

Keystone is split into packages that each do one job and import only what sits below them. The core knows nothing about pixels; the field knows nothing about money; the interface only reads state and sends commands.

The layers

What each part does.

  1. 01Headless core

    core

    Holds the state of a session and a round and plays a round's events in order. It has no React, no PixiJS and no DOM: it compiles without the DOM library, so a browser API inside it fails the type check. The host gives it ports: transport, storage, scheduler, audio output, the operator channel, visibility.

  2. 02Field

    field

    The playing field, drawn with PixiJS 8 and animated with GSAP. One board for every mechanic takes its geometry as input: columns, rows, reels or tumble motion. The presenter turns each event of the round into timed steps; turbo and quick stop are pacing, not separate code.

  3. 03Reference interface

    ui-react

    The controls a player touches: bet, spin, autoplay, turbo, buy, rules, history, settings, boot and error screens. It reads the core's state and sends commands, nothing else, so a provider can keep it, restyle it through CSS custom properties or replace it.

  4. 04Mechanics

    mechanic-*

    A mechanic module declares its events, the symbol roles it needs, which steps each event plays and how its rules are illustrated. The board, the presenter and the interface are configured by it.

  5. 05Round server

    server

    Runs the round: session, outcome, settlement, recovery, limits, replay. The outcome is calculated by the game's pure math; the server stores it before it is shown and talks to the operator's wallet through a port. The platform runs one for every provider.

  6. 06Tools

    preview, publish, math-*, inspector

    A local preview that plays a game folder with its math in play money; the upload command; the math kit that writes, simulates and freezes a math; an inspector for board state, the current event and the time each step took.

Dependency direction

Every arrow points down.

Each package lists only its allowed imports, so the graph has no cycle and a wrong import fails the repository gate. The client side, by level:
level 5
client
devtools
level 4
mechanic-*
level 3
web
field
ui-react
level 2
core
level 1
content
level 0
protocol
i18n

The build preset sits beside the graph as Node tooling and is never part of a game bundle. On the server side the order is the same: event schema and ports at the bottom, then the game contract, the pure round core, and the server application on top.

Interfaces

A UI reads state and sends commands.

The field is driven by the round's events; the interface is driven by the store. Neither reaches into the other.
the contract every interface uses
// Any interface, in any framework, uses the same two calls.
const unsubscribe = engine.state.subscribe((state) => {
  render(state.round.phase, state.hud.canSpin);
});

spinButton.onclick = () => engine.dispatch({ type: "spin" });
  • Commands are plain objects: spin, stop, set bet, step bet, start and stop autoplay, turbo, buy, open a dialog, replay a round.
  • Input actions are named (spin, stop, bet up, bet down, autoplay, turbo, buy, menu, skip) and mapped to keys, pointer and operator messages.
  • The field never sends a money command; it reads only settings and the round's speed.

Packages

Client and tooling.

Each is published as @elsikora/keystone-<name> to a private registry: 46 packages at 0.1.0-next.7.
  • clientReady

    Keystone's composition root: startGame wires the core, the browser ports, the field with one mechanic and a UI into a running game.

    may import: content, core, devtools, field, i18n, protocol, ui-react, web, gsap, pixi.js, react, react-dom

  • contentReady

    Keystone content contracts, platform-neutral: content release envelopes, media documents (atlas, flipbook, bitmap font, alpha clip, audio library), the HUD skin and theme documents, the engine skin manifest, and their validators.

    may import: protocol

  • coreReady

    Keystone headless engine core: store and events, round flow, book playback, net client over a transport port, autoplay and policy, HUD state machine, player settings, audio director over an output port, input actions, money formatting, messages. No DOM, React or PixiJS.

    may import: content, i18n, protocol

  • fieldReady

    Keystone field: PixiJS 8 and GSAP stage, scene, symbols, presenter, FX, blocks, look, assets, media and game audio cues.

    may import: content, core, i18n, protocol, gsap, pixi-filters, pixi.js

  • i18nReady

    Keystone i18n, platform-neutral: locale registry and negotiation, strict ICU messages, catalogs, CLDR formatters, plural rules, text shaping and layout, pseudo-locales, font-manifest and locale-pack contracts.

    may import: nothing

  • mechanic-book-expandReady

    Keystone mechanic book-expand: a drawn symbol expands over whole reels in free spins and pays on every line; the event-to-step map on the engine's board and presenter.

    may import: content, core, event-schema, field, protocol, gsap, pixi.js

  • mechanic-hold-and-winReady

    Keystone mechanic hold-and-win: coins land and lock, the other cells respin, jackpot labels, a full grid pays the grand; the event-to-step map on the engine's board and presenter.

    may import: content, core, event-schema, field, protocol, gsap, pixi.js

  • mechanic-linesReady

    Keystone mechanic lines-collect: reels, paylines, a collector in free spins; the event-to-step map on the engine's board and presenter.

    may import: content, core, event-schema, field, protocol, gsap, pixi.js

  • mechanic-pick-bonusReady

    Keystone mechanic pick-bonus: wins pay on paylines, three scatters trigger one of three bonuses (free spins with a retrigger, a prize wheel, a pick-and-click board the player answers through the engine's decision gate); the event-to-step map on the engine's board and presenter.

    may import: content, core, event-schema, field, protocol, gsap, pixi.js

  • mechanic-tumbleReady

    Keystone mechanic tumble: a tumbling grid, cluster wins, multipliers in free spins; the event-to-step map on the engine's board and presenter.

    may import: content, core, event-schema, field, protocol, gsap, pixi.js

  • mechanic-variable-waysReady

    Keystone mechanic variable ways: reels whose rows change each spin (a horizontal top reel among them) pay left to right by ways, the spin's ways count in a counter, free spins with a retrigger; the event-to-step map on the engine's board and presenter.

    may import: content, core, event-schema, field, protocol, gsap, pixi.js

  • mechanic-waysReady

    Keystone mechanic ways: wins pay left to right by ways, a random shot turns cells into a symbol or a multiplier before the pay, free spins with their own music and mood; the event-to-step map on the engine's board and presenter.

    may import: content, core, event-schema, field, protocol, gsap, pixi.js

  • protocolReady

    Keystone wire types shared by the client and the round server: book, core events, round, session config, money, rules document, flags.

    may import: nothing

  • ui-kitReady

    Keystone UI: the one kit of interface components, tokens, theme and fonts under every Keystone front (the site, the docs, the console, any studio tool). React 19 over headless primitives; Tailwind 4 over the identity's tokens.

    may import: @fontsource/ibm-plex-mono, @fontsource/ibm-plex-sans, @fontsource/space-grotesk, class-variance-authority, radix-ui, react, react-dom, uqr

  • ui-reactReady

    Keystone's reference interface, replaceable: React 19 with TanStack Store and Query over the core's HUD view state and actions.

    may import: content, core, i18n, @tanstack/react-query, @tanstack/react-store, react, react-dom

  • ui-startReady

    Keystone's reference in-slot interface as a TanStack Start application (client-only, its shell prerendered): the launch page, the routes of the menu, rules, history and settings, and the client entry that starts the game. A game's build preset (`createGameBundleConfig({ ui: "start" })`) builds it from this package's source.

    may import: client, core, mechanic-book-expand, mechanic-hold-and-win, mechanic-lines, mechanic-pick-bonus, mechanic-tumble, mechanic-variable-ways, mechanic-ways, ui-react, @tanstack/react-query, @tanstack/react-router, @tanstack/react-start, react, react-dom

  • webReady

    Keystone browser host: the browser implementations of the engine core's ports (fetch transport, Web Audio output, storage, scheduler, page visibility, key and pointer bindings, the operator's postMessage channel, the launch page).

    may import: core, protocol

  • buildReady

    Keystone's build preset for a game's static client bundle (Node only, never in a bundle): the Vite configuration, the launch CSP check, the bundle manifest and code index, data bundling, the check of a game folder against the content schemas, and the tool that makes an audio library asset.

    may import: content, game-pack, protocol, @tanstack/react-start, @vitejs/plugin-react, vite

  • devtoolsReady

    Keystone devtools for QA builds only: the QA frame clock (one virtual clock that steps the PixiJS ticker, GSAP's root timeline, the timers and a seeded random source frame by frame, exposed as globalThis.__ksQaClock under __KS_QA_HOOKS__). Never in a release bundle.

    may import: core, gsap, pixi.js

  • game-packReady

    Keystone game pack: a game folder checked and turned into the pack the platform's ready client takes at run time (plain Node, no bundler); the folder check, the faces and the HUD theme layers.

    may import: content, i18n, protocol, @fontsource-variable/inter

  • inspectorReady

    Keystone's inspector for the dev host, never in a release bundle: beside a running game it shows what the engine is doing (the board's state, the event playing with its place in the round, the phase and the time each step took), and a symbol viewer plays each state of each role of a game. Reads only.

    may import: content, core, field, ui-kit, gsap, pixi.js, react, react-dom

  • math-book-expand-classicReady

    The classic ready math for the book mechanic, written with the Keystone kit only: a 5x3 lines game whose book is wild and scatter, free spins with an expanding symbol and retriggers, a bought feature, tuned and frozen as a release.

    may import: event-schema, game-contract, math-calculator, math-core, math-evaluate, math-exact, math-optimise, math-sim

  • math-bundleReady

    Keystone's bundle loader (Node only): a math release's bundle read from a content-addressed folder by its sha256, proven before any of it runs, and evaluated in a fresh node:vm context with no clock, no randomness, no network, no file system and no environment, behind a JSON membrane.

    may import: game-contract

  • math-calculatorReady

    Keystone math kit composition: createSlotCalculator turns a game's math data and play script into an outcome calculator of the game contract, with the round context, the win cap, the feature loops (free spins, cascades, hold and win, picks), a round that pauses for a decision and player-game state.

    may import: event-schema, game-contract, math-core, math-evaluate

  • math-cliReady

    Keystone's math command, keystone-math (Node only): checks a game's math data, simulates its plans on worker threads into the canonical report or shard files, merges shards made anywhere, and lists the draw sites of its play script.

    may import: event-schema, game-contract, math-calculator, math-core, math-evaluate, math-optimise, math-release, math-sim, vite

  • math-coreReady

    Keystone math kit core: a game's math as typed data with one validator, the board as a value, and the draw primitives over the game contract's random source.

    may import: game-contract

  • math-evaluateReady

    Keystone math kit evaluators and board steps: pure win evaluators (lines, ways, scatter, cluster, expanded symbol) with counting variants, and pure board steps (cascade, wilds, multipliers, hold and win, variable rows).

    may import: game-contract, math-core

  • math-exactReady

    The exact-arithmetic helper of the ready maths: the exact parts they compute from their data alone (window counts per reel, their sum across reels, one payline's expected pay through the kit's own line evaluator), and the round checks their specs run. The exact parts are a candidate for the kit.

    may import: event-schema, game-contract, math-core, math-evaluate, math-sim

  • math-hold-and-win-classicReady

    The classic ready math for the hold-and-win mechanic, written with the Keystone kit only: a 5x3 lines game whose coins start a respin feature with fixed jackpots and a grand prize, a bought feature, tuned and frozen as a release.

    may import: event-schema, game-contract, math-calculator, math-core, math-evaluate, math-exact, math-optimise, math-sim

  • math-lines-collect-classicReady

    The classic ready math for the lines mechanic with a collector, written with the Keystone kit only: a 5x3 game on 10 paylines whose wilds collect the token values on the board in free spins, tuned and frozen as a release.

    may import: event-schema, game-contract, math-calculator, math-core, math-evaluate, math-exact, math-optimise, math-sim

  • math-lines-collect-wideReady

    The wide ready math for the lines mechanic with a collector, written with the Keystone kit only: a 5x4 game on 20 paylines whose wilds collect the token values on the board in free spins and level the collector up, an ante at 5/4 and a bought feature, tuned at 96, 94 and 92 and frozen as one provisional release.

    may import: event-schema, game-contract, math-calculator, math-core, math-evaluate, math-optimise, math-sim

  • math-optimiseReady

    Keystone RTP optimiser: a deterministic compass search over the declared tunable weights, a one-knob RTP trim, integer rounding to each table's total, an independent verification run and the canonical weights document.

    may import: event-schema, game-contract, math-core, math-sim

  • math-pick-bonus-classicReady

    The classic ready math for the pick-bonus mechanic, written with the Keystone kit only: a 5x3 game on 10 paylines whose scatters start one of three bonuses (free spins with retriggers, a wheel, a pick that pauses the round for each tile), a bought bonus, frozen as a release.

    may import: event-schema, game-contract, math-calculator, math-core, math-evaluate, math-exact, math-optimise, math-sim

  • math-releaseReady

    Keystone math release: par sheets built from the simulator's exact reports, the release facts a server and a rules page read, and the freeze of a release into a lock file with its hashes and golden vectors, verified by replay.

    may import: game-contract, math-core, math-sim

  • math-simReady

    Keystone math simulation: any outcome calculator of the game contract played with a seeded generator, in shards that merge exactly, into a report with confidence intervals, choice and session policies and a force-seed index.

    may import: event-schema, game-contract

  • math-tumble-classicReady

    The classic ready math for the tumble mechanic, written with the Keystone kit only: a 6x5 cluster game whose cells fill from weighted tables, cascades with multiplier orbs, free spins on scatters and a bought feature, tuned and frozen as a release.

    may import: event-schema, game-contract, math-calculator, math-core, math-evaluate, math-exact, math-optimise, math-sim

  • math-tumble-grandReady

    A math for the tumble mechanic with the numbers of a full cascading game, written with the Keystone kit only: a 6x5 board that pays nine symbols counted anywhere, orbs to 500x, 15 free spins, a 15000x cap, an ante at 5/4 and a bought feature whose scatter count is drawn, tuned at 96, 94 and 92 and frozen as one provisional release.

    may import: event-schema, game-contract, math-calculator, math-core, math-evaluate, math-exact, math-optimise, math-sim

  • math-variable-ways-classicReady

    The classic ready math for the variable-ways mechanic, written with the Keystone kit only: six reels of 2 to 7 rows a spin and a top reel over the middle four, ways that cascade, scatters that pay and start free spins whose multiplier grows per cascade, a bought feature, tuned and frozen as a release.

    may import: event-schema, game-contract, math-calculator, math-core, math-evaluate, math-exact, math-optimise, math-sim

  • math-ways-classicReady

    The classic ready math for the ways mechanic, written with the Keystone kit only: a 6x4 ways game whose random shot turns cells into a symbol or a multiplier, scatters that pay and start free spins with retriggers, a bought feature, tuned and frozen as a release.

    may import: event-schema, game-contract, math-calculator, math-core, math-evaluate, math-exact, math-optimise, math-sim

  • previewReady

    keystone-preview, a studio's local preview (Node only): serves the platform's ready client and a game folder as it is on disk, with the game's frozen math playing rounds in play money; each save is checked, packed again and reloaded in the page without a build.

    may import: build, content, core, game-contract, game-pack, math-bundle, math-cli, mechanic-book-expand, mechanic-hold-and-win, mechanic-lines, mechanic-pick-bonus, mechanic-tumble, mechanic-variable-ways, mechanic-ways, protocol, round-core, ui-react, ui-start

  • publishReady

    keystone-publish, a studio's upload tool (Node only): makes the signing key of a tenant's service account, and uploads a game's client build (and, with the math route, its math) to the running platform with signed requests.

    may import: content, game-pack, protocol

Packages

Server.

  • event-schemaReady

    Keystone event schema: one schema per mechanic as data (event names, fields, which fields are money), validation, type guards, summarizeRound and labelRound.

    may import: nothing

  • game-contractReady

    Keystone game contract: how a game's math and its mechanic plug into the round server (outcome calculator, mechanic server module, math releases and PAR facts), with a sample dice game.

    may import: event-schema, ports, protocol

  • portsReady

    Keystone server ports: the capability interfaces a round server is configured with (wallet, operator notification, clock, random source, id generator, alert).

    may import: nothing

  • round-coreReady

    Keystone round core: the round's decisions as pure, synchronous, total functions (play planning, transaction ids, the decisions after debit, outcome and credit, resume, sweep) and the round's money.

    may import: game-contract, ports, protocol

  • testkitReady

    Keystone test kit: framework-neutral port conformance suites and in-memory reference adapters (wallet first).

    may import: ports