architecture-advisor

architecture-advisor

Popular

Architecture selection for new or restructured .NET solutions: asks about domain, team and compliance, then recommends modular slices (default), vertical slice, Clean Architecture or DDD. Use for "which architecture", "new solution", "restructure", "DDD", "project structure", "tech stack". Do NOT use for adding features to a modular-slices codebase (modular-slices), scaffolding (scaffold), or CLAUDE.md (dotnet-init).

853estrelas
185forks
Atualizado 28/11/2026
A tradução solicitada ainda não está pronta. Exibindo o original (inglês).
SKILL.md
somente leitura
name
architecture-advisor
description

Architecture selection for new or restructured .NET solutions: asks about domain, team and compliance, then recommends modular slices (default), vertical slice, Clean Architecture or DDD. Use for "which architecture", "new solution", "restructure", "DDD", "project structure", "tech stack". Do NOT use for adding features to a modular-slices codebase (modular-slices), scaffolding (scaffold), or CLAUDE.md (dotnet-init).

Architecture Advisor

Ask first, then recommend. Modular slices (a modular monolith of vertical slices, ADR-008) is the starting point for business applications; the questionnaire confirms it or finds the signals that point elsewhere. Details for each alternative live in references/ and load on demand:

  • references/vertical-slice.md: single-project VSA, discovery code, the Mediator option
  • references/clean-architecture.md: Domain, Application, Infrastructure, Api; IAppDbContext; use cases; endpoints returning TypedResults unions
  • references/ddd.md: aggregates, value objects, strongly-typed IDs, domain events, domain services; usable inside a modular-slices module
  • references/project-structure.md: solution layout, Directory.Build.props, Directory.Packages.props, .slnx, global.json, .editorconfig, analyzers, tech-stack defaults

Core Principles

  1. Start from the default, then test it. For a business application, recommend modular slices and run the questionnaire to confirm. Never prescribe without asking, and never override an existing codebase's conventions.
  2. Right-size the architecture. The simplest structure that handles the real complexity wins. CRUD apps do not need DDD; a startup does not need Clean Architecture. Match structure to requirements, not aspirations.
  3. Architecture is not permanent. Every option has an evolution path (table below). Start simple, add structure when complexity demands it, and record the decision so the team knows when to move.
  4. One default, three alternatives. Modular slices is the default. Single-project VSA, Clean Architecture and DDD stay fully supported. All of them share the kit's conventions: IEndpoint per feature, TypedResults unions, DbContext used directly, no repository over EF Core, no MediatR.
  5. Package versions are never typed from memory. Use dotnet add package <name> for third-party packages; pin Microsoft.* and EF Core to the newest 10.0.x on net10.0, because an unversioned add now resolves 11.x.

The Architecture Questionnaire

Before recommending an architecture, ask questions across these 6 categories. Not every question applies to every project; skip irrelevant ones.

Category 1: Domain Complexity

# Question Low Signal High Signal
1 How many distinct business entities does the system manage? < 10 entities 20+ entities with relationships
2 Do business rules involve multiple entities interacting? Rules are per-entity CRUD Complex invariants across entity groups
3 Are there business workflows with multiple steps? Simple request, response Sagas, approval chains, state machines
4 Do domain experts use specialized vocabulary? Generic terms (create, update) Ubiquitous language (underwrite, adjudicate)

Category 2: Team & Organization

# Question Low Signal High Signal
5 How large is the development team? 1-3 developers 8+ developers, multiple teams
6 Do different teams own different parts of the system? Single team owns everything Teams aligned to business domains
7 What is the team's experience level with .NET? Junior or mixed Senior, experienced with patterns

Category 3: System Lifetime & Scale

# Question Low Signal High Signal
8 Expected system lifetime? < 2 years, MVP/prototype 5+ years, long-lived product
9 How many concurrent users or requests per second? < 100 RPS 1000+ RPS, variable load
10 Will the system need to scale independently by feature area? Uniform load Hot spots need independent scaling

Category 4: Regulatory & Compliance

# Question Low Signal High Signal
11 Are there audit trail or compliance requirements? Basic logging sufficient Full audit trail, SOX/HIPAA/PCI
12 Do different parts of the system have different security boundaries? Single auth boundary Multi-tenant, data isolation

Category 5: Existing Codebase

# Question Low Signal High Signal
13 Is this greenfield or brownfield? Greenfield, starting fresh Brownfield, migrating from legacy
14 Are there existing architectural patterns the team follows? No established patterns Strong conventions in place

Category 6: Integration Complexity

# Question Low Signal High Signal
15 How many external systems does this integrate with? 0-2 simple APIs 5+ systems with complex contracts
16 Are there event-driven or async communication needs? Synchronous request/response Event sourcing, pub/sub, eventual consistency

Recommendation

Map answers to an architecture. Say which signals drove the pick and what would change it.

Profile Recommended Why
Business application with several areas (catalog, orders, billing, users), any team size Modular slices (default) Contracts keep areas apart, slices keep each feature in one folder, no mediator or Result library
Multiple bounded contexts, team per domain, possible later extraction Modular slices Contracts, per-module schemas and outboxes make extraction a deployment change
One business area, a few endpoints, small team, short lifetime Single-project VSA Same slice conventions without the module split
High domain complexity, specialized vocabulary, complex invariants DDD inside the complex modules, or with Clean Architecture Aggregates protect invariants; the surrounding structure still applies
Team standardised on layers, or brownfield N-tier Clean Architecture Familiar layering with the right dependency direction
Library, SDK, desktop or console app No web architecture Modules and endpoints do not apply

When signals conflict

  1. Default to modular slices for business apps. It costs little more than VSA on day one and avoids a restructure later. Drop to single-project VSA only when there is clearly one area.
  2. Domain complexity changes the inside of a module, not the outside. Use DDD aggregates in the module that needs them.
  3. Team familiarity matters. A team fluent in Clean Architecture ships faster with it than learning modular slices under a deadline.
  4. Existing code wins. In a brownfield codebase, follow its architecture unless the user asks to change it.

Patterns

Modular slices (default)

A modular monolith whose modules are built from vertical slices. Load the modular-slices skill; it owns the building blocks and the module layout.

src/
  Modularity/                           # IModule, IEndpoint, IHandler, ModuleDbContext, outbox, Problems
  Modules/
    Orders/Orders/Features/PlaceOrder/  # Endpoint, Handler, Request, RequestValidator
    Orders/Orders.Contracts/            # interfaces, records, integration events; no packages
    Catalog/...
  Api/  Worker/  Migrator/  AppHost/

Single-project VSA

Organize by feature, not layer. One business area, one project, one DbContext. See references/vertical-slice.md.

src/MyApp.Api/
  Features/CreateOrder/   # Endpoint, Handler, Request, Validator
  Features/GetOrder/
  Persistence/AppDbContext.cs

Clean Architecture

Concentric layers, dependencies pointing inward. See references/clean-architecture.md.

src/
  MyApp.Domain/           # entities, domain logic; no references
  MyApp.Application/      # use cases, IAppDbContext, validators
  MyApp.Infrastructure/   # EF Core, external services
  MyApp.Api/              # IEndpoint classes, Program.cs

DDD

Tactical patterns (aggregates, value objects, domain events) for the parts of the domain with real invariants. Lives in a module's Domain/ folder or the Domain project. See references/ddd.md.

Which reference to load

Situation Load
New business app, several areas modular-slices skill, then references/project-structure.md
Small single-area API references/vertical-slice.md
Layered team standard or brownfield N-tier references/clean-architecture.md
Heavy business rules in one area references/ddd.md (plus the architecture it sits in)
New solution files, package management, build props references/project-structure.md
Which database, auth, cache, broker Tech-stack table in references/project-structure.md
Add a feature to a modular-slices codebase modular-slices skill, not this one

Evolution Paths

From To Trigger How
Single-project VSA Clean Architecture Domain logic outgrowing handlers Extract Domain and Application, keep features as use cases
Single-project VSA Modular slices A second business area appears Move features into Modules/<Area>/, add a Contracts project, give each module its own DbContext and schema
Clean Architecture + DDD Invariants getting complex, primitive obsession Introduce aggregates, value objects, domain events
Layered monolith Modular slices Teams stepping on each other, shared-database coupling Split into modules with own DbContexts, schemas and contracts
Modular slices DDD in one module One module's rules outgrow its handlers Introduce aggregates in that module only
Modular slices Microservices Independent scaling or deployment Extract a module; its contracts become the API, its outbox feeds a broker

Anti-patterns

Picking Clean Architecture for a CRUD app

// BAD: 4 projects, 6+ files per feature for simple CRUD
src/MyApp.Domain/Entities/Product.cs
src/MyApp.Application/Products/CreateProduct/CreateProductCommand.cs
src/MyApp.Application/Products/CreateProduct/CreateProductHandler.cs
src/MyApp.Application/Products/CreateProduct/CreateProductValidator.cs
src/MyApp.Infrastructure/Persistence/ProductRepository.cs
src/MyApp.Api/Endpoints/ProductEndpoints.cs

// GOOD: a slice, one folder, no layers to cross
src/Modules/Catalog/Catalog/Features/CreateProduct/CreateProductEndpoint.cs
src/Modules/Catalog/Catalog/Features/CreateProduct/CreateProductHandler.cs
src/Modules/Catalog/Catalog/Features/CreateProduct/CreateProductRequest.cs

DDD everywhere

// BAD: value objects and aggregates for a settings table
public class UserSettings : AggregateRoot
{
    public ThemeName Theme { get; private set; }   // a value object for "dark" or "light"?
}

// GOOD: a plain entity for plain data
public class UserSettings
{
    public Guid UserId { get; init; }
    public string Theme { get; set; } = "light";
}

Premature microservices

// BAD: five services on day one with two developers
OrderService (own repo, own DB, own CI/CD)
CatalogService (own repo, own DB, own CI/CD)
IdentityService, NotificationService, GatewayService ...

// GOOD: modular slices, extract a module when there is evidence
src/Modules/Orders/  src/Modules/Catalog/  src/Modules/Identity/  src/Modules/Notifications/

Skipping the questionnaire

// BAD: scaffolding before asking anything
User: "Set up a new project for a todo app"
Agent: *immediately scaffolds a 4-project Clean Architecture solution*

// GOOD: ask first, then recommend
Agent: *asks about areas, team, lifetime; one area and one developer, so recommends single-project VSA*

Carrying old defaults into the alternatives

// BAD: a Clean Architecture handler on MediatR with a Result-to-HTTP mapper
return result.IsSuccess ? TypedResults.Ok(result.Value) : result.ToProblemDetails();

// GOOD: plain handler, endpoint declares the outcomes in a TypedResults union
private static async Task<Results<Ok<OrderDto>, ProblemHttpResult>> HandleAsync(...)

Decision Guide

Scenario Recommendation
New business application Modular slices; confirm with the questionnaire
New project, unknown requirements Start from modular slices, run the questionnaire
Simple single-area API, 1 to 3 developers Single-project VSA
Several business areas or teams Modular slices
Complex domain, specialized vocabulary Modular slices with DDD in the complex modules, or DDD + Clean Architecture
Existing N-tier codebase to modernize Clean Architecture (familiar migration), or modular slices if areas are clear
MVP or startup, speed first Single-project VSA, or two or three modules if the areas are already known
Regulatory or compliance-heavy Modular slices or Clean Architecture; both enforce boundaries in tests
Independent scaling later Modular slices (extraction-ready)
Existing codebase with its own architecture Keep it
Solution files, package management, editorconfig references/project-structure.md
Adding a feature, scaffolding modular-slices, scaffold
Generating CLAUDE.md for the project dotnet-init