# quickfixgo/quickfix architecture

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

- Interactive diagram: https://gitdiagram.com/quickfixgo/quickfix
- Repository: https://github.com/quickfixgo/quickfix

## Overview

Below are guidelines tailored to this project:

##### Main Components
- Core FIX Engine: Representing the heart of the library, this includes components such as session management (files like session.go, in_session.go, session_state.go, session_rejects.go), connection handling (connection.go, dialer.go, initiator.go, acceptor.go), and message processing (message.go, parser.go, message_router.go).
- Code Generator: The “cmd/generate-fix” directory encapsulates the tool responsible for generating code from FIX specification XML files (located in the “spec” directory) into type-safe messages, fields, and groups.
- Data Dictionary & Specifications: Show a module for the FIX specifications (spec/ folder) and the datadictionary package that builds and validates FIX message definitions.
- Persistence & Stores: Include persistence options such as on-disk file stores, in-memory stores, SQL and MongoDB stores (store/ directory and related tests), which handle session state and message persistence.
- Logging and Error Handling: Highlight the multiple logging options provided (log/file, log/screen, log/mongo, log/sql) alongside error management components.
- Utilities and Internal Services: Capture internal packages like “internal/event” and “internal/time_range” which support timing and event processing required for session management.
- Testing and Configuration: Although these may not be part of the runtime system, include a note for the presence of comprehensive unit tests, acceptance tests (see _test/), devcontainer configurations, and various configuration files (config/).

##### Relationships and Interactions
- Code Generation: Use a separate block to indicate that the “generate-fix” tool converts specification definitions (XML in spec/) into generated code that feeds into the core FIX engine.
- Logging: Connect logging components to key operations in session management, connection handling, and message processing to illustrate real-time tracking of FIX communications.
- Error Handling: Indicate that errors reported by message parsing or session issues get processed through the error management components.

##### Architectural Patterns and Technologies
- Spec-Driven Design: Emphasize that message definitions and validations are generated from formal FIX XML specifications.
- Pluggability: The separation of logging (file, screen, mongo, SQL) and store implementations (file, memory, SQL, Mongo) shows a clear use of the strategy pattern where developers can plug in different persistence or logging strategies.
- Language and Environment: Note that the project is written in Go, utilizes Docker for development (via .devcontainer), and integrates CI/CD pipelines through GitHub workflows.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Supporting Tools
    subgraph "Supporting Tools"
        CG["Code Generation Tool"]:::tool
        DD["Data Dictionary"]:::dict
        SPEC["Specifications"]:::spec
        SPEC -->|"provides"| DD
    end

    %% Core FIX Engine
    subgraph "Core FIX Engine"
        CH["Connection Handler"]:::engine
        SM["Session Manager"]:::engine
        MP["Message Processing"]:::engine
        CH -->|"creates"| SM
        SM -->|"processes"| MP
        SM -->|"validate"| DD
    end

    %% Persistence and Logging/Error Modules
    PL["Persistence Layer"]:::persistence
    LM["Logging Modules"]:::logging
    EH["Error Handling"]:::error

    SM -->|"persist"| PL
    MP -->|"persist"| PL

    SM -->|"log"| LM
    MP -->|"log"| LM
    MP -->|"error"| EH

    %% Code Generation feeds into Core FIX Engine
    CG -->|"generated_code"| MP

    %% Utilities and Internal Services
    subgraph "Utilities and Internal Services"
        IU["Internal Utilities"]:::utility
    end
    IU -->|"support"| SM

    %% Testing and Configuration
    TC["Testing & Configuration"]:::config
    TC --- CH
    TC --- SM
    TC --- MP

    %% Styles
    classDef tool fill:#D5E8D4,stroke:#82B366,stroke-width:2px;
    classDef engine fill:#F8CECC,stroke:#B85450,stroke-width:2px;
    classDef dict fill:#DAE8FC,stroke:#6C8EBF,stroke-width:2px;
    classDef spec fill:#E1D5E7,stroke:#9673A6,stroke-width:2px;
    classDef persistence fill:#FFE6CC,stroke:#D79B00,stroke-width:2px;
    classDef logging fill:#FFF2CC,stroke:#D6B656,stroke-width:2px;
    classDef error fill:#F8CECC,stroke:#B85450,stroke-width:2px;
    classDef utility fill:#D7E9F7,stroke:#6A9FB5,stroke-width:2px;
    classDef config fill:#E2EFDA,stroke:#77A464,stroke-width:2px;

    %% Click Events
    click CG "https://github.com/quickfixgo/quickfix/tree/main/cmd/generate-fix"
    click DD "https://github.com/quickfixgo/quickfix/blob/main/datadictionary/datadictionary.go"
    click SPEC "https://github.com/quickfixgo/quickfix/tree/main/spec/"
    click CH "https://github.com/quickfixgo/quickfix/blob/main/connection.go"
    click SM "https://github.com/quickfixgo/quickfix/blob/main/session.go"
    click MP "https://github.com/quickfixgo/quickfix/blob/main/message.go"
    click PL "https://github.com/quickfixgo/quickfix/tree/main/store/"
    click LM "https://github.com/quickfixgo/quickfix/tree/main/log/"
    click EH "https://github.com/quickfixgo/quickfix/blob/main/errors.go"
    click IU "https://github.com/quickfixgo/quickfix/tree/main/internal/"
    click TC "https://github.com/quickfixgo/quickfix/tree/main/config/"
```
