How sotaaaaa/nest-quickfix works
Main components
• FIX Module Core: At the heart of the application is the FIXModule (as seen in the root, along with configuration files and module registration in the README). This is the entry point where configuration is provided (including TCP settings, authentication, and store options).
• Role-based Components:
– Acceptor: Located in src/acceptor, this handles incoming FIX connections. It is responsible for accepting, validating, and processing incoming messages.
– Initiator: Found under src/initiator, this deals with outbound FIX messages and connection initiation.
• Session Management: Under src/session, you have components that manage session state, configuration, and automatic reconnection. This is complemented by Redis‐based session storage (as configured under the “store” property).
• Message Processing Infrastructure:
– Message Parser & Protocol Handler: The src/protocol directory (with subfolders like messages, parser, flow, and validator) contains all logic for parsing incoming FIX messages, validating checksums, managing the message queue, and handling protocol-specific flows.
– Fields and Constants: The large “fields” folder (and associated types) represents the various FIX fields (such as MsgType, ClOrdID, etc.) which are used to build, inspect, and validate messages.
• Service Layer: In src/services, components like FixService and TradingService abstract the business logic for handling messages (e.g. sending new orders, processing cancellations, and sending reject messages).
• Common Utilities: The common directory includes items such as logging and error handling that are critical for debugging and resilience.
• Decorators and Event Handlers: The project uses TypeScript decorators (e.g., @OnLogon, @OnFixMessage, etc.) that allow users to tie FIX events to custom logic in controllers. This is an integral part of its event-driven architecture.
• External Integrations: Redis is used for session storage, and support for SSL/TLS in the TCP configuration indicates secure connection handling.
Relationships and interactions
• The FIXModule registers the overall system with configuration data and ties together the acceptor/initiator components.
• Incoming TCP connections (secured via TLS if enabled) enter through the Acceptor component, where the raw FIX messages are received.
• The Message Parser (in the protocol layer) takes over to validate, parse, and route messages based on FIX field values (such as MsgType).
• Once parsed, messages are handed off to the appropriate event handlers (using decorators like @OnFixMessage) in controllers or services.
• Session Management maintains the state of each connection, supports automatic message recovery, and integrates with Redis for persistent session storage.
• The Service Layer (e.g., TradingService) handles business logic like sending new orders, cancellations, and reject messages. It communicates back through the FixService to route messages to specific sessions or broadcast to rooms.
• Logging, error handling, and configuration utilities operate across these layers to maintain overall system integrity.
Architectural patterns/design principles
• Modular design: Clear separation into modules such as acceptor, initiator, protocol handlers, and session managers.
• Event-driven architecture: The use of decorators to map FIX events (logon, message, disconnection, etc.) to specific controller functions.
• Layered architecture: Separation between transport (TCP/SSL), protocol parsing/validation, business logic (services), and configuration.
• Abstraction of FIX fields and messages: Dedicated directories for FIX fields and constants ensure that protocol-specific elements are decoupled from core logic.
Relevant technologies
• NestJS (framework)
• TypeScript (language)
• Redis (for session storage)
• TCP with TLS support (for secure messaging)
• Decorators for event-driven handling (custom annotations like @OnLogon, etc.)