explaingit

dtm-labs/dtm

10,873GoAudience · developerComplexity · 4/5LicenseSetup · hard

TLDR

DTM is an open-source Go framework for managing distributed transactions across multiple services or databases, ensuring operations either all succeed or all roll back, with SDKs for Go, Java, Python, Node.js, PHP, and C#.

Mindmap

mindmap
  root((DTM))
    What it does
      Distributed transactions
      Multi-service coordination
      Automatic rollback
    Patterns
      SAGA
      TCC
      XA two-phase commit
      Workflow
    Language SDKs
      Go
      Java
      Python
      Node.js
    Databases
      MySQL
      PostgreSQL
      Redis
    Audience
      Backend developers
      Microservice teams
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Implement a reliable bank-transfer flow across two microservices so money is never lost or double-debited even if one service crashes mid-transfer.

USE CASE 2

Add SAGA-pattern rollback to a multi-step order checkout that touches an inventory service, a payment service, and a shipping service.

USE CASE 3

Replace a fragile Outbox pattern implementation with DTM's two-phase message approach for reliable event publishing after a database write.

USE CASE 4

Coordinate a TCC transaction across a Go and a Java microservice without rewriting either service in the same language.

Tech stack

GoMySQLPostgreSQLRedisMongoDB

Getting it running

Difficulty · hard Time to first run · 1h+

Requires running the DTM server separately plus configuring a supported database (MySQL, PostgreSQL, Redis, or MongoDB) before microservices can join transactions.

Open source under a permissive license, use freely in commercial and personal projects.

In plain English

DTM is a framework for managing distributed transactions, which are operations that span multiple separate services or databases and need to either all succeed or all be undone together. In a typical modern application, different parts of the system run as independent services. When a user action touches several of those services (for example, deducting money from one account and crediting another), keeping all of them in sync when something goes wrong is genuinely hard. DTM exists to solve that problem. The framework supports several well-established patterns for handling this coordination. SAGA breaks the overall transaction into a series of steps, each with a corresponding undo step if something fails. TCC (Try, Confirm, Cancel) reserves resources first before committing. XA is a classic two-phase commit standard supported by many databases. The Workflow pattern lets developers write the coordination logic in code that looks mostly like normal sequential code. There is also a two-phase message pattern described as a cleaner alternative to the traditional Outbox pattern, which is a technique for reliably publishing events when a database write happens. DTM works across multiple languages. SDKs exist for Go, Java, PHP, C#, Python, and Node.js, so teams are not locked into any single technology. On the database side it supports MySQL, MariaDB, PostgreSQL, Redis, and MongoDB. It is built in Go and can scale horizontally for high-traffic situations. Real-world users listed in the README include Tencent and Bytedance, both large technology companies, suggesting the project has been tested in demanding environments. The quick-start example in the README shows a bank transfer scenario: money moves out of one account and into another across two separate microservices, with automatic rollback if the transfer-in step fails. The project is open source and available under a permissive license.

Copy-paste prompts

Prompt 1
Show me how to set up DTM with Go and implement a SAGA transaction that debits one account and credits another, with automatic rollback if the credit fails.
Prompt 2
How do I integrate the DTM Java SDK into a Spring Boot microservice to participate in a distributed transaction managed by the DTM server?
Prompt 3
Walk me through the DTM two-phase message pattern as a replacement for the Outbox pattern when publishing events after a MySQL write.
Prompt 4
How do I deploy the DTM server and connect it to PostgreSQL so my microservices can use it for XA transactions?
Prompt 5
What's the difference between DTM's SAGA, TCC, and Workflow patterns, and which one should I use for an e-commerce checkout flow?
Open on GitHub → Explain another repo

← dtm-labs on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.