# dheera/rosboard architecture

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

- Interactive diagram: https://gitdiagram.com/dheera/rosboard
- Repository: https://github.com/dheera/rosboard

## Overview

##### Main Components
- ROSBoard Node: Represent the central ROS node (executable via “nodes/rosboard_node” and encapsulated by “rosboard/rosboard.py”). This node is responsible for launching the web server and bridging data from ROS topics.
- Web Client (Frontend): Represent the static HTML/CSS/JS content (found in “rosboard/html”) which includes:
- index.html for the main page.
- JavaScript libraries and viewers (under “rosboard/html/js” and “rosboard/html/js/viewers”) that render different types of visualizations (images, maps, plots, etc.).
- CSS and fonts that style and format the page.
- External Libraries & Dependencies: Note the use of Tornado, simplejpeg, psutil, Leaflet.js, Material Design Lite, jQuery, and more. These libraries underpin the functionality of both the web server and the client-side visualization components.
- Build/Configuration: Include ancillary files such as package.xml, CMakeLists.txt, setup.py, and launch files (under “launch”) that are used for building, running, or deploying the package as a ROS node.

##### Relationships and Data Flow
- Inside the node, show the separation between:
- The ROS communication layer (subscribers and message handling, involving modules like “rosboard/subscribers” and “serialization.py”) and
- The Webserver layer (Tornado handling HTTP and websocket connections).
- Optionally, include a configuration/launch component that denotes how the system is started. For example, include a “run” script and ROS launch files that initialize the node.

##### Architectural Patterns and Design Principles
- Separation of concerns: one part of the system is entirely dedicated to interacting with ROS (sensors/topics), and another part deals with serving a responsive web interface.
- Modularity and extensibility: a dedicated directory (“rosboard/html/js/viewers”) allows additional custom visualizers to be added easily.
- Point out the compatibility layer (“rospy2”) which uses a bridge pattern to support both ROS ecosystems without significant code divergence.
- Mention the importance of using a custom, lightweight websocket implementation instead of depending on external packages like rosbridge-suite, to ensure tighter control over security and resource usage.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Global Nodes
    A["ROS Core (ROS1/ROS2)"]:::ros
    B["ROSBoard Node"]:::backend
    A -->|"ROS_topics"| B

    %% Subgraph for ROS Communication Layer
    subgraph "ROS Communication Layer"
        direction TB
        CL1["Subscribers"]:::backend
        CL2["Compatibility Shim"]:::backend
        CL3["Message Serialization"]:::backend
    end

    %% Subgraph for Web Server & Websocket
    subgraph "Web Server & Websocket"
        direction TB
        WS1["Tornado Handlers"]:::backend
        WS2["Data Processing (Compression & cv_bridge)"]:::backend
    end

    %% Web Client
    D["Web Client (Frontend)"]:::frontend

    %% External Libraries and Build/Deployment
    E["External Libraries"]:::external
    F["Build & Deployment"]:::config

    %% Connections between components
    B -->|"initializes"| CL1
    B --> CL2
    B --> CL3
    CL1 -->|"feeds"| WS1
    CL2 --> WS1
    CL3 --> WS1
    WS1 --> WS2
    WS2 -->|"websocket_data"| D
    D ---|"utilizes"| E
    B ---|"built/deployed_via"| F

    %% Click Events for ROSBoard Node
    click B "https://github.com/dheera/rosboard/tree/main/nodes/rosboard_node"
    click B "https://github.com/dheera/rosboard/blob/main/rosboard/rosboard.py"

    %% Click Events for ROS Communication Layer
    click CL1 "https://github.com/dheera/rosboard/tree/main/rosboard/subscribers"
    click CL2 "https://github.com/dheera/rosboard/tree/main/rosboard/rospy2"
    click CL3 "https://github.com/dheera/rosboard/blob/main/rosboard/serialization.py"
    click CL3 "https://github.com/dheera/rosboard/blob/main/rosboard/message_serialization.py"

    %% Click Events for Web Server & Websocket
    click WS1 "https://github.com/dheera/rosboard/blob/main/rosboard/handlers.py"
    click WS2 "https://github.com/dheera/rosboard/blob/main/rosboard/compression.py"
    click WS2 "https://github.com/dheera/rosboard/blob/main/rosboard/cv_bridge.py"

    %% Click Events for Web Client (Frontend)
    click D "https://github.com/dheera/rosboard/blob/main/rosboard/html/index.html"
    click D "https://github.com/dheera/rosboard/tree/main/rosboard/html/js"
    click D "https://github.com/dheera/rosboard/tree/main/rosboard/html/js/viewers"
    click D "https://github.com/dheera/rosboard/tree/main/rosboard/html/css"
    click D "https://github.com/dheera/rosboard/tree/main/rosboard/html/fonts"

    %% Click Events for Build & Deployment
    click F "https://github.com/dheera/rosboard/blob/main/CMakeLists.txt"
    click F "https://github.com/dheera/rosboard/blob/main/package.xml"
    click F "https://github.com/dheera/rosboard/blob/main/setup.py"
    click F "https://github.com/dheera/rosboard/blob/main/setup.cfg"
    click F "https://github.com/dheera/rosboard/blob/main/launch/rosboard.launch"
    click F "https://github.com/dheera/rosboard/tree/main/run"

    %% Styles
    classDef ros fill:#c4f0c5,stroke:#333,stroke-width:2px,color:#000;
    classDef backend fill:#f9e79f,stroke:#333,stroke-width:2px,color:#000;
    classDef frontend fill:#aed6f1,stroke:#333,stroke-width:2px,color:#000;
    classDef external fill:#f5b7b1,stroke:#333,stroke-width:2px,color:#000;
    classDef config fill:#d7bde2,stroke:#333,stroke-width:2px,color:#000;
```
