# santif/ex_fix architecture

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

- Interactive diagram: https://gitdiagram.com/santif/ex_fix
- Repository: https://github.com/santif/ex_fix

## Overview

##### Main Components

a. Core FIX Engine Components:
- Session Management Layer
- Message Processing Layer
- Protocol Handling Layer
- Dictionary Management
- Transport Layer

b. External Interfaces:
- FIX Client Applications
- FIX Counterparties (Sell-side systems)
- SSL/TCP Connection Layer

**[Application Layer]**

**[Session Layer]**

**[Message Processing Layer]**

**[Transport Layer]**

##### Component Details

a. Session Management (Primary Focus):
- It to multiple Session Workers
- Session Supervisor hierarchy
- Session Timer component

b. Message Processing:
- Parser and Serializer components
- Dictionary component
- Message flow (InMessage and OutMessage)

c. Connection Handling:
- SSL/TCP transport layer
- Reconnection logic

##### Specific Implementation Elements

- ExFix.Session
- ExFix.SessionWorker
- ExFix.SessionRegistry
- ExFix.Parser
- ExFix.Serializer
- ExFix.Dictionary

##### Flow Directions

- Incoming messages: bottom-to-top
- Session management: bi-directional

##### Implementation Details

Notes about:
- FIXT.1.1 protocol support
- Session validation points
- Auto-reconnection mechanism
- Message validation steps

##### Extension points

Remember to maintain a balance between showing enough detail to understand the system while keeping it clean and readable. Focus on the session initiator functionality since that's the current implementation scope.

- How messages flow through the system
- Where validation occurs
- How sessions are managed
- How the two-phase parse optimization works
- Where to add new features or modifications

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Application Layer"
        Client["Client Application"]
        SessionHandler["Session Handler"]:::handler
        SessionConfig["Session Config"]:::config
    end

    subgraph "Session Management Layer"
        SessionSup["Session Supervisor"]:::supervisor
        SessionRegistry["Session Registry"]:::registry
        SessionWorker["Session Worker"]:::worker
        Session["Session Core"]:::session
        SessionTimer["Session Timer"]:::timer
    end

    subgraph "Message Processing Layer"
        Parser["Parser"]:::processor
        Serializer["Serializer"]:::processor
        InMessage["Incoming Messages"]:::message
        OutMessage["Outgoing Messages"]:::message
        Dictionary["Dictionary"]:::dict
        DefaultDict["Default Dictionary"]:::dict
    end

    subgraph "Transport Layer"
        SSL["SSL/TCP Connection"]:::transport
    end

    %% Relationships
    Client --> SessionHandler
    SessionHandler --> SessionConfig
    SessionConfig --> SessionSup
    SessionSup --> SessionRegistry
    SessionRegistry --> SessionWorker
    SessionWorker --> Session
    Session --> SessionTimer
    Session --> Parser
    Session --> Serializer
    Parser --> InMessage
    Serializer --> OutMessage
    Parser --> Dictionary
    Serializer --> Dictionary
    Dictionary --> DefaultDict
    Session --> SSL

    %% Styles
    classDef handler fill:#90CAF9
    classDef config fill:#90CAF9
    classDef supervisor fill:#1976D2
    classDef registry fill:#1976D2
    classDef worker fill:#1976D2
    classDef session fill:#1976D2
    classDef timer fill:#1976D2
    classDef processor fill:#FDD835
    classDef message fill:#FDD835
    classDef dict fill:#FDD835
    classDef transport fill:#9E9E9E

    %% Click Events
    click SessionHandler "https://github.com/santif/ex_fix/blob/master/lib/ex_fix/session_handler.ex"
    click SessionConfig "https://github.com/santif/ex_fix/blob/master/lib/ex_fix/session_config.ex"
    click SessionSup "https://github.com/santif/ex_fix/blob/master/lib/ex_fix/session_sup.ex"
    click SessionRegistry "https://github.com/santif/ex_fix/blob/master/lib/ex_fix/session_registry.ex"
    click SessionWorker "https://github.com/santif/ex_fix/blob/master/lib/ex_fix/session_worker.ex"
    click Session "https://github.com/santif/ex_fix/blob/master/lib/ex_fix/session.ex"
    click SessionTimer "https://github.com/santif/ex_fix/blob/master/lib/ex_fix/session_timer.ex"
    click Parser "https://github.com/santif/ex_fix/blob/master/lib/ex_fix/parser.ex"
    click Serializer "https://github.com/santif/ex_fix/blob/master/lib/ex_fix/serializer.ex"
    click InMessage "https://github.com/santif/ex_fix/blob/master/lib/ex_fix/in_message.ex"
    click OutMessage "https://github.com/santif/ex_fix/blob/master/lib/ex_fix/out_message.ex"
    click Dictionary "https://github.com/santif/ex_fix/blob/master/lib/ex_fix/dictionary.ex"
    click DefaultDict "https://github.com/santif/ex_fix/blob/master/lib/ex_fix/default_dictionary.ex"
```
