Skip to content

Commit cdba763

Browse files
committed
docs(architecture): align overview with DDD and authoritative aggregate catalog
1 parent fb6815e commit cdba763

1 file changed

Lines changed: 53 additions & 37 deletions

File tree

docs/architecture/overview.md

Lines changed: 53 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ UMS serves as an authorization and identity gateway that can either function as
2727
▼ │
2828
┌────────────────────────────────────────────┴────────────┐
2929
│ Domain Layer │
30-
Pure POCO Aggregates / Value Objects / Events
30+
│ Pure DDD Model: Aggregates / Entities / VOs / Events
3131
└────────────▲───────────────────────────────┬────────────┘
3232
│ Implements │ Integrates
3333
│ ▼
@@ -38,7 +38,8 @@ UMS serves as an authorization and identity gateway that can either function as
3838
```
3939

4040
### Shared Architectural Principles
41-
1. **Domain Purity**: The Domain layer (`{BoundedContext}.Domain`) consists of pure C# objects (POCOs) with zero external library references, ensuring business logic remains unpolluted.
41+
42+
1. **Domain Purity**: The Domain layer (`{BoundedContext}.Domain`) contains the pure DDD model — Aggregate Roots, Entities, Value Objects, Domain Events, invariants, and domain services — with zero external framework references.
4243
2. **Explicit Boundaries**: Cross-context interactions are strictly decoupled using event-driven communication (Transactional Outbox) or explicit Application-layer Anti-Corruption Layers (ACLs). Direct cross-context database joins are strictly prohibited.
4344
3. **Tenant Isolation**: High-security multi-tenancy is enforced natively in the Application layer, with SQL Server Row-Level Security (RLS) serving as an infrastructure-level secondary failsafe (R-10).
4445
4. **Command-Query Responsibility Segregation (CQRS)**: Read models are highly optimized and separated from write models. Writes are strictly transaction-safe, while reads leverage efficient flat projections or direct GraphQL execution.
@@ -78,17 +79,19 @@ graph TD
7879

7980
## 3. High-Level Bounded Context Map
8081

81-
UMS is partitioned into **nine Bounded Contexts** (seven with owned entities, plus Cache and Console support contexts). Two contexts — Approvals and Compliance — are unified under `Ums.Domain.Approvals` in the codebase for implementation simplicity:
82+
UMS is partitioned into **nine logical Bounded Contexts**. Seven own domain entities directly; Cache and Console are support contexts. The Compliance logical context is implemented under the Approvals namespace for implementation simplicity, but remains conceptually distinct for business language and governance.
8283

83-
1. **Identity BC** (`ums_identity`): Governs tenant registration, organizational branches, white-label branding, identity providers, and user account lifecycles.
84-
2. **Authorization BC** (`ums_authz`): Manages application suites, functional modules, granular options, profiles/roles, and dynamic permission matrices.
85-
3. **Configuration BC** (`ums_config`): Controls application behavior dynamically via feature flags and custom Identity Provider configuration.
86-
4. **Approvals BC** (`ums_approval`): Coordinates multi-step human-in-the-loop workflows for access elevation and tenant transitions.
87-
5. **Compliance BC** (`ums_compliance`, unified with Approvals in code): Enforces document-based access policies, expiration notifications, and automated enforcement.
88-
6. **IGA BC** (`ums_iga`): Evaluates role maturity, promotion request impacts, and separation of duties.
89-
7. **Audit BC** (`ums_audit`): Collects immutable, non-repudiable logs of all critical platform transitions.
90-
8. **Cache BC** (`ums_cache`): Distributed caching layer for configuration, session data, and feature flags.
91-
9. **Console BC** (`ums_console`): Administrative console context for platform-level operations.
84+
| Logical Bounded Context | Persistence / Schema | Implementation Namespace | Notes |
85+
|---|---|---|---|
86+
| Identity | `ums_identity` | `Ums.Domain.Identity` | Tenant, branch, branding, IdP, user lifecycle. |
87+
| Authorization | `ums_authz` | `Ums.Domain.Authorization` | Suites, modules, menus, options, roles, profiles, permission templates. |
88+
| Configuration | `ums_config` | `Ums.Domain.Configuration` | IdP config, app configuration, feature flags, parameterization. |
89+
| Approvals | `ums_approval` | `Ums.Domain.Approvals` | Human-in-the-loop workflow and approval request lifecycle. |
90+
| Compliance | `ums_compliance` | `Ums.Domain.Approvals` | Logical compliance model implemented inside Approvals: document types, user documents, enforcement policies. |
91+
| IGA | `ums_iga` | `Ums.Domain.IGA` | Promotion request analysis, role maturity, separation of duties. |
92+
| Audit | `ums_audit` | `Ums.Domain.Audit` | Immutable audit records. |
93+
| Cache | `ums_cache` | Infrastructure / support | Distributed caching layer for configuration, session data, and feature flags. |
94+
| Console | `ums_console` | Presentation / support | Administrative console for platform-level operations. |
9295

9396
See [Bounded Context Map](../governance/construction/ddd-design/01-bounded-context-map.md) for full relationship detail.
9497

@@ -98,6 +101,7 @@ flowchart TD
98101
Authorization["Authorization BC"]
99102
Configuration["Configuration BC"]
100103
Approvals["Approvals BC"]
104+
Compliance["Compliance BC"]
101105
IGA["IGA BC"]
102106
Audit["Audit BC"]
103107
@@ -107,13 +111,15 @@ flowchart TD
107111
Identity -->|Provide Identity Context| Audit
108112
109113
Authorization -->|Enforce Access Context| Approvals
110-
Authorization -->|Consume for Elevation Analyis| IGA
114+
Authorization -->|Consume for Elevation Analysis| IGA
111115
Authorization -->|Publish: Profile/Permission Events| Audit
112116
113117
Configuration -->|Feature Flags & IdP parameters| Identity
114118
115119
Approvals -->|Elevate Roles / Approve Changes| Authorization
116120
Approvals -->|Trigger Notifications| Audit
121+
Compliance -->|Document Policy Inputs| Approvals
122+
Compliance -->|Enforcement Events| Audit
117123
118124
IGA -->|Request Promotion / Role Recertification| Approvals
119125
@@ -130,33 +136,25 @@ flowchart TD
130136
| **Configuration** | **Identity** | Upstream-Downstream | Conformist (Dynamic flags regulate features) |
131137
| **Authorization** | **IGA** | Upstream-Downstream | Partnership (IGA evaluates role structures) |
132138
| **IGA** | **Approvals** | Upstream-Downstream | Customer-Supplier (Promotion requests trigger approvals) |
139+
| **Compliance** | **Approvals** | Upstream-Downstream | Customer-Supplier (document policy feeds approval and access workflows) |
133140
| **All Contexts** | **Audit** | Downstream | Publish-Subscribe (Transactional Outbox events) |
134141

135142
---
136143

137144
## 4. Aggregate Root Catalog
138145

139-
All domain rules, invariants, and architectural diagrams are consolidated within each Aggregate Root's dedicated documentation file. Owned child entities are documented within their parent AR's page — they do not have separate top-level entries.
146+
The authoritative aggregate-root inventory is maintained in the [Domain Aggregate Index](../domain/index.md). This overview intentionally summarizes rather than duplicating all entity detail.
140147

141-
See [Domain Aggregate Index](../domain/index.md) for the full inventory.
148+
| Bounded Context | Aggregate Roots |
149+
|---|---|
150+
| **Identity** | [Tenant](../domain/identity/tenant.md), [UserAccount](../domain/identity/user-account.md), [UserManagementDelegation](../domain/identity/user-management-delegation.md) |
151+
| **Authorization** | [SystemSuite](../domain/authorization/system-suite.md), [Role](../domain/authorization/role.md), [PermissionTemplate](../domain/authorization/permission-template.md), [Profile](../domain/authorization/profile.md) |
152+
| **Configuration** | [IdpConfiguration](../domain/configuration/idp-configuration.md), [AppConfiguration](../domain/configuration/app-configuration.md), [FeatureFlag](../domain/configuration/feature-flag.md) |
153+
| **Approvals / Compliance** | [ApprovalWorkflow](../domain/approvals/approval-workflow.md), [ApprovalRequest](../domain/approvals/approval-request.md), [DocumentType](../domain/approvals/document-type.md), [UserDocument](../domain/approvals/user-document.md), [AccessEnforcementPolicy](../domain/approvals/access-enforcement-policy.md) |
154+
| **IGA** | [PromotionRequest](../domain/iga/promotion-request.md), [RoleMaturityStatus](../domain/iga/role-maturity-status.md) |
155+
| **Audit** | [AuditRecord](../domain/audit/audit-record.md) |
142156

143-
| BC | Aggregate Root | Owned Entities (documented within AR) |
144-
|---|---|---|
145-
| **Identity** | [Tenant](../domain/identity/tenant.md) | Branch · Branding · IdentityProvider |
146-
| **Identity** | [UserAccount](../domain/identity/user-account.md) | PasswordCredential · MfaEnrollment |
147-
| **Authorization** | [SystemSuite](../domain/authorization/system-suite.md) | FunctionalModule · FunctionalMenu · FunctionalSubMenu · FunctionalOption · Action |
148-
| **Authorization** | [PermissionTemplate](../domain/authorization/permission-template.md) | PermissionTemplateItem |
149-
| **Authorization** | [Profile](../domain/authorization/profile.md) | ProfilePermission |
150-
| **Configuration** | [IdpConfiguration](../domain/configuration/idp-configuration.md) | *(none)* |
151-
| **Configuration** | [AppConfiguration](../domain/configuration/app-configuration.md) | *(none)* |
152-
| **Configuration** | [FeatureFlag](../domain/configuration/feature-flag.md) | FlagEvaluationLog |
153-
| **Approvals** | [ApprovalWorkflow](../domain/approvals/approval-workflow.md) | ApprovalRequiredDocument |
154-
| **Approvals** | [ApprovalRequest](../domain/approvals/approval-request.md) | ApprovalLog |
155-
| **Compliance** | [DocumentType](../domain/approvals/document-type.md) | NotificationRule · AccessEnforcementPolicy |
156-
| **Compliance** | [UserDocument](../domain/approvals/user-document.md) | AccessNotification |
157-
| **IGA** | [PromotionRequest](../domain/iga/promotion-request.md) | PromotionImpactAnalysis |
158-
| **IGA** | [RoleMaturityStatus](../domain/iga/role-maturity-status.md) | *(none)* |
159-
| **Audit** | [AuditRecord](../domain/audit/audit-record.md) | *(none — append-only)* |
157+
> **Counting rule:** The Domain Aggregate Index is the source of truth for aggregate count and ownership. Architecture summaries must not define independent aggregate totals.
160158
161159
---
162160

@@ -165,22 +163,40 @@ See [Domain Aggregate Index](../domain/index.md) for the full inventory.
165163
To preserve DDD bounded context purity while maintaining system cohesion, the following integration standards must be strictly followed:
166164

167165
### 1. The Transactional Outbox Pattern
166+
168167
Every state-changing operation within an aggregate must publish events to a local outbox table **in the same database transaction**. An asynchronous dispatcher reads these entries and forwards them to Dapr PubSub for cross-context delivery. This ensures reliable eventual consistency without distributed 2PC transactions.
169168

170169
### 2. Integration via Core Identifiers
170+
171171
Aggregates in downstream contexts must NEVER reference entities of upstream contexts directly. Instead, they reference only their global identifier (`TenantId`, `UserId`, `BranchId`, etc.) stored as strong Value Objects.
172172

173173
### 3. Anti-Corruption Layers (ACL)
174-
When a context integrates with external directories or Legacy HR Systems, an explicit Anti-Corruption Layer (consisting of Adapters, Translators, and Facades) is built inside the infrastructure layer to prevent external concepts from bleeding into the pure Domain model.
174+
175+
When a context integrates with external directories or legacy HR systems, an explicit Anti-Corruption Layer (consisting of Adapters, Translators, and Facades) is built inside the infrastructure layer to prevent external concepts from bleeding into the pure Domain model.
176+
177+
---
178+
179+
## 6. Data Model Governance
180+
181+
UMS has three complementary data-model views:
182+
183+
| View | Source | Purpose |
184+
|---|---|---|
185+
| Conceptual | [Conceptual Data Model](../governance/requirements/conceptual-data-model.md) | Business-readable language and early requirements validation. |
186+
| Domain | [Domain Aggregate Index](../domain/index.md) | DDD Aggregate Roots, owned entities, invariants, and behavioral model. |
187+
| Physical | [Database Design ER](./blueprints/database-design-er.md) | Authoritative SQL Server / EF Core-aligned physical entity-relationship model. |
188+
189+
Use [Data Model Consistency Review](./blueprints/data-model-consistency-review.md) when validating alignment across conceptual names, DDD aggregates, ER diagrams, and EF Core persistence records.
175190

176191
---
177192

178-
## 6. Shared Architectural Rules
193+
## 7. Shared Architectural Rules
179194

180-
- **Zero NuGet References in Domain**: The Domain project is 100% pure C#.
195+
- **Zero Framework References in Domain**: The Domain project is pure C# and must not reference EF Core, ASP.NET, HotChocolate, Dapr, or infrastructure libraries.
196+
- **DDD-first Language**: Architecture documents should use Aggregate Root, Entity, Value Object, Domain Event, Invariant, and Bounded Context as the dominant vocabulary. Technical .NET terms may be used only when clarifying implementation constraints.
181197
- **Result Pattern**: Application flows do not throw control exceptions. All business validations return a `Result<T>` structure mapping out failure cases clearly.
182-
- **Single Source of Truth**: Business invariants and entity schemas belong strictly in their respective aggregate files listed in Section 4. Do not copy ER schemas or diagrams into any other architectural indexes.
198+
- **Single Source of Truth**: Business invariants and domain entity schemas belong in their respective aggregate files listed in the Domain Aggregate Index. Physical schema belongs in the Database Design ER.
183199

184200
---
185201

186-
**[Back to Master Index](../MASTER_INDEX.md)** | **[Go to Domain Index](../domain/index.md)**
202+
**[Back to Master Index](../MASTER_INDEX.md)** | **[Go to Domain Index](../domain/index.md)**

0 commit comments

Comments
 (0)