@noddde/engine
v0.3.8
Published
Runtime engine for noddde: domain orchestration and in-memory implementations for DDD, CQRS, and Event Sourcing
Downloads
777
Maintainers
Readme
@noddde/engine
Runtime engine for noddde: domain orchestration and in-memory implementations for DDD, CQRS, and Event Sourcing.
Install
yarn add @noddde/core @noddde/engine
# or
npm install @noddde/core @noddde/engineWhat's Inside
@noddde/engine provides:
- Domain orchestration (
wireDomain) to compose aggregates, projections, and sagas into a running domain (thedefineDomainstructural helper lives in@noddde/coreand is re-exported here for backward compatibility) - In-memory implementations for all infrastructure contracts: command bus, query bus, event bus, aggregate persistence, saga persistence, snapshot store, outbox store, unit of work, locking, and idempotency
- Outbox relay for reliable event publishing
- Logger with pluggable backends
The in-memory implementations are useful for development, testing, and prototyping. For production, swap them out with a persistence adapter (@noddde/drizzle, @noddde/prisma, or @noddde/typeorm).
Usage
import { defineDomain } from "@noddde/core";
import { wireDomain } from "@noddde/engine";
import { BankAccount } from "./aggregates/bank-account";
import { BalanceProjection } from "./projections/balance";
const definition = defineDomain({
writeModel: {
aggregates: { BankAccount },
},
readModel: {
projections: { BalanceProjection },
},
});
// Wire with in-memory backends (no adapter needed)
const domain = await wireDomain(definition);
// Dispatch commands
await domain.dispatchCommand({
name: "Deposit",
targetAggregateId: "acc-1",
payload: { amount: 100 },
});With a Persistence Adapter
import { DrizzleAdapter } from "@noddde/drizzle";
const adapter = new DrizzleAdapter(db);
const domain = await wireDomain(definition, {
persistenceAdapter: adapter,
});Related Packages
| Package | Description |
| :----------------------------------------------------------------- | :------------------------------------------------------------- |
| @noddde/core | Types, interfaces, and definition functions |
| @noddde/testing | Test harnesses for aggregates, sagas, projections, and domains |
| @noddde/drizzle | Drizzle ORM persistence adapter |
| @noddde/prisma | Prisma persistence adapter |
| @noddde/typeorm | TypeORM persistence adapter |
License
MIT
