# livepeer/go-livepeer architecture

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

- Interactive diagram: https://gitdiagram.com/livepeer/go-livepeer
- Repository: https://github.com/livepeer/go-livepeer

## Overview

##### Main Components

a. Core Network Roles (represented as distinct services):
- Broadcaster Node
- Orchestrator Node
- Transcoder Node

b. Key System Components (represented as modules):
- Media Processing Layer
- RTMP handling
- Segment processing
- Transcoding pipeline
- Blockchain Integration Layer
- Smart Contracts interaction
- Transaction management
- Price feed monitoring
- Discovery System
- Payment System (PM - Payment Manager)
- Monitoring & Analytics
- AI Processing Pipeline

**┌─ Application Layer ─────────────────────┐**
- CLI Interface   |   HTTP/RPC Endpoints  │
- Service Layer ──────────────────────────┤
- Broadcaster | Orchestrator | Transcoder  │
- Core Layer ────────────────────────────┤
- Media Processing | Discovery | Payments  │
- Infrastructure Layer ──────────────────┤
- Blockchain | Storage | Network Protocol │
- ┘

##### Key Interactions to Highlight

a. Media Flow:
- RTMP ingestion path
- Segment creation and distribution
- Transcoding workflow
- Stream delivery

b. Network Communication:
- Node discovery process
- Orchestrator selection
- Payment channel establishment
- Verification process

##### Specific Implementation Details

- Smart contract integration (from /eth directory)
- Payment management system (from /pm directory)
- Discovery mechanisms (from /discovery directory)
- Media processing pipeline (from /media directory)
- AI processing capabilities (from /ai directory)

##### Connection Types

- Double lines: High-bandwidth media flows

##### Additional Elements

- Configuration components
- Monitoring systems
- External integrations (like Ethereum network)
- Security components (auth, verification)

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and Classes
    classDef application fill:#e1f5fe,stroke:#01579b
    classDef service fill:#e8f5e9,stroke:#2e7d32
    classDef core fill:#fff3e0,stroke:#ef6c00
    classDef infrastructure fill:#fce4ec,stroke:#c2185b
    classDef media fill:#90caf9,stroke:#1976d2
    classDef blockchain fill:#fff59d,stroke:#fbc02d
    classDef payment fill:#ce93d8,stroke:#7b1fa2
    classDef discovery fill:#ffcc80,stroke:#f57c00
    classDef monitoring fill:#a5d6a7,stroke:#388e3c
    classDef ai fill:#b39ddb,stroke:#512da8

    %% Application Layer
    subgraph AppLayer["Application Layer"]
        CLI["CLI Interface"]
        API["HTTP/RPC Endpoints"]
    end

    %% Service Layer
    subgraph ServiceLayer["Service Layer"]
        BN["Broadcaster Node"]
        ON["Orchestrator Node"]
        TN["Transcoder Node"]
    end

    %% Core Layer
    subgraph CoreLayer["Core Layer"]
        MP["Media Processing"]
        DS["Discovery System"]
        PM["Payment Manager"]
        VS["Verification System"]
        AI["AI Processing Pipeline"]
    end

    %% Infrastructure Layer
    subgraph InfraLayer["Infrastructure Layer"]
        BC["Blockchain Integration"]
        ST["Storage"]
        NP["Network Protocol"]
    end

    %% Connections
    CLI --> BN
    CLI --> ON
    CLI --> TN
    API --> BN
    API --> ON
    API --> TN

    BN --> MP
    ON --> MP
    TN --> MP

    BN --> DS
    ON --> DS
    TN --> DS

    BN --> PM
    ON --> PM
    TN --> PM

    MP --> VS
    MP --> AI

    DS --> NP
    PM --> BC
    VS --> BC

    %% Click Events
    click BN "https://github.com/livepeer/go-livepeer/blob/master/core/broadcaster.go"
    click ON "https://github.com/livepeer/go-livepeer/blob/master/core/orchestrator.go"
    click TN "https://github.com/livepeer/go-livepeer/blob/master/core/transcoder.go"
    click MP "https://github.com/livepeer/go-livepeer/tree/master/media"
    click BC "https://github.com/livepeer/go-livepeer/tree/master/eth"
    click DS "https://github.com/livepeer/go-livepeer/tree/master/discovery"
    click PM "https://github.com/livepeer/go-livepeer/tree/master/pm"
    click VS "https://github.com/livepeer/go-livepeer/tree/master/verification"
    click AI "https://github.com/livepeer/go-livepeer/tree/master/ai"
    click CLI "https://github.com/livepeer/go-livepeer/tree/master/cmd/livepeer_cli"
    click NP "https://github.com/livepeer/go-livepeer/tree/master/net"

    %% Legend
    subgraph Legend
        L1["Application Components"]:::application
        L2["Service Components"]:::service
        L3["Core Components"]:::core
        L4["Infrastructure Components"]:::infrastructure
    end

    %% Style Applications
    class CLI,API application
    class BN,ON,TN service
    class MP,DS,PM,VS,AI core
    class BC,ST,NP infrastructure
```
