Introduction
go-sequent documentation
Documentation for go-sequent, a Go library for CQRS and event sourcing built for ledgers and payments. Start here to find guides, API reference, operations runbooks and security notes.
go-sequent documentation
go-sequent is a Go library for CQRS and event sourcing, aimed at financial ledgers and payment systems. You write commands, aggregates, events and projections. The library runs them inside one database transaction, with optimistic concurrency, unique keys, tenant-scoped idempotency and hash-chain integrity already wired in.
It is a pure library. There is no HTTP or gRPC server in the repository; you embed it in your own service. The Go module is github.com/go-sequent/go-sequent, released under the MIT license.
The design follows the concepts of Sequent for Ruby (command, aggregate root, event store, projector, workflow). The Go APIs and the PostgreSQL schema are written from scratch. go-sequent never reads or imports a Ruby Sequent database.
Where to start
| If you want to… | Read |
|---|---|
| Run the bank example in five minutes | Getting started |
| Decide whether the library fits your system | What is go-sequent |
| See how one command travels through the code | Core loop |
| Build an aggregate step by step | Modelling the domain |
| Understand how OCC, idempotency and the UnitOfWork fit together | Write-path consistency |
| Look up a specific API | The Reference section below |
| Run it in production | Operations overview |
Introduction
- Getting started: install, run the bank example, first commands.
- What is go-sequent: scope, fit, and what it deliberately does not do.
- Core loop:
CommandService.Executefrom entry to commit.
Guides
- Modelling the domain: a tutorial built around the bank
Accountaggregate. - Write-path consistency: UnitOfWork, OCC and idempotency, and what each one covers.
- Bank example: a tour of
examples/bankandexamples/bankpg.
Reference
Building blocks: Command, Event, AggregateRoot, CommandHandler, Repository and UnitOfWork, CommandService.
Storage and publishing: EventStore, Publisher and SyncInTxn, Projector, Workflow, Snapshotting.
Correctness and security: Unique keys and OCC, Idempotency, AuthZ, Tenancy, Money.
Tooling: OpenTelemetry, Migrations and CLI, Wiring the façade, Testing.
Background: Glossary, Locked decisions, go-sequent vs Sequent (Ruby).
Operations and security
- Operations overview, Failover, Projection rebuild, Backup and restore, Partitioning.
- Threat model, Event evolution.
Design commitments
These choices are fixed and the rest of the documentation assumes them.
- Ledger projections run with
SyncInTxn, inside the write transaction. - Money is a decimal (
types.Money).float64is banned for amounts. - Integrity is a per-aggregate hash chain. There are no event signatures.
- Tenancy is a shared schema with a
tenant_idcolumn. - GDPR handling is tombstone-only.
- The outbox is a Postgres table that a poller drains.
- No Ruby Sequent database is ever imported.
Source code is at github.com/go-sequent/go-sequent. When this site and the code disagree, the code is right; please open an issue.
Docs track the go-sequent library. When APIs drift, the source wins.