# bhaptics/haptic-library architecture

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

- Interactive diagram: https://gitdiagram.com/bhaptics/haptic-library
- Repository: https://github.com/bhaptics/haptic-library

## Overview

##### Core Library Layer
- Sub-components:
- HapticManager
- ProjectModel
- WebSocket Client
- Timer/Utils

##### Integration Layers
- Unity Integration
- Unreal Integration
- C# Integration (WPF)

##### Hardware Communication Layer
- WebSocket connection between core library and player
- Supported haptic devices (Vest, Arms, Hands, etc.)

##### API Interface Layer
- Public API surface:
- Haptic Clip Management
- Device Status/Connection
- Playback Controls
- Event System

**[Applications/Games]**
- ↓
**[Integration Layers]**
- ↓
**[Haptic Library Core]**
- ↓
**[bHaptics Player]**
- ↓
**[Hardware Devices]**

##### Connection Types
- Double lines: Data flow

Key Elements to Highlight:

##### Data Flow
- How haptic feedback data flows from application through the system:
- Application → Integration Layer → Core Library → Player → Devices

##### Communication Protocols
- WebSocket connection between library and player
- Device communication protocols

##### Cross-Platform Support
- Platform-specific components
- Shared core functionality

##### Component Relationships
- Dependency management
- Initialization flow
- Event handling paths

Additional Notes:

##### Version Information
- Current version: 1.4.14
- Supported platforms
- Required dependencies

##### System Requirements
- BHaptics Player requirement
- OS compatibility
- Hardware dependencies

## Diagram (Mermaid)

```mermaid
graph TB
    %% Main Layers
    subgraph Applications
        Game["Games & Applications"]
    end

    subgraph IntegrationLayer
        Unity["Unity Integration"]:::integration
        Unreal["Unreal Integration"]:::integration
        CSharp["C# Integration (WPF)"]:::integration
    end

    subgraph CoreLibrary["Haptic Library Core (C++)"]
        HapticMgr["HapticManager"]:::core
        ProjModel["ProjectModel"]:::core
        WSClient["WebSocket Client"]:::core
        Utils["Timer/Utils"]:::core
        API["Public API Interface"]:::api
    end

    subgraph Communication
        Player["bHaptics Player"]:::hardware
    end

    subgraph Devices["Hardware Devices"]
        Vest["Tactsuit"]:::hardware
        Arms["Tactosy Arms"]:::hardware
        Hands["Tactal & Tactosy Hands"]:::hardware
    end

    %% Connections
    Game --> Unity & Unreal & CSharp
    Unity & Unreal & CSharp --> API
    API --> HapticMgr
    HapticMgr --> ProjModel
    HapticMgr --> WSClient
    HapticMgr --> Utils
    WSClient -.->|WebSocket| Player
    Player --> Vest & Arms & Hands

    %% Styling
    classDef core fill:#a2d2ff
    classDef integration fill:#95d5b2
    classDef hardware fill:#ffb347
    classDef api fill:#c8b6ff

    %% Click Events
    click HapticMgr "https://github.com/bhaptics/haptic-library/blob/master/src/hapticsManager.h"
    click ProjModel "https://github.com/bhaptics/haptic-library/blob/master/src/ProjectModel.h"
    click WSClient "https://github.com/bhaptics/haptic-library/blob/master/src/easywsclient.h"
    click Utils "https://github.com/bhaptics/haptic-library/blob/master/src/util.h"
    click API "https://github.com/bhaptics/haptic-library/blob/master/include/shared/HapticLibrary.h"
    click Unity "https://github.com/bhaptics/haptic-library/tree/master/samples/unity-plugin/Assets/Bhaptics/SDK/"
    click CSharp "https://github.com/bhaptics/haptic-library/tree/master/samples/csharp/src/Bhaptics.Tact/"

    %% Legend
    subgraph Legend
        L1["Core Components"]:::core
        L2["Integration Layers"]:::integration
        L3["Hardware Components"]:::hardware
        L4["API Interfaces"]:::api
        L5["--> Direct Dependency"]
        L6["-.-> Communication Channel"]
    end
```
