# agent-network-protocol/agentconnect architecture

> Architecture diagram of the GitHub repository agent-network-protocol/agentconnect, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/agent-network-protocol/agentconnect
- Repository: https://github.com/agent-network-protocol/agentconnect

## Overview

##### Project type and purpose
- AgentConnect is an open-source, cross-language (Python + Java) library implementing the Agent Network Protocol (ANP).
- Its goal is to provide three core capabilities—DID-based authentication & end-to-end encryption, meta-protocol negotiation (via LLMs), and an application-layer protocol integration framework—so that autonomous “agents” can discover, authenticate, negotiate and communicate with each other over HTTP or WebSockets.

##### Main components (three layers + supporting modules)
A. Authentication & E2E Encryption Layer
- DID management (generation, verification, resolvers)
- Authentication headers (did:wba, DIDAll)
- Crypto primitives (ECDHE, Ed25519, Secp256k1)
B. Meta-Protocol Layer
- Protocol negotiator (uses Azure OpenAI under the hood)
- Code generators (provider/requester)
- Protocol container and runner
C. Application-Layer Protocol Framework
- Protocol definitions (JSON, Markdown)
- Loader/unloader/config manager
- Base classes for providers/requesters
D. Simple Node & Transport
- WebSocket client/server wrappers (wss_message_sdk, simple_node)
- Message generation & short-term key exchange
E. Utilities & Tooling
- CryptoTool, DIDGenerator, DIDVerifier
- LLM output processor
- Logging base classes
F. Language SDKs & Examples
- Python package (agent_connect/python/…)
- Java package (agent_connect/java/…)
- CLI tool: DID document generator (tools/did_generater)
- Demos (examples/*) and tests (tests/*)
G. External Dependencies
- Azure OpenAI API (for meta-protocol negotiation)
- DID:wba test server (for HTTP-based DID authentication)

##### Relationships & data flows
- Agent SDK ⇄ DID Server: fetch/store DID documents (HTTP)
- Agent SDK (auth module) ⇄ Peer Agent SDK: authenticate requests over HTTP or WSS
- Auth module ⇒ produces secure channel for Meta-Protocol negotiation
- Meta-Protocol negotiator ⇄ Azure OpenAI: exchange prompts & get code snippets
- Generated code loaded by App-Protocol framework ⇒ drives protocol-specific messaging
- Simple Node transports messages (WebSocket/WSS) using agreed protocol

##### Architectural Patterns & Principles
- Layered architecture: clear separation of auth, meta-protocol and application layers
- Plugin/loader pattern in App-Protocol: runtime loading/unloading of protocol modules
- Generator pattern in meta-protocol: code generation via LLMs
- Adapter pattern in multiple SDKs: unify Python and Java interfaces to core modules
- Use of standard DID and crypto specs (W3C DID, ECDHE, Ed25519)

##### Key technologies & frameworks
- Python: asyncio, websockets, requests, cryptography, openai SDK
- Java: Maven, logback, okhttp (in tests), JUnit
- DID standards: did:wba, DIDAll
- E2E crypto: ECDHE, Ed25519, Secp256k1
- JSON/Markdown for protocol specs
- Azure OpenAI for meta-protocol negotiation

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Application-Layer Protocol Framework
    subgraph "Application-Layer Protocol Framework"
        direction TB
        AppProtocols["App Protocol Framework"]:::pythonApp
        subgraph "Protocol Base"
            direction TB
            ProviderBase["Provider Base"]:::pythonApp
            RequesterBase["Requester Base"]:::pythonApp
        end
    end

    %% Meta-Protocol Layer
    subgraph "Meta-Protocol Layer"
        direction TB
        Negotiator["Protocol Negotiator"]:::pythonMeta
        MetaProto["Meta-Protocol Core"]:::pythonMeta
        subgraph "Code Generators"
            direction TB
            CGCore["Code Generator"]:::pythonMeta
            ProviderGen["Provider Generator"]:::pythonMeta
            RequesterGen["Requester Generator"]:::pythonMeta
        end
    end

    %% Authentication & E2E Encryption Layer
    subgraph "Authentication & E2E Encryption Layer"
        direction TB
        subgraph "Python Auth & E2E"
            direction TB
            DIDMgmtPy["DID Management & Auth Headers"]:::pythonAuth
            E2E_Py["E2E Crypto Primitives"]:::pythonAuth
        end
        subgraph "Java Auth & Utils"
            direction TB
            DIDMgmtJ["DID Management & Auth Headers (Java)"]:::javaAuth
            UtilsJ["Crypto Utilities (Java)"]:::javaAuth
        end
    end

    %% Transport Layer
    subgraph "Transport (HTTP / WebSocket)"
        direction TB
        SimpleNode["Simple Node Transport"]:::pythonTransport
        HTTP["HTTP Transport"]:::transport
        WebSocket["WebSocket Transport"]:::transport
    end

    %% External Dependencies
    AzureOpenAI["Azure OpenAI"]:::external
    DIDServer["DID Test Server"]:::external

    %% Language SDK Entries
    PySDK["Python SDK Entry"]:::pythonSdk
    JavaSDK["Java SDK Entry"]:::javaSdk

    %% User-Facing Tools
    subgraph "User Tools & Examples"
        direction TB
        CLI["CLI DID Document Generator"]:::tools
        Examples["Examples & Demos"]:::tools
    end

    %% Data Flows
    PySDK --> DIDMgmtPy
    JavaSDK --> DIDMgmtJ
    DIDMgmtPy --> DIDServer
    DIDMgmtJ --> DIDServer
    DIDMgmtPy --> Negotiator
    DIDMgmtJ --> Negotiator
    Negotiator --> AzureOpenAI
    AzureOpenAI --> Negotiator
    Negotiator --> CGCore
    CGCore --> AppProtocols
    AppProtocols --> SimpleNode
    SimpleNode --> HTTP
    SimpleNode --> WebSocket

    %% Click Events
    click DIDMgmtPy "https://github.com/agent-network-protocol/agentconnect/tree/master/agent_connect/python/authentication/"
    click E2E_Py "https://github.com/agent-network-protocol/agentconnect/tree/master/agent_connect/python/e2e_encryption/"
    click DIDMgmtJ "https://github.com/agent-network-protocol/agentconnect/tree/master/agent_connect/java/src/main/java/com/agentconnect/authentication/"
    click UtilsJ "https://github.com/agent-network-protocol/agentconnect/tree/master/agent_connect/java/src/main/java/com/agentconnect/utils/"
    click Negotiator "https://github.com/agent-network-protocol/agentconnect/blob/master/agent_connect/python/meta_protocol/protocol_negotiator.py"
    click MetaProto "https://github.com/agent-network-protocol/agentconnect/blob/master/agent_connect/python/meta_protocol/meta_protocol.py"
    click CGCore "https://github.com/agent-network-protocol/agentconnect/blob/master/agent_connect/python/meta_protocol/code_generator/code_generator.py"
    click ProviderGen "https://github.com/agent-network-protocol/agentconnect/blob/master/agent_connect/python/meta_protocol/code_generator/provider_generator.py"
    click RequesterGen "https://github.com/agent-network-protocol/agentconnect/blob/master/agent_connect/python/meta_protocol/code_generator/requester_generator.py"
    click AppProtocols "https://github.com/agent-network-protocol/agentconnect/tree/master/agent_connect/python/app_protocols/"
    click ProviderBase "https://github.com/agent-network-protocol/agentconnect/blob/master/agent_connect/python/app_protocols/protocol_base/provider_base.py"
    click RequesterBase "https://github.com/agent-network-protocol/agentconnect/blob/master/agent_connect/python/app_protocols/protocol_base/requester_base.py"
    click SimpleNode "https://github.com/agent-network-protocol/agentconnect/tree/master/agent_connect/python/simple_node/"
    click PySDK "https://github.com/agent-network-protocol/agentconnect/blob/master/agent_connect/python/__init__.py"
    click JavaSDK "https://github.com/agent-network-protocol/agentconnect/blob/master/agent_connect/java/pom.xml"
    click CLI "https://github.com/agent-network-protocol/agentconnect/blob/master/tools/did_generater/generate_did_doc.py"
    click Examples "https://github.com/agent-network-protocol/agentconnect/tree/master/examples/"

    %% Styles
    classDef pythonAuth fill:#E8F5E9,stroke:#388E3C
    classDef javaAuth fill:#E3F2FD,stroke:#1976D2
    classDef pythonMeta fill:#F3E5F5,stroke:#8E24AA
    classDef pythonApp fill:#FFF3E0,stroke:#FB8C00
    classDef pythonTransport fill:#E0F7FA,stroke:#0097A7
    classDef transport fill:#CFD8DC,stroke:#607D8B,stroke-dasharray: 5 5
    classDef external fill:none,stroke:#FF5722,stroke-dasharray: 5 5
    classDef pythonSdk fill:#C8E6C9,stroke:#2E7D32
    classDef javaSdk fill:#BBDEFB,stroke:#1565C0
    classDef tools fill:#FFFDE7,stroke:#FDD835
```
