# stahk-collab/deribit_order_management architecture

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

- Interactive diagram: https://gitdiagram.com/stahk-collab/deribit_order_management
- Repository: https://github.com/stahk-collab/deribit_order_management

## Overview

##### Main Components

a) Client Application Layer:
- Main C++ application components:
- OrderManager (order_manager.h/cpp)
- WebSocketServer (websocket_server.h/cpp)
- Utils (utils.h/cpp)
- Configuration (config.h)

b) External Services Layer:
- Deribit API (Test Environment)
- Authentication Service
- Order Management Services
- Market Data Services

**[Client Application]**

- [Core Components]
- [Order Manager]
- [WebSocket Server]
- [Utils]

- [Configuration]
- [API Credentials]

- [External Interface]
- [HTTP/WebSocket Client]

- v
**[Deribit API Gateway]**

- [Authentication Service]

- [Order Services]
- Place Order
- Cancel Order
- Modify Order
- Get Positions

- [Market Data Services]
- Order Book

##### Component Relationships

- Data flow between OrderManager and WebSocket Server
- Authentication flow from client to Deribit API
- Order execution flow
- Market data flow
- Configuration dependencies

##### Specific Implementation Details

a) Client Components:
- OrderManager as the central component
- WebSocket Server handling real-time communications
- Utils providing support functions
- Config.h feeding credentials

b) API Integration:
- Six main API endpoints:
- Authentication
- Order
- Cancel Order
- Modify Order
- Get Order Book
- Get Positions

##### Technical Specifications

- C++ (11 or later)
- cURL dependency
- nlohmann/json library
- CMake build system
- vcpkg package manager

## Diagram (Mermaid)

```mermaid
graph TB
    %% Main Application Layer
    subgraph ClientApp["Client Application"]
        Main["Main Application"]
        OrderMgr["Order Manager"]
        WSServer["WebSocket Server"]
        Utils["Utilities"]
        Config["Configuration"]
    end

    %% Core Components Layer
    subgraph CoreComponents["Core Components"]
        OrderMgrImpl["Order Management Implementation"]
        WSServerImpl["WebSocket Server Implementation"]
        UtilsImpl["Utilities Implementation"]
    end

    %% External Interface Layer
    subgraph ExternalInterface["External Interface"]
        HTTPClient["HTTP/WebSocket Client"]
    end

    %% Deribit API Layer
    subgraph DeribitAPI["Deribit API Gateway"]
        Auth["Authentication Service"]
        
        subgraph OrderServices["Order Services"]
            PlaceOrder["Place Order"]
            CancelOrder["Cancel Order"]
            ModifyOrder["Modify Order"]
            GetPositions["Get Positions"]
        end
        
        subgraph MarketData["Market Data Services"]
            OrderBook["Order Book"]
        end
    end

    %% Relationships
    Main --> OrderMgr
    Main --> WSServer
    Main --> Config
    OrderMgr --> OrderMgrImpl
    WSServer --> WSServerImpl
    Utils --> UtilsImpl
    OrderMgrImpl --> HTTPClient
    WSServerImpl --> HTTPClient
    HTTPClient --> Auth
    Auth --> OrderServices
    Auth --> MarketData

    %% Component Mappings
    click Main "https://github.com/StaHk-collab/deribit_order_management/blob/main/src/main.cpp"
    click OrderMgr "https://github.com/StaHk-collab/deribit_order_management/blob/main/include/order_manager.h"
    click OrderMgrImpl "https://github.com/StaHk-collab/deribit_order_management/blob/main/src/order_manager.cpp"
    click WSServer "https://github.com/StaHk-collab/deribit_order_management/blob/main/include/websocket_server.h"
    click WSServerImpl "https://github.com/StaHk-collab/deribit_order_management/blob/main/src/websocket_server.cpp"
    click Utils "https://github.com/StaHk-collab/deribit_order_management/blob/main/include/utils.h"
    click UtilsImpl "https://github.com/StaHk-collab/deribit_order_management/blob/main/src/utils.cpp"
    click Config "https://github.com/StaHk-collab/deribit_order_management/blob/main/include/config.h"

    %% Styling
    classDef default fill:#f9f9f9,stroke:#333,stroke-width:1px
    classDef main fill:#d4e6f1,stroke:#2874a6
    classDef core fill:#d5f5e3,stroke:#196f3d
    classDef external fill:#fdebd0,stroke:#d35400
    classDef api fill:#ebdef0,stroke:#6c3483
    classDef config fill:#f2f4f4,stroke:#566573

    class Main,OrderMgr,WSServer,Utils,Config main
    class OrderMgrImpl,WSServerImpl,UtilsImpl core
    class HTTPClient external
    class Auth,PlaceOrder,CancelOrder,ModifyOrder,GetPositions,OrderBook api
    class Config config

    %% Legend
    subgraph Legend
        Client["Client Components"]:::main
        CoreComp["Core Components"]:::core
        ExtInt["External Interface"]:::external
        ApiServ["API Services"]:::api
        Conf["Configuration"]:::config
    end
```
