# fuellabs/fuel-agent-kit architecture

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

- Interactive diagram: https://gitdiagram.com/fuellabs/fuel-agent-kit
- Repository: https://github.com/fuellabs/fuel-agent-kit

## Overview

##### Main Components

a) External Services Layer:
- OpenAI/Gemini/Anthropic API Services
- Fuel Blockchain Network

b) Core Agent Layer:
- FuelAgent Class (main entry point)
- Language Model Integration
- Wallet Management

c) Feature Modules:
- Transfers Module
- Swaps Module (Mira)
- Liquidity Module
- Lending Module (SwayLend)
- Balance Reading Module

d) Utility Layer:
- Asset Management
- Explorer Integration
- Setup Utilities
- Common Types/Models

##### Component Relationships

- User → FuelAgent → Language Model → Specific Module → Fuel Network
- FuelAgent → Utility Layer → Feature Modules
- Feature Modules → External Services

##### Specific Implementation Details

**[User Application]**
- ↓
**[FuelAgent (Core)]**
- ↙     ↓     ↘
**[AI Models] [Wallet] [Tools]**
- ↓         ↓        ↓
**┌─────────────────────────┐**
- Feature Modules     │
- ┤
- Transfers            │
- Mira (Swaps/Liquidity)│
- SwayLend             │
- Balance Reader       │
- ┘
- ↓
**[Utility Layer]**
- ↓
**[Fuel Blockchain Network]**

##### Important Elements to Highlight

- The modular architecture with distinct feature sets
- The AI model integration for natural language processing
- The wallet integration for transaction signing
- The utility layer supporting all modules

##### Technical Details

- TypeScript as the implementation language
- Supported AI models (GPT-4, Gemini, Anthropic)
- Supported blockchain operations (transfers, swaps, lending)
- Configuration requirements (API keys, wallet keys)

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph External["External Services"]
        AI[AI Language Models]:::external
        FN[Fuel Network]:::external
    end

    subgraph Core["Core Agent Layer"]
        FA["FuelAgent"]:::core
        AG["Agent Implementation"]:::core
        TL["Tools Integration"]:::core
    end

    subgraph Features["Feature Modules"]
        direction TB
        TM["Transfers Module"]:::feature
        subgraph MiraFeatures["Mira Features"]
            direction TB
            SW["Swaps"]:::feature
            LQ["Liquidity"]:::feature
        end
        subgraph SwayFeatures["SwayLend Features"]
            direction TB
            BR["Borrowing"]:::feature
            SP["Supply"]:::feature
        end
        BL["Balance Reader"]:::feature
    end

    subgraph Utils["Utility Layer"]
        direction TB
        AM["Asset Management"]:::util
        EI["Explorer Integration"]:::util
        LMI["Language Models"]:::util
        SU["Setup Utilities"]:::util
        CT["Common Types"]:::util
        MT["Market Types"]:::util
        CN["Constants"]:::util
    end

    UA[User Application]:::external --> FA
    FA --> AG
    AG --> TL
    FA --> AI
    AI --> Features
    Features --> FN
    Features --> Utils
    Utils --> FN

    %% Click Events
    click FA "https://github.com/FuelLabs/fuel-agent-kit/blob/main/src/FuelAgent.ts"
    click AG "https://github.com/FuelLabs/fuel-agent-kit/blob/main/src/agent.ts"
    click TL "https://github.com/FuelLabs/fuel-agent-kit/blob/main/src/tools.ts"
    click TM "https://github.com/FuelLabs/fuel-agent-kit/blob/main/src/transfers/transfers.ts"
    click SW "https://github.com/FuelLabs/fuel-agent-kit/blob/main/src/mira/swap.ts"
    click LQ "https://github.com/FuelLabs/fuel-agent-kit/blob/main/src/mira/addLiquidity.ts"
    click BR "https://github.com/FuelLabs/fuel-agent-kit/blob/main/src/swaylend/borrow.ts"
    click SP "https://github.com/FuelLabs/fuel-agent-kit/blob/main/src/swaylend/supply.ts"
    click BL "https://github.com/FuelLabs/fuel-agent-kit/blob/main/src/read/balance.ts"
    click AM "https://github.com/FuelLabs/fuel-agent-kit/blob/main/src/utils/assets.ts"
    click EI "https://github.com/FuelLabs/fuel-agent-kit/blob/main/src/utils/explorer.ts"
    click LMI "https://github.com/FuelLabs/fuel-agent-kit/blob/main/src/utils/models.ts"
    click SU "https://github.com/FuelLabs/fuel-agent-kit/blob/main/src/utils/setup.ts"
    click CT "https://github.com/FuelLabs/fuel-agent-kit/blob/main/src/types/common.ts"
    click MT "https://github.com/FuelLabs/fuel-agent-kit/blob/main/src/types/Market.ts"
    click CN "https://github.com/FuelLabs/fuel-agent-kit/blob/main/src/constants.ts"

    %% Styling
    classDef external fill:#90EE90,stroke:#333,stroke-width:2px
    classDef core fill:#87CEEB,stroke:#333,stroke-width:2px
    classDef feature fill:#FFA500,stroke:#333,stroke-width:2px
    classDef util fill:#D3D3D3,stroke:#333,stroke-width:2px

    %% Legend
    subgraph Legend
        direction TB
        L1[External Services]:::external
        L2[Core Components]:::core
        L3[Feature Modules]:::feature
        L4[Utility Components]:::util
    end
```
