# kop0311/adk-python architecture

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

- Interactive diagram: https://gitdiagram.com/kop0311/adk-python
- Repository: https://github.com/kop0311/adk-python

## Overview

##### Project type and purpose
- This is a code-first, modular Python framework (not a monolithic application) for building, evaluating, and deploying AI agents.
- It provides:
- A core “Agent Engine” library (`src/google/adk/…`)
- A CLI (`adk` commands via Click/FastAPI) and a browser-based dev UI
- Integrations with LLMs (Gemini, Vertex AI, LiteLLM, Anthropic, etc.) and Google Cloud services
- A rich tool ecosystem (BigQuery, Bigtable, OpenAPI, custom functions)
- Session, memory, artifact, auth, telemetry, evaluation modules

##### File structure
- Top-level “src/google/adk” directory subdivided into feature modules:
- a2a – agent-to-agent protocol converters & executors
- agents – core agent abstractions (LlmAgent, LoopAgent, ParallelAgent), configs, contexts
- flows – orchestration flows (NL planning, function calls, schema enforcement)
- tools – adapters for external services (BigQuery, Bigtable, OpenAPI, application integration)
- auth – credential management, exchangers, refreshers
- memory & sessions – state management (in-memory, Vertex AI)
- artifacts – persistence backends (GCS, in-memory)
- evaluation – eval set managers, metrics, judges
- cli – command-line entrypoints & browser UI (FastAPI, JS assets)
- telemetry – tracing & metrics (Google Cloud)
- code_executors – local, containerized, GKE, Vertex AI, unsafe local
- Configuration & schema files (`AgentConfig.json`, YAML agent configs under samples),
build scripts (`pyproject.toml`), test suites (unit + integration).

##### README for additional insights
- Describes core capabilities: agents + tools + flows
- Mentions Code-First and Config-First agent definitions
- Highlights deployment targets: Cloud Run, Vertex AI Agent Engine
- Shows multi-agent orchestration patterns

##### Main components
a. Frontends
- CLI interface (`google.adk.cli.cli.py`)
- Browser-based Dev UI (FastAPI server + JS assets)
b. Core Agent Engine
- Agent abstractions (`agents/…`)
- Flow orchestrators (`flows/…`)
- Model connectors (`models/…`)
c. Support Services
- Auth service (credential managers, exchangers, refreshers)
- Memory & Session services
- Artifact service
- Telemetry (tracing, metrics)
- Evaluation engine (eval sets, metrics, generators)
d. Tool Adapters
- Google Cloud tools (BigQuery, Bigtable, Spanner)
- OpenAPI tools
- Custom function tools
- Application Integration tool
- A2A executor
e. External Dependencies
- LLM endpoints (Gemini, Vertex AI, Anthropic, LiteLLM)
- Google Cloud Storage, BigQuery, Bigtable, Cloud Run, Vertex AI Agent Engine
- A2A protocol peers

##### Relationships & data flows
- User ▶ CLI / Browser UI ▶ Core Agent Engine ▶ Agents ▶ Flows ▶ Models (LLM calls)
- Agents ▶ Tools ▶ External services (e.g., BigQuery)
- Agents ▶ Auth service to retrieve credentials for Tools or LLM endpoints
- Agents ▶ Memory/Session service to read/write conversation context
- Agents ▶ Artifact service to store logs, files
- Core Engine ▶ Telemetry ▶ Google Cloud Monitoring
- CLI / UI ▶ Evaluation module (to run eval sets)

##### Architectural patterns & principles
- Layered modular architecture (separate concerns into subpackages)
- Plugin/adapter patterns for Tools, Auth, Memory, Artifact, Session
- Strategy pattern for code executors, evaluators, planners
- Dependency injection via config files and Python objects
- Event-driven flows (Agents emit events ▶ Flows process them)

##### Detail without over-splitting
- Major subpackages but avoid drawing every single class.
- One representative sample of each plugin type (e.g., one BigQuery tool, one Memory service).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Tier
    subgraph "Frontend Tier"
        CLI["CLI Interface"]:::frontend
        FASTAPI["Dev UI Server (FastAPI)"]:::frontend
        ASSETS["Dev UI Assets (JS/CSS)"]:::frontend
    end

    %% Core Agent Engine
    subgraph "Core Agent Engine"
        subgraph "Agents"
            AGENTS["Agent Abstractions"]:::core
        end
        subgraph "Flows"
            FLOWS["Flow Orchestrators"]:::core
        end
        subgraph "Models"
            MODELS["Model Connectors"]:::core
        end
    end

    %% Support Services
    subgraph "Support Services"
        AUTH["Authentication Service"]:::support
        MEM["Memory Management"]:::support
        SESS["Session Management"]:::support
        ART["Artifact Persistence"]:::support
        TEL["Telemetry (Tracing & Metrics)"]:::support
        EVAL["Evaluation Engine"]:::support
    end

    %% Tool Adapters
    subgraph "Tool Adapters"
        BQ["BigQuery Adapter"]:::tools
        BT["Bigtable Adapter"]:::tools
        SP["Spanner Adapter"]:::tools
        OAPI["OpenAPI Adapter"]:::tools
        APPINT["Application Integration Tool"]:::tools
        FUNCT["Custom Function Tool"]:::tools
        A2A["A2A Protocol Executor"]:::tools
    end

    %% External Systems
    subgraph "External Systems"
        LLM["LLM Endpoints"]:::external
        GCS["Google Cloud Storage"]:::external
        BQ_EXT["BigQuery"]:::external
        BT_EXT["Bigtable"]:::external
        CR["Cloud Run"]:::external
        VERTEX["Vertex AI Agent Engine"]:::external
        A2A_PEER["A2A Peers"]:::external
    end

    %% Relationships
    User-->CLI
    User-->FASTAPI
    CLI-->AGENTS
    FASTAPI-->AGENTS
    CLI-->EVAL
    FASTAPI-->EVAL
    AGENTS-->FLOWS
    AGENTS-->MODELS
    MODELS-->LLM
    AGENTS-->BQ
    AGENTS-->BT
    AGENTS-->SP
    AGENTS-->OAPI
    AGENTS-->APPINT
    AGENTS-->FUNCT
    AGENTS-->A2A
    BQ-->BQ_EXT
    BT-->BT_EXT
    A2A-->A2A_PEER
    AGENTS-->AUTH
    AGENTS-->MEM
    AGENTS-->SESS
    AGENTS-->ART
    AGENTS-->TEL
    CLI-->|"runs eval sets"|EVAL

    %% Click Events
    click CLI "https://github.com/kop0311/adk-python/blob/main/src/google/adk/cli/cli.py"
    click FASTAPI "https://github.com/kop0311/adk-python/blob/main/src/google/adk/cli/adk_web_server.py"
    click ASSETS "https://github.com/kop0311/adk-python/tree/main/src/google/adk/cli/browser/"
    click AGENTS "https://github.com/kop0311/adk-python/tree/main/src/google/adk/agents/"
    click FLOWS "https://github.com/kop0311/adk-python/tree/main/src/google/adk/flows/"
    click MODELS "https://github.com/kop0311/adk-python/tree/main/src/google/adk/models/"
    click AUTH "https://github.com/kop0311/adk-python/tree/main/src/google/adk/auth/"
    click MEM "https://github.com/kop0311/adk-python/tree/main/src/google/adk/memory/"
    click SESS "https://github.com/kop0311/adk-python/tree/main/src/google/adk/sessions/"
    click ART "https://github.com/kop0311/adk-python/tree/main/src/google/adk/artifacts/"
    click TEL "https://github.com/kop0311/adk-python/tree/main/src/google/adk/telemetry/"
    click EVAL "https://github.com/kop0311/adk-python/tree/main/src/google/adk/evaluation/"
    click BQ "https://github.com/kop0311/adk-python/tree/main/src/google/adk/tools/bigquery/"
    click BT "https://github.com/kop0311/adk-python/tree/main/src/google/adk/tools/bigtable/"
    click SP "https://github.com/kop0311/adk-python/tree/main/src/google/adk/tools/spanner/"
    click OAPI "https://github.com/kop0311/adk-python/tree/main/src/google/adk/tools/openapi_tool/"
    click APPINT "https://github.com/kop0311/adk-python/tree/main/src/google/adk/tools/application_integration_tool/"
    click FUNCT "https://github.com/kop0311/adk-python/blob/main/src/google/adk/tools/function_tool.py"
    click A2A "https://github.com/kop0311/adk-python/tree/main/src/google/adk/a2a/executor/"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0366d6,color:#0366d6;
    classDef core fill:#DFFFE0,stroke:#22863a,color:#22863a;
    classDef support fill:#FFF5B1,stroke:#d73a49,color:#d73a49;
    classDef tools fill:#F0E6FF,stroke:#6f42c1,color:#6f42c1;
    classDef external fill:#F6F8FA,stroke:#586069,color:#586069;
```
