Skip to content
dogmatiqPublic

About

An example Dogma application with the features of a simple bank.

Resources

Contributing

Stars

4 stars

Watchers

3 watching

Forks

Repository files navigation

Dogma Example Application

An example Dogma application, which implements the features of a simple bank.

Build Status Code Coverage

Running locally

Start PostgreSQL:

docker run --rm -d --name dogma-example-postgres \
  -e POSTGRES_PASSWORD=password -e POSTGRES_DB=bank \
  -p 5432:5432 postgres:18-alpine

Once PostgreSQL is ready, run the example:

DOGMA_EXAMPLE_ENGINE_DSN='postgres://postgres:password@localhost:5432/bank?sslmode=disable' \
DOGMA_EXAMPLE_PROJECTION_DSN='postgres://postgres:password@localhost:5432/bank?sslmode=disable' \
  go run ./cmd/bank

The application creates the engine and projection schemas on startup and preserves state across restarts. Both DSNs can use the same PostgreSQL 18 database, as above, or separate databases. Use sslmode=disable only for local databases.

Run go test ./... with Docker available. Projection tests use testcontainers with PostgreSQL 18 and an isolated database per test. CGO is not required.

Commands and the UI

Runkit accepts commands asynchronously. The deposit, withdrawal, and transfer handlers use WithEventObserver() to wait for outcome events, so the UI can show a result such as a declined withdrawal. These waits are bounded by the request deadline; a timeout does not cancel a command already accepted by the engine.

An observed event does not mean the UI projections have caught up. Account creation uses waitForAccount() before redirecting so the next page can read the customer and account. This demonstrates one way to support a synchronous UI; a UI that shows pending work and updates as projections arrive would avoid holding the request open.

About

An example Dogma application with the features of a simple bank.

Resources

Contributing

Stars

4 stars

Watchers

3 watching

Forks

Releases

Packages

Used by

Contributors

Languages