# jamisonrobey/itch_mold_replay architecture

> Architecture diagram of the GitHub repository jamisonrobey/itch_mold_replay, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jamisonrobey/itch_mold_replay
- Repository: https://github.com/jamisonrobey/itch_mold_replay

## Overview

##### Project type and purpose
- This is a C++ command-line network utility (“open-source tool”) that reads a binary Nasdaq TotalView-ITCH file and replays it over the network using the MoldUDP64 protocol. It also implements a retransmission server to satisfy client requests for missing messages.

##### File structure
- Top-level:
- CMakeLists.txt and .clang-format: build and style config
- .gitmodules + external/jamutils: a submodule for shared utilities
- src/ directory:
- main.cpp: parses CLI, initializes components
- mold_udp_64.h, downstream_server.h: downstream multicast server interface
- retransmission_server.h, retransmission_worker.h: UDP server for retransmission
- itch.h, nasdaq.h: message definitions/parsers for ITCH protocol
- message_buffer.h: in-memory buffer of parsed messages for replay/retransmission
- server.h, downstream_server.h: abstract server interfaces

##### README for additional insights
- Describes two core servers:
- Downstream server: multicasts replayed messages at original timestamps
- Retransmission server: listens for UDP requests and responds with retained messages
- Configurable via CLI: multicast group/port, TTL, replay speed, start phase
- Built with CMake + g++14, runs on Linux

## Diagram (Mermaid)

```mermaid
flowchart TB
  subgraph "Build Configuration"
    CMake["CMakeLists.txt"]:::build
    ClangFmt[".clang-format"]:::build
  end

  subgraph "Input & Configuration"
    CLI["CLI/Configuration Loader"]:::cli
  end

  subgraph "Core Modules"
    FileReader["File Reader"]:::core
    ITCHParser["ITCH Parser"]:::core
    NASDAQParser["NASDAQ Parser"]:::core
    MessageBuffer["Message Buffer"]:::core
    Pacer["Time Controller / Pacer"]:::core
    AbstractServerInterfaces["Abstract Server Interfaces"]:::core
  end

  subgraph "Network Services"
    DownstreamServerInterface["Downstream Server Interface"]:::network
    MoldUDP64Module["MoldUDP64 Multicast Module"]:::network
    RetransmissionServer["Retransmission Server"]:::network
    RetransmissionWorker["Retransmission Worker Threads"]:::network
  end

  subgraph "External & OS"
    ExternalUtils["External Utilities (jamutils)"]:::external
    OSNetworkLayer["OS/Network Layer (sockets API)"]:::external
    Clients["Clients (multicast/unicast)"]:::external
  end

  CLI --> FileReader
  FileReader --> ITCHParser
  FileReader --> NASDAQParser
  ITCHParser --> MessageBuffer
  NASDAQParser --> MessageBuffer
  MessageBuffer --> Pacer
  MessageBuffer --> RetransmissionServer
  MessageBuffer --> RetransmissionWorker
  Pacer --> DownstreamServerInterface
  DownstreamServerInterface --> MoldUDP64Module
  MoldUDP64Module --> OSNetworkLayer
  RetransmissionServer --> OSNetworkLayer
  RetransmissionServer --> RetransmissionWorker
  ExternalUtils --> Pacer
  ExternalUtils --> RetransmissionServer
  AbstractServerInterfaces --> DownstreamServerInterface
  AbstractServerInterfaces --> RetransmissionServer
  Clients --> OSNetworkLayer
  Clients --> RetransmissionServer

  click CLI "https://github.com/jamisonrobey/itch_mold_replay/blob/main/src/main.cpp"
  click ITCHParser "https://github.com/jamisonrobey/itch_mold_replay/blob/main/src/itch.h"
  click NASDAQParser "https://github.com/jamisonrobey/itch_mold_replay/blob/main/src/nasdaq.h"
  click MessageBuffer "https://github.com/jamisonrobey/itch_mold_replay/blob/main/src/message_bufffer.h"
  click Pacer "https://github.com/jamisonrobey/itch_mold_replay/tree/main/external/jamutils"
  click DownstreamServerInterface "https://github.com/jamisonrobey/itch_mold_replay/blob/main/src/downstream_server.h"
  click MoldUDP64Module "https://github.com/jamisonrobey/itch_mold_replay/blob/main/src/mold_udp_64.h"
  click RetransmissionServer "https://github.com/jamisonrobey/itch_mold_replay/blob/main/src/retransmission_server.h"
  click RetransmissionWorker "https://github.com/jamisonrobey/itch_mold_replay/blob/main/src/retransmission_worker.h"
  click AbstractServerInterfaces "https://github.com/jamisonrobey/itch_mold_replay/blob/main/src/server.h"
  click ExternalUtils "https://github.com/jamisonrobey/itch_mold_replay/tree/main/external/jamutils"
  click CMake "https://github.com/jamisonrobey/itch_mold_replay/blob/main/CMakeLists.txt"
  click ClangFmt "https://github.com/jamisonrobey/itch_mold_replay/blob/main/.clang-format"

  classDef core fill:#A5D8FF,stroke:#1E40AF,color:#1E40AF
  classDef network fill:#B2F2BB,stroke:#2B8A3E,color:#2B8A3E
  classDef external fill:#E9ECEF,stroke:#495057,color:#495057
  classDef cli fill:#FFF3BF,stroke:#F08C00,color:#F08C00
  classDef build fill:#FFDBE6,stroke:#D6336C,color:#D6336C
```
