---
name: dotnet-structure
description: .NET Clean Architecture 4-layer SmartStack
group: A
allowed-tools: [Read, Glob, Grep]
---

# Skill: .NET Clean Architecture SmartStack

## 4-Layer Architecture

```
{App}.Domain/          # Entities, value objects, enums
{App}.Application/     # Services, DTOs, validators
{App}.Infrastructure/  # EF Core, repositories, external services
{App}.Api/             # Controllers, Program.cs, appsettings
```

> Inside each project, generated artifacts are classified by business app + module:
> `Domain/Entities/<App>/<Module>/`, `Application/<App>/<Module>/…`,
> `Infrastructure/Services/<App>/<Module>/`, `Api/Controllers/<App>/<Module>/`
> (screen controllers add `/<Section>/`). The Domain layer keeps a FLAT namespace
> despite the folder move (cross-module FK rule). See `conventions` (Namespaces)
> + `lib/app-classification.ts`.

## Project References
```
Domain  ←──  Application  ←──  Api
   ↑              ↑
   └──  Infrastructure  ──→  Api
```

## Dual-DbContext
- `ExtensionsDbContext` inherits from SmartStack `ApplicationDbContext`
- `IExtensionsDbContext` inherits from `IApplicationDbContext`

## Program.cs — 4 Mandatory Calls
```csharp
builder.Services.AddSmartStack(builder.Configuration);
await app.InitializeSmartStackAsync();
app.UseSmartStack();
app.MapSmartStack();
```

## Directory.Build.props
```xml
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
```

## Standard Ports
- API HTTP: `localhost:5142` / HTTPS: `localhost:7142`
- Frontend dev: `localhost:3000`
