Introduction
go-mink is an Event Sourcing and CQRS toolkit for Go. It gives you the building blocks to record changes as events, rebuild domain state, and create read models for your application.
Start with a small event stream. Add commands, projections, and workflow coordination as your application needs them.
Choose your starting point
| If you want to… | Start here |
|---|---|
| Build an application step by step | The order system tutorial |
| Understand the moving parts | Architecture |
| Append events and load a stream | The event store |
| Build query-friendly views | Read models and projections |
| Compare storage capabilities | Adapters |
| Learn the concepts from first principles | The Event Sourcing series |
Install the module
From a Go module, add go-mink:
go get go-mink.dev
Use the memory adapter for tests and local experiments. Use PostgreSQL when your events need durable storage. The project setup tutorial walks through configuration, schema initialization, and your first application.
Think in events
A conventional state update records that an order is now shipped. An event-sourced model also records the steps that got it there:
OrderCreated → ItemAdded → PaymentReceived → OrderShipped
The event stream is the history. An aggregate applies that history to rebuild its current state. A projection transforms events into a view designed for a specific query: an order summary, a fulfillment queue, or a report.
This is useful when the sequence of changes matters. It also introduces responsibilities: event schema evolution, projection maintenance, replay safety, and operational monitoring. For a small CRUD application with no need for historical behavior, a conventional database model may be simpler.
Follow the data
- Handle a command. Your domain logic validates an action and decides which events to record. The command bus can add validation, logging, tracing, and other middleware.
- Persist the events. The event store serializes events and appends them through an adapter. Expected stream versions protect against conflicting writes.
- Build a view. Your application explicitly invokes inline projections, runs async projections, or notifies live projections according to its consistency needs.
- Query the read model. Read a view shaped for your application instead of rebuilding an entire stream for every screen.
Appending an event does not automatically run every projection. Inline projections are invoked through ProcessInlineProjections; async projections poll stored events and maintain checkpoints; live projections receive notifications through NotifyLiveProjections.
Add capabilities as you need them
- Domain modeling: aggregates and the event store, optimistic concurrency, and snapshots.
- Application workflows: the command bus, sagas, and outbox.
- Evolution: event versioning and upcasting.
- Data protection: field-level encryption and data governance.
- Verification: Given–When–Then tests, assertions, and projection utilities.
- Operations: the CLI, benchmarks, and production guidance.
The library provides mechanisms; your application defines domain rules, consistency boundaries, access controls, and retention policies. The architecture guide explains how these pieces fit together.