# receptron/graphai architecture

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

- Interactive diagram: https://gitdiagram.com/receptron/graphai
- Repository: https://github.com/receptron/graphai

## Overview

##### Main Components
- Agent Modules: Include the various agent types distributed throughout the repository. You have several groups:
- agents (with subdirectories like agent_utils, data_agents, input_agents, llm_agents, service_agents, sleeper_agents, vanilla_agents, vanilla_node_agents)
- llm_agents (including modules for anthropic, gemini, groq, openai, replicate, slashgpt, token_bound_string, and tools)
- packages/agents, packages/agent_filters, and others for testing and utilities.
- CLI & Tooling: Represent the GraphAI CLI (in packages/cli) as an interface or gateway that allows users to run and interact with the engine. Also include packages/agentdoc and packages/test_utils to denote documentation and testing utilities.
- API and External Interfaces: As noted by the documentation and API references, include an API layer, and optionally external integration points (such as the web demo and Grapys GUI tool).
- Configuration and DSL Layer: Since developers define workflows in YAML/JSON (with examples in packages/samples, docs/examples, etc.), include a “Workflow Definition” component that feeds into the engine.

##### Architectural Patterns and Design Principles
- Modular and Plugin-like Structure: Emphasize that the system follows a plugin or modular architecture where diverse agent implementations can be added, replaced, or extended.
- Asynchronous Data Flow: Note that the engine is built around an asynchronous execution design, processing declarative data flows.
- Declarative Workflow DSL: Highlight the separation of workflow definition (YAML/JSON) from execution, similar to a configuration-driven runtime.
- Separation of Concerns: Illustrate clear demarcations – for example, the core engine versus communication with external LLM services (in llm_agents) and utility functions provided in packages.

##### Relevant Technologies, Frameworks, and Tools
- Node.js & TypeScript: Indications that the project is written in TypeScript (as seen in tsconfig.json files and .ts files).
- Build/Workflow Tools: Mention GitHub Actions workflows (.github/workflows folder), rollup builds (rollup.config.mjs), and linting/configuration files.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Workflow Definition Subgraph
    subgraph "Workflow Definition"
        WF1["Workflow Samples (YAML/JSON)"]:::workflow
        WF2["Workflow Examples (Docs)"]:::workflow
    end

    %% Core Execution Engine
    CoreEngine["GraphAI Core Execution Engine"]:::core

    %% Agent Modules Subgraph
    subgraph "Agent Modules"
        DA["Data Agents"]:::agent
        IA["Input Agents"]:::agent
        LLA["LLM Agents"]:::agent
        SA["Service Agents"]:::agent
        SLA["Sleeper Agents"]:::agent
        VA["Vanilla Agents"]:::agent
        VNA["Vanilla Node Agents"]:::agent
    end

    %% CLI & Tooling
    CLI["GraphAI CLI & Tooling"]:::cli

    %% Documentation & Testing Subgraph
    subgraph "Documentation & Testing"
        AD["AgentDoc"]:::docs
        TU["TestUtils"]:::docs
        APID["API Doc"]:::docs
        APIDM["API Doc Md"]:::docs
    end

    %% Data Flows
    WF1 -->|"ingests"| CoreEngine
    WF2 -->|"ingests"| CoreEngine

    CLI -->|"command"| CoreEngine

    CoreEngine -->|"dispatch: data"| DA
    CoreEngine -->|"dispatch: input"| IA
    CoreEngine -->|"dispatch: llm"| LLA
    CoreEngine -->|"dispatch: service"| SA
    CoreEngine -->|"dispatch: sleeper"| SLA
    CoreEngine -->|"dispatch: vanilla"| VA
    CoreEngine -->|"dispatch: vanilla"| VNA

    %% Example of inter-agent communication (dotted arrows)
    DA ---|"collaborates"| IA
    LLA ---|"collaborates"| SA

    %% Styles
    classDef core fill:#a0c4ff,stroke:#00509e,stroke-width:2px;
    classDef workflow fill:#d8f3dc,stroke:#40916c,stroke-width:2px;
    classDef agent fill:#ffcfdf,stroke:#d00000,stroke-width:2px;
    classDef cli fill:#ffc8dd,stroke:#9d0208,stroke-width:2px;
    classDef docs fill:#ffe5d9,stroke:#bb3e03,stroke-width:2px;

    %% Click Events
    click CoreEngine "https://github.com/receptron/graphai/tree/main/packages/graphai"
    click DA "https://github.com/receptron/graphai/tree/main/agents/data_agents"
    click IA "https://github.com/receptron/graphai/tree/main/agents/input_agents"
    click LLA "https://github.com/receptron/graphai/tree/main/agents/llm_agents"
    click SA "https://github.com/receptron/graphai/tree/main/agents/service_agents"
    click SLA "https://github.com/receptron/graphai/tree/main/agents/sleeper_agents"
    click VA "https://github.com/receptron/graphai/tree/main/agents/vanilla_agents"
    click VNA "https://github.com/receptron/graphai/tree/main/agents/vanilla_node_agents"
    click CLI "https://github.com/receptron/graphai/tree/main/packages/cli"
    click AD "https://github.com/receptron/graphai/tree/main/packages/agentdoc"
    click TU "https://github.com/receptron/graphai/tree/main/packages/test_utils"
    click APID "https://github.com/receptron/graphai/tree/main/docs/apiDoc"
    click APIDM "https://github.com/receptron/graphai/tree/main/docs/apiDocMd"
    click WF1 "https://github.com/receptron/graphai/tree/main/packages/samples"
    click WF2 "https://github.com/receptron/graphai/tree/main/docs/examples"
```
