# nasa-jpl/rosa architecture

> Architecture diagram of the GitHub repository nasa-jpl/rosa, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nasa-jpl/rosa
- Repository: https://github.com/nasa-jpl/rosa

## Overview

##### Main Components

a) Core ROSA Framework:
- Main ROSA class (from src/rosa/rosa.py) as the central component
- Prompts system (src/rosa/prompts.py) connected to the main class

b) Tools Layer:
- ROS1 tools (ros1.py)
- ROS2 tools (ros2.py)
- Calculation tools (calculation.py)
- System tools (system.py)
- Logging tools (log.py)

c) External Dependencies:
- LangChain framework integration
- ROS System (both ROS1 and ROS2)
- LLM Interface

d) Demo Implementation:
- TurtleAgent as a separate component showing implementation example

##### Specific Design Elements

Use the following visual elements:
- Rectangle with rounded corners for the ROSA Core
- Hexagons for the Tools Layer components

##### Important Architectural Patterns to Highlight

- Plugin Architecture: Show how tools can be added/extended
- Bridge Pattern: Demonstrate ROS1/ROS2 compatibility
- Command Pattern: Illustrate natural language to action flow

##### Additional Details

Elements:
- Version compatibility badges (ROS1 Noetic, ROS2 Humble/Iron/Jazzy)
- Data flow indicators showing natural language input → processing → robot actions
- Extension points for custom implementations
- Testing framework integration

- Input Layer (Natural Language Processing)
- Core Processing Layer (ROSA Framework)
- Tools and Integration Layer
- Output Layer (Robot Control)

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Input Layer"
        NLP[Natural Language Input]
        LLM[LLM Interface]:::llm
    end

    subgraph "Core Processing Layer"
        ROSA[ROSA Core]:::core
        click ROSA "https://github.com/nasa-jpl/rosa/blob/main/src/rosa/rosa.py"
        PROMPTS[Prompts System]:::core
        click PROMPTS "https://github.com/nasa-jpl/rosa/blob/main/src/rosa/prompts.py"
        LANGCHAIN[LangChain Framework]:::external
    end

    subgraph "Tools Layer"
        ROS1[ROS1 Tools]:::tools
        click ROS1 "https://github.com/nasa-jpl/rosa/blob/main/src/rosa/tools/ros1.py"
        ROS2[ROS2 Tools]:::tools
        click ROS2 "https://github.com/nasa-jpl/rosa/blob/main/src/rosa/tools/ros2.py"
        CALC[Calculation Tools]:::tools
        click CALC "https://github.com/nasa-jpl/rosa/blob/main/src/rosa/tools/calculation.py"
        SYS[System Tools]:::tools
        click SYS "https://github.com/nasa-jpl/rosa/blob/main/src/rosa/tools/system.py"
        LOG[Logging Tools]:::tools
        click LOG "https://github.com/nasa-jpl/rosa/blob/main/src/rosa/tools/log.py"
    end

    subgraph "Demo Implementation"
        TURTLE[TurtleAgent Core]:::demo
        click TURTLE "https://github.com/nasa-jpl/rosa/blob/main/src/turtle_agent/scripts/turtle_agent.py"
        TURTLE_TOOLS[TurtleAgent Tools]:::demo
        click TURTLE_TOOLS "https://github.com/nasa-jpl/rosa/blob/main/src/turtle_agent/scripts/tools/turtle.py"
        TURTLE_PROMPTS[TurtleAgent Prompts]:::demo
        click TURTLE_PROMPTS "https://github.com/nasa-jpl/rosa/blob/main/src/turtle_agent/scripts/prompts.py"
        TURTLE_LLM[TurtleAgent LLM]:::demo
        click TURTLE_LLM "https://github.com/nasa-jpl/rosa/blob/main/src/turtle_agent/scripts/llm.py"
    end

    subgraph "Testing Framework"
        TEST_CORE[Core Tests]:::test
        click TEST_CORE "https://github.com/nasa-jpl/rosa/blob/main/tests/rosa/test_rosa.py"
        TEST_PROMPTS[Prompts Tests]:::test
        click TEST_PROMPTS "https://github.com/nasa-jpl/rosa/blob/main/tests/rosa/test_prompts.py"
        TEST_TOOLS[Tools Tests]:::test
        click TEST_TOOLS "https://github.com/nasa-jpl/rosa/tree/main/tests/rosa/tools"
    end

    subgraph "ROS System"
        ROS1_SYS[ROS1 Noetic]:::ros
        ROS2_SYS[ROS2 Humble/Iron/Jazzy]:::ros
    end

    %% Connections
    NLP --> LLM
    LLM <--> ROSA
    ROSA <--> PROMPTS
    ROSA <--> LANGCHAIN
    
    ROSA --> ROS1
    ROSA --> ROS2
    ROSA --> CALC
    ROSA --> SYS
    ROSA --> LOG
    
    ROS1 --> ROS1_SYS
    ROS2 --> ROS2_SYS
    
    ROSA -.-> TURTLE
    TURTLE --> TURTLE_TOOLS
    TURTLE --> TURTLE_PROMPTS
    TURTLE --> TURTLE_LLM
    
    TEST_CORE -.-> ROSA
    TEST_PROMPTS -.-> PROMPTS
    TEST_TOOLS -.-> ROS1
    TEST_TOOLS -.-> ROS2
    TEST_TOOLS -.-> CALC
    TEST_TOOLS -.-> SYS
    TEST_TOOLS -.-> LOG

    %% Styles
    classDef core fill:#3498db,stroke:#2980b9,color:white
    classDef tools fill:#2ecc71,stroke:#27ae60,color:white
    classDef external fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef demo fill:#e67e22,stroke:#d35400,color:white
    classDef llm fill:#9b59b6,stroke:#8e44ad,color:white
    classDef ros fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef test fill:#e74c3c,stroke:#c0392b,color:white

    %% Legend
    subgraph Legend
        L_CORE[Core Components]:::core
        L_TOOLS[Tools]:::tools
        L_EXT[External Systems]:::external
        L_DEMO[Demo Implementation]:::demo
        L_LLM[LLM/AI Components]:::llm
        L_TEST[Testing Framework]:::test
    end
```
