# golemfactory/yagna architecture

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

- Interactive diagram: https://gitdiagram.com/golemfactory/yagna
- Repository: https://github.com/golemfactory/yagna

## Overview

##### Main Components

a) Core Services Layer:
- Identity Service (core/identity)
- Market Service (core/market)
- Payment Service (core/payment)
- Activity Service (core/activity)
- Network Service (core/net)
- GSB (Golem Service Bus) API (core/gsb-api)

b) Agent Layer:
- Provider Agent (agent/provider)
- Requestor Interface

c) Execution Layer:
- ExeUnit Supervisor (exe-unit)
- Runtime Implementations:
- WASM Runtime
- VM Runtime
- SGX Runtime

d) Payment Infrastructure:
- Payment Drivers (core/payment-driver)
- ERC20 Implementation
- Layer 1 & Layer 2 Support

##### Component Relationships

a) Market Flow:
**Requestor -> Market Service -> Provider Agent**
- ↓
- Identity Service

b) Execution Flow:
**Provider Agent -> ExeUnit Supervisor -> Runtime Implementation**
- ↓                    ↓
**Activity Service     Network Service**

c) Payment Flow:
**Payment Service -> Payment Drivers -> Blockchain**
- ↓
**Market Service**

##### Layer Organization

**[Application Layer]**
- ↓
**[Core Services Layer]**
- ↓
**[Execution Layer]**
- ↓
**[Infrastructure Layer]**

##### Critical Elements to Highlight

- GSB (Golem Service Bus) as the central communication backbone
- P2P Network Infrastructure
- Market Matching System
- Payment Processing Pipeline
- Runtime Environment Management

##### Additional Details

Annotations for:
- GLM Token Integration
- Layer 1/Layer 2 Payment Channels
- Security Components (SGX)
- Service Discovery Mechanisms
- Resource Management

##### Implementation Notes

- Version/state indicators for beta/production components

## Diagram (Mermaid)

```mermaid
graph TB
    %% Define styles
    classDef core fill:#b3d1ff,stroke:#333,stroke-width:1px
    classDef agent fill:#98fb98,stroke:#333,stroke-width:1px
    classDef execution fill:#fff68f,stroke:#333,stroke-width:1px
    classDef payment fill:#dda0dd,stroke:#333,stroke-width:1px
    classDef external fill:#d3d3d3,stroke:#333,stroke-width:1px
    classDef infrastructure fill:#ffdab9,stroke:#333,stroke-width:1px

    %% Application Layer
    subgraph Application
        REQ[Requestor Interface]:::agent
        PA[Provider Agent]:::agent
    end

    %% Core Services Layer
    subgraph CoreServices
        GSB[GSB API]:::core
        ID[Identity Service]:::core
        MS[Market Service]:::core
        PS[Payment Service]:::core
        AS[Activity Service]:::core
        NS[Network Service]:::core
        MR[Market Resolver]:::core
        GFTP[GFTP Service]:::core
        VS[Version Service]:::core
        HC[Health Check]:::core
    end

    %% Execution Layer
    subgraph Execution
        EUS[ExeUnit Supervisor]:::execution
        subgraph Runtimes
            WASM[WASM Runtime]:::execution
            VM[VM Runtime]:::execution
            SGX[SGX Runtime]:::execution
        end
        RA[Runtime API]:::execution
    end

    %% Payment Infrastructure
    subgraph PaymentInfra
        PD[Payment Drivers]:::payment
        ERC[ERC20 Implementation]:::payment
        subgraph Blockchain
            L1[Layer 1]:::external
            L2[Layer 2]:::external
        end
    end

    %% Relationships
    REQ --> GSB
    PA --> GSB
    GSB --> ID
    GSB --> MS
    GSB --> PS
    GSB --> AS
    GSB --> NS
    MS --> MR
    PA --> EUS
    EUS --> RA
    RA --> WASM & VM & SGX
    PS --> PD
    PD --> ERC
    ERC --> L1 & L2
    NS --> GFTP

    %% Click events
    click ID "https://github.com/golemfactory/yagna/tree/master/core/identity"
    click MS "https://github.com/golemfactory/yagna/tree/master/core/market"
    click PS "https://github.com/golemfactory/yagna/tree/master/core/payment"
    click AS "https://github.com/golemfactory/yagna/tree/master/core/activity"
    click NS "https://github.com/golemfactory/yagna/tree/master/core/net"
    click GSB "https://github.com/golemfactory/yagna/tree/master/core/gsb-api"
    click PA "https://github.com/golemfactory/yagna/tree/master/agent/provider"
    click EUS "https://github.com/golemfactory/yagna/tree/master/exe-unit"
    click PD "https://github.com/golemfactory/yagna/tree/master/core/payment-driver"
    click ERC "https://github.com/golemfactory/yagna/tree/master/core/payment-driver/erc20"
    click RA "https://github.com/golemfactory/yagna/tree/master/exe-unit/runtime-api"
    click MR "https://github.com/golemfactory/yagna/tree/master/core/market/resolver"
    click GFTP "https://github.com/golemfactory/yagna/tree/master/core/gftp"
    click VS "https://github.com/golemfactory/yagna/tree/master/core/version"
    click HC "https://github.com/golemfactory/yagna/tree/master/core/healthcheck"

    %% Legend
    subgraph Legend
        L1[Core Services]:::core
        L2[Agent Components]:::agent
        L3[Execution Components]:::execution
        L4[Payment Components]:::payment
        L5[External Systems]:::external
    end
```
