Skip to main content

In-Memory Risk Gateway

A two-tier pre-trade risk admission gate on the LMAX BLP: an in-process Gateway replica screens without synchronous lookup, and the single-writer BLP makes the authoritative decision and reserves exact aggregate exposure in global sequence order.

  • Inherits architectural baseline from: YU02-lmax-kubernetes
  • Generated from: system/architecture.model.json
  • Canonical flows: ../001-baseline-uncontainerized-parity/system/end-to-end-flows.md

Architecture Diagram​

Node Catalog​

NodeKindLabelNotes
clientactorClient / Trade ServiceSubmits order / market-trade over REST (optional clientOrderId).
operatoractorRisk OperatorAdministers versioned controls via /risk/control/* (token + operator provenance).
gatewaycomponentTier 1; Gateway screeningGatewayReplicaStore.screen(): in-process, memory-only, no REST/DB (FR-IMRG01/06); fail-closed until ready; reject to 422 / 503 (stale).
input_ringcomponentInput DisruptorGlobal input sequence carrying commands, prices, and control events (ADR-020).
journalercomponentJournaler + ReplicatorDurable journal + NATS JetStream replication before the BLP (FR-IMRG10).
blpcomponentTier 2; BLP (single writer)BlpRiskState.decideAndReserve / decideMarketTrade: ordered pipeline, exact aggregate exposure, check+reserve as one single-threaded op (FR-IMRG12/13).
bookcomponentOrder Book / ExecutionACCEPTED commands enter the book and execute; the accepted order's exposure stays reserved until filled or cancelled.
output_ringcomponentOutput DisruptorThe BLP's only side-effect channel (FR-IMRG27); gains order-rejected and trade-decision kinds (FR-IMRG45).
marshallercomponentMarshallerIn-memory read model + correlation acks (KIND_TRADE_ACCEPTED/REJECTED).
natscomponentNATS bridgesOrder/trade lifecycle subjects, carrying riskReason on rejection (FR-IMRG15).
projectorcomponentProjectorProjects accepted outcomes to the MariaDB read model; reads no admission state back (FR-IMRG41).
mariadbserviceMariaDB read modelAsync projection only, never the source of admission state.