# corndogmillionaire/hyperswarm architecture

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

- Interactive diagram: https://gitdiagram.com/corndogmillionaire/hyperswarm
- Repository: https://github.com/corndogmillionaire/hyperswarm

## Overview

##### Core Components
- Node System (Agents)
- Hyperedge System
- API Interface Layer
- Graph Management System

##### External Dependencies
- Oobabooga text-generation-webui
- Alternative LLM APIs (as mentioned in README)

##### Central Architecture Layer
- Node Manager (from graph.py)
- Individual agents as nested components
- Memory storage for agents with memory_enable=True
- Hyperedge Manager (from graph.py)
- Information flow patterns
- Prompt template processing

##### API Integration Layer
- API Abstraction (from api.py)
- Connection to LLM services

##### Implementation Layer
Examples implementation (from examples/debate.py) as a practical usage layer

Use the following visual elements:

- Blue: Core system components
- Green: Active agents/nodes
- Orange: Hyperedges
- Purple: API/External services
- Gray: Memory storage

Special Considerations:

##### Hypergraph Visualization
- How multiple nodes can be connected through hyperedges
- Many-to-many relationships possible in the system
- Demonstrate how hyperpt templates modify node prompts

##### Information Flow
- Input → processing → output flow
- Where memory is stored and accessed
- How the initialize() and update() methods affect the system

##### API Flexibility
- Modular nature of the API system
- Possible connection points for different LLM services

Level of Detail:
##### The memory system architecture

- Node types and their purposes
- Different types of connections
- Special symbols used for memory and API connections

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles and classes
    classDef core fill:#e1f5fe,stroke:#01579b
    classDef agent fill:#c8e6c9,stroke:#2e7d32
    classDef edge fill:#ffe0b2,stroke:#ef6c00
    classDef api fill:#e1bee7,stroke:#6a1b9a
    classDef memory fill:#f5f5f5,stroke:#424242
    classDef example fill:#bbdefb,stroke:#1565c0

    %% Legend
    subgraph Legend
        L1[Core Components]:::core
        L2[Agents/Nodes]:::agent
        L3[Hyperedges]:::edge
        L4[API/External]:::api
        L5[Memory Storage]:::memory
        L6[Examples]:::example
    end

    %% Central Architecture Layer
    subgraph CentralArchitecture
        GraphSystem[Graph Management System]:::core
        
        subgraph NodeSystem
            NodeManager[Node Manager]:::core
            Agent1[Agent 1]:::agent
            Agent2[Agent 2]:::agent
            Agent3[Agent 3]:::agent
            MemStore[(Memory Storage)]:::memory
            
            NodeManager --> Agent1
            NodeManager --> Agent2
            NodeManager --> Agent3
            Agent1 -.-> MemStore
            Agent2 -.-> MemStore
            Agent3 -.-> MemStore
        end
        
        subgraph HyperEdgeSystem
            EdgeManager[Hyperedge Manager]:::core
            Edge1{Hyperedge 1}:::edge
            Edge2{Hyperedge 2}:::edge
            
            EdgeManager --> Edge1
            EdgeManager --> Edge2
            Edge1 --> Agent1
            Edge1 --> Agent2
            Edge2 --> Agent2
            Edge2 --> Agent3
        end
        
        GraphSystem --> NodeSystem
        GraphSystem --> HyperEdgeSystem
    end

    %% API Integration Layer
    subgraph APILayer
        APIInterface[API Interface]:::api
        Oobabooga[Oobabooga WebUI]:::api
        OtherLLM[Other LLM Services]:::api
        
        APIInterface <--> Oobabooga
        APIInterface <--> OtherLLM
    end

    %% Implementation Layer
    subgraph Implementation
        DebateExample[Debate Example]:::example
    end

    %% Main connections
    APILayer <--> CentralArchitecture
    CentralArchitecture --> Implementation

    %% Click events for component mapping
    click APIInterface "https://github.com/CorndogMillionaire/HyperSwarm/blob/master/api.py"
    click GraphSystem "https://github.com/CorndogMillionaire/HyperSwarm/blob/master/graph.py"
    click NodeManager "https://github.com/CorndogMillionaire/HyperSwarm/blob/master/graph.py"
    click EdgeManager "https://github.com/CorndogMillionaire/HyperSwarm/blob/master/graph.py"
    click DebateExample "https://github.com/CorndogMillionaire/HyperSwarm/blob/master/examples/debate.py"
```
