rea-analysis-optimization
MOmorluto/rea485k近 7 天新增 9,215 个 star
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).
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 optionreferences/clean-architecture.md: Domain, Application, Infrastructure, Api; IAppDbContext; use cases; endpoints returning TypedResults unionsreferences/ddd.md: aggregates, value objects, strongly-typed IDs, domain events, domain services; usable inside a modular-slices modulereferences/project-structure.md: solution layout, Directory.Build.props, Directory.Packages.props, .slnx, global.json, .editorconfig, analyzers, tech-stack defaultsIEndpoint per feature, TypedResults unions, DbContext used directly, no repository over EF Core, no MediatR.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.Before recommending an architecture, ask questions across these 6 categories. Not every question applies to every project; skip irrelevant ones.
| # | 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) |
| # | 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 |
| # | 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 |
| # | 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 |
| # | 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 |
| # | 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 |
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 |
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/
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
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
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.
| 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 |
| 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 |
// 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
// 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";
}
// 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/
// 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*
// 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(...)
| 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 |
MOmorluto/rea485k近 7 天新增 9,215 个 star
MAmattpocock/skills336k近 7 天新增 5,004 个 star
MAmattpocock/skills336k近 7 天新增 5,004 个 star
MAmattpocock/skills336k近 7 天新增 5,004 个 star
MAmattpocock/skills336k近 7 天新增 5,004 个 star