# jasonhedman/the-hive architecture

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

- Interactive diagram: https://gitdiagram.com/jasonhedman/the-hive
- Repository: https://github.com/jasonhedman/the-hive

## Overview

##### Main System Components

The system should be represented with these key components:

a) Frontend Layer:
- Next.js App Router structure (app/ directory)
- UI Components (components/ui/)
- Client-side Hooks (hooks/)
- Context Providers (app/_contexts/)

b) API Layer:
- Next.js API Routes (app/api/)
- External Service Integrations (services/)
- Database Operations (db/)

c) AI/Agent System:
- AI Agents (ai/agents/)
- Actions System (ai/cdp/, ai/invoke/, ai/knowledge/, ai/solana/, ai/twitter/)

d) Blockchain Integration:
- Solana Integration
- Multiple DeFi Protocol Integrations (Jupiter, Raydium, Orca)
- Wallet Management

##### Component Relationships

**[Frontend Layer]**

- [UI Components]
- Components UI Library

- [Page Routes]
- Chat Interface
- Portfolio View
- Token Explorer

- [Client Hooks]
- Data Fetching
- Blockchain Integration
- Authentication

**[API Layer]**

- [External Services]
- Birdeye
- Helius
- Jupiter
- Twitter

- [Database]
- Chats
- Knowledge
- Tokens

**[AI System]**

- [Agents]
- Knowledge
- Liquidity
- Market
- Social
- Staking
- Trading

- [Actions]
- CDP Actions
- Invoke Actions
- Knowledge Actions
- Solana Actions

##### Important Design Elements to Highlight

a) Architecture Patterns:
- Next.js App Router pattern
- Feature-based folder structure
- Service-oriented architecture for external integrations

b) Key Integration Points:
- AI agent system with blockchain operations
- External service connections
- Database interactions

c) Data Flow:
- User interactions → Frontend → AI Agents → Blockchain
- External data aggregation → API Layer → Frontend
- Chat system → AI processing → Action execution

##### Technical Stack Indicators

- Next.js 13+ (App Router)
- TypeScript
- Cosmos DB
- Solana Web3
- Multiple DeFi protocols
- AI/ML integration

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Frontend
        UI["UI Components"]
        Pages["Page Routes"]
        Hooks["Client Hooks"]
        Context["Context Providers"]
        
        UI --> Pages
        Hooks --> Pages
        Context --> Pages
    end

    subgraph API
        ExtServices["External Services"]
        Database["Database Layer"]
        APIRoutes["API Routes"]
        
        ExtServices --> APIRoutes
        Database --> APIRoutes
    end

    subgraph AI
        Agents["AI Agents"]
        Actions["Actions System"]
        
        subgraph AgentTypes
            Knowledge["Knowledge Agent"]
            Liquidity["Liquidity Agent"]
            Market["Market Agent"]
            Social["Social Agent"]
            Staking["Staking Agent"]
            Trading["Trading Agent"]
        end
        
        subgraph ActionTypes
            CDP["CDP Actions"]
            Invoke["Invoke Actions"]
            KnowledgeAct["Knowledge Actions"]
            SolanaAct["Solana Actions"]
            TwitterAct["Twitter Actions"]
        end
    end

    subgraph Blockchain
        Solana["Solana Integration"]
        DeFi["DeFi Protocols"]
        Wallet["Wallet Management"]
        
        subgraph Protocols
            Jupiter["Jupiter"]
            Raydium["Raydium"]
            Orca["Orca"]
        end
    end

    subgraph ExternalAPIs
        Birdeye["Birdeye API"]
        Helius["Helius API"]
        Twitter["Twitter API"]
    end

    Frontend --> API
    API --> AI
    AI --> Blockchain
    Blockchain --> ExternalAPIs
    ExternalAPIs --> API

    %% Click events for component mapping
    click UI "https://github.com/jasonhedman/the-hive/tree/main/components/ui/"
    click Hooks "https://github.com/jasonhedman/the-hive/tree/main/hooks/"
    click Context "https://github.com/jasonhedman/the-hive/tree/main/app/_contexts/"
    click APIRoutes "https://github.com/jasonhedman/the-hive/tree/main/app/(app)/api/"
    click ExtServices "https://github.com/jasonhedman/the-hive/tree/main/services/"
    click Database "https://github.com/jasonhedman/the-hive/tree/main/db/"
    click Agents "https://github.com/jasonhedman/the-hive/tree/main/ai/agents/"
    click CDP "https://github.com/jasonhedman/the-hive/tree/main/ai/cdp/actions/"
    click Invoke "https://github.com/jasonhedman/the-hive/tree/main/ai/invoke/actions/"
    click KnowledgeAct "https://github.com/jasonhedman/the-hive/tree/main/ai/knowledge/actions/"
    click SolanaAct "https://github.com/jasonhedman/the-hive/tree/main/ai/solana/actions/"
    click TwitterAct "https://github.com/jasonhedman/the-hive/tree/main/ai/twitter/actions/"
    click Solana "https://github.com/jasonhedman/the-hive/tree/main/services/helius/"
    click Jupiter "https://github.com/jasonhedman/the-hive/tree/main/services/jupiter/"
    click Raydium "https://github.com/jasonhedman/the-hive/tree/main/services/raydium/"
    click Orca "https://github.com/jasonhedman/the-hive/tree/main/services/orca/"
    click Wallet "https://github.com/jasonhedman/the-hive/tree/main/hooks/privy/"
    click Database "https://github.com/jasonhedman/the-hive/tree/main/db/containers/"
    click Birdeye "https://github.com/jasonhedman/the-hive/tree/main/services/birdeye/"
    click Twitter "https://github.com/jasonhedman/the-hive/tree/main/services/twitter/"
    click Helius "https://github.com/jasonhedman/the-hive/tree/main/services/helius/"

    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef api fill:#2ecc71,stroke:#27ae60,color:white
    classDef ai fill:#9b59b6,stroke:#8e44ad,color:white
    classDef blockchain fill:#e67e22,stroke:#d35400,color:white
    classDef external fill:#95a5a6,stroke:#7f8c8d,color:white

    class UI,Pages,Hooks,Context frontend
    class ExtServices,Database,APIRoutes api
    class Agents,Actions,Knowledge,Liquidity,Market,Social,Staking,Trading,CDP,Invoke,KnowledgeAct,SolanaAct,TwitterAct ai
    class Solana,DeFi,Wallet,Jupiter,Raydium,Orca blockchain
    class Birdeye,Helius,Twitter external
```
