# eggai-tech/eggai architecture

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

- Interactive diagram: https://gitdiagram.com/eggai-tech/eggai
- Repository: https://github.com/eggai-tech/eggai

## Overview

##### Project Type and Purpose
- This project is a framework designed for orchestrating and integrating multi-agent systems. Its goal is to enable asynchronous, distributed interactions between agents (i.e., autonomous units of business logic) via an event-driven communication layer.
- The README and file structure indicate that the primary value proposition is “plug-and-play” orchestration with integrations for DSPy, LangChain, LiteLLM, LlamaIndex, and evaluation workflows, among others. The project also includes a stand-alone SDK (located under the sdk/ directory) and a wide range of examples demonstrating various use cases.

##### Key Components from the File Structure
- Core SDK/Framework:
- The “sdk/eggai” directory contains the core components like Agent, Channel, hooks, schemas, and transport implementations. These represent the heart of the multi-agent communication.
- Different transport modules (such as “inmemory” and “kafka”) indicate a pluggable messaging layer that can operate in asynchronous/distributed environments.
- Examples and Use Cases:
- The “examples” directory is rich with varied sample implementations (e.g., multi_agent_conversation, coordinator, triage_agent, and safe_agents_guardrails). This shows how the framework can be used in real-world scenarios and with different architectural patterns.
- Documentation and CI/CD:
- The “docs” directory (and the presence of .github workflows) indicate that the project places a strong emphasis on documentation, testing, and continuous integration.

a. Main Components:
- Agents: Representing the autonomous units (logic handlers, communication endpoints) that subscribe to and publish events.
- Channel: The communication backbone that abstracts the underlying message bus using either an in-memory or Kafka transport.
- Transports: Illustrate the two (or more) alternative communication layers (e.g., “inmemory” for local testing and “kafka” for production scalability).
- Integration Modules/Plugins: Show capabilities for integrating with external AI frameworks such as DSPy, LangChain, LiteLLM, and LlamaIndex.
- Evaluation & Optimization: Highlight components or example modules that perform agent evaluation (as seen, for example, in the agent evaluation example using DSPy).
b. Relationships and Interactions:
- Subscription mechanisms where Agents are listening for specific event types and then publishing new events as part of a workflow.
c. Architectural Patterns and Design Principles:
- Event-driven, asynchronous architecture.
- Separation of concerns: encapsulate agent logic, event communication, and data transport in distinct components.
- Make note of the loose coupling between agents in the system – a key advantage in distributed, multi-agent setups.
d. Technologies and Frameworks:
- Node the integration with asynchronous frameworks (i.e., using asyncio) and external libraries (dspy, langchain, litellm, etc.).
- Support for containerization/deployment (as seen by the docker-compose files in many examples).
- Use of CI/CD workflows (.github/workflows) for automated testing and publishing.

- Annotations or side notes listing key external technologies (dspy, langchain, docker-compose) that appear in the README or file tree.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Core Section
    CoreFramework["EggAI Core Framework"]:::core
    subgraph "EggAI Core Modules"
        Agent["Agent Component"]:::core
        Channel["Channel Component"]:::core
        Transport["Transport Implementations"]:::core
        subgraph "Transport Options"
            InMemory["InMemory Transport"]:::core2
            Kafka["Kafka Transport"]:::core2
        end
    end

    %% Integration Section
    subgraph "Integrations"
        DSPy["DSPy Integration (Agent Evaluation)"]:::integration
        LangChain["LangChain Integration"]:::integration
        LiteLLM["LiteLLM Integration"]:::integration
    end

    %% CI/CD Section
    subgraph "CI/CD"
        GitHubWorkflows["GitHub Workflows"]:::cicd
        Makefile["Makefile"]:::cicd
    end

    %% Documentation Section
    subgraph "Documentation"
        Docs["Docs Directory"]:::docs
        MkDocs["MkDocs Config"]:::docs
    end

    %% Connections from CoreFramework to Core Modules
    CoreFramework --> Agent
    CoreFramework --> Channel
    CoreFramework --> Transport

    %% Internal Core Modules connections
    Agent -->|"publish"| Channel
    Channel -->|"deliver"| Agent
    Channel -->|"uses"| Transport
    Transport --> InMemory
    Transport --> Kafka

    %% Connections from Core Modules to Integrations
    Agent -->|"integrates"| DSPy
    Agent -->|"integrates"| LangChain
    Agent -->|"integrates"| LiteLLM

    %% Connections from CoreFramework to CI/CD and Documentation
    CoreFramework -->|"tested_by"| GitHubWorkflows
    CoreFramework -->|"tested_by"| Makefile
    CoreFramework -->|"documented_in"| Docs
    CoreFramework -->|"documented_in"| MkDocs

    %% Click Event Mappings
    click CoreFramework "https://github.com/eggai-tech/eggai/tree/main/sdk/eggai"
    click Agent "https://github.com/eggai-tech/eggai/blob/main/sdk/eggai/agent.py"
    click Channel "https://github.com/eggai-tech/eggai/blob/main/sdk/eggai/channel.py"
    click InMemory "https://github.com/eggai-tech/eggai/blob/main/sdk/eggai/transport/inmemory.py"
    click Kafka "https://github.com/eggai-tech/eggai/blob/main/sdk/eggai/transport/kafka.py"
    click DSPy "https://github.com/eggai-tech/eggai/tree/main/examples/agent_evaluation_dspy"
    click LangChain "https://github.com/eggai-tech/eggai/tree/main/examples/langchain_tool_calling"
    click LiteLLM "https://github.com/eggai-tech/eggai/tree/main/examples/litellm_agent"
    click GitHubWorkflows "https://github.com/eggai-tech/eggai/tree/main/.github/workflows"
    click Makefile "https://github.com/eggai-tech/eggai/tree/main/Makefile"
    click Docs "https://github.com/eggai-tech/eggai/tree/main/docs/docs"
    click MkDocs "https://github.com/eggai-tech/eggai/blob/main/docs/mkdocs.yml"

    %% Style Definitions
    classDef core fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef core2 fill:#87CEFA,stroke:#000,stroke-width:2px;
    classDef integration fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef cicd fill:#DDA0DD,stroke:#000,stroke-width:2px;
    classDef docs fill:#F0E68C,stroke:#000,stroke-width:2px;
```
