Alchemy Domain models a business as commands, aggregates, and events

Alchemy Domain is the @alchemy.run/domain package, shipped with Alchemy 2.0.0-beta.85. The Domain docs call it a domain-driven design framework for Effect35. It models a business in its own terms: commands, aggregates, events, views, projections, and policies.

Commands, aggregates, and events

A command asks for a change. An aggregate decides whether the change happens, using its current state. An event records what happened. Views, projections, and policies then answer reads, feed other stores, and react to events.

The example: deposit money into an account

The Domain docs build a bank, and its first example deposits money into an account.

The DepositMoney command names its target, an account id. It takes an amount as input.

It declares the one event it can record, MoneyDeposited, with the amount and the balance after. It declares the one way it can be refused, NotOpen. It replies with the new balance.

The account aggregate decides the command against the account’s state. A closed account refuses it with NotOpen. An open account records MoneyDeposited with the balance plus the amount.

A story tests it in the business’s own words. Given an account opened for an owner, when 100 is deposited, then MoneyDeposited records 100 with a balance of 100. The reply is a balance of 100.

The links point at the docs page at the commit tagged v2.0.0-beta.85, so the example matches the version rat-stack pins.

One model, two places to run it

The same model runs in memory for tests and on Cloudflare Durable Objects in production, with one ordered partition per key. Story runs the real model in memory, so a story describes what the model does. On Cloudflare, every aggregate instance, view key, and policy gets its own Durable Object60, and the app declares none of them. Swapping DomainCloudflare.layerDurableObjects() for Domain.InMemory changes nothing else in the program.

Where it meets rat-stack

rat-stack pins Alchemy 2.0.0-beta.85, the release that ships this package. rat-stack’s own Workers do not run on Alchemy Domain yet. An optional @alchemy.run/domain/Foldkit adapter30 connects a Domain Api to a Foldkit27 app, as the Foldkit chapter describes.

Sources

  1. Domain. Alchemy. What the package models, where it runs, and the bank account example. Accessed 2026-11-06.
  2. Cloudflare Durable Objects. Alchemy. Hosting a model on Durable Objects behind a Worker. Accessed 2026-11-06.
  3. Story. Alchemy. Given, when, then tests that run the real model in memory. Accessed 2026-11-06.
  4. packages/domain at v2.0.0-beta.85. alchemy-run/alchemy. Source of @alchemy.run/domain at the Alchemy version rat-stack pins. Accessed 2026-11-06.

Last changed 2026-11-06 in a23ab72. Source on GitHub. Change log.

Linked from

  1. Agent guide. An Effect stack so pure (aspirational) Kit Langton will blush.
    Link context

    Alchemy Domain models a business as commands, aggregates, and events — Alchemy Domain is a domain-driven design framework for Effect whose one model runs in memory for tests and on Cloudflare Durable Objects in production.

  2. Change log. What changed in the files served here, newest first.

    Alchemy Domain models a business as commands, aggregates, and events — new page: Initial commit from joelhooks/rat-stack template

  3. Full agent guide. An Effect stack so pure (aspirational) Kit Langton will blush.
  4. Rat Stack lore | rat-stack. Short, source-grounded notes on the ideas and decisions behind rat-stack.
    Link context

    Alchemy Domain models a business as commands, aggregates, and events — Alchemy Domain is a domain-driven design framework for Effect whose one model runs in memory for tests and on Cloudflare Durable Objects in production.

  5. Source change history (log.md). The generated change log as Markdown.

    Alchemy Domain models a business as commands, aggregates, and events — new page: Initial commit from joelhooks/rat-stack template