Skip to content
Early preview

AlveolusKeep your domain model clean, whoever writes the code.

Domain-Driven Design building blocks and architecture checks for TypeScript, for teams and their agents.

Alveolus logo

Architectures drift ​

Deadlines, new teammates, shortcuts taken once and copied ten times: the structure a project started with erodes. Coding agents speed this up. They solve the task in front of them and forget the decisions behind the code around it.

Alveolus turns those decisions into code. The patterns of Domain-Driven Design become classes you extend, a shared layout tells everyone where things go, and a check run in continuous integration reports what breaks them. It works the same for a developer who knows DDD and for an agent that has never heard of it.

Write the domain with building blocks ​

order.aggregate.ts
ts
export class Order extends AggregateRoot<OrderId, OrderPlaced, OrderSnapshot> {
	place(total: number, eventId: string, now: Date): Result<void, InvalidTotal> {
		if (total <= 0) {
			return err(new InvalidTotal({ total }));
		}
		this.placedTotal = total;
		this.record(new OrderPlaced({ aggregateId: this.id, id: eventId, occurredAt: now, payload: { total } }));
		return ok();
	}
}

Check it on every run ​

sh
$ npx alveolus arch check
src/ordering/domain/aggregates/order.aggregate.ts:1
  domain-purity: The domain imports @nestjs/common: add it
  to domainDependencies if the domain really needs it.

src/ordering/application/commands/place-order.command.ts:3
  layer-direction: The application layer imports
  src/ordering/driven/pg/adapters/pg-orders.adapter.ts
  (ordering driven): it may only import domain,
  application, published-language.

2 violations

Two packages ​

Start in a minute ​

sh
pnpm add @alveolus/core
pnpm add -D @alveolus/arch
sh
npm install @alveolus/core
npm install -D @alveolus/arch
sh
yarn add @alveolus/core
yarn add -D @alveolus/arch
sh
bun add @alveolus/core
bun add -d @alveolus/arch

Then describe your bounded contexts in alveolus.config.ts and run npx alveolus arch check: Getting started walks through it.

Released under the MIT License.