dotnet-corelisted
Install: claude install-skill alexander-danilenko/cortex-ai-skills
# .NET Core Architecture
House architecture conventions for .NET 8 backend services. This covers how a service is _structured_; for language-level conventions see the `csharp` skill.
## Layering
Dependencies point inward only. Domain knows nothing about anything else, and Infrastructure is the one layer allowed to reference a database or an SDK — which is what lets the inner layers be tested without either.
```text
Domain entities, value objects, domain events, interfaces → no dependencies
Application use cases, CQRS handlers, DTOs, validators → Domain
Infrastructure EF Core, external APIs, implementations of Domain interfaces → Domain + Application
Api endpoints, DI wiring, middleware → all of the above
```
The test that keeps this honest: if `Domain` compiles with no package references beyond the BCL, the boundary is intact.
Entities enforce their own invariants: private setters, a private parameterless constructor for EF Core's materialiser, and a static factory that validates. Public setters mean any layer can put the entity into an invalid state, and then "the domain guarantees X" is just a comment.
```csharp
public class Product
{
public string Name { get; private set; } = string.Empty;
public decimal Price { get; private set; }
private Product() { } // EF Core materialisation only
public static Product Create(string name, decimal price) =>
price <= 0
? throw new DomainEx