Skip to content

GodSpeedAI/DomainForge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ›οΈ DomainForge

Your Business Rules, Everywhere. Always Correct. Always in Sync.

What if your team never had to ask "which version is right?" again?

Rust Python TypeScript WASM License Tests


The Hidden Cost You're Already Paying

Every enterprise faces the same invisible tax:

πŸ”΄ The Documentation Drift Problem Your team spends weeks documenting business requirements. Then someone codes them in Python. Then someone else needs the same logic in TypeScript. Six months later, three different "source of truth" documents existβ€”and none of them match production.

πŸ”΄ The Translation Telephone Game
Business requirement β†’ Technical spec β†’ Backend code β†’ Frontend code β†’ Reality
At each handoff, fidelity is lost. At the end, you're left wondering: "Is what we built actually what we agreed to?"

πŸ”΄ The Compliance Nightmare
Auditors ask: "Show me where this rule is enforced."
You scramble across Confluence pages, Jira tickets, Python services, and TypeScript frontendsβ€”hoping you didn't miss anything.


What If You Could Write It Once?

DomainForge makes your business logic portable, provable, and permanent.

Write your rules in plain language. Run them identically in Python, TypeScript, Rust, or your browser. Change them in one placeβ€”watch the change cascade everywhere, automatically.

What You Get Why It Matters
One model, every language Python validation = TypeScript validation. Period. No drift.
Instant rule checking 10,000 entities validated in under 100 milliseconds
Business-readable, machine-executable Your analysts can read the rules. Your systems enforce them.
Architecture-as-Code Export directly to FINOS CALM for enterprise governance
Formal mathematical rigor Not just documentationβ€”provable correctness

See It Working (60 seconds)

from sea import Model

# Define WHO does the work
assembly_line = model.entity("Assembly Line A")
warehouse = model.entity("Warehouse")

# Define WHAT moves between them
camera = model.resource("Camera", unit="units")

# Define HOW much moves
production = model.flow(
    name="Daily Production",
    resource=camera,
    from_entity=assembly_line,
    to_entity=warehouse,
    quantity=1000
)

# Define the RULES that must always be true
model.policy(
    "Minimum Production Threshold",
    expression="forall f in Flow where f.resource = Camera: f.quantity >= 500",
    severity="error"
)

# Validate everythingβ€”instantly
results = model.validate()
print(f"βœ… Model valid: {results.is_valid}")

That's it. You just created a formal, executable business rule that:

  • Validates production quantities instantly
  • Works identically in Python, TypeScript, Rust, or the browser
  • Exports to FINOS CALM for architecture governance
  • Becomes the single source of truth everyone can trust

Install in 30 Seconds

# Python
pip install sea-dsl

# TypeScript / Node.js
npm install @domainforge/sea

# Rust
cargo add sea-core

# Verify it works
python -c "import sea_dsl; print('βœ… Ready:', sea_dsl.__version__)"

πŸ’‘ Pre-built packages for PyPI, npm, and Crates.io. No compilation required.


Who Benefits?

πŸ’Ό Business Analysts

"I can finally model our processes without waiting for developers."

  • Write rules in controlled natural language
  • Get instant validation feedback
  • See the same model developers use

πŸ›οΈ Enterprise Architects

"Single source of truth for the entire business architecture."

  • Export to FINOS CALM
  • Formal mathematical foundation
  • Integrates with existing governance tools

πŸ’» Software Developers

"Type-safe domain models that work across our whole stack."

  • Native APIs for Python, TypeScript, Rust, WASM
  • Fast enough for runtime validation
  • No more "which system has the right logic?"

πŸ“‹ Compliance Officers

"Regulations become executable, auditable policies."

  • Express complex rules in controlled language
  • Automatic compliance checking
  • Complete audit trail of policy changes

How It Works: Six Building Blocks

DomainForge models any business domain using just six universal concepts:

Concept What It Represents Example
🏒 Entity Actors and locations in your system Assembly Line, Customer, Warehouse
πŸ“¦ Resource Things of value that move Products, Money, Information
πŸ”„ Flow Movement between entities Shipments, Payments, Work Orders
πŸ”– Instance Specific, trackable items Camera #SN12345, Invoice #INV-2024
οΏ½ Pattern Reusable validation patterns Email format, SKU codes
οΏ½πŸ“œ Policy Business rules and constraints "All shipments must be inspected"

That's the entire vocabulary. No magic syntax to learn. No framework lock-in.


SEA DSL Syntax

Write models directly in .sea filesβ€”human-readable, version-controllable, and parseable by all bindings.

Basic Example

// Define entities (who/where)
Entity "Warehouse" in logistics
Entity "Factory" in manufacturing

// Define resources (what moves)
Resource "Camera" units in inventory

// Define flows (how things move)
Flow "Camera" from "Warehouse" to "Factory" quantity 100

// Define validation patterns
Pattern "SKU" matches "^[A-Z]{3}-[0-9]{4}$"

// Define business rules
Policy min_shipment as: quantity >= 10

Advanced Features

// Versioned entities with evolution tracking
Entity "Vendor" v2.0.0
  @replaces "Supplier" v1.0.0
  @changes ["renamed", "added_fields"]

// Roles and relations
Role "Approver" in governance

Relation "Payment"
  subject: "Buyer"
  predicate: "pays"
  object: "Seller"
  via: flow "Money"

// Typed instances
Instance acme_corp of "Vendor" {
  name: "Acme Corporation",
  credit_limit: 50000 "USD"
}

// Quantified policy expressions
Policy all_shipments_inspected as:
  forall s in flows: (s.inspected = true)

All Declaration Types

Declaration Syntax
Entity Entity "Name" [vX.Y.Z] [in domain]
Resource Resource "Name" [unit] [in domain]
Flow Flow "Resource" from "A" to "B" [quantity N]
Pattern Pattern "Name" matches "regex"
Role Role "Name" [in domain]
Relation Relation "Name" subject: ... predicate: ... object: ...
Instance Instance id of "Entity" { field: value }
Policy Policy name as: expression
Dimension Dimension "Name"
Unit Unit "Name" of "Dimension" factor N base "Base"
Metric Metric "Name" as: expression
Mapping Mapping "Name" for format { ... }
Projection Projection "Name" for format { ... }
ConceptChange ConceptChange "Name" @from_version ... @to_version ...

Real-World Impact

🏭 Manufacturing: Assembly Line Control (click to expand)
model = Model("electronics-manufacturing")

# Define the supply chain
supplier = model.entity("Component Supplier")
assembly = model.entity("Assembly Line A")
quality_control = model.entity("QC Department")
finished_goods = model.entity("Finished Goods Warehouse")

# Define what's being built
pcb_board = model.resource("PCB Board", unit="pieces")
camera_module = model.resource("Camera Module", unit="units")

# Define the flow of components
component_delivery = model.flow(
    resource=pcb_board,
    from_entity=supplier,
    to_entity=assembly,
    quantity=500
)

# Enforce Just-in-Time inventory limits
model.policy(
    "JIT Inventory Control",
    expression="""
        forall e in Entity where e.type = 'Assembly':
            sum(Instance.quantity where Instance.at = e) <= 1000
    """,
    severity="warn"
)

Result: Inventory violations caught before they cause production delays.

πŸ’° Finance: Payment Fraud Detection (click to expand)
const model = new Model("payment-system");

const customer = model.entity("Customer Account");
const merchant = model.entity("Merchant Account");
const gateway = model.entity("Payment Gateway");

const money = model.resource("USD", { unit: "dollars" });

// Detect unusual spending patterns
model.policy({
  name: "Unusual Activity Detection",
  expression: `
    forall c in Entity where c.type = 'Customer':
      sum(Flow.quantity where Flow.from = c and Flow.timestamp > now() - 1hour) <= 10000
  `,
  severity: "error",
});

Result: Suspicious transactions flagged automaticallyβ€”before they clear.

🚚 Logistics: Cross-Border Compliance (click to expand)
model = Model("global-supply-chain")

# Multi-location warehouses
warehouse_us = model.entity("US Distribution Center", location="USA")
warehouse_eu = model.entity("EU Distribution Center", location="Germany")
retail_store = model.entity("Retail Store", location="France")

product = model.resource("Widget", unit="boxes")

# Ensure customs documentation for international shipments
model.policy(
    "Customs Documentation Required",
    expression="""
        forall f in Flow where f.from.location != f.to.location:
            f.attributes.customs_cleared = true
    """,
    severity="error"
)

Result: Cross-border shipments without proper documentation are blocked automatically.


Technical Foundation

⚑ Performance Characteristics
  • 10,000 entities validated in < 100ms
  • Rust core for maximum performance
  • FFI overhead < 1ms per operation
  • Streaming validation for large models
πŸ”Œ Language Bindings

Python (PyO3):

import sea_dsl

d = sea_dsl.Dimension.parse("currency")
u = sea_dsl.Unit("USD", "US Dollar", "Currency", 1.0, "USD")

TypeScript (napi-rs):

import { Dimension, Unit } from "@domainforge/sea";

const d = Dimension.parse("currency");
const u = new Unit("USD", "US Dollar", "Currency", 1.0, "USD");

WASM (browser):

import init, { Dimension, Unit } from "./sea_core.js";
await init();

const d = new Dimension("currency");
const u = new Unit("USD", "US Dollar", "Currency", 1.0, "USD");

// Programmatic Expression Building & Normalization
const expr = Expression.binary(
  BinaryOp.And,
  Expression.variable("b"),
  Expression.variable("a")
);
console.log(expr.normalize().toStringRepr()); // "(a AND b)"

All bindings provide identical semanticsβ€”zero behavioral drift.

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Your Application β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Python API β”‚ TypeScript β”‚ WASM β”‚
β”‚ (PyO3) β”‚ (napi-rs) β”‚ (wasm-bindgen) β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Rust Core Engine (sea-core) β”‚
β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚ β”‚ Primitives β”‚ Graph Store β”‚ Policy Engine β”‚ β”‚
β”‚ β”‚ (5 types) β”‚ (IndexMap) β”‚ (SBVR logic) β”‚ β”‚
β”‚ β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ β”‚
β”‚ β”‚ Parser β”‚ Validator β”‚ CALM Integrationβ”‚ β”‚
β”‚ β”‚ (Pest) β”‚ (Ref check) β”‚ (export/import) β”‚ β”‚
β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Design Principles:

  1. Rust core is canonical. Bindings wrap coreβ€”never duplicate logic.
  2. Deterministic behavior. IndexMap ensures stable ordering across runs.
  3. Standards-based. SBVR-aligned expressions, FINOS CALM export.
πŸ”§ CLI Usage
# Install the CLI
cargo install --path sea-core --features cli

# Validate a model
sea validate model.sea

# Export to FINOS CALM
sea project --format calm model.sea architecture.json

# Import from Knowledge Graph
sea import --format kg model.ttl

# Normalize Expressions
sea normalize "b AND a"  # -> "(a AND b)"

Full CLI Reference β†’

πŸ” Error Diagnostics

Comprehensive error handling with fuzzy matching suggestions:

Error[E001]: Undefined Entity: 'Warehous' at line 1
  --> 1:23
  |
1 | Flow "Materials" from "Warehous" to "Factory"
  |                       ^^^^^^^^^^
  |
  hint: Did you mean 'Warehouse'?
  • 30+ structured error codes with detailed descriptions
  • Multiple output formats: JSON, Human-readable, LSP
  • Native error types for Python, TypeScript, and WASM

Error Code Catalog β†’


Getting Started

Quick Start

# Clone and set up
git clone https://github.com/GodSpeedAI/DomainForge.git
cd DomainForge
pip install maturin
maturin develop

# Run your first model
python examples/camera_factory.py

Running Tests

# Per-language tests
just rust-test      # Rust core
just python-test    # Python bindings
just ts-test        # TypeScript bindings

# All tests at once
just all-tests

Build from Source

# Python bindings
pip install maturin && maturin build --release

# TypeScript bindings
npm install && npm run build

# WebAssembly
./scripts/build-wasm.sh

Documentation

Resource Description
πŸ“˜ Copilot Instructions Essential guide for AI coding agents
πŸ”— API Specification Complete API reference
πŸ“™ Product Requirements PRD with success metrics
πŸ“• System Design Technical specifications
πŸ›οΈ Architecture Decisions Key architectural choices
πŸ—ΊοΈ CALM Mapping SEA ↔ CALM conversion
πŸ“– Error Codes Validation error reference

Contributing

We welcome contributions! Please see Contributing Guide for developer notes on building the CLI, TypeScript bindings, and WASM.


License

DomainForge is open source under the Apache-2.0 License.


Acknowledgments

Built on foundational work from:


Your business rules, everywhere. Always correct. Always in sync.

Get Started β†’ Β· Read the Docs β†’ Β· See Examples β†’

About

A domain modeling language that lets you describe your business in plain terms

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •