πŸ“š Event Ontology

Introduction to Event Ontology

@sullux/event-ontology is a declarative, schema-driven toolchain for building, validating, and projecting event-sourced domains in Node.js.

In event-driven and event-sourced architectures, maintaining parity between validation schemas (Ajv/JSON Schema), database projection DDLs (SQL tables and indexes), side-effect handlers, and documentation across multiple evolving versions is notoriously error-prone.

@sullux/event-ontology solves this by introducing a single source of truth defined entirely in human-readable YAML definitions.


Core Capabilities

  • Declarative Schemas: Define domain entities and versioned events using standard JSON Schema syntax with clean, expressive YAML shorthand.
  • Schema Inheritance ($merge): Compose common structures, shared types, and domain metadata hierarchically without code duplication.
  • Zero-Runtime Plugin Compilation: Generates self-contained, pre-compiled JavaScript modules ready to register directly into @sullux/event-engine.
  • Automated Projection DDL: Automatically generates SQL CREATE TABLE IF NOT EXISTS migration statements from the $dbSchema declarations on your events.
  • First-Class Partitioning & Deduplication: Declare custom $partitionKey and $deduplicationId handlers directly in YAML expressions.
  • Automatic Documentation: Compiles complete markdown ontology references directly from the inline YAML comments and properties.

The Compilation Pipeline

  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
  β”‚                   src/*.yaml files                     β”‚
  β”‚  (Domain types, Entity schemas, Versioned events)      β”‚
  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                              β”‚
                    npx event-ontology build
                              β”‚
             β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
             β–Ό                β–Ό                β–Ό
     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
     β”‚ dist/index.js β”‚ β”‚dist/schema.sqlβ”‚ β”‚docs/README.mdβ”‚
     β”‚ Event-Engine  β”‚ β”‚Database DDL  β”‚ β”‚ Domain Doc   β”‚
     β”‚    Plugin     β”‚ β”‚  Migrations  β”‚ β”‚  Reference   β”‚
     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Next Steps