Skip to content

Aggregate Roots

Target Architecture — Final-State Design

The 15 aggregate roots below are the planned domain model of the ConnectSoft.Factory.Templates.* services, built on ConnectSoft.Extensions.DomainModel DDD building blocks and persisted with ConnectSoft.Extensions.PersistenceModel.NHibernate over Azure SQL / PostgreSQL (with Azure Blob, Azure Artifacts, and Git for payloads). Naming follows Naming Conventions. Domain events use the canonical event envelope.

The platform's domain splits into the Template context (generators, versions, parameters, executions, validation, publication, upgrade) and the Library context (packages, versions, capabilities, dependencies, compatibility, publication). Each aggregate root is the consistency boundary for its own data and the sole emitter of its domain events.

erDiagram
    Template ||--o{ TemplateVersion : owns
    TemplateVersion ||--|| TemplateParameterSchema : defines
    TemplateVersion ||--o{ TemplateCompatibilityRule : declares
    TemplateVersion ||--o{ TemplateValidationResult : validated-by
    Template ||--o{ TemplatePublication : published-via
    Template ||--o{ TemplateExecution : executed-as
    TemplateExecution ||--|| ScaffoldOutput : produces
    Template ||--o{ TemplateUpgradePlan : upgraded-via
    LibraryPackage ||--o{ LibraryVersion : owns
    LibraryPackage ||--o{ LibraryCapability : exposes
    LibraryVersion ||--o{ DependencyGraph : contributes
    LibraryVersion ||--o{ PackagePublication : published-via
    CompatibilityMatrix }o--o{ TemplateCompatibilityRule : rolls-up
Hold "Alt" / "Option" to enable pan & zoom

Template

Purpose — The stable, version-independent identity of a code generator (e.g. ConnectSoft.Template.Microservice). The root of the template aggregate and owner of its versions.

FieldstemplateId, name, title, category, owner, status (Draft/Active/Deprecated/Retired), tags, createdAt, updatedAt, tenantId.

EntitiesTemplateVersion (owned collection; the version history).

Value objectsTemplateName (enforces ConnectSoft.Template.* convention), TemplateCategory, OwnerRef, Tag.

Invariantsname is unique per tenant; category is immutable after creation; a Template cannot be Retired while it has Published versions still referenced by active products; status transitions are monotonic (Active → Deprecated → Retired).

Domain eventsTemplateRegistered, TemplateDeprecated, TemplateRetired.

RepositoryTemplateRepository.

Persistence — NHibernate over Azure SQL / PostgreSQL; hot catalog entries cached in Redis.


TemplateVersion

Purpose — An immutable, semantically versioned snapshot of a template's generator content. The reproducibility anchor for generation.

FieldstemplateVersionId, templateId, semanticVersion, engineKind (DotnetNewTemplatePack/BaseTemplateFolder), sourceRef (Git), payloadBlobRef (Azure Blob), targetFramework, changelog, status (Draft/Validated/Published/Deprecated), createdAt.

EntitiesTemplateParameterSchema (1:1 owned), TemplateCompatibilityRule (owned collection).

Value objectsSemanticVersion, SourceRef, BlobRef, TargetFramework.

InvariantssemanticVersion is unique within the template; once Published the version is immutable (no payload/schema mutation); a version cannot be Published without a passed TemplateValidationResult; targetFramework must satisfy declared RuntimeRequires rules.

Domain eventsTemplateVersionCreated, TemplateVersionDeprecated.

RepositoryTemplateVersionRepository.

Persistence — NHibernate (metadata) over Azure SQL; payload in Azure Blob; source in Git.


TemplateParameterSchema

Purpose — The typed input contract for a TemplateVersion, expressed as JSON Schema, used to validate parameter values before execution.

FieldsschemaId, templateVersionId, jsonSchemaRef, parameterCount, definedAt.

EntitiesParameterDefinition (owned; one per parameter: name, type, required, default, constraints).

Value objectsJsonSchemaDocument, ParameterConstraint, ConditionalRule (e.g. "includeAuthorization requires authority").

Invariants — schema is valid JSON Schema; every required parameter has a definition; conditional rules reference only declared parameters; schema is immutable once its TemplateVersion is Published.

Domain eventsTemplateParameterSchemaDefined.

RepositoryTemplateParameterSchemaRepository.

Persistence — NHibernate over Azure SQL (schema document stored as JSON column).


TemplateCompatibilityRule

Purpose — A single declarative compatibility constraint owned by a template (or library) version — runtime floors, required capabilities, and banned combinations.

FieldsruleId, subjectRef (the version it constrains), constraintKind (RuntimeRequires/LibraryRequires/LibraryConflictsWith/TemplateConflictsWith/ParameterConstraint), expression, severity (Error/Warning), createdAt.

Entities — none (leaf within its subject version).

Value objectsConstraintExpression, VersionRange, CapabilityRef.

Invariantsexpression parses for its constraintKind; rules are versioned with their subject and immutable once the subject is Published; Error-severity rules block generation, Warning rules surface but do not block.

Domain eventsCompatibilityRuleDeclared (recorded with version creation).

RepositoryTemplateCompatibilityRuleRepository.

Persistence — NHibernate over Azure SQL.


TemplateExecution

Purpose — Tracks a single run of the Scaffold Engine from request to committed output. The unit of generation traceability.

FieldsexecutionId, templateId, templateVersionId, parameters, resolvedLibraries, target (repository/branch), agentTaskId, status (Requested/Validating/Rejected/Generating/Generated/Failed/Committed), scaffoldOutputId, requestedAt, completedAt, tenantId.

Entities — none owned directly; references ScaffoldOutput (separate aggregate produced by the execution).

Value objectsParameterValues, LibrarySelection, TargetCoordinates, CorrelationRef (agent task- id).

Invariants — parameters must validate against the version's TemplateParameterSchema before leaving Validating; compatibility must pass before Generating; an execution produces at most one ScaffoldOutput; state transitions follow the lifecycle (no Generated without prior Generating); idempotency key prevents duplicate execution.

Domain eventsTemplateExecutionRequested, TemplateExecutionRejected, TemplateExecutionFailed, TemplateExecuted.

RepositoryTemplateExecutionRepository.

Persistence — NHibernate over Azure SQL (execution metadata); links to Blob/Git for output.


ScaffoldOutput

Purpose — The immutable result of a TemplateExecution — a complete, buildable solution artifact with full provenance.

FieldsscaffoldOutputId, executionId, templateVersionId, payloadBlobRef, gitCommitRef, provenanceManifest, contentHash, compositionManifestRef (for multi-template solutions), producedAt, tenantId.

EntitiesGeneratedFileEntry (owned manifest entries describing the generated tree).

Value objectsProvenanceManifest (template/library versions, parameters, engine), ContentHash, CommitRef, BlobRef.

Invariants — immutable once produced; contentHash matches the stored payload; provenanceManifest references only Published template and library versions; conforms to the artifact metadata model.

Domain eventsScaffoldGenerated.

RepositoryScaffoldOutputRepository.

Persistence — metadata in Azure SQL via NHibernate; payload in Azure Blob; committed to Git.


TemplateValidationResult

Purpose — The outcome of running validation checks against a TemplateVersion.

FieldsvalidationResultId, templateVersionId, checkSet, outcome (Passed/Failed), findings, validatedAt.

EntitiesValidationFinding (owned; per-check result: severity, message, location).

Value objectsCheckSet (StructuralLint/ParameterSchema/SampleGeneration), Outcome, Severity.

Invariantsoutcome is Passed only when no Error-severity findings exist; result is tied to one templateVersionId; a Failed result blocks publishing.

Domain eventsTemplateValidated.

RepositoryTemplateValidationResultRepository.

Persistence — NHibernate over Azure SQL.


TemplatePublication

Purpose — Records the promotion of a validated TemplateVersion to Published, including any governance approval.

FieldspublicationId, templateId, templateVersionId, publishedBy, approvalRef, gitTagRef, publishedAt, status (Pending/Approved/Published/Rejected).

EntitiesApprovalStep (owned; governance approval chain when required).

Value objectsApprovalRef, GitTagRef, Publisher.

Invariants — publication requires a Passed TemplateValidationResult; cannot move to Published without required approvals; publishing a version transitions the TemplateVersion to Published and is irreversible (a withdrawn version is Deprecated, not deleted).

Domain eventsTemplatePublished.

RepositoryTemplatePublicationRepository.

Persistence — NHibernate over Azure SQL; Git tag for the published source.


TemplateUpgradePlan

Purpose — A computed migration plan for moving dependent products from one template version to a newer one.

FieldsupgradePlanId, templateId, fromVersion, toVersion, impactedProducts, steps, riskLevel (Low/Medium/High), createdAt, status (Draft/Proposed/Accepted/Applied).

EntitiesUpgradeStep (owned; ordered migration actions), ImpactedProductRef (owned).

Value objectsVersionDelta, RiskLevel, BreakingChange.

InvariantsfromVersion < toVersion; riskLevel is High when the delta crosses a major version with breaking parameter-schema changes; the plan references only Published versions.

Domain eventsTemplateUpgradePlanCreated, TemplateUpgradePlanApplied.

RepositoryTemplateUpgradePlanRepository.

Persistence — NHibernate over Azure SQL.


LibraryPackage

Purpose — The version-independent identity of a reusable library (e.g. ConnectSoft.Extensions.PersistenceModel.PostgreSQL). Root of the library aggregate; also the carrier of the API-client facet.

FieldslibraryId, packageName, area, owner, status (Active/Deprecated/Retired), isApiClient, upstreamApi (when client), tags, tenantId, createdAt.

EntitiesLibraryVersion (owned collection), LibraryCapability (owned collection).

Value objectsPackageName (enforces ConnectSoft.{Area}.{Capability}), LibraryArea, UpstreamApiRef.

InvariantspackageName unique per tenant; area immutable; a package marked isApiClient must declare an upstreamApi; cannot be Retired while Published versions are referenced by active products.

Domain eventsLibraryRegistered, ApiClientCataloged, LibraryDeprecated.

RepositoryLibraryPackageRepository.

Persistence — NHibernate over Azure SQL / PostgreSQL; cached in Redis; capabilities indexed for search.


LibraryVersion

Purpose — An immutable semantically versioned release of a LibraryPackage, with its declared dependencies.

FieldslibraryVersionId, libraryId, semanticVersion, targetFramework, feedRef (Azure Artifacts), declaredDependencies, releaseNotes, status (Draft/Scanned/Published/Deprecated), createdAt.

EntitiesDeclaredDependency (owned; package + version range).

Value objectsSemanticVersion, TargetFramework, VersionRange, FeedRef.

InvariantssemanticVersion unique within the package; immutable once Published; cannot publish without a completed DependencyScanned; declared dependency ranges must resolve in the DependencyGraph.

Domain eventsLibraryVersionCreated, LibraryVersionDeprecated.

RepositoryLibraryVersionRepository.

Persistence — NHibernate over Azure SQL (metadata); package binary in Azure Artifacts.


LibraryCapability

Purpose — A machine-consumable description of what a package provides (e.g. RelationalPersistence, MeteredBilling, McpToolHost), enabling capability-based discovery.

FieldscapabilityId, libraryId, name, contract (the abstraction/interface satisfied), description, declaredAt.

Entities — none (leaf within LibraryPackage).

Value objectsCapabilityName, ContractRef.

Invariantsname unique within the package; contract references a known abstraction; capabilities are indexed by the Knowledge Platform for search.

Domain eventsLibraryCapabilityDeclared (recorded with registration).

RepositoryLibraryCapabilityRepository.

Persistence — NHibernate over Azure SQL; replicated into the search index.


DependencyGraph

Purpose — The directed graph of library-to-library dependencies with resolved version ranges, powering transitive resolution, conflict detection, and impact analysis.

FieldsgraphId, scope (global or composition), nodeCount, edgeCount, conflictCount, computedAt.

EntitiesDependencyNode (owned; a library version), DependencyEdge (owned; node→node with version range).

Value objectsNodeRef, VersionRange, ConflictDescriptor.

Invariants — the graph is acyclic for resolvable compositions (cycles flagged as conflicts); each node references a known LibraryVersion; conflictCount reflects detected diamond/banned conflicts; recomputation is deterministic from current versions.

Domain eventsDependencyScanned.

RepositoryDependencyGraphRepository.

Persistence — NHibernate over Azure SQL (nodes/edges); resolved closures cached in Redis.


CompatibilityMatrix

Purpose — The rolled-up, queryable compatibility answer for a scope (template version, library version, or candidate composition), computed from rules and the dependency graph.

FieldsmatrixId, scope, subjects (versions evaluated), compatible, violations, computedAt, cacheTtl.

EntitiesViolationEntry (owned; broken rule, offending versions, suggested resolution).

Value objectsScope, Verdict, SuggestedResolution.

Invariantscompatible is true only when no Error-severity rule is violated; the matrix references the exact subject versions evaluated; a recompute supersedes the prior matrix for the same scope; cached copies expire per cacheTtl.

Domain eventsCompatibilityEvaluated.

RepositoryCompatibilityMatrixRepository.

Persistence — authoritative copy in Azure SQL via NHibernate; computed result cached in Redis.


PackagePublication

Purpose — Records the publication of a LibraryVersion to Azure Artifacts (NuGet), including approval.

FieldspackagePublicationId, libraryId, libraryVersionId, feedRef, publishedBy, approvalRef, publishedAt, status (Pending/Approved/Published/Rejected).

EntitiesApprovalStep (owned; governance chain when required).

Value objectsFeedRef, ApprovalRef, Publisher.

Invariants — publication requires a completed DependencyScanned; cannot move to Published without required approvals; a published version's feed entry is immutable (NuGet semantics); withdrawal deprecates rather than deletes.

Domain eventsLibraryPublished.

RepositoryPackagePublicationRepository.

Persistence — NHibernate over Azure SQL (publication record); binary in Azure Artifacts.