The Architecture Contract

ArchitectureAnalyzer keeps application-specific architecture policy in a small JSON file owned by the consuming repository.

Minimal example

{
  "layers": [
    { "name": "Domain", "namespaceRoots": ["MyApp.Domain"] },
    { "name": "Application", "namespaceRoots": ["MyApp.Application"] }
  ],
  "forbiddenDependencies": [
    { "from": "Domain", "to": "Application", "reason": "Keep Domain independent." }
  ],
  "forbiddenApis": [
    { "layer": "Domain", "type": "System.Console", "reason": "No console I/O in Domain." }
  ]
}

Contract responsibilities

How enforcement runs

Add the NuGet analyzer and register the JSON file as an AdditionalFiles item. ArchitectureAnalyzer reads the contract during Roslyn analysis and reports diagnostics in normal builds and IDE analysis.

<PackageReference Include="loach.ArchitectureAnalyzer" Version="..." PrivateAssets="all" />
<AdditionalFiles Include="architecture.contract.json" />

Contract versus configuration

The contract answers what architecture rules exist. Standard Roslyn severity settings and architecture_analyzer.* options answer how the analyzer runs. For the complete schema, see docs/architecture.md.