# dtm-labs/dtm architecture

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

- Interactive diagram: https://gitdiagram.com/dtm-labs/dtm
- Repository: https://github.com/dtm-labs/dtm

## Overview

DTM is a distributed transaction manager with Go client libraries, a coordinating server, interchangeable persistence backends, and a Vue administration UI. The main workflow is a caller starting a transaction; the server dispatches branch operations, tracks status and retries, and persists transaction state. Documented transaction modes include Saga, TCC, XA, two-phase messages, and Workflow. The README documents the modes and workflow use; sampled server code shows branch dispatch and storage selection, but not every mode’s complete execution path.

Main entry points: [`dtmsvr/storage/registry/registry.go`](https://github.com/dtm-labs/dtm/blob/main/dtmsvr/storage/registry/registry.go) (Storage registry), [`client/workflow/workflow.go`](https://github.com/dtm-labs/dtm/blob/main/client/workflow/workflow.go) (Workflow SDK), [`dtmsvr/entry/main.go`](https://github.com/dtm-labs/dtm/blob/main/dtmsvr/entry/main.go) (Server startup), [`dtmsvr/trans_status.go`](https://github.com/dtm-labs/dtm/blob/main/dtmsvr/trans_status.go) (Status and dispatch)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client SDKs"]
  node_go_sdk["Go transaction SDK<br/>[trans_saga.go]"]
  node_grpc_sdk["gRPC SDK<br/>[msg.go]"]
  node_workflow_sdk["Workflow SDK<br/>[workflow.go]"]
  node_barrier["Branch barriers<br/>[barrier.go]"]
end

subgraph group_server["Transaction server"]
  node_server_entry["Server startup<br/>[main.go]"]
  node_http_api["HTTP API<br/>[api_http.go]"]
  node_transaction_status["Status and dispatch<br/>[trans_status.go]"]
  node_saga["Saga processing<br/>[trans_type_saga.go]"]
  node_transaction_modes["Other transaction modes"]
end

subgraph group_storage["Persistence"]
  node_transaction_records["Transaction records<br/>[trans.go]"]
  node_storage_registry["Storage registry<br/>[registry.go]"]
  node_sql_store[("SQL store<br/>[sql.go]")]
  node_redis_store[("Redis store<br/>[redis.go]")]
  node_bolt_store[("BoltDB store<br/>[boltdb.go]")]
end

subgraph group_admin["Admin console"]
  node_admin_app["Admin application<br/>[App.vue]"]
  node_admin_layout["Admin layout<br/>[content.vue]"]
  node_admin_sidebar["Navigation sidebar<br/>[sidebar.vue]"]
  node_transaction_view["Global transactions"]
  node_transaction_detail["Transaction detail"]
  node_topics_view["Topic management<br/>[Topics.vue]"]
  node_nodes_view["Live nodes<br/>[LivingNodes.vue]"]
end

node_caller(("Service caller"))
node_browser(("Administrator"))

node_caller -.->|"starts transaction"| node_go_sdk
node_caller -->|"executes workflow"| node_workflow_sdk
node_workflow_sdk -->|"registers workflow"| node_workflow_sdk
node_server_entry -->|"waits for store"| node_storage_registry
node_server_entry -->|"starts server API"| node_http_api
node_transaction_status -.->|"dispatches branches"| node_saga
node_transaction_status -.->|"updates status"| node_transaction_records
node_http_api -->|"uses storage"| node_transaction_records
node_storage_registry -->|"registers driver"| node_sql_store
node_storage_registry -->|"registers driver"| node_redis_store
node_storage_registry -->|"registers driver"| node_bolt_store
node_browser -.->|"opens console"| node_admin_app
node_admin_app -.->|"renders layout"| node_admin_layout
node_admin_layout -->|"renders navigation"| node_admin_sidebar
node_transaction_view -->|"opens detail"| node_transaction_detail

click node_go_sdk "https://github.com/dtm-labs/dtm/blob/main/client/dtmcli/trans_saga.go"
click node_grpc_sdk "https://github.com/dtm-labs/dtm/blob/main/client/dtmgrpc/msg.go"
click node_workflow_sdk "https://github.com/dtm-labs/dtm/blob/main/client/workflow/workflow.go"
click node_barrier "https://github.com/dtm-labs/dtm/blob/main/client/dtmcli/barrier.go"
click node_server_entry "https://github.com/dtm-labs/dtm/blob/main/dtmsvr/entry/main.go"
click node_http_api "https://github.com/dtm-labs/dtm/blob/main/dtmsvr/api_http.go"
click node_transaction_status "https://github.com/dtm-labs/dtm/blob/main/dtmsvr/trans_status.go"
click node_saga "https://github.com/dtm-labs/dtm/blob/main/dtmsvr/trans_type_saga.go"
click node_transaction_modes "https://github.com/dtm-labs/dtm/tree/main/dtmsvr"
click node_transaction_records "https://github.com/dtm-labs/dtm/blob/main/dtmsvr/storage/trans.go"
click node_storage_registry "https://github.com/dtm-labs/dtm/blob/main/dtmsvr/storage/registry/registry.go"
click node_sql_store "https://github.com/dtm-labs/dtm/blob/main/dtmsvr/storage/sql/sql.go"
click node_redis_store "https://github.com/dtm-labs/dtm/blob/main/dtmsvr/storage/redis/redis.go"
click node_bolt_store "https://github.com/dtm-labs/dtm/blob/main/dtmsvr/storage/boltdb/boltdb.go"
click node_admin_app "https://github.com/dtm-labs/dtm/blob/main/admin/src/App.vue"
click node_admin_layout "https://github.com/dtm-labs/dtm/blob/main/admin/src/layout/components/content.vue"
click node_admin_sidebar "https://github.com/dtm-labs/dtm/blob/main/admin/src/layout/components/sidebar.vue"
click node_transaction_view "https://github.com/dtm-labs/dtm/blob/main/admin/src/views/Dashboard/GlobalTransactions/AllTransactions.vue"
click node_transaction_detail "https://github.com/dtm-labs/dtm/blob/main/admin/src/views/Dashboard/GlobalTransactions/DialogTransactionDetail.vue"
click node_topics_view "https://github.com/dtm-labs/dtm/blob/main/admin/src/views/Dashboard/KVPairs/Topics.vue"
click node_nodes_view "https://github.com/dtm-labs/dtm/blob/main/admin/src/views/Dashboard/Nodes/LivingNodes.vue"

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_go_sdk,node_grpc_sdk,node_workflow_sdk,node_barrier toneBlue
class node_server_entry,node_http_api,node_transaction_status,node_saga,node_transaction_modes toneAmber
class node_transaction_records,node_storage_registry,node_sql_store,node_redis_store,node_bolt_store toneMint
class node_admin_app,node_admin_layout,node_admin_sidebar,node_transaction_view,node_transaction_detail,node_topics_view,node_nodes_view toneRose
class node_caller,node_browser toneIndigo
```

## Components

### Client SDKs

- [Go transaction SDK](https://github.com/dtm-labs/dtm/blob/main/client/dtmcli/trans_saga.go): `client/dtmcli/trans_saga.go`
- [gRPC SDK](https://github.com/dtm-labs/dtm/blob/main/client/dtmgrpc/msg.go): `client/dtmgrpc/msg.go`
- [Workflow SDK](https://github.com/dtm-labs/dtm/blob/main/client/workflow/workflow.go): `client/workflow/workflow.go`
- [Branch barriers](https://github.com/dtm-labs/dtm/blob/main/client/dtmcli/barrier.go): `client/dtmcli/barrier.go`

### Transaction server

- [Server startup](https://github.com/dtm-labs/dtm/blob/main/dtmsvr/entry/main.go): `dtmsvr/entry/main.go`
- [HTTP API](https://github.com/dtm-labs/dtm/blob/main/dtmsvr/api_http.go): `dtmsvr/api_http.go`
- [Status and dispatch](https://github.com/dtm-labs/dtm/blob/main/dtmsvr/trans_status.go): `dtmsvr/trans_status.go`
- [Saga processing](https://github.com/dtm-labs/dtm/blob/main/dtmsvr/trans_type_saga.go): `dtmsvr/trans_type_saga.go`
- [Other transaction modes](https://github.com/dtm-labs/dtm/tree/main/dtmsvr): `dtmsvr`

### Persistence

- [Transaction records](https://github.com/dtm-labs/dtm/blob/main/dtmsvr/storage/trans.go): `dtmsvr/storage/trans.go`
- [Storage registry](https://github.com/dtm-labs/dtm/blob/main/dtmsvr/storage/registry/registry.go): `dtmsvr/storage/registry/registry.go`
- [SQL store](https://github.com/dtm-labs/dtm/blob/main/dtmsvr/storage/sql/sql.go): `dtmsvr/storage/sql/sql.go`
- [Redis store](https://github.com/dtm-labs/dtm/blob/main/dtmsvr/storage/redis/redis.go): `dtmsvr/storage/redis/redis.go`
- [BoltDB store](https://github.com/dtm-labs/dtm/blob/main/dtmsvr/storage/boltdb/boltdb.go): `dtmsvr/storage/boltdb/boltdb.go`

### Admin console

- [Admin application](https://github.com/dtm-labs/dtm/blob/main/admin/src/App.vue): `admin/src/App.vue`
- [Admin layout](https://github.com/dtm-labs/dtm/blob/main/admin/src/layout/components/content.vue): `admin/src/layout/components/content.vue`
- [Navigation sidebar](https://github.com/dtm-labs/dtm/blob/main/admin/src/layout/components/sidebar.vue): `admin/src/layout/components/sidebar.vue`
- [Global transactions](https://github.com/dtm-labs/dtm/blob/main/admin/src/views/Dashboard/GlobalTransactions/AllTransactions.vue): `admin/src/views/Dashboard/GlobalTransactions/AllTransactions.vue`
- [Transaction detail](https://github.com/dtm-labs/dtm/blob/main/admin/src/views/Dashboard/GlobalTransactions/DialogTransactionDetail.vue): `admin/src/views/Dashboard/GlobalTransactions/DialogTransactionDetail.vue`
- [Topic management](https://github.com/dtm-labs/dtm/blob/main/admin/src/views/Dashboard/KVPairs/Topics.vue): `admin/src/views/Dashboard/KVPairs/Topics.vue`
- [Live nodes](https://github.com/dtm-labs/dtm/blob/main/admin/src/views/Dashboard/Nodes/LivingNodes.vue): `admin/src/views/Dashboard/Nodes/LivingNodes.vue`

### Other components

- **Service caller**
- **Administrator**

## Connections

- Service caller → Go transaction SDK: starts transaction
- Service caller → Workflow SDK: executes workflow
- Workflow SDK → Workflow SDK: registers workflow (evidence: `client/workflow/workflow.go`)
- Server startup → Storage registry: waits for store (evidence: `dtmsvr/entry/main.go`)
- Server startup → HTTP API: starts server API (evidence: `dtmsvr/entry/main.go`)
- Status and dispatch → Saga processing: dispatches branches
- Status and dispatch → Transaction records: updates status
- HTTP API → Transaction records: uses storage (evidence: `dtmsvr/api_http.go`)
- Storage registry → SQL store: registers driver (evidence: `dtmsvr/storage/registry/registry.go`)
- Storage registry → Redis store: registers driver (evidence: `dtmsvr/storage/registry/registry.go`)
- Storage registry → BoltDB store: registers driver (evidence: `dtmsvr/storage/registry/registry.go`)
- Administrator → Admin application: opens console
- Admin application → Admin layout: renders layout
- Admin layout → Navigation sidebar: renders navigation (evidence: `admin/src/layout/aside.vue`)
- Global transactions → Transaction detail: opens detail (evidence: `admin/src/views/Dashboard/GlobalTransactions/AllTransactions.vue`)
