ArchitectureKit WhyCapabilitiesGet started Get started →
Products / Building / ArchitectureKit
Building

ArchitectureKit

DDD, CQRS, and Event Sourcing for Go.

Building blocks for applications based on Domain-Driven Design, CQRS, and Event Sourcing, in Go and on top of EventSourcingDB. A kit rather than a framework – every piece can be used on its own, and nothing happens behind your back.

Open source under the MIT license.

License
MIT License
Language
Go
ArchitectureKit
Why ArchitectureKit

Two places where event-sourced applications rely on luck.

Two concurrent writes to the same thing on the way in, and a read right after a write on the way out. ArchitectureKit handles both, and it covers both sides of an application – commands, events, and state for writing, projections, views, and queries for reading.

  • Every command writes with its preconditions. The database rejects duplicates and concurrent changes, not your luck.
  • A read can wait for your own write. Views track the revision they have seen, and a query waits until it is reached.
  • Tests need no database. A test package checks deciders, projections, and queries without a database.
var acquireBook = architecturekit.Decider[AcquireBook, Book]{
  State: bookState,
  Decide: func(ctx context.Context, cmd AcquireBook, book Book) ([]architecturekit.Event, error) {
    if book.IsAcquired {
      return nil, architecturekit.NewDomainError("book %s has already been acquired", cmd.BookID)
    }

    return []architecturekit.Event{
      BookAcquired{Title: cmd.Title, Author: cmd.Author, ISBN: cmd.ISBN},
    }, nil
  },
}

A decider receives a command and the current state, and returns the events to write. Execute reads the events, evolves the state, decides, and writes.

Capabilities

Both sides of an event-sourced application.

Every capability links to the part of the docs that explains it.

Writing

Decisions on commands

  • Commands, events, and statePlain structs, with the state evolved from the events of a subject.Defining Commands
  • DecidersThe decision on a command, as a function of the command and the state.Making Decisions
  • PreconditionsPrevent duplicates, guard against concurrent changes, enforce rules across subjects.Using Preconditions
  • Versioned eventsUpcasters translate stored events of an old type into the new one.Versioning Events
Reading

Views that keep up

  • ProjectionsTurn events into views, and resume where they stopped.Projections
  • ViewsHold the data that queries read, in memory or in a database of your own.Defining Views
  • QueriesFilter, order, page, and count the items of a view.Defining Queries
  • Reading your own writesWait until a view has seen the events you have written.Reading Your Own Writes
HTTP

An API for commands and queries

Testing

Tests without a database

Talk to us

Planning something bigger?

Whether you need a quote, support, or a second opinion on your architecture – we are happy to help.