# bayllama/marinabox architecture

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

- Interactive diagram: https://gitdiagram.com/bayllama/marinabox
- Repository: https://github.com/bayllama/marinabox

## Overview

##### Main Components

a) Frontend Layer:
- React-based UI (evident from .jsx files)
- Key components: Dashboard, ChatInput, LiveAgentConsole, SessionDialog, SessionList
- Built with Vite (shown by vite.config.js)

b) Backend Core:
- Python-based server (server.py)
- SDK interface (sdk.py)
- API layer (api.py)
- Configuration management (config.py)

c) Environment Management:
- Local Manager (local_manager.py)
- Cloud Manager (cloud_manager.py)
- Models layer (models.py)

d) Computer Use Module:
- Tools collection (computer_use/tools/)
- Execution loop (computer_use/loop.py)
- Various tool implementations (bash.py, computer.py, edit.py, run.py)

e) External Dependencies:
- Docker containers (marinabox-browser, marinabox-desktop)
- Anthropic API integration
- noVNC for remote desktop access

##### Component Relationships

- Frontend → Backend API (REST/WebSocket communication)
- SDK → Environment Managers
- Environment Managers → Docker Containers
- Computer Use Module → Tools
- External Services Integration

##### Specific Design Elements

Use these visual elements:

**[Frontend Layer (UI Components)]**
- ↓
**[Backend API/SDK Layer]**
- ↓
**[Environment Management Layer]**
- ↙            ↘
**[Local Docker]  [Cloud Services]**
- ↓
**[Computer Use Module]**
- ↓
**[External Services]**

##### Important Details

- Session management flow
- Sandbox isolation boundaries
- API communication paths
- Tool execution pipeline
- Security perimeter

## Diagram (Mermaid)

```mermaid
graph TB
    %% Frontend Layer
    subgraph Frontend
        App["Main Application"]
        Dashboard["Dashboard"]
        ChatInput["Chat Interface"]
        AgentConsole["Agent Console"]
        SessionMgmt["Session Management"]
    end

    %% Backend Core
    subgraph Backend
        Server["Server"]
        SDK["SDK Interface"]
        API["API Layer"]
        Config["Configuration"]
    end

    %% Environment Management
    subgraph EnvManagement
        LocalMgr["Local Manager"]
        CloudMgr["Cloud Manager"]
        Models["Models Layer"]
    end

    %% Computer Use Module
    subgraph ComputerUse
        ExecLoop["Execution Loop"]
        ToolBase["Tools Base"]
        subgraph Tools
            BashTool["Bash Tool"]
            CompTool["Computer Tool"]
            EditTool["Edit Tool"]
            RunTool["Run Tool"]
        end
        ToolCollection["Tools Collection"]
    end

    %% CLI Interfaces
    subgraph CLI
        MainCLI["Main CLI"]
        LocalCLI["Local CLI"]
        CloudCLI["Cloud CLI"]
        CompUseCLI["Computer Use CLI"]
    end

    %% External Services
    subgraph External
        Docker["Docker Containers"]
        Anthropic["Anthropic API"]
        NoVNC["noVNC"]
    end

    %% Relationships
    App --> API
    Dashboard --> API
    ChatInput --> API
    AgentConsole --> API
    SessionMgmt --> API

    API --> SDK
    SDK --> LocalMgr
    SDK --> CloudMgr
    LocalMgr --> Docker
    CloudMgr -.-> External
    
    LocalMgr --> ExecLoop
    ExecLoop --> ToolCollection
    ToolCollection --> Tools
    
    MainCLI --> SDK
    LocalCLI --> LocalMgr
    CloudCLI --> CloudMgr
    CompUseCLI --> ExecLoop

    %% Styles
    classDef frontend fill:#a8d1f0
    classDef backend fill:#90EE90
    classDef envmgmt fill:#FFE5B4
    classDef compute fill:#DDA0DD
    classDef cli fill:#F0E68C
    classDef external fill:#FA8072

    class App,Dashboard,ChatInput,AgentConsole,SessionMgmt frontend
    class Server,SDK,API,Config backend
    class LocalMgr,CloudMgr,Models envmgmt
    class ExecLoop,ToolBase,BashTool,CompTool,EditTool,RunTool,ToolCollection compute
    class MainCLI,LocalCLI,CloudCLI,CompUseCLI cli
    class Docker,Anthropic,NoVNC external

    %% Click Events
    click App "https://github.com/bayllama/marinabox/blob/main/frontend/src/App.jsx"
    click Dashboard "https://github.com/bayllama/marinabox/blob/main/frontend/src/components/Dashboard.jsx"
    click ChatInput "https://github.com/bayllama/marinabox/blob/main/frontend/src/components/ChatInput.jsx"
    click AgentConsole "https://github.com/bayllama/marinabox/blob/main/frontend/src/components/LiveAgentConsole.jsx"
    click SessionMgmt "https://github.com/bayllama/marinabox/blob/main/frontend/src/components/SessionDialog.jsx"
    click Server "https://github.com/bayllama/marinabox/blob/main/marinabox/server.py"
    click SDK "https://github.com/bayllama/marinabox/blob/main/marinabox/sdk.py"
    click API "https://github.com/bayllama/marinabox/blob/main/marinabox/api.py"
    click Config "https://github.com/bayllama/marinabox/blob/main/marinabox/config.py"
    click LocalMgr "https://github.com/bayllama/marinabox/blob/main/marinabox/local_manager.py"
    click CloudMgr "https://github.com/bayllama/marinabox/blob/main/marinabox/cloud_manager.py"
    click Models "https://github.com/bayllama/marinabox/blob/main/marinabox/models.py"
    click ExecLoop "https://github.com/bayllama/marinabox/blob/main/marinabox/computer_use/loop.py"
    click ToolBase "https://github.com/bayllama/marinabox/blob/main/marinabox/computer_use/tools/base.py"
    click BashTool "https://github.com/bayllama/marinabox/blob/main/marinabox/computer_use/tools/bash.py"
    click CompTool "https://github.com/bayllama/marinabox/blob/main/marinabox/computer_use/tools/computer.py"
    click EditTool "https://github.com/bayllama/marinabox/blob/main/marinabox/computer_use/tools/edit.py"
    click RunTool "https://github.com/bayllama/marinabox/blob/main/marinabox/computer_use/tools/run.py"
    click ToolCollection "https://github.com/bayllama/marinabox/blob/main/marinabox/computer_use/tools/collection.py"
    click MainCLI "https://github.com/bayllama/marinabox/blob/main/marinabox/cli.py"
    click LocalCLI "https://github.com/bayllama/marinabox/blob/main/marinabox/local_cli.py"
    click CloudCLI "https://github.com/bayllama/marinabox/blob/main/marinabox/cloud_cli.py"
    click CompUseCLI "https://github.com/bayllama/marinabox/blob/main/marinabox/computer_use/cli.py"
```
