# ghost-oo5/alpha-agi architecture

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

- Interactive diagram: https://gitdiagram.com/ghost-oo5/alpha-agi
- Repository: https://github.com/ghost-oo5/alpha-agi

## Overview

##### Main System Components

a. Frontend Layer (Next.js Application)
- Client-side UI components (/src/apps/*)
- Common components (/src/common/*)
- Layout system (/src/common/layout/*)
- State management stores (/src/common/stores/*)

b. Core Modules Layer (/src/modules/*)
- AI/LLM integrations
- Authentication
- File handling
- Chat processing
- Voice/Speech processing
- Image generation
- Search functionality

c. Backend Layer
- API Routes (/app/api/*)
- TRPC Router (/server/trpc/*)
- Database connections (/server/prisma/*)

d. External Services Integration
- AI Providers (OpenAI, Anthropic, Google, etc.)
- Cloud Services (storage, authentication)
- Third-party tools (Browserless, search engines)

##### Component Relationships

- Data flow between frontend components and core modules
- API communication paths between frontend and backend
- External service integration points
- State management flow

##### Key Architectural Patterns

Highlight:
- Next.js Pages Router architecture
- TRPC for type-safe API communication
- Module-based organization for AI services
- Component composition patterns

##### Specific Implementation Details

Specialized features:
- Chat system architecture (/src/apps/chat/*)
- Beam feature implementation (/src/apps/beam/*)
- Voice call system (/src/apps/call/*)

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Frontend
        UI["Client UI Components"]
        Common["Common Components"]
        Layout["Layout System"]
        State["State Management"]
    end

    subgraph CoreModules
        AI["AI/LLM Integration"]
        Voice["Voice/Speech Processing"]
        Image["Image Generation"]
        Search["Search Functionality"]
        Files["File Handling"]
        Blocks["Message Blocks"]
        AiFn["AI Functions"]
        AiEx["AI Execution"]
    end

    subgraph Backend
        API["API Routes"]
        TRPC["TRPC Router"]
        DB[(Database)]
    end

    subgraph Features
        Chat["Chat System"]
        Beam["Beam Feature"]
        VoiceCall["Voice Call System"]
        Drawing["Drawing System"]
        ChatProc["Chat Processing"]
    end

    subgraph External
        AIProviders["AI Providers"]
        Auth["Authentication"]
        Cloud["Cloud Services"]
    end

    %% Connections
    UI --> Common
    UI --> Layout
    UI --> State
    Common --> CoreModules
    Features --> CoreModules
    CoreModules --> TRPC
    TRPC --> API
    API --> External
    API --> DB

    %% Styling
    classDef frontend fill:#a8d1ff
    classDef core fill:#90EE90
    classDef backend fill:#FFB6C1
    classDef feature fill:#DDA0DD
    classDef external fill:#F0E68C

    class UI,Common,Layout,State frontend
    class AI,Voice,Image,Search,Files,Blocks,AiFn,AiEx core
    class API,TRPC,DB backend
    class Chat,Beam,VoiceCall,Drawing,ChatProc feature
    class AIProviders,Auth,Cloud external

    %% Click Events
    click UI "https://github.com/Ghost-oo5/alpha-AGI/tree/v2-dev/src/apps/*"
    click Common "https://github.com/Ghost-oo5/alpha-AGI/tree/v2-dev/src/common/components/*"
    click Layout "https://github.com/Ghost-oo5/alpha-AGI/tree/v2-dev/src/common/layout/*"
    click State "https://github.com/Ghost-oo5/alpha-AGI/tree/v2-dev/src/common/stores/*"
    click AI "https://github.com/Ghost-oo5/alpha-AGI/tree/v2-dev/src/modules/llms/*"
    click Voice "https://github.com/Ghost-oo5/alpha-AGI/tree/v2-dev/src/modules/elevenlabs/*"
    click Image "https://github.com/Ghost-oo5/alpha-AGI/tree/v2-dev/src/modules/t2i/*"
    click Search "https://github.com/Ghost-oo5/alpha-AGI/tree/v2-dev/src/modules/google/*"
    click Files "https://github.com/Ghost-oo5/alpha-AGI/tree/v2-dev/src/modules/dblobs/*"
    click API "https://github.com/Ghost-oo5/alpha-AGI/tree/v2-dev/app/api/*"
    click TRPC "https://github.com/Ghost-oo5/alpha-AGI/tree/v2-dev/src/server/trpc/*"
    click DB "https://github.com/Ghost-oo5/alpha-AGI/tree/v2-dev/src/server/prisma/*"
    click Chat "https://github.com/Ghost-oo5/alpha-AGI/tree/v2-dev/src/apps/chat/*"
    click Beam "https://github.com/Ghost-oo5/alpha-AGI/tree/v2-dev/src/apps/beam/*"
    click VoiceCall "https://github.com/Ghost-oo5/alpha-AGI/tree/v2-dev/src/apps/call/*"
    click Drawing "https://github.com/Ghost-oo5/alpha-AGI/tree/v2-dev/src/apps/draw/*"
    click AIProviders "https://github.com/Ghost-oo5/alpha-AGI/tree/v2-dev/src/modules/llms/vendors/*"
    click Auth "https://github.com/Ghost-oo5/alpha-AGI/blob/v2-dev/docs/deploy-authentication.md"
    click Cloud "https://github.com/Ghost-oo5/alpha-AGI/tree/v2-dev/app/api/cloud/*"
    click ChatProc "https://github.com/Ghost-oo5/alpha-AGI/tree/v2-dev/src/common/chat-overlay/*"
    click Blocks "https://github.com/Ghost-oo5/alpha-AGI/tree/v2-dev/src/modules/blocks/*"
    click AiFn "https://github.com/Ghost-oo5/alpha-AGI/tree/v2-dev/src/modules/aifn/*"
    click AiEx "https://github.com/Ghost-oo5/alpha-AGI/tree/v2-dev/src/modules/aix/*"
```
