# firebase/genkit architecture

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

- Interactive diagram: https://gitdiagram.com/firebase/genkit
- Repository: https://github.com/firebase/genkit

## Overview

##### High-Level Architecture Components

a) Core Runtime Environments (2 parallel stacks):
- Node.js Runtime
- Go Runtime (Alpha)

b) Framework Core Components:
- Generation Engine
- Flow Management System
- Plugin System
- Telemetry & Tracing
- Developer Tools

##### Key Architectural Layers

**┌─ Application Layer ─────────────────────┐**
- User Applications                     │
- Sample Apps (Coffee Shop, Chatbot)    │
- ┘
- ↕
**┌─ Framework Layer ──────────────────────┐**
- ┌─ AI Features ─┐  ┌─ Core Services ─┐ │
- Generation  │  │ - Flow Engine   │ │
- RAG        │  │ - Prompt System │ │
- Embeddings │  │ - Tracing      │ │
- ┘  └───────────────────┘ │
- ┘
- ↕
**┌─ Plugin Layer ────────────────────────┐**
- Model Providers (Vertex AI, Ollama) │
- Vector Stores (Pinecone, Firestore) │
- Platform Integration (Firebase)     │
- ┘
- ↕
**┌─ Infrastructure Layer ───────────────┐**
- Cloud Providers                    │
- Vector Databases                   │
- Model APIs                         │
- ┘

##### Development Tools Section

**┌─ Developer Tools ──────────────────────┐**

- ┌─ CLI ─────┐    ┌─ Dev UI ────────┐ │
- Commands  │    │ - Flow Testing  │ │
- Telemetry │    │ - Trace Viewer │ │
- Eval Tools│    │ - Debugging    │ │
- ┘    └────────────────┘ │
- ┘

##### Data Flow Indicators

- Request flow through the system
- Plugin interactions
- Data streaming paths
- Telemetry collection routes

##### Component Details

For each major component, include:
- Component name
- Key responsibilities
- Interface points
- Supported features

##### Integration Points

Highlight:
- API endpoints
- Plugin interfaces
- External service connections
- Client integration points

##### Dual Runtime Support
- Parallel implementations for Node.js and Go
- Shared components and differences

##### Plugin Architecture
- Demonstrate extensibility points
- Standard plugin interfaces
- Example plugin integrations

##### Development Workflow
- Tooling integration
- Debugging and monitoring paths
- Evaluation flows

##### Streaming Capabilities
- Streaming data paths
- Real-time processing components

- Nested components
- Text annotations
- Grouping of related components

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef runtime fill:#e1f5fe,stroke:#01579b
    classDef framework fill:#e8f5e9,stroke:#1b5e20
    classDef plugin fill:#fff3e0,stroke:#e65100
    classDef infra fill:#f3e5f5,stroke:#4a148c
    classDef tools fill:#fbe9e7,stroke:#bf360c
    classDef ai fill:#f3e5f5,stroke:#4a148c

    %% Infrastructure Layer
    subgraph Infrastructure
        CloudProviders["Cloud Providers"]:::infra
        VectorDBs["Vector Databases"]:::infra
        ModelAPIs["Model APIs"]:::infra
    end

    %% Plugin Layer
    subgraph Plugins
        ModelProviders["Model Providers"]:::plugin
        VectorStores["Vector Stores"]:::plugin
        PlatformIntegration["Platform Integration"]:::plugin
    end

    %% Framework Layer
    subgraph Framework
        subgraph AIFeatures
            Generation["Generation Engine"]:::ai
            RAG["RAG"]:::ai
            Embeddings["Embeddings"]:::ai
        end

        subgraph CoreServices
            FlowEngine["Flow Engine"]:::framework
            PromptSystem["Prompt System"]:::framework
            Tracing["Tracing"]:::framework
        end
    end

    %% Runtime Layer
    subgraph Runtimes
        NodeRuntime["Node.js Runtime"]:::runtime
        GoRuntime["Go Runtime (Alpha)"]:::runtime
    end

    %% Developer Tools
    subgraph DevTools
        CLI["CLI"]:::tools
        DevUI["Dev UI"]:::tools
        EvalTools["Evaluation Tools"]:::tools
    end

    %% Application Layer
    subgraph Applications
        UserApps["User Applications"]
        SampleApps["Sample Apps"]
    end

    %% Relationships
    Applications --> Framework
    Framework --> Plugins
    Plugins --> Infrastructure
    DevTools --> Framework

    %% Click Events
    click NodeRuntime "https://github.com/firebase/genkit/tree/main/js"
    click GoRuntime "https://github.com/firebase/genkit/tree/main/go"
    click Generation "https://github.com/firebase/genkit/tree/main/js/ai"
    click FlowEngine "https://github.com/firebase/genkit/tree/main/js/core"
    click ModelProviders "https://github.com/firebase/genkit/tree/main/js/plugins/vertexai"
    click VectorStores "https://github.com/firebase/genkit/tree/main/js/plugins/pinecone"
    click PlatformIntegration "https://github.com/firebase/genkit/tree/main/js/plugins/firebase"
    click CLI "https://github.com/firebase/genkit/tree/main/genkit-tools/cli"
    click DevUI "https://github.com/firebase/genkit/blob/main/genkit-tools/cli/src/commands/ui-start.ts"
    click EvalTools "https://github.com/firebase/genkit/blob/main/genkit-tools/cli/src/commands/eval-flow.ts"
    click Tracing "https://github.com/firebase/genkit/tree/main/genkit-tools/telemetry-server"

    %% Legend
    subgraph Legend
        L1["Runtime Components"]:::runtime
        L2["Framework Components"]:::framework
        L3["Plugin Components"]:::plugin
        L4["Infrastructure"]:::infra
        L5["Developer Tools"]:::tools
        L6["AI Components"]:::ai
    end
```
