---
title: Architecture Constraints
summary: Mandatory technical, organizational, and engineering guardrails for BookWorm.
owners:
  - architecture-enabling-team
badges:
  - content: Architecture
    backgroundColor: blue
    textColor: blue
---

This chapter defines the guardrails for decisions that shape BookWorm across .NET 11 services, Next.js 16 microfrontends, and Aspire 17 orchestration. It separates mandatory constraints from engineering conventions and open commitments: constraints limit options, while principles guide choices and exceptions.

The catalog distinguishes:

- **Mandatory constraints:** changes require an approved exception or an architecture decision record (ADR).
- **Engineering conventions:** repository standards that automated checks or review should enforce.
- **Open commitments:** targets or controls that are not yet signed off and must not be presented as guarantees.

## Executive summary

- Preserve bounded-context ownership and explicit interoperability.
- Resolve breaking changes through impact and migration planning.
- Name an owner and approver for every material exception.
- Enforce platform standards and evidence-based architecture changes.
- Avoid uncontrolled technology, compliance, vendor, or operational commitments.

BookWorm is an open-source reference architecture. It does not, by itself, establish organization-specific procurement mandates, staffing models, regulatory certification, approved service levels, or named production approvers.

## Architecture constraint principles

These principles translate architecture governance into practical BookWorm rules.

1. **Domain ownership is explicit.** One bounded context owns one domain and its authoritative data.
2. **Contracts are products.** Consumers depend on stable, versioned interfaces owned and evolved by a producer.
3. **Standards reduce variance.** Approved runtimes, frameworks, protocols, and verification tools take precedence over local alternatives.
4. **Independent deployment follows compatibility.** Deployment autonomy is earned through validated contracts and operational readiness.
5. **Infrastructure is supportive.** Shared platform components must not become hidden domain owners or transaction coordinators.
6. **Decisions must be traceable.** Material changes include an ADR, updated documentation, and recorded evidence.
7. **Gaps remain visible.** Proposed targets remain proposals until scope, owners, budgets, and acceptance evidence are approved.

## Technical constraints

| ID      | Mandatory constraint                                                                                                                                                                                                                   | Business and architectural impact                                                                               | Primary evidence                                                             |
| :------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :-------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------- |
| **TC1** | **Preserve bounded-context data ownership.** Each bounded context owns its domain behavior and persistence. Services do not query another service's database directly.                                                                 | Limits change blast radius, protects domain invariants, and requires explicit cross-boundary contracts.         | Service boundaries and persistence configuration; `BookWorm.ArchTests`       |
| **TC2** | **Integrate through owned, explicit contracts.** Cross-service communication uses versioned HTTP (`ApiVersions.V1`), Protocol Buffers gRPC, or CloudEvents JSON over Kafka through Wolverine.                                          | Gives producers and consumers a stable interoperability surface and makes compatibility a release gate.         | Contract definitions; Pact and Protocol Buffer verification                  |
| **TC3** | **Evolve Protocol Buffer contracts compatibly.** Lint `.proto` definitions (`edition = "2023"`) and verify backward compatibility against the committed baseline. Breaking changes require consumer coordination and a migration plan. | Prevents incompatible gRPC clients and avoids unplanned rollout coupling.                                       | `.proto` lint and compatibility jobs                                         |
| **TC4** | **Use the approved backend stack.** Target `net11.0`, C# 15, `BookWorm.slnx`, `Mediator.SourceGenerator` for CQRS, Wolverine and Kafka, Microsoft Entra ID, Aspire 17, and TUnit on Microsoft.Testing.Platform.                        | Standardizes runtime behavior, tooling, observability, identity, and delivery pipelines.                        | `Directory.Packages.props`, solution projects, CI workflows                  |
| **TC5** | **Use the approved frontend stack.** Use Bun, Turborepo, Next.js 16, React 19, TypeScript, and Better Auth integrated with Microsoft Entra ID across Storefront, Commerce, and Backoffice.                                             | Prevents lockfile and dependency-layer drift while preserving consistent identity and delivery behavior.        | Bun lockfile, Turbo boundaries, frontend CI                                  |
| **TC6** | **Make independent deployability a compatibility property.** A service may deploy independently only when the intended contract and behavior remain compatible with consumers.                                                         | Supports faster, lower-risk releases; breaking changes require a coordinated migration or compatibility period. | Contract tests, deployment pipelines, release evidence                       |
| **TC7** | **Keep shared infrastructure domain-neutral.** Notification, Scheduler, API Gateway, and BuildingBlocks must not own commerce domain state or enforce commerce business rules.                                                         | Prevents shared infrastructure from becoming an implicit coupling point or hidden source of truth.              | Architecture tests, code ownership, service boundaries                       |
| **TC8** | **Apply security controls at platform and endpoint boundaries.** Authenticate and authorize external requests, protect secrets, and apply PII and AI governance controls where sensitive data or agents are used.                      | Reduces exposure from identity, privacy, and model-integration failures.                                        | Endpoint policies, secret configuration, Presidio and AI governance settings |

## Organizational constraints

| ID      | Mandatory constraint                                                                                                                                                           | Enforcement and governance                                                                                                                   |
| :------ | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------- |
| **OC1** | **Assign bounded-context ownership.** Every service, contract, and cross-context flow has an explicit owner and escalation path before production adoption or boundary change. | Architecture review confirms ownership; the owning team maintains implementation and contract evolution.                                     |
| **OC2** | **Keep architecture artifacts synchronized.** Behavior, contract, persistence, or boundary changes update the relevant architecture views and ADR set.                         | Pull-request review and documentation/architecture fitness checks identify drift.                                                            |
| **OC3** | **Protect credentials and toolchain baselines.** Secrets remain outside source control. SDK and package-feed configuration changes require explicit approval.                  | GitHub Actions or Azure OIDC, user secrets, or environment variables contain credentials; `global.json` and `NuGet.config` remain protected. |
| **OC4** | **Record material architecture decisions.** Non-reversible or cross-team decisions require an ADR describing context, options, consequences, and ownership.                    | Accepted ADRs are reviewed and linked to implementation, roadmap, and operational runbooks.                                                  |
| **OC5** | **Use evidence for production commitments.** Availability, recovery, latency, privacy, security, and AI safeguards require frozen test conditions and recorded evidence.       | Service owners report evidence; designated review forums grant production status.                                                            |

## Engineering conventions

| ID     | Convention                                                                                                                                                                                                                                           | Repository and CI enforcement                                                                                                |
| :----- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------- |
| **C1** | Use `mise` tasks for restore, build, test, format, and workspace preparation.                                                                                                                                                                        | Repository task definitions and pre-commit checks provide a repeatable workflow.                                             |
| **C2** | Keep C# types, async flows, namespaces, and dependencies consistent. Endpoints, handlers, `DbContext` types, and tests are sealed by default; `CancellationToken` is propagated; namespaces are file-scoped; package versions are centrally managed. | `.editorconfig`, analyzers, Central Package Management, and `BookWorm.ArchTests` enforce and detect violations.              |
| **C3** | Use `snake_case` PostgreSQL identifiers and explicit API versioning. Authorization is applied at endpoint boundaries.                                                                                                                                | Naming conventions, migrations, OpenAPI metadata, and endpoint tests preserve consistency.                                   |
| **C4** | Preserve integration-event naming and routing metadata. Shared contracts live in `BookWorm.Contracts`; events follow owned naming and identity conventions.                                                                                          | Wolverine routing, contract tests, and EventCatalog fitness checks validate interoperability.                                |
| **C5** | Validate boundaries continuously. Combine unit, contract, architecture, frontend, and documentation checks.                                                                                                                                          | TUnit, PactNet, ArchUnitNET, Vitest, Playwright BDD, Turbo boundaries, and documentation checks form the change-safety gate. |

## Architecture governance

Architecture governance should make constraints visible, proportionate, and reviewable before implementation.

| Governance stage            | Required output                                                                                        | Decision authority                        |
| :-------------------------- | :----------------------------------------------------------------------------------------------------- | :---------------------------------------- |
| **Architecture principles** | Confirm that the proposal follows the principles in this chapter                                       | Architecture review                       |
| **Baseline and target**     | Compare current and target business, application, data, and technology states                          | Product and architecture review           |
| **Impact assessment**       | Identify affected bounded contexts, consumers, data, security, operations, cost, and rollout risk      | Domain owners and delivery management     |
| **Decision and roadmap**    | Record an ADR and sequence migrations, compatibility periods, and verification                         | Delegated architecture authority          |
| **Implementation review**   | Demonstrate contract compatibility, automated checks, operational readiness, and documentation updates | Engineering leads and governance forum    |
| **Benefit and risk review** | Record outcomes and unresolved risks against the approved target                                       | Executive sponsor and architecture review |

### Exception process

An exception is a documented, time-bound deviation; it is not an informal bypass.

1. Identify the constraint or convention, affected systems, and the reason the baseline is unsuitable.
2. Assess user, security, compliance, delivery, cost, operability, and migration impacts.
3. Define compensating controls, an expiry or exit condition, and a named accountable owner.
4. Obtain approval from the authority appropriate to the risk.
5. Record the exception in an ADR or governed exception register.
6. Review the exception before expiry and remove or renew it with evidence.

## Open commitments and scope limits

The following items require formal approval and are intentionally not represented as current guarantees:

- Numerical latency, availability, throughput, freshness, recovery, and retention budgets.
- Named production SLAs, RTO/RPO targets, and contractual compliance obligations.
- Organization-specific regulatory scope, security certification, vendor procurement, and staffing requirements.
- End-to-end operational evidence for all proposed quality scenarios.

Unresolved numerical budgets belong in the quality requirements and decisions records rather than this constraint catalog.

## Related architecture documentation

- [[doc|development/004-engineering-standards]] — Detailed backend and frontend coding standards.
- [[doc|arc42/04-solution-strategy]] — How BookWorm satisfies quality goals within these constraints.
- [[doc|arc42/08-crosscutting-concepts/002-contracts-and-messaging]] — Detailed gRPC, REST, and Kafka contract rules.
- [[doc|arc42/08-crosscutting-concepts/006-testing-and-change-safety]] — Verification layers enforcing compatibility and boundary rules.
- [[doc|arc42/09-architecture-decisions]] — Formal decisions behind these constraints.
- [[doc|arc42/10-quality-requirements]] — Proposed quality targets and measurable scenarios.
