# Module Map

## Core Runtime

| Module | Path | Responsibility |
| --- | --- | --- |
| Engine runtime | `src/engine/core/mod.rs` | Engine builder, thread startup, command loop, event publishing, batch-slot fill checks |
| Engine aggregate | `src/engine/root.rs` | Aggregate root wrapper and read-side snapshots |
| Engine state | `src/engine/state.rs` | Command validation, event emission, event application |
| Journal API | `src/engine/journal.rs` | Public read-only journal replay surface (`JournalReader`, `JournalEvent`) |
| Journal internals | `src/engine/journaler.rs` | Segmented LMDB WAL persistence, shared replay scanner, WAL poller integration |
| Journal scanner | `src/engine/journal_scan.rs` | Shared WAL scan, validation, cursor semantics, and replay helpers |
| Consumers | `src/engine/consumers.rs` | Response callback consumer and tx-level response synthesis |

## Domain Model

| Module | Path | Responsibility |
| --- | --- | --- |
| Book facade | `src/book/mod.rs` | Unified interface over book variants |
| Two-runner book | `src/book/two_runner.rs` | Two-runner exchange matching (direct + implied) |
| Multi-runner book | `src/book/multi_runner.rs` | Multi-runner exchange matching (direct) |
| Binary yes book | `src/book/binary_yes.rs` | Prediction-market matching using ticks/shares, close/void batching, strict settlement validation |
| Protocol | `src/book/protocol/` | Commands, responses, and reject reasons |
| Book common | `src/book/common/` | Shared event types, state, validation, and fast storage primitives |

## Platform Modules

| Module | Path | Responsibility |
| --- | --- | --- |
| Disruptor envelope | `src/disruptor/mod.rs` | Ring envelope framing (`seq`, `tx_id`, `tx_len`, `tx_ix`) |
| Snapshot types | `src/snapshot.rs` | Market snapshot models for read-side consumers |
| Stream wire types | `src/stream.rs` | Streamed event format for websocket/SSE style consumers |
| Primitive types | `src/types/` | Domain IDs, money/odds/quantity primitives, formatting, and serde/rkyv mappings |
| Idempotency | `src/idempotency.rs` | Idempotency helper and default in-memory store |
| Cross-match orchestrator | `src/cross_match/mod.rs` | 3-runner cross-matching execution and compensation flow |
| Cross-match hedge solver | `src/cross_match/hedge.rs` | Integer hedge search with bounded scan and tolerance-aware constraints |
