# foxglove/foxglove-sdk architecture

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

- Interactive diagram: https://gitdiagram.com/foxglove/foxglove-sdk
- Repository: https://github.com/foxglove/foxglove-sdk

## Overview

##### Project Type & Purpose
- The project is an open-source SDK designed for logging and visualizing multimodal data.
- Its core is implemented in Rust, with language-specific bindings and packages available for Python and (upcoming) C, C++, and ROS integrations.
- It provides support for live data visualizations via a WebSocket protocol and logging data to MCAP files.
- Multiple schema definitions (in Flatbuffer, Protobuf, JSON Schema, OMG IDL, and ROS message formats) are part of the project, ensuring wide compatibility.

##### File Structure to Identify Main Components
- Language-Specific Roots:
– “rust/foxglove”: This directory forms the core SDK implementation (modules for channels, schemas, mcap writing, websockets, etc.).
– “python/foxglove-sdk”: The Python binding/wrapper that gives Python users access to the Rust SDK’s capabilities.
– “cpp” and “c”: These directories provide C/C++ examples and tools (including build scripts, examples like quickstart and ws-server) for integration with native applications.
– “ros/foxglove_msgs”: Contains ROS message definitions to integrate with ROS ecosystems.
– “typescript/schemas”: Provides schema definitions for TypeScript projects.
- Schema Definitions:
– “schemas”: The raw schema definitions are provided for various serialization formats—important for visualizing supported data structures.
- Supporting and Utility Directories:
– “.github”, “scripts”, and configuration files support CI/CD, automated tests, and schema generation.

a. Core SDK Layer (Rust):
– Represent the Rust “foxglove” core as the heart of the system.
– Within it, illustrate key modules such as:
- Channel & Data Flow Management
- MCAP Writer (for logging data)
- WebSocket Communication (live data visualization)
- Schema Management (handling multiple schema types)
b. Language Bindings & User Interfaces:
– Python Package:
- Python “foxglove-sdk” wrapper that exposes the core functionalities.
– C/C++ Components:
- “c” and “cpp” directories as example integrations or additional interface layers.
– ROS Integration:
– TypeScript Package:
- “@foxglove/schemas” package that enables TypeScript projects to use the predefined schema definitions.
c. Data Flow & External Interactions:
– Show data logging paths where data can be written to MCAP files.
– Mark external dependencies/libraries (e.g., Flatbuffer, Protobuf, JSON Schema processing libraries) that support serialization and schema conversion.
d. Architectural Patterns and Design Principles:
– Highlight the separation of core functionality (in Rust) from various binding layers.
– Indicate modularity in schema support (different directories for Flatbuffer, JSON, OMG IDL, etc.).
– Emphasize test and example components to illustrate extensibility and validation of the SDK.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Core SDK Layer (Rust)
    subgraph "Core SDK Layer (Rust)"
        Core["Core SDK (Rust)"]:::core
        Channel["Channel & Data Flow Management"]:::module
        MCAP["MCAP Writer (Logging to MCAP Files)"]:::module
        WS["WebSocket Communication Service"]:::module
        SchemaMgmt["Schema Management"]:::module
    end

    %% Language Bindings & Interfaces
    subgraph "Language Bindings & Interfaces"
        Python["Python Binding"]:::binding
        subgraph "C/C++ Integration"
            CExample["C Example"]:::binding
            CPPExample["C++ Example"]:::binding
        end
        ROS["ROS Integration (Message Definitions)"]:::binding
        TS["TypeScript Schema Definitions"]:::binding
    end

    %% Raw Schema Definitions Module
    RawSchemas["Raw Schema Definitions"]:::schema

    %% External Systems
    ExternalVis["Foxglove Visualization Client"]:::external
    MCAPFiles["MCAP Files"]:::external

    %% Connections within Core SDK Layer
    Core -->|"manages"| Channel
    Core -->|"logs with"| MCAP
    Core -->|"streams via"| WS
    Core -->|"handles"| SchemaMgmt

    %% Data Flow to External Systems
    WS -->|"live_stream"| ExternalVis
    MCAP -->|"log_data"| MCAPFiles

    %% Schema Management loads raw schemas
    RawSchemas -->|"loaded_by"| SchemaMgmt

    %% Core SDK exposes capabilities to language bindings
    Core -->|"API"| Python
    Core -->|"API"| CExample
    Core -->|"API"| CPPExample
    Core -->|"API"| ROS
    Core -->|"API"| TS

    %% Styling
    classDef core fill:#F4A460,stroke:#000,stroke-width:2px;
    classDef module fill:#FFE4B5,stroke:#000,stroke-width:2px;
    classDef binding fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef external fill:#98FB98,stroke:#000,stroke-width:2px;
    classDef schema fill:#DDA0DD,stroke:#000,stroke-width:2px;

    %% Click Events
    click Core "https://github.com/foxglove/foxglove-sdk/tree/main/rust/foxglove"
    click Python "https://github.com/foxglove/foxglove-sdk/tree/main/python/foxglove-sdk"
    click CExample "https://github.com/foxglove/foxglove-sdk/tree/main/c"
    click CPPExample "https://github.com/foxglove/foxglove-sdk/tree/main/cpp"
    click ROS "https://github.com/foxglove/foxglove-sdk/tree/main/ros/foxglove_msgs"
    click TS "https://github.com/foxglove/foxglove-sdk/tree/main/typescript/schemas"
    click RawSchemas "https://github.com/foxglove/foxglove-sdk/tree/main/schemas"
```
