Skip to content

Domain-Driven Design (DDD)

Document ID: ARCH-005 Version: 1.0.1 Status: Draft — the bounded-context model genuinely matches the real crate boundaries (workflow/runtime/memory/tenancy/plugins map cleanly onto wovyr-workflow/wovyr-agent/wovyr-memory/wovyr-tenancy/wovyr-plugin). Corrected 2026-07-07: its one NATS Adapter example does not exist — no message broker is wired anywhere (consistent with ADR-0010’s Path A decision; see ADR-0005’s current-status note). Owner: Architecture Team Last Updated: 2026-07-07


This document defines the Domain-Driven Design (DDD) model for the Wovyr AI Platform.

It identifies the platform’s bounded contexts, aggregates, entities, value objects, domain events, repositories, and context relationships.

This document serves as the authoritative guide for:

  • Rust workspace organization
  • Service boundaries
  • API ownership
  • Database ownership
  • Event ownership
  • Team ownership

The platform is organized around business capabilities, not technologies.

Each bounded context:

  • Owns its data
  • Owns its business rules
  • Owns its APIs
  • Publishes domain events
  • Maintains independent evolution

No bounded context may directly manipulate another context’s internal state.


The platform is divided into the following strategic domains.

These domains provide the unique competitive value of Wovyr.

  • Agent Runtime
  • Workflow Engine
  • Memory Engine
  • LLM Gateway

These domains enable the core domains.

  • Tool Runtime
  • Plugin Framework
  • Scheduler
  • Event Bus

These domains provide common enterprise capabilities.

  • Identity
  • Projects
  • Organizations
  • Configuration
  • Audit
  • Notifications
  • Observability

+---------------------+
| Platform Kernel |
|---------------------|
| Identity |
| Config |
| Events |
| Audit |
| Observability |
+----------+----------+
|
---------------------------------------------------------
| | | | |
▼ ▼ ▼ ▼ ▼
+---------------+ +---------------+ +---------------+ +---------------+ +---------------+
| Agent Runtime | | Workflow | | Memory Engine | | LLM Gateway | | Tool Runtime |
| | | Engine | | | | | | |
+-------+-------+ +-------+-------+ +-------+-------+ +-------+-------+ +-------+-------+
| | | | |
---------------------------------------------------------------
|
+------------------+
| Plugin Framework |
+------------------+

  • Identity
  • Configuration
  • Secrets
  • Logging
  • Metrics
  • Events
  • Health
  • Audit
  • Feature flags
  • Users
  • Roles
  • Permissions
  • Global configuration

  • Goal execution
  • Planning
  • Reflection
  • Context management
  • Multi-agent coordination
  • Agent
  • Goal
  • Execution Session
  • AgentCreated
  • GoalStarted
  • GoalCompleted
  • GoalFailed

  • Workflow lifecycle
  • DAG execution
  • Scheduling
  • Retry
  • Compensation
  • Checkpointing
  • Workflow
  • WorkflowExecution
  • Activity
  • Schedule
  • WorkflowStarted
  • WorkflowPaused
  • WorkflowCompleted
  • WorkflowFailed
  • ActivityCompleted

  • Semantic retrieval
  • Episodic memory
  • Long-term storage
  • Embeddings
  • Memory
  • Collection
  • KnowledgeGraph
  • Embedding
  • MemoryStored
  • MemoryRetrieved
  • EmbeddingGenerated

  • Provider abstraction
  • Routing
  • Cost accounting
  • Streaming
  • Failover
  • Provider
  • Model
  • CompletionRequest
  • ProviderSelected
  • CompletionGenerated
  • ProviderUnavailable

  • Tool registration
  • Execution
  • Sandboxing
  • Permissions
  • Tool
  • Invocation
  • Permission
  • ToolRegistered
  • ToolInvoked
  • ToolCompleted

  • Plugin discovery
  • Lifecycle
  • Version management
  • Dependency resolution
  • Plugin
  • Extension
  • Capability
  • PluginInstalled
  • PluginEnabled
  • PluginDisabled

The following concepts are shared across bounded contexts:

  • UserId
  • ProjectId
  • OrganizationId
  • WorkflowId
  • ExecutionId
  • CorrelationId
  • TenantId
  • Timestamp
  • Version

These are represented as immutable value objects.


Examples include:

  • Identifier
  • Email
  • ModelName
  • Prompt
  • TokenCount
  • ExecutionStatus
  • RetryPolicy
  • ScheduleExpression
  • Version
  • ResourceLimit

Value objects are immutable and contain no identity beyond their values.


All bounded contexts communicate through domain events.

Examples:

  • WorkflowCompleted
  • GoalCompleted
  • MemoryStored
  • ToolInvoked
  • PluginInstalled
  • UserAuthenticated
  • ProjectCreated

Events should be immutable, versioned, and idempotent where possible.


Each aggregate root has a corresponding repository interface.

Examples:

  • WorkflowRepository
  • AgentRepository
  • MemoryRepository
  • PluginRepository
  • UserRepository

Repository interfaces belong to the domain layer; implementations belong to the infrastructure layer.


Application services coordinate use cases without containing business rules.

Examples:

  • StartWorkflow
  • ResumeWorkflow
  • ExecuteGoal
  • RetrieveContext
  • RegisterPlugin
  • InvokeTool

Business logic remains inside aggregates and domain services.


Domain services encapsulate business logic that spans multiple aggregates.

Examples:

  • WorkflowPlanner
  • RetryPolicyEvaluator
  • MemoryRankingService
  • ProviderSelectionStrategy
  • PluginCompatibilityChecker

External systems are accessed through anti-corruption layers (ACLs).

Examples:

  • OpenAI Adapter
  • Anthropic Adapter
  • Qdrant Adapter
  • PostgreSQL Adapter
  • NATS Adapter
  • Keycloak Adapter

Adapters translate external models into internal domain concepts.


Mandatory rules:

  1. Core domains must not depend on supporting or generic domains.
  2. Supporting domains may depend on generic domains.
  3. Infrastructure depends on domain interfaces.
  4. Domain logic must not depend on infrastructure implementations.
  5. Communication across contexts occurs through APIs or domain events.

Each bounded context should have a clearly defined owning team.

DomainOwning Team
Platform KernelPlatform
Agent RuntimeAI Runtime
Workflow EngineWorkflow
Memory EngineAI Infrastructure
LLM GatewayAI Platform
Tool RuntimeRuntime
Plugin FrameworkEcosystem

Recommended crate structure:

crates/
├── platform-kernel/
├── platform-identity/
├── platform-config/
├── platform-audit/
├── engine-runtime/
├── engine-workflow/
├── engine-memory/
├── engine-llm/
├── engine-tools/
├── engine-plugin/
├── sdk-core/
└── shared-types/

Each crate corresponds to one bounded context or a shared abstraction.


New capabilities should be introduced as new bounded contexts when they represent distinct business domains.

Examples:

  • Policy Engine
  • Billing
  • Marketplace
  • Evaluation Engine
  • Model Registry

Avoid expanding existing contexts beyond their core responsibilities.


  • System Overview
  • C4 Context
  • C4 Container
  • C4 Component
  • Clean Architecture
  • Event-Driven Architecture
  • Rust Workspace Design
  • ADRs

VersionDateDescription
1.0.12026-07-07Added a header note: the bounded-context model matches real crate boundaries; its one NATS Adapter example doesn’t exist. Found during a project-wide doc review; no content changed
1.0.02026-06-26Initial Domain-Driven Design document