# coinbase/agentkit architecture

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

- Interactive diagram: https://gitdiagram.com/coinbase/agentkit
- Repository: https://github.com/coinbase/agentkit

## Overview

##### Main components
– Action Providers: These modules (e.g., “basename”, “cdp”, “erc20”, “erc721”, “morpho”, “pyth”, “superfluid”, “twitter”, “wallet”, “weth”, “wow”) define the actions your agents can execute.
– Wallet Providers: Modules that manage wallet-specific operations for varied onchain wallet types.
– Network Components: Handling chain definitions, network interfaces, and related operations.
– Analytics & Validators: Handling telemetry (analytics events) and data consistency/checks across different actions.
- Language-specific Implementations:
– Python Package: Located under the python/coinbase-agentkit and corresponding examples.
– TypeScript Package: Found in typescript/agentkit along with its examples and framework extensions.
- Examples/Use Cases: You see fully working examples (chatbots) that tie the actions, wallet operations, and networking together with external API keys. These illustrate integration with external protocols.
- Framework Extensions: Both Python and TypeScript include “framework-extensions” (for example, the langchain extension). These are essentially adapters or integration layers that allow AgentKit to plug into external frameworks.
- Supporting Infrastructure:
– CI/CD Workflows: Found in the “.github/workflows/” directory, these drive linting, testing, and package publishing.
– Documentation: Both embedded documentation (docs/) and external reference sites are established for developer support.
- Configuration/Build Tools: Files like package.json, pyproject.toml, and various eslint/prettier configs are present to maintain consistency.

##### Relationships and Interactions
- Agent core as a central component (or hub) that connects to various “action providers” and “wallet providers”.
- Examples (chatbot use cases) as “client” applications that use the underlying agentkit libraries. They illustrate how agents interpret a user prompt into actionable blockchain operations.
- Extension layers (langchain, etc.) as adapter modules that sit between the core agentkit logic and external AI frameworks.

##### Architectural Patterns and Design Principles
- Modular Design: The repository is segregated into multiple language-specific packages, each exemplifying a modular architecture that separates concerns (actions, networking, validations).
- Plugin / Provider Pattern: The extensive usage of “action providers” and “wallet providers” indicates a plugin-like system where each component can be extended or replaced.
- Monorepo Structure: The overall organization as a monorepo allows shared configuration and tests while keeping language-specific implementations under their own directories.
- Test-Driven Organization: There is a dedicated tests directory for ensuring component reliability, with test files closely mirroring the structure of the code (e.g., separate folders for each provider).
- CI/CD Integration: Automated workflows indicate the importance of continuous integration, which is a key aspect of the overall deployment and maintenance of the project.

##### Relevant technologies
- For TypeScript: Node.js 18+, Jest (for tests), ESLint/Prettier for code formatting.
- For Python: Python 3.10+, Poetry (for dependency management).
- External Services: Coinbase CDP, OpenAI, and various blockchain ecosystems (Alchemy, Base, Farcaster, Morph, Moonwell, Pyth) as indicated by the supported protocols section.
- Documentation Tools: Sphinx for Python docs (e.g., conf.py) and other static site generators for hosted API references.

- Clear labels for each major component such as “Core AgentKit”, “Action Providers”, “Wallet Providers”, “Network Layer”, “Analytics Module”, “Extension/Adapter Layers”, and “Example Applications.”
– From the front-end user input (chatbot interfaces) to the agent processing layer.
– From the agent processing to external blockchain networks and data analytics.
– Between plugins and the core framework indicating extensibility.
- Sub-module (such as each “action provider”) is represented in context with its contributions to the overall workflow.

## Diagram (Mermaid)

```mermaid
graph TD
    A["AgentKit Monorepo"]:::core
    UI["User Input (Chatbot Interface)"]:::client

    %% Infrastructure Nodes
    INF1["CI/CD Workflows"]:::infra
    INF2["Documentation"]:::infra
    INF3["Package Config (Root)"]:::infra
    INF5["TypeScript Build Config"]:::infra

    %% Top-level connections from Monorepo
    A -->|"contains"| Tpkg
    A -->|"contains"| INF1
    A -->|"contains"| INF2
    A -->|"contains"| INF3
    A -->|"contains"| INF5

    %% User input routes to Example Applications in TypeScript implementation
    UI -->|"initiates"| T6

    %% TypeScript Implementation Subgraph
    subgraph "TypeScript Implementation"
        Tpkg["TypeScript Package"]:::typescript
        T6["Example Applications (TypeScript)"]:::typescript
        T1["Core Framework Logic (TypeScript)"]:::typescript
        T2["Action Providers (TypeScript)"]:::typescript
        T3["Wallet Providers (TypeScript)"]:::typescript
        T4["Network Components (TypeScript)"]:::typescript
        T5["Analytics (TypeScript)"]:::typescript
        T7["Framework Extensions (TypeScript)"]:::typescript

        Tpkg --> T6
        T6 -->|"triggers"| T1
        T2 -->|"plugins"| T1
        T3 -->|"plugins"| T1
        T1 -->|"onchain"| T4
        T1 -->|"analytics"| T5
        T1 -->|"extends"| T7
    end

    %% Click Events for TypeScript Components
    click Tpkg "https://github.com/coinbase/agentkit/tree/main/typescript/agentkit"
    click T1 "https://github.com/coinbase/agentkit/tree/main/typescript/agentkit/src"
    click T2 "https://github.com/coinbase/agentkit/tree/main/typescript/agentkit/src/action-providers"
    click T3 "https://github.com/coinbase/agentkit/tree/main/typescript/agentkit/src/wallet-providers"
    click T4 "https://github.com/coinbase/agentkit/tree/main/typescript/agentkit/src/network"
    click T5 "https://github.com/coinbase/agentkit/tree/main/typescript/agentkit/src/analytics"
    click T6 "https://github.com/coinbase/agentkit/tree/main/typescript/examples"
    click T7 "https://github.com/coinbase/agentkit/tree/main/typescript/framework-extensions"

    %% Click Events for Infrastructure
    click INF1 "https://github.com/coinbase/agentkit/tree/main/.github/workflows"
    click INF2 "https://github.com/coinbase/agentkit/tree/main/python/coinbase-agentkit/docs"
    click INF3 "https://github.com/coinbase/agentkit/blob/main/package.json"
    click INF5 "https://github.com/coinbase/agentkit/blob/main/typescript/agentkit/package.json"

    %% Class Definitions (Colors and Styles)
    classDef core fill:#D5F5E3,stroke:#27AE60,stroke-width:2px;
    classDef typescript fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef infra fill:#F2D7D5,stroke:#C0392B,stroke-width:2px;
    classDef client fill:#FDEBD0,stroke:#D35400,stroke-width:2px;
```
