# viamrobotics/rdk architecture

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

- Interactive diagram: https://gitdiagram.com/viamrobotics/rdk
- Repository: https://github.com/viamrobotics/rdk

## Overview

##### Main Components
- Robot Server/Core: At the heart of the system, you have the server application (seen in directories such as “app”, “web/cmd/server”, and the “robot” package) that coordinates robot operations.
- Components/Drivers: The “components” directory contains numerous modules for hardware devices (e.g., arm, camera, board, motor, sensor, etc.) – these serve as the hardware abstraction layer. They register as resources and handle interactions with physical devices.
- Services Layer: The “services” directory (with subfolders like “motion”, “navigation”, “vision”, “datamanager”, “discovery”, and others) provides domain-specific functionalities. This layer abstracts control loops, planning, communication with sensors, and robot-specific tasks.
- Communication Infrastructure: The “grpc” package and other networking code facilitate communication. They provide APIs (using Protocol Buffers/gRPC) for clients and external SDKs – these are your service interfaces.
- Client SDKs and CLI: Separate directories “cli” and “robot/client” indicate the presence of client-side interfaces. They allow external applications (in Go, Python, Typescript, C++, Rust) to interact with the robot through APIs.
- Configuration and Logging: The “config” and “logging” layers manage robot configuration data, dynamic reconfiguration, and logging. They are cross-cutting concerns present in many subsystems.
- Cloud and Integration: The “cloud” folder represents cloud connectivity and integration capabilities. This, along with the API documentation and SDK references, bridges the local robot operating system with remote interfaces.

##### Relationships and Interactions
– The Component Modules (hardware drivers and abstraction, e.g., camera, arm, motor)
– Various Service Modules (motion planning, navigation, vision, data management, etc.)
– The Configuration and Logging Frameworks (for dynamic resource setup and debugging).
- The Communication Layer (gRPC and APIs) forms external interfaces:
– Client SDKs (Go, Python, etc.) and CLI applications send requests to the server.
– These client interactions pass through the gRPC layer.

##### Architectural Patterns to Highlight
- Modularity: Emphasize how each hardware component or service (organized as separate directories) is developed as an independent module. Show a “registry” concept used by the resource manager (found in “components/register”, “services/register”).
- Abstraction & Plugins: The system appears to use plugin-like design patterns for the various components, enabling easy extensibility and replacement.
- Client–Server / API Gateway: Illustrate that client requests (via CLI or SDKs) are handled by the server that dispatches commands to lower-level modules.
- Layered Architecture: Separate the system into layers – UI/Client, API/Communication, Core/Resource Manager, Services, and Hardware Abstractions.

##### Key Technologies and Frameworks
- Languages & Tools: The project is primarily in Go (as indicated by the .go files, go.mod, and test files). It includes Makefiles and CI configurations (.github/workflows, etc.).
- APIs: gRPC is used (the grpc directory) so include a block for “API Interface (gRPC/Protobuf)” that communicates with external clients.
- Cloud Integration: Mark the cloud module and related configurations (e.g., “cloud/cloud.go”) that facilitate remote control and monitoring via the cloud.
- SDKs & Extensibility: Mention that there are Go, Python, Typescript, C++, and Rust SDKs which connect to the server API.

## Diagram (Mermaid)

```mermaid
flowchart TD

    %% Client/Interface Layer
    subgraph "Client/Interface Layer"
        CI("Client SDKs/CLI"):::client
    end

    %% API/Communication Layer
    subgraph "API/Communication Layer"
        COM("API Interface (gRPC)"):::api
    end

    %% Core/Resource Manager Layer
    subgraph "Core/Resource Manager"
        RS("Robot Server/Core"):::core
        REG("Resource Registry"):::config
    end

    %% Service Layer
    subgraph "Service Layer"
        SERV("Service Modules"):::service
    end

    %% Hardware Abstraction Layer
    subgraph "Hardware Abstraction Layer"
        HW("Hardware Components"):::hardware
    end

    %% Configuration & Cloud Layer
    subgraph "Configuration & Cloud"
        CONF("Configuration & Logging"):::config
        CLOUD("Cloud Integration"):::cloud
    end

    %% Connections between layers
    CI -->|"sends_request"| COM
    COM -->|"api_call"| RS
    RS -->|"dispatch_command"| SERV
    RS -->|"control_command"| HW
    RS -->|"config_update"| CONF
    REG -->|"registers"| HW
    REG -->|"registers"| SERV
    RS -->|"status_update"| COM
    COM -->|"response"| CI
    CLOUD -->|"sync_config"| CONF

    %% Styling
    classDef core fill:#c0aede,stroke:#333,stroke-width:2px;
    classDef hardware fill:#b3d9ff,stroke:#000,stroke-width:2px;
    classDef service fill:#c1fcd3,stroke:#000,stroke-width:2px;
    classDef api fill:#ffd699,stroke:#000,stroke-width:2px;
    classDef client fill:#ffb3b3,stroke:#000,stroke-width:2px;
    classDef config fill:#e6e6e6,stroke:#000,stroke-width:2px;
    classDef cloud fill:#d9b3ff,stroke:#000,stroke-width:2px;

    %% Click Events
    click RS "https://github.com/viamrobotics/rdk/tree/main/app"
    click RS "https://github.com/viamrobotics/rdk/tree/main/web/cmd/server"
    click RS "https://github.com/viamrobotics/rdk/blob/main/robot/server/server.go"
    click RS "https://github.com/viamrobotics/rdk/blob/main/robot/robot.go"
    click HW "https://github.com/viamrobotics/rdk/tree/main/components"
    click SERV "https://github.com/viamrobotics/rdk/tree/main/services"
    click COM "https://github.com/viamrobotics/rdk/tree/main/grpc"
    click CI "https://github.com/viamrobotics/rdk/tree/main/cli"
    click CI "https://github.com/viamrobotics/rdk/blob/main/robot/client/client.go"
    click CONF "https://github.com/viamrobotics/rdk/blob/main/config/config.go"
    click CONF "https://github.com/viamrobotics/rdk/blob/main/logging/logger.go"
    click CLOUD "https://github.com/viamrobotics/rdk/blob/main/cloud/cloud.go"
```
