# openinterpreter/open-interpreter architecture

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

- Interactive diagram: https://gitdiagram.com/openinterpreter/open-interpreter
- Repository: https://github.com/openinterpreter/open-interpreter

## Overview

##### Main Components
- Terminal and UI Interface:
- The components in interpreter/terminal_interface form the interactive chat interface in the terminal (with support for conversation rendering, profiles, and special commands such as %reset or %verbose).
- Core Interpreter and LLM Integration:
- Modules within interpreter/core and interpreter/core/llm handle the processing of user commands, message streaming, and function-calling to code.
- This is where connections to external language models (using LiteLLM) are established.
- Computer Control Tools:
- Under interpreter/core/computer (with folders like browser, filesystem, calendar, etc.), the project abstracts system-level capabilities enabling the execution of local code, automating tasks, and interacting with operating system functionalities.
- API/Server Layer:
- The sample FastAPI server (as shown in the README and illustrative code in docs) demonstrates a REST interface layer for external control or integration.
- Configuration and Profiles:
- The existence of YAML configuration files (profiles in interpreter/terminal_interface/profiles and installers) indicate that user-configurable profiles adjust behaviors at runtime.
- CI/DevOps and Documentation:
- GitHub workflows and the Dockerfiles (.devcontainer, Dockerfile at root, and installers) indicate support for development environment isolation, testing, and deployment.
- External Integrations:
- Hosts integration instructions for local LLM servers (LM Studio, ollama, etc.) and a couple of Docker-based samples in the examples folder.

##### Relationships and Data Flow
- The interface relays these commands to the Core Interpreter, which then negotiates with the LLM Integration component (possibly through an external API or a local LLM server via LiteLLM).
- Once the LLM generates a response, the Core Interpreter may call into several “computer” tools (file, browser, OS, etc.) depending on the command, and then stream the execution results back to the UI.
- Additionally, an HTTP (FastAPI) endpoint provides an alternate path where incoming REST requests are funneled into the same interpreter chat methods.

##### Architectural Patterns
- Modular Design: Notice the separation of concerns between UI, core logic (LLM, command parsing), and tool execution (computer module).
- Extensibility: The profiles folder and customization instructions (like modifying system_message, switching language models, etc.) reveal a design aimed at extensibility.
- Integration-Focused: The architecture tightly integrates external services (LLM providers, Docker, FastAPI, local OS commands) with internal Python modules.
- CLI and API Duality: There’s an emphasis on both interactive command-line use and API-driven interactions.

##### Relevant Technologies/Frameworks
- Python is the language and core runtime.
- LiteLLM for interacting with language models.
- FastAPI (and Uvicorn) for the REST API server.
- Docker, .devcontainer, and GitHub workflows for development operations.
- Possibly Node.js (for documentation) and Mintlify for the offline docs.

##### Detailed Architectural Elements
- Callouts for important functions (e.g., “exec() function for executing LLM-generated code”) and features like streaming responses.

## Diagram (Mermaid)

```mermaid
flowchart TD
    User("User"):::user
    UI("Terminal & UI Interface (interpreter/terminal_interface)"):::ui
    API("API/Server Layer (docs/server, examples/local_server.ipynb)"):::api
    Core("Core Interpreter & LLM Integration (interpreter/core, interpreter/core/llm, core.py)"):::core
    Tools("Computer Control Tools (interpreter/core/computer, interpreter/computer_use)"):::tools
    Config("Configuration & Profiles (interpreter/terminal_interface/profiles, installers)"):::config
    DevOps("CI/DevOps & Documentation (.github, .devcontainer, Dockerfile, docs)"):::ops
    Ext("External Integrations (docs/language-models, examples)"):::external

    %% User interactions
    User -->|"command"| UI
    User -.->|"invokes API"| API

    %% Frontend communication with core
    UI -->|"forwardsCommands"| Core
    API -->|"RESTRequest"| Core

    %% Core interactions with computer tools and response path
    Core -->|"executes"| Tools
    Tools -->|"returnsResults"| Core
    Core -->|"sendsResponse"| UI

    %% Configuration influences
    Config -->|"configures"| UI
    Config -->|"configures"| Core

    %% External Integrations hook into core engine
    Ext -->|"LLMIntegration"| Core

    %% Developer operations support (dotted lines)
    DevOps -.-> UI
    DevOps -.-> Core
    DevOps -.-> API
    DevOps -.-> Tools

    %% Click Events
    click UI "https://github.com/openinterpreter/open-interpreter/tree/main/interpreter/terminal_interface"
    click Core "https://github.com/openinterpreter/open-interpreter/tree/main/interpreter/core"
    click Tools "https://github.com/openinterpreter/open-interpreter/tree/main/interpreter/core/computer"
    click API "https://github.com/openinterpreter/open-interpreter/tree/main/docs/server"
    click Config "https://github.com/openinterpreter/open-interpreter/tree/main/interpreter/terminal_interface/profiles"
    click DevOps "https://github.com/openinterpreter/open-interpreter/blob/main/.github"
    click Ext "https://github.com/openinterpreter/open-interpreter/tree/main/docs/language-models"

    %% Styles
    classDef user fill:#ffcc00,stroke:#333,stroke-width:2px,color:#000;
    classDef ui fill:#a2d9ce,stroke:#333,stroke-width:2px,color:#000,stroke-dasharray:5 5;
    classDef api fill:#f7dc6f,stroke:#333,stroke-width:2px,color:#000;
    classDef core fill:#82e0aa,stroke:#333,stroke-width:2px,color:#000;
    classDef tools fill:#f1948a,stroke:#333,stroke-width:2px,color:#000;
    classDef config fill:#d7bde2,stroke:#333,stroke-width:2px,color:#000;
    classDef ops fill:#aed6f1,stroke:#333,stroke-width:2px,color:#000;
    classDef external fill:#f5b7b1,stroke:#333,stroke-width:2px,color:#000;
```
