Skip to content

VaughnVernon/DomoTactical-TS

Repository files navigation

DomoTactical-TS

Domo tactical domain modeling tools for TypeScript using DomoActors-TS.

License: RPL-1.5 TypeScript npm version V8 Runtimes npm downloads GitHub stars

Overview

DomoTactical-TS is a comprehensive Domain-Driven Design (DDD) tactical patterns library for TypeScript, built on the DomoActors actor model. It provides DDD-friendly implementations of:

  • Domain Model Actors - Uses DomoActors (npm domo-actors) concurrency and supervision
  • Event-Driven Architecture - Aggregates, Commands, and the resulting Events; publish across contexts
  • Event Sourcing - Persist and restore entity state from domain events
  • Command Sourcing - Alternative sourcing using commands instead of events
  • CQRS Projections - Build read models from event/command streams
  • Journal Storage - Append-only event/command persistence with stream readers
  • Document Store - Key-value storage for documents, read models, and serialized object state
  • Schema Evolution - Versioned events/commands with custom adapters
  • Test Utilities - In-memory implementations for rapid development and testing

Key Features

  • 🎭 Actor-Based Aggregates - Built on DomoActors for concurrency and fault tolerance
  • 🔄 Full CQRS Pipeline - From commands/events through projections to read models
  • 📦 Zero Dependencies - Pure V8 JavaScript, runs anywhere (Node.js, Deno, Bun, Cloudflare Workers)
  • 🧪 Test-Ready - Complete testkit module with in-memory implementations
  • 📘 Type-Safe - Full TypeScript support with comprehensive type definitions
  • 🔌 Pluggable Storage - Abstract interfaces for custom journal and document store implementations

Requirements

  • Runtimes: Node.js >= 18.0.0, Deno, Bun, Cloudflare Workers, or any V8-based JavaScript runtime
  • TypeScript: >= 5.0.0 (for development)
  • DomoActors-TS: >= 1.0.2

DomoTactical-TS and DomoActors-TS have zero Node.js-specific dependencies and runs on any V8-compatible runtime.

Cross-Team and Cross-Context Event and Other Schema Management

  • DomoSchemaMinder - The Domo schema registry for managing cross-team, cross-context events and other schema types

Quick Start

# Install
npm install domo-tactical domo-actors

# Or with your preferred package manager
pnpm add domo-tactical domo-actors
yarn add domo-tactical domo-actors
import { EventSourcedEntity, DomainEvent } from 'domo-tactical'
import { TestJournal } from 'domo-tactical/testkit'

// Define events
class AccountOpened extends DomainEvent {
  constructor(public accountId: string, public balance: number) { super() }
  override id() { return this.accountId }
}

class FundsDeposited extends DomainEvent {
  constructor(public accountId: string, public amount: number) { super() }
  override id() { return this.accountId }
}

// Define entity
class BankAccount extends EventSourcedEntity {
  private balance = 0

  static {
    // Register event handlers
    EventSourcedEntity.registerConsumer(BankAccount, AccountOpened,
      (account, event) => account.balance = event.balance)
    EventSourcedEntity.registerConsumer(BankAccount, FundsDeposited,
      (account, event) => account.balance += event.amount)
  }

  async open(initialBalance: number) {
    await this.apply(new AccountOpened(this.streamName, initialBalance))
  }

  async deposit(amount: number) {
    await this.apply(new FundsDeposited(this.streamName, amount))
  }

  getBalance() { return this.balance }
}

// Usage
const journal = new TestJournal<string>()
const account = new BankAccount('account-123')
account.setJournal(journal) // use setJournal() for tests

await account.open(1000)
await account.deposit(500)
console.log(account.getBalance())  // 1500

Documentation

Contributing

DomoActors is authored by Vaughn Vernon and maintained as part of the Domo product family.

For issues and feature requests, please visit: https://github.com/VaughnVernon/DomoTactical-TS/issues

License

Reciprocal Public License 1.5

See: ./LICENSE.md

Copyright © 2012-2025 Vaughn Vernon. All rights reserved. Copyright © 2012-2025 Kalele, Inc. All rights reserved.

About the Creator and Author

Vaughn Vernon

About

Domo tactical domain modeling tools for TypeScript using DomoActors-TS.

Resources

License

Stars

Watchers

Forks

Packages

No packages published