Skip to content

Round server

One server. Your games. The same guarantees.

The round server is the platform's: one server plays every round of every provider's games. A provider is a tenant of it and uploads its games; it never installs, hosts or deploys a server. The database keeps each tenant's rows apart.

Who owns what

The platform runs the round; the provider runs the business.

The platform provides

  • sessions, rounds, settlement, recovery, limits and replay, for every tenant
  • every call to an operator's wallet: a provider writes no wallet code
  • the pure round core: state machine, settlement and refund decisions
  • a test kit: wallet adapter conformance, money audit, crash and chaos drills
  • a dev host: the platform's server on your machine, with demo operators and a demo wallet

Each provider brings

  • its games, uploaded as folders
  • its own math, when it brings one, uploaded as a frozen release
  • its contracts with the operators that play its games
  • its staff, and the role each has in the console
  • the certification of each game

The wallet port

A wallet plugs in through one port.

An operator's wallet plugs in through one interface, and the platform makes every call. A connection says how an operator's wallet is reached; the round never knows whose wallet it is talking to.
keystone-ports (abridged)
// An operator's wallet, implemented by each operator adapter. A money call is
// prepared once, stored, and sent as the same bytes as often as it takes.
export interface IWalletPort {
  balance(context: IWalletContext): Promise<TWalletAnswer>;
  prepare(context: IWalletContext, call: TWalletCall): IPreparedWalletRequest;
  send(context: IWalletContext, prepared: IPreparedWalletRequest): Promise<TWalletAnswer>;
}

export type TWalletCall =
  | { operation: "debit"; request: IWalletDebit }
  | { operation: "credit"; request: IWalletCredit }
  | { operation: "refund"; request: IWalletRefund };

// Only a final answer returns; anything else throws WalletIndeterminateError.
export type TWalletAnswer =
  | { status: "OK"; balanceMinor: number }
  | { status: "DECLINED"; code: EWalletDeclineCode; rawCode: string };
  • One HTTP call per wallet call, no retry inside it, with the session's timeout.
  • A conformance suite in the test kit feeds an adapter timeouts, error statuses, conflicts and malformed replies and checks each is reported as unknown.
  • A demo wallet ships with the dev host, with modes for every failure: decline, timeout, server error, malformed reply, lost answer, hang.

Money

Seven guarantees, in plain words.

Each one is written as a requirement with the database transaction it commits in and the test or drill that proves it.
  1. 01

    Every wallet call has a stable id, saved first.

    The transaction id is derived from the round and the kind of call (bet, win, refund) and stored before the wallet hears of it. A crash before the call restarts into the same request with the same id.

  2. 02

    No answer is never a no.

    A timeout, an error status or a malformed reply is treated as unknown, not as a decline. The exact same request, byte for byte, is sent again later until the wallet gives a final answer.

  3. 03

    One bet and one win per round.

    Exactly one debit and one credit per round, enforced by the database. The win is sent even when it is zero, so the operator always sees the round close.

  4. 04

    A refund only before an outcome exists.

    A bet is refunded only while no outcome has been stored. A win the wallet declines is never rolled back: the round is marked for reconciliation and an alert is raised.

  5. 05

    One timeout, and no retry inside a call.

    Each session has one wallet timeout, capped at 45 seconds. Every other timeout on the path is longer, and the server refuses to start with a configuration that breaks this.

  6. 06

    The outcome is stored before it is shown.

    The round's events, random tape and checksum are written before the player sees anything. A crash at any point resumes to the same outcome.

  7. 07

    One writer per player and game.

    A lease with a fencing revision lets only one process write a player's round at a time. A background worker settles whatever a stopped process left behind.

How it is built

A pure core inside a conventional server.

The round core is a pure library: no framework, no database, no network, no clock or randomness of its own. Clock, random source and ids arrive as arguments, so every decision can be tested and replayed.

The application is NestJS with the Fastify adapter and TypeORM over PostgreSQL. It persists what the core decides, each step in one named transaction, and never holds a transaction open across a wallet call.

Four runtime roles share one codebase: two one-shot roles that set up the database and apply its migrations, the API that serves players and operators, and the worker that sweeps unfinished rounds.

Readyports, event schema, game contract, round core, test kit: published packages
Readythe server application, run by the platform, and its dev host