# sriprarabdha/webagi architecture

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

- Interactive diagram: https://gitdiagram.com/sriprarabdha/webagi
- Repository: https://github.com/sriprarabdha/webagi

## Overview

##### Main Components

A. Frontend Layer:
- Next.js Web Application
- React Components (/src/components)
- Pages (/src/pages)
- Internationalization System (/public/locales)

B. Agent Layer:
- Multiple Agent Implementations:
- BabyAGI
- BabyAGIUI-mod
- BabyBeeAGI
- BabyCatAGI
- BabyDeerAGI
- LawGPT

C. API Layer:
- REST Endpoints (/src/pages/api)
- Agent Management
- Tool Integration

D. External Services:
- Pinecone Vector Database
- Language Models (implied from LangChain usage)
- SerpAPI (for search capabilities)

**[Client Layer]**
- ↕️
**[API Layer]**
- ↕️
**[Agent Layer]**
- ↕️
**[External Services]**

##### Component Relationships

- Frontend to API communication
- API to Agent interaction
- Agent to External Services dependencies
- Cross-component communication between agents

##### Detailed Component Breakdown

Frontend Layer:
**[Web Interface]**
- Agent Components
- Agent Message UI
- Agent Parameters
- Execution Controls
- Sidebar Navigation
- Mobile Components

Agent Layer:
**[Agent System]**
- Base Agent Executor
- Specialized Agents
- Task Creation
- Task Execution
- Task Prioritization
- Common Tools
- Text Completion
- Web Scraping
- Web Search

##### Implementation Details

Use these symbols:
- Rectangles: Components and services
- Diamonds: Decision points
- Double lines: API boundaries

##### Additional Elements

- Component types
- State flow indicators

##### The tool ecosystem

Keep the abstraction level high enough to show the overall architecture while including enough detail to understand the interaction between components, especially in the agent system where multiple implementations coexist.

Remember to include annotations for:
- Authentication flows
- Data persistence paths
- Agent execution pipelines
- Tool integration points
- Language model interactions

This will create a comprehensive visualization that accurately represents the WebAGI system's architecture while maintaining clarity and usefulness for development and documentation purposes.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client
        WI[Web Interface]
        AC[Agent Components]
        SN[Sidebar Navigation]
        MC[Mobile Components]
        I18N[Internationalization]
    end

    subgraph API
        RE["REST Endpoints"]:::api
        AM["Agent Management"]:::api
        TI["Tool Integration"]:::api
    end

    subgraph Agents
        BAE[Base Agent Executor]:::agent
        subgraph "Agent Implementations"
            BAGI[BabyAGI]:::agent
            BAGIUI[BabyAGIUI-mod]:::agent
            BBAGI[BabyBeeAGI]:::agent
            BCAGI[BabyCatAGI]:::agent
            BDAGI[BabyDeerAGI]:::agent
            LGPT[LawGPT]:::agent
        end
        subgraph "Common Tools"
            TC[Text Completion]:::tool
            WS[Web Scraping]:::tool
            WSE[Web Search]:::tool
        end
    end

    subgraph "External Services"
        PDB[(Pinecone DB)]:::external
        LLM[Language Models]:::external
        SERP[SerpAPI]:::external
    end

    subgraph "Utility Services"
        EU[Execution Utils]:::util
        TU[Task Utils]:::util
        MU[Message Utils]:::util
    end

    %% Frontend Connections
    WI --> RE
    AC --> RE
    SN --> RE
    MC --> RE
    I18N -.-> Client

    %% API Connections
    RE --> AM
    RE --> TI
    AM --> BAE
    TI --> TC
    TI --> WS
    TI --> WSE

    %% Agent Connections
    BAE --> BAGI
    BAE --> BAGIUI
    BAE --> BBAGI
    BAE --> BCAGI
    BAE --> BDAGI
    BAE --> LGPT

    %% Tool Connections
    TC --> LLM
    WS --> SERP
    WSE --> SERP

    %% External Service Connections
    BAGI --> PDB
    BAGIUI --> PDB
    BBAGI --> PDB
    BCAGI --> PDB
    BDAGI --> PDB
    LGPT --> PDB

    %% Utility Connections
    EU --> BAE
    TU --> BAE
    MU --> BAE

    %% Styles
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef api fill:#2ecc71,stroke:#27ae60,color:white
    classDef agent fill:#f1c40f,stroke:#f39c12,color:black
    classDef tool fill:#e67e22,stroke:#d35400,color:white
    classDef external fill:#9b59b6,stroke:#8e44ad,color:white
    classDef util fill:#95a5a6,stroke:#7f8c8d,color:white

    %% Click Events
    click AC "https://github.com/SriPrarabdha/WebAGI/tree/main/src/components"
    click WI "https://github.com/SriPrarabdha/WebAGI/tree/main/src/pages"
    click I18N "https://github.com/SriPrarabdha/WebAGI/tree/main/public/locales"
    click RE "https://github.com/SriPrarabdha/WebAGI/tree/main/src/pages/api"
    click AM "https://github.com/SriPrarabdha/WebAGI/tree/main/src/pages/api/agents"
    click TI "https://github.com/SriPrarabdha/WebAGI/tree/main/src/pages/api/tools"
    click BAGI "https://github.com/SriPrarabdha/WebAGI/tree/main/src/agents/babyagi"
    click BAGIUI "https://github.com/SriPrarabdha/WebAGI/tree/main/src/agents/babyagiui-mod"
    click BBAGI "https://github.com/SriPrarabdha/WebAGI/tree/main/src/agents/babybeeagi"
    click BCAGI "https://github.com/SriPrarabdha/WebAGI/tree/main/src/agents/babycatagi"
    click BDAGI "https://github.com/SriPrarabdha/WebAGI/tree/main/src/agents/babydeeragi"
    click LGPT "https://github.com/SriPrarabdha/WebAGI/tree/main/src/agents/lawgpt"
    click TC "https://github.com/SriPrarabdha/WebAGI/blob/main/src/agents/common/tools/textCompletionTool.ts"
    click WS "https://github.com/SriPrarabdha/WebAGI/blob/main/src/agents/common/tools/webScrape.ts"
    click WSE "https://github.com/SriPrarabdha/WebAGI/blob/main/src/agents/common/tools/webSearch.ts"
    click BAE "https://github.com/SriPrarabdha/WebAGI/blob/main/src/agents/base/AgentExecuter.ts"
    click EU "https://github.com/SriPrarabdha/WebAGI/blob/main/src/utils/execution.ts"
    click TU "https://github.com/SriPrarabdha/WebAGI/blob/main/src/utils/task.ts"
    click MU "https://github.com/SriPrarabdha/WebAGI/blob/main/src/utils/message.ts"
```
