# databricks/databricks-sdk-go architecture

> Architecture diagram of the GitHub repository databricks/databricks-sdk-go, 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/databricks/databricks-sdk-go
- Repository: https://github.com/databricks/databricks-sdk-go

## Overview

##### Main Components

a. Core SDK Components:
- Authentication Layer
- HTTP Client Layer
- Service Clients Layer
- Utility Components
- Testing Infrastructure

b. External Integration Points:
- Databricks REST API
- Cloud Provider Authentication (Azure, GCP, AWS)
- Configuration Sources

**┌─ Application Layer (SDK Users) ─────────────────────────────────────┐**

- SDK Public Interface ───────────────────────────────────────────┐  │
- ┌─ Workspace Client ─┐ ┌─ Account Client ─┐                     │  │

- ┘ └───────────────────┘                    │  │

- Service Layer ──────────────────────────────────────────────────┤  │
- ┌─ Generated Service Clients ────────────────────────────┐      │  │
- Compute │ IAM │ Files │ SQL │ Catalog │ ... │         │      │  │
- ┘    │  │

- Core Infrastructure ───────────────────────────────────────────────┤
- ┌─ Authentication ─┐ ┌─ HTTP Client ──┐ ┌─ Request/Response ─┐    │
- Native        │ │ - Retries      │ │ - Serialization    │    │
- Azure        │ │ - Timeouts     │ │ - Error Handling   │    │
- GCP          │ │ - Logging      │ │ - Pagination       │    │
- ┘ └───────────────┘ └──────────────────────┘    │

- Utilities ────────────────────────────────────────────────────────┤
- ┌─ Configuration ─┐ ┌─ Logging ───────┐ ┌─ Testing ──────────┐   │
- File         │ │ - Simple Logger │ │ - Mocks            │   │
- Environment  │ │ - Custom Logger │ │ - Fixtures         │   │
- ┘ └────────────────┘ └───────────────────────┘  │

- ┘

##### Connection Types

- Double lines: Data flow

##### Important Details to Highlight

a. Authentication Flow:
- Multiple authentication methods (Databricks native, Azure, GCP)
- Configuration sources (environment, file, explicit)

b. Request Processing:
- Request/response cycle
- Retry mechanism
- Error handling flow

c. Service Integration:
- How generated clients interact with core infrastructure
- Relationship between workspace and account clients

##### Additional Elements

- Notes for important configuration points
- Version compatibility information
- Extension points for custom implementations

##### Implementation Notes

- The modular nature of the SDK
- Clear separation of concerns
- The extensive testing infrastructure
- The flexibility of authentication methods
- The robust error handling system

##### Key Relationships

- How authentication providers interact with the HTTP client
- How service clients utilize the core infrastructure
- How configuration flows through the system
- How testing components integrate with the main system

This system design should be created using a tool that supports:
- Nested components
- Custom styling
- Clear text labels
- Export to common formats

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Application Layer"
        AppUsers["SDK Users"]
    end

    subgraph "SDK Public Interface"
        WC["Workspace Client"]:::public
        AC["Account Client"]:::public
        click WC "https://github.com/databricks/databricks-sdk-go/blob/main/workspace_client.go"
        click AC "https://github.com/databricks/databricks-sdk-go/blob/main/account_client.go"
    end

    subgraph "Service Layer"
        SC["Service Clients"]:::service
        click SC "https://github.com/databricks/databricks-sdk-go/tree/main/service"
    end

    subgraph "Core Infrastructure"
        direction TB
        subgraph "Authentication"
            Auth["Authentication Providers"]:::auth
            Creds["Credentials Manager"]:::auth
            click Auth "https://github.com/databricks/databricks-sdk-go/tree/main/config"
            click Creds "https://github.com/databricks/databricks-sdk-go/tree/main/credentials"
        end

        subgraph "HTTP Components"
            HC["HTTP Client"]:::http
            Retry["Retry Handler"]:::http
            click HC "https://github.com/databricks/databricks-sdk-go/tree/main/httpclient"
            click Retry "https://github.com/databricks/databricks-sdk-go/tree/main/retries"
        end

        subgraph "Request Processing"
            ReqHandler["Request Handler"]:::core
            ErrHandler["Error Handler"]:::core
            click ReqHandler "https://github.com/databricks/databricks-sdk-go/tree/main/client"
            click ErrHandler "https://github.com/databricks/databricks-sdk-go/tree/main/apierr"
        end
    end

    subgraph "Utilities"
        direction TB
        Log["Logger"]:::util
        Marshal["Data Serializer"]:::util
        UA["User Agent"]:::util
        List["List Handler"]:::util
        click Log "https://github.com/databricks/databricks-sdk-go/tree/main/logger"
        click Marshal "https://github.com/databricks/databricks-sdk-go/tree/main/marshal"
        click UA "https://github.com/databricks/databricks-sdk-go/tree/main/useragent"
        click List "https://github.com/databricks/databricks-sdk-go/tree/main/listing"
    end

    subgraph "Testing Infrastructure"
        Mocks["Mocks"]:::test
        QA["QA Utils"]:::test
        Fixtures["Test Fixtures"]:::test
        click Mocks "https://github.com/databricks/databricks-sdk-go/tree/main/experimental/mocks"
        click QA "https://github.com/databricks/databricks-sdk-go/tree/main/qa"
        click Fixtures "https://github.com/databricks/databricks-sdk-go/tree/main/httpclient/fixtures"
    end

    subgraph "Configuration"
        Config["Config Manager"]:::config
        Env["Environment"]:::config
        click Config "https://github.com/databricks/databricks-sdk-go/tree/main/config"
        click Env "https://github.com/databricks/databricks-sdk-go/tree/main/common/environment"
    end

    subgraph "API Generation"
        OpenAPI["OpenAPI Generator"]:::gen
        CodeGen["Code Generator Config"]:::gen
        click OpenAPI "https://github.com/databricks/databricks-sdk-go/tree/main/openapi"
        click CodeGen "https://github.com/databricks/databricks-sdk-go/blob/main/.codegen"
    end

    %% Connections
    AppUsers --> WC & AC
    WC & AC --> SC
    SC --> ReqHandler
    ReqHandler --> HC
    HC --> Retry
    Auth --> HC
    Creds --> Auth
    Config --> Auth
    Env --> Config
    HC --> ErrHandler
    ReqHandler --> Marshal
    HC --> Log
    HC --> UA
    SC --> List

    %% Testing Connections
    Mocks -.-> SC
    QA -.-> HC
    Fixtures -.-> HC

    %% Generation Connections
    OpenAPI --> SC
    CodeGen --> OpenAPI

    %% Styles
    classDef public fill:#2196F3,stroke:#1565C0,color:white
    classDef service fill:#4CAF50,stroke:#2E7D32,color:white
    classDef auth fill:#FFC107,stroke:#FFA000,color:black
    classDef http fill:#9C27B0,stroke:#7B1FA2,color:white
    classDef core fill:#3F51B5,stroke:#303F9F,color:white
    classDef util fill:#607D8B,stroke:#455A64,color:white
    classDef test fill:#FF5722,stroke:#E64A19,color:white
    classDef config fill:#00BCD4,stroke:#0097A7,color:white
    classDef gen fill:#795548,stroke:#5D4037,color:white
```
