# tkhq/go-sdk architecture

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

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

## Overview

Turnkey Go SDK is a client library for authenticated Turnkey API calls, with separate crypto and encoding modules. The main workflow builds a client with a stamper, invokes generated operations, signs authenticated requests, sends HTTP requests, and decodes results; activity operations may wait for completion. Handwritten secret import/export helpers add an encryption workflow, while crypto also provides key, signing, and enclave capabilities. Code generation and protobuf schemas are included as product-supporting interfaces. Relationships shown are limited to README claims and sampled source; unsampled links are omitted.

Main entry points: [`client_gen.go`](https://github.com/tkhq/go-sdk/blob/main/client_gen.go) (API operations), [`client.go`](https://github.com/tkhq/go-sdk/blob/main/client.go) (HTTP client), [`codegen/generators/generate.go`](https://github.com/tkhq/go-sdk/blob/main/codegen/generators/generate.go) (SDK generator), [`stamper.go`](https://github.com/tkhq/go-sdk/blob/main/stamper.go) (Request stamper)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API client"]
  node_client["HTTP client<br/>[client.go]"]
  node_operations["API operations<br/>[client_gen.go]"]
  node_api_types["API types<br/>[types_gen.go]"]
  node_extensions["Client helpers"]
end

subgraph group_auth["Authentication and crypto"]
  node_stamper["Request stamper<br/>[stamper.go]"]
  node_crypto_keys["API key crypto<br/>[apikey.go]"]
  node_crypto_ecdsa["ECDSA keys<br/>[apikey_ecdsa.go]"]
  node_crypto_ed25519["Ed25519 keys<br/>[apikey_ed25519.go]"]
  node_crypto_encrypt["Encryption keys<br/>[encryptionkey.go]"]
  node_crypto_hpke["HPKE<br/>[hpke.go]"]
  node_crypto_verify["Signature verification<br/>[verify.go]"]
  node_crypto_store[("Key storage<br/>[store.go]")]
  node_enclave["Enclave crypto<br/>[enclave.go]"]
  node_encoding["Encoding utilities"]
end

subgraph group_secrets["Secret transport"]
  node_secret_helpers["Secret import/export"]
end

subgraph group_generation["Schema and generation"]
  node_swagger["API specifications<br/>[swagger.go]"]
  node_activity_config["Activity definitions<br/>[activities.go]"]
  node_generator["SDK generator<br/>[generate.go]"]
  node_proto_schemas["Protocol schemas"]
  node_proto_codegen["Protobuf generator<br/>[main.go]"]
end

node_developer(("SDK caller"))
node_turnkey_api{{"Turnkey API"}}
node_custom_stamper["Custom stamper"]
node_secret_service{{"Secret API"}}

node_developer -->|"constructs and calls"| node_client
node_developer -->|"invokes operation"| node_operations
node_operations -->|"sends requests"| node_client
node_client -->|"posts HTTP"| node_turnkey_api
node_client -.->|"signs requests"| node_stamper
node_stamper -->|"signs with key"| node_crypto_keys
node_stamper -->|"accepts substitute"| node_custom_stamper
node_operations -->|"uses request types"| node_api_types
node_operations -->|"submits activities"| node_turnkey_api
node_operations -->|"waits for activity"| node_client
node_extensions -->|"decrypts exports"| node_crypto_encrypt
node_secret_helpers -->|"imports and exports"| node_secret_service
node_secret_helpers -->|"encrypts and decrypts"| node_enclave
node_enclave -->|"verifies signatures"| node_crypto_verify
node_enclave -->|"uses encoding"| node_encoding
node_crypto_keys -.->|"supports scheme"| node_crypto_ecdsa
node_crypto_keys -.->|"supports scheme"| node_crypto_ed25519
node_crypto_encrypt -.->|"uses HPKE"| node_crypto_hpke
node_generator -->|"reads specifications"| node_swagger
node_generator -->|"reads activities"| node_activity_config
node_generator -.->|"generates methods"| node_operations
node_generator -.->|"generates types"| node_api_types
node_proto_codegen -->|"compiles schemas"| node_proto_schemas

click node_client "https://github.com/tkhq/go-sdk/blob/main/client.go"
click node_operations "https://github.com/tkhq/go-sdk/blob/main/client_gen.go"
click node_api_types "https://github.com/tkhq/go-sdk/blob/main/types_gen.go"
click node_extensions "https://github.com/tkhq/go-sdk/blob/main/client_extensions.go"
click node_stamper "https://github.com/tkhq/go-sdk/blob/main/stamper.go"
click node_crypto_keys "https://github.com/tkhq/go-sdk/blob/main/crypto/apikey.go"
click node_crypto_ecdsa "https://github.com/tkhq/go-sdk/blob/main/crypto/apikey_ecdsa.go"
click node_crypto_ed25519 "https://github.com/tkhq/go-sdk/blob/main/crypto/apikey_ed25519.go"
click node_crypto_encrypt "https://github.com/tkhq/go-sdk/blob/main/crypto/encryptionkey.go"
click node_crypto_hpke "https://github.com/tkhq/go-sdk/blob/main/crypto/hpke.go"
click node_crypto_verify "https://github.com/tkhq/go-sdk/blob/main/crypto/verify.go"
click node_crypto_store "https://github.com/tkhq/go-sdk/blob/main/crypto/store.go"
click node_enclave "https://github.com/tkhq/go-sdk/blob/main/crypto/enclave.go"
click node_encoding "https://github.com/tkhq/go-sdk/tree/main/encoding"
click node_secret_helpers "https://github.com/tkhq/go-sdk/blob/main/client_extensions.go"
click node_swagger "https://github.com/tkhq/go-sdk/blob/main/codegen/generators/swagger.go"
click node_activity_config "https://github.com/tkhq/go-sdk/blob/main/codegen/generators/activities.go"
click node_generator "https://github.com/tkhq/go-sdk/blob/main/codegen/generators/generate.go"
click node_proto_schemas "https://github.com/tkhq/go-sdk/tree/main/proto/schema"
click node_proto_codegen "https://github.com/tkhq/go-sdk/blob/main/proto/cmd/gen/main.go"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_client,node_operations,node_api_types,node_extensions toneBlue
class node_stamper,node_crypto_keys,node_crypto_ecdsa,node_crypto_ed25519,node_crypto_encrypt,node_crypto_hpke,node_crypto_verify,node_crypto_store,node_enclave,node_encoding toneAmber
class node_secret_helpers,node_turnkey_api,node_secret_service toneMint
class node_swagger,node_activity_config,node_generator,node_proto_schemas,node_proto_codegen toneRose
class node_developer,node_custom_stamper toneIndigo
```

## Components

### API client

- [HTTP client](https://github.com/tkhq/go-sdk/blob/main/client.go): `client.go`
- [API operations](https://github.com/tkhq/go-sdk/blob/main/client_gen.go): `client_gen.go`
- [API types](https://github.com/tkhq/go-sdk/blob/main/types_gen.go): `types_gen.go`
- [Client helpers](https://github.com/tkhq/go-sdk/blob/main/client_extensions.go): `client_extensions.go`

### Authentication and crypto

- [Request stamper](https://github.com/tkhq/go-sdk/blob/main/stamper.go): `stamper.go`
- [API key crypto](https://github.com/tkhq/go-sdk/blob/main/crypto/apikey.go): `crypto/apikey.go`
- [ECDSA keys](https://github.com/tkhq/go-sdk/blob/main/crypto/apikey_ecdsa.go): `crypto/apikey_ecdsa.go`
- [Ed25519 keys](https://github.com/tkhq/go-sdk/blob/main/crypto/apikey_ed25519.go): `crypto/apikey_ed25519.go`
- [Encryption keys](https://github.com/tkhq/go-sdk/blob/main/crypto/encryptionkey.go): `crypto/encryptionkey.go`
- [HPKE](https://github.com/tkhq/go-sdk/blob/main/crypto/hpke.go): `crypto/hpke.go`
- [Signature verification](https://github.com/tkhq/go-sdk/blob/main/crypto/verify.go): `crypto/verify.go`
- [Key storage](https://github.com/tkhq/go-sdk/blob/main/crypto/store.go): `crypto/store.go`
- [Enclave crypto](https://github.com/tkhq/go-sdk/blob/main/crypto/enclave.go): `crypto/enclave.go`
- [Encoding utilities](https://github.com/tkhq/go-sdk/tree/main/encoding): `encoding`

### Secret transport

- [Secret import/export](https://github.com/tkhq/go-sdk/blob/main/client_extensions.go): `client_extensions.go`

### Schema and generation

- [API specifications](https://github.com/tkhq/go-sdk/blob/main/codegen/generators/swagger.go): `codegen/generators/swagger.go`
- [Activity definitions](https://github.com/tkhq/go-sdk/blob/main/codegen/generators/activities.go): `codegen/generators/activities.go`
- [SDK generator](https://github.com/tkhq/go-sdk/blob/main/codegen/generators/generate.go): `codegen/generators/generate.go`
- [Protocol schemas](https://github.com/tkhq/go-sdk/tree/main/proto/schema): `proto/schema`
- [Protobuf generator](https://github.com/tkhq/go-sdk/blob/main/proto/cmd/gen/main.go): `proto/cmd/gen/main.go`

### Other components

- **SDK caller**
- **Turnkey API**
- **Custom stamper**
- **Secret API**

## Connections

- SDK caller → HTTP client: constructs and calls
- SDK caller → API operations: invokes operation
- API operations → HTTP client: sends requests (evidence: `client_gen.go`)
- HTTP client → Turnkey API: posts HTTP (evidence: `client.go`)
- HTTP client → Request stamper: signs requests
- Request stamper → API key crypto: signs with key (evidence: `stamper.go`)
- Request stamper → Custom stamper: accepts substitute
- API operations → API types: uses request types (evidence: `client_gen.go`)
- API operations → Turnkey API: submits activities (evidence: `client_gen.go`)
- API operations → HTTP client: waits for activity (evidence: `client_gen.go`)
- Client helpers → Encryption keys: decrypts exports (evidence: `client_extensions.go`)
- Secret import/export → Secret API: imports and exports (evidence: `client_extensions.go`)
- Secret import/export → Enclave crypto: encrypts and decrypts (evidence: `client_extensions.go`)
- Enclave crypto → Signature verification: verifies signatures (evidence: `crypto/enclave.go`)
- Enclave crypto → Encoding utilities: uses encoding (evidence: `crypto/enclave.go`)
- API key crypto → ECDSA keys: supports scheme
- API key crypto → Ed25519 keys: supports scheme
- Encryption keys → HPKE: uses HPKE
- SDK generator → API specifications: reads specifications (evidence: `codegen/generators/generate.go`)
- SDK generator → Activity definitions: reads activities (evidence: `codegen/generators/generate.go`)
- SDK generator → API operations: generates methods
- SDK generator → API types: generates types
- Protobuf generator → Protocol schemas: compiles schemas (evidence: `proto/cmd/gen/main.go`)
