Skip to content

Aggregate Roots

Target Architecture — Final-State Design

The 9 aggregate roots below form the domain model of the Runtime & Cloud Platform. Each is a consistency boundary owned by exactly one microservice, persisted via NHibernate, and the source of the domain events it emits. Naming follows the conventions: singular PascalCase nouns.

RuntimeEnvironment

Purpose — represents an isolated, Pulumi-provisioned runtime environment (a stage/region slice) that hosts generated SaaS workloads.

  • FieldsenvironmentId, tenantId, projectId, name, stage (dev/test/staging/prod), region, status, pulumiStackRef, isolationModel, createdAt, decommissionedAt.
  • EntitiesComputeTarget (per AKS/ACA/Functions/App Service surface, with its provisioned resource ids), NetworkBoundary.
  • Value ObjectsEnvironmentStage, Region, IsolationModel (silo/pool/shared), ProvisioningStatus.
  • Invariants — an environment cannot accept deployments unless status = Provisioned; region and stage are immutable after provisioning; a prod environment requires a RuntimeTenantBinding before first deployment.
  • Domain EventsRuntimeEnvironmentProvisioned, RuntimeEnvironmentDecommissioned.
  • RepositoryRuntimeEnvironmentRepository.
  • Persistence — Azure SQL / PostgreSQL via NHibernate; one row per environment with child rows for compute targets.

RuntimeService

Purpose — the live inventory record of a single generated component running in an environment (gateway, microservice, worker, portal, mobile backend).

  • FieldsserviceId, tenantId, environmentId, moduleId, componentType, image, version, computeTarget, replicas, endpointUrl, status, lastObservedAt.
  • EntitiesServiceInstance (per replica/revision), EndpointBinding.
  • Value ObjectsComponentType (gateway/microservice/worker/admin-portal/customer-portal/mobile-backend), ImageReference, RuntimeStatus.
  • Invariantsversion must match a known RuntimeDeployment for the environment; a service cannot be Running without at least one healthy instance; tenantId is immutable.
  • Domain EventsRuntimeInventoryUpdated, RuntimeServiceRetired.
  • RepositoryRuntimeServiceRepository.
  • Persistence — Azure SQL / PostgreSQL via NHibernate; reconciled by the RuntimeInventoryWorker.

RuntimeDeployment

Purpose — a single rollout of one or more generated components into an environment, with a health-gated, reversible state machine.

  • FieldsdeploymentId, tenantId, environmentId, releaseRef, strategy, status, configurationId, startedAt, completedAt, previousDeploymentId.
  • EntitiesDeploymentStep (per component rollout), HealthGate, RollbackPoint.
  • Value ObjectsDeploymentStrategy (RollingHealthGated/BlueGreen/Canary), DeploymentStatus, ReleaseReference.
  • Invariants — a deployment cannot reach Completed unless all HealthGates pass; rollback targets must reference a prior Completed deployment; only one in-flight deployment per environment+component at a time.
  • Domain EventsRuntimeDeploymentRequested, RuntimeDeploymentCompleted, RuntimeDeploymentRolledBack.
  • RepositoryRuntimeDeploymentRepository.
  • Persistence — Azure SQL / PostgreSQL via NHibernate; step logs to Blob.

RuntimeConfiguration

Purpose — a versioned set of runtime configuration applied to workloads in an environment.

  • FieldsconfigurationId, tenantId, environmentId, version, status, appliedAt, checksum.
  • EntitiesConfigurationEntry (key/value/scope), ConfigurationScope.
  • Value ObjectsConfigVersion, ConfigScope (environment/service/tenant), Checksum.
  • Invariantsversion is monotonic per environment; configuration entries never contain secret values (only SecretBinding references); a published version is immutable.
  • Domain EventsConfigurationPublished, ConfigurationSynced.
  • RepositoryRuntimeConfigurationRepository.
  • Persistence — Azure SQL / PostgreSQL via NHibernate.

SecretBinding

Purpose — binds a workload to one or more Azure Key Vault secrets via managed identity, without materializing secret values.

  • FieldssecretBindingId, tenantId, environmentId, serviceId, keyVaultRef, secretName, currentVersion, rotationSchedule, status.
  • EntitiesSecretReference (Key Vault URI + version), RotationRecord.
  • Value ObjectsKeyVaultReference, RotationSchedule, ManagedIdentityRef.
  • Invariants — a binding references Key Vault only (no plaintext); rotation produces a new version without changing the binding identity; bindings are tenant- and environment-scoped.
  • Domain EventsSecretBound, SecretRotated.
  • RepositorySecretBindingRepository.
  • Persistence — Azure SQL / PostgreSQL via NHibernate for metadata; secret material remains in Azure Key Vault.

ScalingPolicy

Purpose — declares how a running service scales against live telemetry and SLOs.

  • FieldsscalingPolicyId, tenantId, environmentId, serviceId, target, metric, minReplicas, maxReplicas, targetUtilizationPercent, scaleToZero, cooldownSeconds, status.
  • EntitiesScalingRule (metric → threshold → action), ScalingEvent (applied action history).
  • Value ObjectsScalingMetric (cpu/memory/queue-length/request-rate), ReplicaBounds, Cooldown.
  • InvariantsminReplicasmaxReplicas; scaleToZero only permitted on event-driven targets (Container Apps/Functions); a policy applies to exactly one service.
  • Domain EventsScalingPolicyApplied, ScalingPolicyViolated.
  • RepositoryScalingPolicyRepository.
  • Persistence — Azure SQL / PostgreSQL via NHibernate.

HealthCheckResult

Purpose — an immutable record of a single health evaluation of a running service.

  • FieldshealthCheckResultId, tenantId, environmentId, serviceId, status, evaluatedAt, evaluationWindow.
  • EntitiesCheckEntry (probe name/status/duration/data).
  • Value ObjectsHealthStatus (Healthy/Degraded/Unhealthy), ProbeKind (self/liveness/readiness/dependency), LatencyMs.
  • Invariants — results are append-only and immutable; aggregate status is the worst of its CheckEntry statuses; each result belongs to exactly one service + window.
  • Domain EventsHealthCheckCompleted, HealthDegraded.
  • RepositoryHealthCheckResultRepository.
  • Persistence — Azure SQL / PostgreSQL for recent results; telemetry detail to Application Insights.

RuntimeDriftFinding

Purpose — a detected divergence between actual runtime state and Git/Pulumi desired state.

  • FieldsfindingId, tenantId, environmentId, serviceId, kind, desired, actual, severity, status, detectedAt, remediatedAt, remediationDeploymentId.
  • EntitiesRemediationAttempt (action/result/timestamp).
  • Value ObjectsDriftKind (ImageVersionMismatch/ReplicaMismatch/ConfigDrift/MissingResource/UnmanagedResource), Severity, DriftStatus.
  • Invariants — a finding cannot be Resolved without a recorded remediation or an accepted exception; duplicate findings with the same hash are merged; desired is always sourced from authoritative Git/Pulumi state.
  • Domain EventsRuntimeDriftDetected, RuntimeDriftRemediated.
  • RepositoryRuntimeDriftFindingRepository.
  • Persistence — Azure SQL / PostgreSQL for findings; full state snapshots to Cosmos DB.

RuntimeTenantBinding

Purpose — binds a tenant to a runtime environment with an enforced isolation model, the cross-cutting multi-tenant boundary.

  • FieldstenantBindingId, tenantId, environmentId, isolationModel, quota, networkPartition, dataPartition, status, boundAt.
  • EntitiesQuotaAllocation (compute/storage/throughput limits), PartitionAssignment.
  • Value ObjectsIsolationModel (silo/pool/shared), ResourceQuota, PartitionKey.
  • Invariants — a silo binding maps to a dedicated environment; quota allocations cannot exceed environment capacity; tenantId + environmentId is unique.
  • Domain EventsRuntimeTenantBound, RuntimeTenantQuotaAdjusted.
  • RepositoryRuntimeTenantBindingRepository.
  • Persistence — Azure SQL / PostgreSQL via NHibernate.

Aggregate Relationships

flowchart TB
    Env["RuntimeEnvironment"] --> Svc["RuntimeService"]
    Env --> Dep["RuntimeDeployment"]
    Env --> TB["RuntimeTenantBinding"]
    Dep --> Cfg["RuntimeConfiguration"]
    Dep --> SB["SecretBinding"]
    Svc --> SP["ScalingPolicy"]
    Svc --> HC["HealthCheckResult"]
    Env --> DF["RuntimeDriftFinding"]
    DF --> Dep
Hold "Alt" / "Option" to enable pan & zoom