# romerik/voice-control-unitree-go2 architecture

> Architecture diagram of the GitHub repository romerik/voice-control-unitree-go2, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/romerik/voice-control-unitree-go2
- Repository: https://github.com/romerik/voice-control-unitree-go2

## Overview

##### Project type and purpose
- This is an open-source Python application that provides a realtime, multimodal “copilot” experience using Chainlit.
- Key features:
- Real-time Python client for the OpenAI realtime API
- Multimodal I/O: speech and text in parallel
- Tool-calling framework for executing tasks
- Gesture control integration (e.g., Unitree Go2 robot)
- Internationalized UI with Chainlit translations

##### File structure
- Top-level files:
- app.py / main.py / main_app.py – entry points for different modes (Chainlit UI, CLI, gesture launcher)
- gesture-receiver.py, launch-gesture-control.py – modules to capture and forward gesture events
- robot_control.py – interfaces to control the Unitree Go2 robot
- realtime/ – contains realtime API client wrappers and custom tool definitions
- .chainlit/ – Chainlit configuration (config.toml) and translations for UI
- requirements.txt – lists dependencies (openai-realtime, chainlit, etc.)
- Patterns:
- Modular separation: UI (app.py), API layer (realtime/), tool layer (realtime/tools.py), hardware layer (robot_control.py and gesture modules)
- Configurations for environment (.env.example) and Chainlit UI

##### README for additional insights
- Emphasizes realtime API, multimodal I/O, tool calling, visual presence cues
- Mentions Chainlit cookbook context

##### Final reminder
- Essential interactions and data flows without overcomplicating.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% User I/O Layer
    subgraph "User I/O" 
        direction TB
        MicCamera["Microphone & Camera"]:::hardware
        TextInput["Text Input (Browser)"]:::frontend
    end

    %% Frontend Layer
    subgraph "Chainlit Frontend"
        direction TB
        ChainlitFrontend["Web UI with i18n"]:::frontend
    end

    %% CLI Entry
    CLI["CLI Entry Point"]:::backend

    %% Backend Layer
    subgraph "Chainlit Backend"
        direction TB
        BackendOrchestrator["Backend Orchestrator"]:::backend
        RealtimeClient["Realtime API Client"]:::api
        ToolDefinitions["Tool Definitions"]:::api
    end

    %% Gesture Control Layer
    subgraph "Gesture Control Subsystem"
        direction TB
        GestureReceiver["Gesture Receiver"]:::hardware
        GestureLauncher["Gesture Launcher"]:::hardware
    end

    %% Robot Control
    RobotController["Robot Controller"]:::hardware

    %% External Services & Config
    OpenAI["OpenAI Realtime API"]:::external
    subgraph "Configuration"
        direction TB
        EnvExample["Environment Variables (.env.example)"]:::config
        ChainlitConfig["Chainlit Config & Translations"]:::config
        Requirements["Dependency List (requirements.txt)"]:::config
    end

    %% Data Flows
    MicCamera -->|"audio/gesture events"| ChainlitFrontend
    TextInput -->|"text events"| ChainlitFrontend
    ChainlitFrontend -->|"UI events"| BackendOrchestrator
    CLI -->|"CLI commands"| BackendOrchestrator

    BackendOrchestrator -->|"stream request"| RealtimeClient
    RealtimeClient -->|"stream response"| BackendOrchestrator
    BackendOrchestrator -->|"invoke tools"| ToolDefinitions
    ToolDefinitions -->|"results"| BackendOrchestrator

    GestureReceiver -->|"gesture data"| BackendOrchestrator
    GestureLauncher -->|“launch events”| GestureReceiver

    BackendOrchestrator -->|"robot commands"| RobotController

    BackendOrchestrator -->|"API calls"| OpenAI
    OpenAI -->|"responses"| BackendOrchestrator

    %% Config Dependencies
    EnvExample -.-> BackendOrchestrator
    ChainlitConfig -.-> ChainlitFrontend
    Requirements -.-> BackendOrchestrator
    Requirements -.-> ChainlitFrontend

    %% Click Events
    click ChainlitFrontend "https://github.com/romerik/voice-control-unitree-go2/blob/main/app.py"
    click BackendOrchestrator "https://github.com/romerik/voice-control-unitree-go2/blob/main/main_app.py"
    click CLI "https://github.com/romerik/voice-control-unitree-go2/blob/main/main.py"
    click GestureReceiver "https://github.com/romerik/voice-control-unitree-go2/blob/main/gesture-receiver.py"
    click GestureLauncher "https://github.com/romerik/voice-control-unitree-go2/blob/main/launch-gesture-control.py"
    click RobotController "https://github.com/romerik/voice-control-unitree-go2/blob/main/robot_control.py"
    click RealtimeClient "https://github.com/romerik/voice-control-unitree-go2/blob/main/realtime/__init__.py"
    click ToolDefinitions "https://github.com/romerik/voice-control-unitree-go2/blob/main/realtime/tools.py"
    click ChainlitConfig "https://github.com/romerik/voice-control-unitree-go2/blob/main/.chainlit/config.toml"
    click ChainlitConfig "https://github.com/romerik/voice-control-unitree-go2/tree/main/.chainlit/translations/"
    click EnvExample "https://github.com/romerik/voice-control-unitree-go2/blob/main/.env.example"
    click Requirements "https://github.com/romerik/voice-control-unitree-go2/blob/main/requirements.txt"

    %% Styles
    classDef frontend fill:#E3F2FD,stroke:#1976D2,color:#0D47A1;
    classDef backend fill:#F3E5F5,stroke:#8E24AA,color:#4A148C;
    classDef api fill:#E8F5E9,stroke:#43A047,color:#1B5E20;
    classDef hardware fill:#FFF3E0,stroke:#FB8C00,color:#E65100;
    classDef external fill:#E0F7FA,stroke:#00ACC1,color:#006064,stroke-dasharray: 5 5;
    classDef config fill:#F5F5F5,stroke:#9E9E9E,color:#424242,stroke-dasharray: 2 2;
```
