# 2bbb/ofxpubsubosc architecture

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

- Interactive diagram: https://gitdiagram.com/2bbb/ofxpubsubosc
- Repository: https://github.com/2bbb/ofxpubsubosc

## Overview

- Core Addon Library – the heart of ofxPubSubOsc. Inside the “src” directory, you have key files such as “ofxOscPublisher.h”, “ofxOscSubscriber.h”, and the extended messaging classes (e.g., “ofxOscMessageEx.h”, plus other utility headers).
- Publisher Module – implement publishing logic and data binding for OSC messages (see files in “src/details/Publisher”). This module uses the OSC system to push messages to a network endpoint.
- Subscriber Module – handles subscribing logic, message reception, callback handling, and data binding (located in “src/details/Subscriber”).
- Examples/Demo Applications – several sample projects (organized in directories beginning with “01_”, “02_”, “03_”) that demonstrate both basic and advanced usage of the library on different platforms (Xcode projects, Visual Studio projects, makefiles, etc.).
- External Dependency – external libraries that the core addon depends on (e.g., the “ofxOsc” library which is a part of openFrameworks and provides the lower-level OSC communication).

##### Relationships and interactions between components
- The sample applications interact with the Core Addon Library by calling its API (e.g., ofxPublishOsc, ofxSubscribeOsc, and ofxRegisterPublishingOsc).
- Inside the Core Library, the Publisher and Subscriber modules are logically separate but coexist as part of the publish/subscribe architecture. Publisher components send OSC messages to a specified IP/port, while Subscriber components listen on a port for specific address patterns.
- Example Applications → use the API (calls to functions) of the Core Library.
- Publisher Module → sends OSC messages out to an OSC Network (represented as an external “OSC Network / Target Device” entity).
- OSC Network → may deliver messages back to Subscriber Module if the target is a consumer of the published events.
- Additionally, callbacks within the Subscriber Module relay received messages back to the application or registered callback functions.

##### Architectural patterns/design principles
- Publish/Subscribe Pattern – clearly indicate that the core design leverages a loosely-coupled callback mechanism for OSC messaging.
- Modularity – separate examples (client-side demonstration apps) from the core implementation.
- Extendibility – note that there are “register” functions and support for different data types (arithmetic, strings, openFrameworks types, and callbacks), implying an extensible design.

##### Detail the technologies, frameworks, and libraries involved
- openFrameworks – the addon depends on it, and the examples are built as openFrameworks applications.
- ofxOsc – an OSC library serving as the base for OSC communications.
- Build Tools – Xcode and Visual Studio projects, as well as makefiles used for compiling the various example applications.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Example Applications"
        E1["01_1_ofxPublishOscSimpleExample"]:::example
        E2["01_2_ofxSubscribeOscSimpleExample"]:::example
        E3["02_1_ofxOscPublisherExample"]:::example
        E4["02_2_ofxOscSubscriberExample"]:::example
        E5["03_ofxOscMessageExExample"]:::example
    end

    CA["Core Addon Library"]:::core
    PM["Publisher Module"]:::publisher
    SM["Subscriber Module"]:::subscriber
    ON["OSC Network/Target Device"]:::network
    ED["ofxOsc (openFrameworks)"]:::external

    %% Connections from Example Applications to Core Addon API
    E1 -->|"calls_API"| CA
    E2 -->|"calls_API"| CA
    E3 -->|"calls_API"| CA
    E4 -->|"calls_API"| CA
    E5 -->|"calls_API"| CA

    %% Core Addon contains Publisher and Subscriber Modules
    CA -->|"contains"| PM
    CA -->|"contains"| SM

    %% Publisher Module sends OSC messages to Network
    PM -->|"sends_OSC"| ON

    %% OSC Network delivers messages to Subscriber Module
    ON -->|"receives_OSC"| SM

    %% Subscriber Module triggers callbacks back to Example Applications
    SM -->|"callbacks"| E1
    SM -->|"callbacks"| E2
    SM -->|"callbacks"| E3
    SM -->|"callbacks"| E4
    SM -->|"callbacks"| E5

    %% Core dependency on external ofxOsc library (openFrameworks)
    CA -->|"depends_on"| ED

    %% Styles
    classDef core fill:#E0BBE4,stroke:#4B0082,stroke-width:2px;
    classDef publisher fill:#ADD8E6,stroke:#0000FF,stroke-width:2px;
    classDef subscriber fill:#90EE90,stroke:#008000,stroke-width:2px;
    classDef example fill:#FFFACD,stroke:#DAA520,stroke-width:2px;
    classDef network fill:#FFB347,stroke:#FF8C00,stroke-width:2px;
    classDef external fill:#FFD1DC,stroke:#FF69B4,stroke-width:2px;

    %% Click Events
    click CA "https://github.com/2bbb/ofxpubsubosc/tree/master/src"
    click PM "https://github.com/2bbb/ofxpubsubosc/tree/master/src/details/Publisher"
    click SM "https://github.com/2bbb/ofxpubsubosc/tree/master/src/details/Subscriber"
    click E1 "https://github.com/2bbb/ofxpubsubosc/tree/master/01_1_ofxPublishOscSimpleExample"
    click E2 "https://github.com/2bbb/ofxpubsubosc/tree/master/01_2_ofxSubscribeOscSimpleExample"
    click E3 "https://github.com/2bbb/ofxpubsubosc/tree/master/02_1_ofxOscPublisherExample"
    click E4 "https://github.com/2bbb/ofxpubsubosc/tree/master/02_2_ofxOscSubscriberExample"
    click E5 "https://github.com/2bbb/ofxpubsubosc/tree/master/03_ofxOscMessageExExample"
```
