# niceberginc/agentipy architecture

> Architecture diagram of the GitHub repository niceberginc/agentipy, 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/niceberginc/agentipy
- Repository: https://github.com/niceberginc/agentipy

## Overview

##### Main Components

a) Core Components:
- SolanaAgentKit (Central Controller)
- LangChain Integration Layer
- Tools Module
- Utils Module
- Types Module

b) External Services:
- Solana Blockchain
- Jupiter Exchange
- Raydium DEX
- Meteora DLMM
- Lulo Lending
- OpenAI API (for LangChain)
- Pyth Oracle

**┌─────────────────────┐**
- SolanaAgentKit    │
- ┘

**┌─────────┐ ┌─────────┐ ┌─────────┐**
- Tools   │ │LangChain│ │ Utils   │
- ┘ └─────────┘ └─────────┘

**┌────────┐ ┌────────┐ ┌────────┐ ┌────────┐**
- Jupiter │ │Raydium │ │Meteora │ │ Lulo   │
- ┘ └────────┘ └────────┘ └────────┘

**┌─────────────────────────┐**
- Solana Blockchain    │
- ┘

##### Component Relationships

- Data flow between components
- Dependencies between modules
- API calls to external services
- Transaction flow

##### Detailed Component Breakdown

Tools Module (Show as expandable section):
- Token Operations
- Trading Operations
- Yield Farming
- Performance Tracking
- Token Management

Utils Module (Show as expandable section):
- Keypair Management
- Transaction Handling
- DEX-specific Utils (Raydium, Meteora)
- JSON Utilities

##### Implementation Notes

- The modular nature of the toolkit
- The separation of concerns between components
- The async nature of operations
- The integration points with external services
- The security considerations for private key handling

##### Technical Details

- Supported token standards (SPL)
- Transaction types
- Integration protocols
- API endpoints
- Configuration requirements

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client["Client Interface"]
        SAK["SolanaAgentKit"]:::core
    end

    subgraph CoreServices["Core Services"]
        Tools["Tools Module"]:::core
        Lang["LangChain Integration"]:::core
        Utils["Utils Module"]:::core
        Types["Types Module"]:::core
    end

    subgraph IntegrationServices["Integration Services"]
        Jupiter["Jupiter Exchange"]:::integration
        Raydium["Raydium DEX"]:::integration
        Meteora["Meteora DLMM"]:::integration
        Lulo["Lulo Lending"]:::integration
        Pyth["Pyth Oracle"]:::integration
    end

    subgraph Tools_Breakdown["Tools Breakdown"]
        TokenOps["Token Operations"]:::tool
        TradingOps["Trading Operations"]:::tool
        TransferOps["Transfer Operations"]:::tool
    end

    subgraph Utils_Breakdown["Utils Breakdown"]
        KeyMgmt["Keypair Management"]:::util
        TxHandler["Transaction Handler"]:::util
        JsonUtils["JSON Utilities"]:::util
    end

    subgraph Blockchain["Blockchain Layer"]
        Solana["Solana Blockchain"]:::blockchain
    end

    %% Relationships
    SAK --> Tools
    SAK --> Lang
    SAK --> Utils
    SAK --> Types

    Tools --> Jupiter
    Tools --> Raydium
    Tools --> Meteora
    Tools --> Lulo
    Tools --> Pyth

    Tools --> Tools_Breakdown
    Utils --> Utils_Breakdown

    Jupiter --> Solana
    Raydium --> Solana
    Meteora --> Solana
    Lulo --> Solana
    Pyth --> Solana

    %% Click Events
    click SAK "https://github.com/niceberginc/agentipy/blob/main/agentipy/__init__.py"
    click Lang "https://github.com/niceberginc/agentipy/tree/main/agentipy/langchain/"
    click Tools "https://github.com/niceberginc/agentipy/tree/main/agentipy/tools/"
    click Utils "https://github.com/niceberginc/agentipy/tree/main/agentipy/utils/"
    click Types "https://github.com/niceberginc/agentipy/tree/main/agentipy/types/"
    click Jupiter "https://github.com/niceberginc/agentipy/blob/main/agentipy/tools/stake_with_jup.py"
    click Raydium "https://github.com/niceberginc/agentipy/tree/main/agentipy/utils/raydium/"
    click Meteora "https://github.com/niceberginc/agentipy/tree/main/agentipy/utils/meteora_dlmm/"
    click Lulo "https://github.com/niceberginc/agentipy/blob/main/agentipy/tools/lend.py"
    click Pyth "https://github.com/niceberginc/agentipy/blob/main/agentipy/tools/use_pyth.py"
    click KeyMgmt "https://github.com/niceberginc/agentipy/blob/main/agentipy/utils/keypair.py"
    click TxHandler "https://github.com/niceberginc/agentipy/blob/main/agentipy/utils/send_tx.py"
    click JsonUtils "https://github.com/niceberginc/agentipy/blob/main/agentipy/utils/toJSON.py"
    click TokenOps "https://github.com/niceberginc/agentipy/blob/main/agentipy/tools/deploy_token.py"
    click TradingOps "https://github.com/niceberginc/agentipy/blob/main/agentipy/tools/trade.py"
    click TransferOps "https://github.com/niceberginc/agentipy/blob/main/agentipy/tools/transfer.py"

    %% Styling
    classDef core fill:#2374ab,stroke:#000,stroke-width:2px,color:#fff
    classDef integration fill:#48a9a6,stroke:#000,stroke-width:2px,color:#fff
    classDef blockchain fill:#d4a373,stroke:#000,stroke-width:2px,color:#fff
    classDef tool fill:#457b9d,stroke:#000,stroke-width:2px,color:#fff
    classDef util fill:#6c757d,stroke:#000,stroke-width:2px,color:#fff

    %% Legend
    subgraph Legend
        L1["Core Component"]:::core
        L2["Integration Service"]:::integration
        L3["Tool Component"]:::tool
        L4["Utility Component"]:::util
        L5["Blockchain"]:::blockchain
    end
```
