# uber-go/cadence-client architecture

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

- Interactive diagram: https://gitdiagram.com/uber-go/cadence-client
- Repository: https://github.com/uber-go/cadence-client

## Overview

##### Main Components

a. Core Components:
- Workflow Engine
- Activity System
- Worker System
- Client Interface
- Internal Services

b. Supporting Components:
- Authentication System
- Metrics & Monitoring
- Serialization Services
- Cache System
- Auto-scaling Components

**┌─ Application Layer ─────────────────────────────┐**

- ┌─ Client APIs ──┐    ┌─ Workflow Engine ──┐  │
- Domain       │    │ - State Machine    │  │
- Workflow     │    │ - Context         │  │
- Activity     │    │ - Error Handling  │  │
- ┘    └──────────────────┘  │

- Worker Layer ──────────────────────────────┐  │
- ┌─ Worker Components ─┐  ┌─ Activities ──┐ │  │
- Task Handlers     │  │ - Execution   │ │  │
- Pollers          │  │ - Heartbeat    │ │  │
- Auto-scaler      │  │ - Recovery     │ │  │
- ┘  └───────────────┘ │  │

- Infrastructure Layer ────────────────────┘  │
- ┌─ Common Services ─────────────────────┐   │
- Authentication                      │   │
- Metrics                            │   │
- Serialization                      │   │
- Caching                            │   │
- ┘   │
- ┘

##### Key Relationships to Highlight

- Bidirectional communication between Client APIs and Workflow Engine
- Task flow from Worker Components to Activities
- How Infrastructure Services support all upper layers
- Integration points with the main Cadence server

##### Technical Details

- YARPC communication paths
- Thrift/Proto serialization flows
- Cache interaction patterns
- Auto-scaling decision flows

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Application
        CI[Client Interface]:::client
        WE[Workflow Engine]:::core
        WI[Workflow Interceptors]:::core
        SM[Session Management]:::core
        
        CI --> WE
        WE --> WI
        WE --> SM
    end

    subgraph Worker
        WS[Worker System]:::worker
        TH[Task Handlers]:::worker
        AS[Activity System]:::worker
        AC[Auto-scaling Components]:::worker
        IG[Isolation Groups]:::worker
        
        WS --> TH
        WS --> AS
        WS --> AC
        WS --> IG
    end

    subgraph Infrastructure
        Auth[Authentication System]:::infra
        MM[Metrics & Monitoring]:::infra
        SS[Serialization Services]:::infra
        CS[Cache System]:::infra
        SH[Shadower System]:::infra
        TI[Testing Infrastructure]:::infra
        
        Auth --> SS
        MM --> SS
        SS --> CS
        SH --> SS
    end

    WE --> WS
    AS --> Auth
    WS --> Auth
    CI --> Auth
    
    %% Component Mappings
    click WE "https://github.com/uber-go/cadence-client/blob/master/workflow/workflow.go"
    click AS "https://github.com/uber-go/cadence-client/blob/master/activity/activity.go"
    click WS "https://github.com/uber-go/cadence-client/blob/master/worker/worker.go"
    click CI "https://github.com/uber-go/cadence-client/blob/master/client/client.go"
    click Auth "https://github.com/uber-go/cadence-client/blob/master/internal/common/auth/service_wrapper.go"
    click MM "https://github.com/uber-go/cadence-client/blob/master/internal/common/metrics/service_wrapper.go"
    click SS "https://github.com/uber-go/cadence-client/blob/master/internal/common/serializer/history_serializer.go"
    click CS "https://github.com/uber-go/cadence-client/blob/master/internal/common/cache/cache.go"
    click AC "https://github.com/uber-go/cadence-client/blob/master/internal/common/autoscaler/autoscaler.go"
    click SM "https://github.com/uber-go/cadence-client/blob/master/workflow/session.go"
    click WI "https://github.com/uber-go/cadence-client/blob/master/interceptors/workflow_interceptor.go"
    click SH "https://github.com/uber-go/cadence-client/blob/master/internal/workflow_shadower.go"
    click IG "https://github.com/uber-go/cadence-client/blob/master/isolationgroup/wrapper.go"
    click TH "https://github.com/uber-go/cadence-client/blob/master/internal/activity_task_handler.go"
    click TI "https://github.com/uber-go/cadence-client/blob/master/testsuite/testsuite.go"

    %% Styling
    classDef core fill:#2374f7,stroke:#fff,stroke-width:2px,color:#fff
    classDef worker fill:#48a14d,stroke:#fff,stroke-width:2px,color:#fff
    classDef infra fill:#f4c430,stroke:#fff,stroke-width:2px,color:#fff
    classDef client fill:#808080,stroke:#fff,stroke-width:2px,color:#fff

    %% Legend
    subgraph Legend
        L1[Core Components]:::core
        L2[Worker Components]:::worker
        L3[Infrastructure Components]:::infra
        L4[Client Interface]:::client
    end
```
