# breadboard-ai/breadboard architecture

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

- Interactive diagram: https://gitdiagram.com/breadboard-ai/breadboard
- Repository: https://github.com/breadboard-ai/breadboard

## Overview

##### Project type & purpose
- A large TypeScript monorepo for prototyping generative‐AI “boards.”
- Contains core libraries (breadboard runtime, kits, connectors), CLI tools, multiple board‐server implementations, web UIs (Visual Editor, Docs site), plus example boards.

##### High‐level structure (based on file tree & README)
Top‐level:
- “core” & “packages/*” folders: independent npm packages (breadboard runtime, agent‐kit, gemini‐kit, google‐drive‐kit, etc.)
- “boards/” tooling for working with OpenAPI board definitions
- “breadboard/” – the core runtime engine and editor harness
- “visual-editor/”, “unified-server/”, “board-server/”: full‐stack apps for editing & running boards in the browser
- “website/”: documentation site (Eleventy)
- CLI tools: “build/”, “build-code/”

##### Main architectural components
a. Core Runtime Layer (“breadboard” package + supporting libraries)
– Board definition loader, execution engine, data stores, transports, driver abstractions (OpenAI, Gemini)
– Plugin architecture for connectors (Google Drive, Gmail, etc.)
b. Kit Libraries (e.g. agent-kit, gemini-kit, google-drive-kit)
– Pre‐built board modules & connectors, published separately
c. CLI & Build Tools
– “build/”, “build-code/”: compile TS, generate schemas, emit package artifacts
d. Board Servers (multiple implementations)
– board-server: production server (Node + Express) with API, Firestore or GCS storage
– filesystem-board-server / idb-board-server / embedded-board-server / remote-board-server: alternate persistence & hosting
e. Web UIs
– Visual Editor (React/Vite) served by unified-server or static host
– unified-server: serves editor assets + proxy to board-server APIs
– website: static docs site
f. External Services
– LLM Providers (OpenAI, Gemini)
– Cloud storage (Firestore, GCS, IndexedDB)
– OAuth flows (Google Drive)

##### Interactions & data flows
1. User opens Visual Editor (front-end).
2. Editor fetches board definitions, connectors, and UI components via unified-server.
3. When running a board: front-end issues “Run Board” HTTP request → unified-server → proxies to board-server or embedded/idb‐server.
4. Server loads board definition, instantiates breadboard runtime, resolves connectors & drivers.
5. Runtime invokes LLM driver (OpenAI/Gemini) or storage connector (Google Drive).
6. Runtime writes/reads from data-store (Firestore, GCS, IndexedDB).
7. Server streams events/responses back to front-end over HTTP/websocket.

##### Architectural patterns & principles
- Monorepo with workspaces: encourages code sharing, local package linking.
- Plugin/driver pattern: supports multiple LLM backends & connectors.
- Micro‐service style: separate board‐servers for different persistence needs.
- Clear separation of concerns:
– Runtime engine (pure TS library)
– Kit libraries (modular building blocks)
– UI layer (React, HTML/CSS)
– API layer (Express/GCP functions)

##### Elements
– Clear component names (e.g. “breadboard Runtime”, “agent‐kit”, “board‐server”)

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Libraries"
        BBRT["breadboard Runtime"]:::lib
    end
    click BBRT "https://github.com/breadboard-ai/breadboard/tree/main/packages/breadboard/src"

    subgraph "Browser Harness"
        BBRTH["bbrt (Browser Harness)"]:::lib
    end
    click BBRTH "https://github.com/breadboard-ai/breadboard/tree/main/packages/bbrt/src"

    subgraph "Kit Libraries"
        AGENT["agent-kit"]:::kit
        GEMINI["gemini-kit"]:::kit
        GDRIVE["google-drive-kit"]:::kit
        COREKIT["core-kit"]:::kit
    end
    click AGENT "https://github.com/breadboard-ai/breadboard/tree/main/packages/agent-kit"
    click GEMINI "https://github.com/breadboard-ai/breadboard/tree/main/packages/gemini-kit"
    click GDRIVE "https://github.com/breadboard-ai/breadboard/tree/main/packages/google-drive-kit"
    click COREKIT "https://github.com/breadboard-ai/breadboard/tree/main/packages/core-kit"

    subgraph "CLI & Build Tools"
        TSBUILD["TypeScript Builder"]:::tool
        SCGEN["Schema/Code Generator"]:::tool
    end
    click TSBUILD "https://github.com/breadboard-ai/breadboard/tree/main/packages/build"
    click SCGEN "https://github.com/breadboard-ai/breadboard/tree/main/packages/build-code"

    subgraph "Board Servers"
        PROD["board-server (Node+Express)"]:::service
        FS["filesystem-board-server"]:::service
        IDB["idb-board-server"]:::service
        EMB["embedded-board-server"]:::service
        REMOTE["remote-board-server"]:::service
    end
    click PROD "https://github.com/breadboard-ai/breadboard/tree/main/packages/board-server/src"
    click FS "https://github.com/breadboard-ai/breadboard/tree/main/packages/filesystem-board-server/src"
    click IDB "https://github.com/breadboard-ai/breadboard/tree/main/packages/idb-board-server/src"
    click EMB "https://github.com/breadboard-ai/breadboard/tree/main/packages/embedded-board-server/src"
    click REMOTE "https://github.com/breadboard-ai/breadboard/tree/main/packages/remote-board-server/src"

    subgraph "Web UIs"
        VE["Visual Editor"]:::ui
        UNIFIED["unified-server"]:::service
        WEBSITE["website (Docs)"]:::ui
    end
    click VE "https://github.com/breadboard-ai/breadboard/tree/main/packages/visual-editor/src"
    click UNIFIED "https://github.com/breadboard-ai/breadboard/tree/main/packages/unified-server/src"
    click WEBSITE "https://github.com/breadboard-ai/breadboard/tree/main/packages/website/src"

    subgraph "Board Tooling"
        OPENAPI["OpenAPI Board Tooling"]:::tool
    end
    click OPENAPI "https://github.com/breadboard-ai/breadboard/tree/main/boards/tools/openapi"

    subgraph "External Services"
        OPENAI["OpenAI API"]:::external
        GEMINIAPI["Gemini API"]:::external
        FIRESTORE["Firestore"]:::db
        GCS["GCS Storage"]:::db
        IDBSTORE["IndexedDB"]:::db
    end

    %% Data Flows
    VE -->|"HTTP/WebSocket"| UNIFIED
    UNIFIED -->|"Proxy HTTP"| PROD
    UNIFIED -->|"Proxy HTTP"| FS
    UNIFIED -->|"Proxy HTTP"| IDB
    UNIFIED -->|"In-process"| EMB
    UNIFIED -->|"Proxy HTTP"| REMOTE

    PROD -->|"Load definition & exec"| BBRT
    FS -->|"Load definition & exec"| BBRT
    IDB -->|"Load definition & exec"| BBRT
    EMB -->|"Load definition & exec"| BBRT
    REMOTE -->|"Load definition & exec"| BBRT

    BBRT -->|"LLM API calls"| OPENAI
    BBRT -->|"LLM API calls"| GEMINIAPI
    BBRT -->|"Store Read/Write"| FIRESTORE
    BBRT -->|"Store Read/Write"| GCS
    BBRT -->|"IndexedDB API"| IDBSTORE

    TSBUILD -->|"build packages"| BBRT
    TSBUILD -->|"build packages"| AGENT
    TSBUILD --> GEMINI
    TSBUILD --> GDRIVE
    TSBUILD --> COREKIT
    SCGEN -->|"generate schemas"| BBRT

    OPENAPI -->|"generate definitions"| BBRT

    %% Connections between Kits and Runtime
    AGENT -->|"plugin to"| BBRT
    GEMINI -->|"plugin to"| BBRT
    GDRIVE -->|"plugin to"| BBRT
    COREKIT -->|"plugin to"| BBRT

    %% Styles
    classDef lib fill:#D6EAF8,stroke:#2980B9
    classDef kit fill:#E8F8F5,stroke:#1ABC9C
    classDef tool fill:#FDEBD0,stroke:#D35400
    classDef service fill:#F2F3F4,stroke:#7F8C8D
    classDef ui fill:#FCF3CF,stroke:#F1C40F
    classDef external fill:#F4ECF7,stroke:#8E44AD
    classDef db fill:#D5F5E3,stroke:#27AE60
```
