From 4577ad2e751d182d701d00772efd7a88deedd78e Mon Sep 17 00:00:00 2001 From: Stephen Walsh <868017+stphnwlsh@users.noreply.github.com> Date: Sat, 5 Dec 2026 20:00:48 +0000 Subject: [PATCH 1/2] Add a page comparing Lean Mean Clean with textbook Clean Architecture --- .../docs/graphql/explanation/architecture.mdx | 2 +- .../docs/lambda/explanation/architecture.mdx | 2 +- .../docs/mcp/explanation/architecture.mdx | 2 +- .../minimalapi/explanation/architecture.mdx | 2 +- src/content/docs/not-your-uncles-clean.mdx | 109 ++++++++++++++++++ .../docs/webapi/explanation/architecture.mdx | 2 +- 6 files changed, 114 insertions(+), 5 deletions(-) create mode 100644 src/content/docs/not-your-uncles-clean.mdx diff --git a/src/content/docs/graphql/explanation/architecture.mdx b/src/content/docs/graphql/explanation/architecture.mdx index 7c11fcb..dc1ee40 100644 --- a/src/content/docs/graphql/explanation/architecture.mdx +++ b/src/content/docs/graphql/explanation/architecture.mdx @@ -7,7 +7,7 @@ sidebar: import { Aside } from '@astrojs/starlight/components'; -This solution is loosely based on Clean Architecture. It's by no means perfect, so we prefer to call it **Lean Mean Clean Architecture**. The inspiration is [Jason Taylor's Clean Architecture template](https://github.com/jasontaylordev/CleanArchitecture), with some ideas taken further and others scaled back. +This solution is loosely based on Clean Architecture. It's by no means perfect, so we prefer to call it **Lean Mean Clean Architecture**. The inspiration is [Jason Taylor's Clean Architecture template](https://github.com/jasontaylordev/CleanArchitecture), with some ideas taken further and others scaled back. [Not your uncle's Clean](/not-your-uncles-clean/) lays it side by side with textbook Clean Architecture, and explains how it ended up this way. ## Dependencies point inwards diff --git a/src/content/docs/lambda/explanation/architecture.mdx b/src/content/docs/lambda/explanation/architecture.mdx index 82e5fe7..b76872c 100644 --- a/src/content/docs/lambda/explanation/architecture.mdx +++ b/src/content/docs/lambda/explanation/architecture.mdx @@ -7,7 +7,7 @@ sidebar: import { Aside } from '@astrojs/starlight/components'; -This solution is loosely based on Clean Architecture. It's by no means perfect, so we prefer to call it **Lean Mean Clean Architecture**. The inspiration is [Jason Taylor's Clean Architecture template](https://github.com/jasontaylordev/CleanArchitecture), with some ideas taken further and others scaled back. +This solution is loosely based on Clean Architecture. It's by no means perfect, so we prefer to call it **Lean Mean Clean Architecture**. The inspiration is [Jason Taylor's Clean Architecture template](https://github.com/jasontaylordev/CleanArchitecture), with some ideas taken further and others scaled back. [Not your uncle's Clean](/not-your-uncles-clean/) lays it side by side with textbook Clean Architecture, and explains how it ended up this way. ## Dependencies point inwards diff --git a/src/content/docs/mcp/explanation/architecture.mdx b/src/content/docs/mcp/explanation/architecture.mdx index a700115..7ece54d 100644 --- a/src/content/docs/mcp/explanation/architecture.mdx +++ b/src/content/docs/mcp/explanation/architecture.mdx @@ -7,7 +7,7 @@ sidebar: import { Aside } from '@astrojs/starlight/components'; -This solution is loosely based on Clean Architecture. It's by no means perfect, so we prefer to call it **Lean Mean Clean Architecture**. The inspiration is [Jason Taylor's Clean Architecture template](https://github.com/jasontaylordev/CleanArchitecture), with some ideas taken further and others scaled back. +This solution is loosely based on Clean Architecture. It's by no means perfect, so we prefer to call it **Lean Mean Clean Architecture**. The inspiration is [Jason Taylor's Clean Architecture template](https://github.com/jasontaylordev/CleanArchitecture), with some ideas taken further and others scaled back. [Not your uncle's Clean](/not-your-uncles-clean/) lays it side by side with textbook Clean Architecture, and explains how it ended up this way. ## Dependencies point inwards diff --git a/src/content/docs/minimalapi/explanation/architecture.mdx b/src/content/docs/minimalapi/explanation/architecture.mdx index 8f7361d..5263ade 100644 --- a/src/content/docs/minimalapi/explanation/architecture.mdx +++ b/src/content/docs/minimalapi/explanation/architecture.mdx @@ -7,7 +7,7 @@ sidebar: import { Aside } from '@astrojs/starlight/components'; -This solution is loosely based on Clean Architecture. It's by no means perfect, so we prefer to call it **Lean Mean Clean Architecture**. The inspiration is [Jason Taylor's Clean Architecture template](https://github.com/jasontaylordev/CleanArchitecture), with some ideas taken further and others scaled back. +This solution is loosely based on Clean Architecture. It's by no means perfect, so we prefer to call it **Lean Mean Clean Architecture**. The inspiration is [Jason Taylor's Clean Architecture template](https://github.com/jasontaylordev/CleanArchitecture), with some ideas taken further and others scaled back. [Not your uncle's Clean](/not-your-uncles-clean/) lays it side by side with textbook Clean Architecture, and explains how it ended up this way. ## Dependencies point inwards diff --git a/src/content/docs/not-your-uncles-clean.mdx b/src/content/docs/not-your-uncles-clean.mdx new file mode 100644 index 0000000..4723979 --- /dev/null +++ b/src/content/docs/not-your-uncles-clean.mdx @@ -0,0 +1,109 @@ +--- +title: "Not your uncle's Clean" +description: "How Lean Mean Clean Architecture compares with textbook Clean Architecture, how it got this way, and the seams we kept on purpose." +template: splash +--- + +The five templates are loosely based on Clean Architecture, the one Uncle Bob made famous. "Loosely" is doing a lot of work in that sentence. It's not as clean as your uncle's, and that's on purpose. + +## Where it came from + +This didn't start as an exercise in Clean Architecture. It started with one question: what's a good way to put different front doors on what is basically the same system? An HTTP API, a GraphQL schema, an MCP server for AI clients and an AWS Lambda function, all serving the same movie reviews with the same rules. + +What popped out was one shared middle and a thin outside you can swap. It looked a lot like Clean Architecture, minus the parts that didn't earn their keep. We call it Lean Mean Clean Architecture, or clean-ish when nobody's listening. + +## Side by side + + + + + + + TEXTBOOK + LEAN MEAN CLEAN + + + + + + + + + Web + Controllers, DTOs, mapping profiles + Application + IThingService, IDateTime, IUnitOfWork... + Domain + Value objects, events, specifications + Infrastructure + IRepository<T> and a unit of work on DbSet<T> + + + + + + + + Minimal + MCP + GraphQL + Web API + Lambda + + Presentation: one front door per template + + + Application, the same in all five + Feature folders, one folder per use case + Command, handler and validator together + Plain records, no Domain project + No services, TimeProvider for time + Three repository interfaces + + + + Infrastructure, the same in all five + One class, LINQ straight on the DbContext + + + + + + + Four or five projects, an interface per class + Three projects, three interfaces + + + +## What's different + +| | Textbook | Lean Mean Clean | Why | +| --- | --- | --- | --- | +| Projects | Web, Application, Domain, Infrastructure, sometimes a shared kernel | Presentation, Application, Infrastructure | Fewer "does this go in Domain or Application?" debates. | +| Folders | By layer and type: `Services`, `Interfaces`, `Dtos` | By feature, then use case: `Reviews/Commands/CreateReview` | Everything one change touches sits in one folder. | +| Entities | A rich domain model in its own project | Plain records next to the use cases that return them | The rules live in validators and handlers, and there isn't enough domain to fill a project. | +| Services | An `IThingService` and `ThingService` for each area | None | Each use case has one handler, and the handler is the service. | +| Interfaces | One for nearly every class | Three, all repository interfaces | See the seams below. | +| Data access | A generic repository and unit of work wrapped around `DbSet` | One class implements all three repository interfaces with LINQ on the DbContext | EF Core already is a repository and a unit of work. | +| Time | An `IDateTime` of your own | `TimeProvider` | It's been in the box since .NET 8. | +| Dependency rule | Presentation never references Infrastructure | Presentation references it to wire up dependency injection, and everything else in Infrastructure is `internal` | Saves a project whose only job is to call two methods. | + +## The seams we kept + +Some abstractions did earn their keep. Here's what's left, and why. + +- **Three repository interfaces, one implementation.** Yes, that's the bit critics point at, and they're not wrong about most apps. These stay because Application is identical in five templates and has no idea which front door it's behind, and because handler tests run against NSubstitute instead of a database. +- **Separate database models.** Infrastructure keeps its own EF Core models and maps them to the Application records with [Mapperly](https://mapperly.riok.app), so navigation properties and database config never leak into what clients see. It costs a mapper, and Mapperly writes that at build time. +- **[Mediator](https://github.com/martinothamar/Mediator).** Every front door sends the same commands and queries through one pipeline, so validation, logging and a trace span per use case are written once. It's free and source-generated, so there's no reflection on the way through. + +## When to fold it away + +If you'll only ever have one front door, you could fold Application and Infrastructure into the host, drop the repository interfaces and query the DbContext straight from the handlers. That's a perfectly good shape. These templates show the version with five front doors, so they keep the seam. + +Pick the template with the front door you need, and delete whatever you don't. We won't take it personally. + +- [Clean Minimal API](/minimalapi/explanation/architecture/) +- [Clean Model Context Protocol](/mcp/explanation/architecture/) +- [Clean GraphQL API](/graphql/explanation/architecture/) +- [Clean Web API](/webapi/explanation/architecture/) +- [Clean Lambda Function](/lambda/explanation/architecture/) diff --git a/src/content/docs/webapi/explanation/architecture.mdx b/src/content/docs/webapi/explanation/architecture.mdx index e140d70..ba08ce1 100644 --- a/src/content/docs/webapi/explanation/architecture.mdx +++ b/src/content/docs/webapi/explanation/architecture.mdx @@ -7,7 +7,7 @@ sidebar: import { Aside } from '@astrojs/starlight/components'; -This solution is loosely based on Clean Architecture. It's by no means perfect, so we prefer to call it **Lean Mean Clean Architecture**. The inspiration is [Jason Taylor's Clean Architecture template](https://github.com/jasontaylordev/CleanArchitecture), with some ideas taken further and others scaled back. +This solution is loosely based on Clean Architecture. It's by no means perfect, so we prefer to call it **Lean Mean Clean Architecture**. The inspiration is [Jason Taylor's Clean Architecture template](https://github.com/jasontaylordev/CleanArchitecture), with some ideas taken further and others scaled back. [Not your uncle's Clean](/not-your-uncles-clean/) lays it side by side with textbook Clean Architecture, and explains how it ended up this way. ## Dependencies point inwards From 037b8826898b820a5a4102e962ea2e4fb7d12798 Mon Sep 17 00:00:00 2001 From: Stephen Walsh <868017+stphnwlsh@users.noreply.github.com> Date: Sat, 5 Dec 2026 20:05:01 +0000 Subject: [PATCH 2/2] Stack the comparison diagram on narrow screens --- src/content/docs/not-your-uncles-clean.mdx | 117 +++++++++++++++------ src/styles/docs/theme.css | 15 +++ 2 files changed, 102 insertions(+), 30 deletions(-) diff --git a/src/content/docs/not-your-uncles-clean.mdx b/src/content/docs/not-your-uncles-clean.mdx index 4723979..6f55f19 100644 --- a/src/content/docs/not-your-uncles-clean.mdx +++ b/src/content/docs/not-your-uncles-clean.mdx @@ -14,14 +14,11 @@ What popped out was one shared middle and a thin outside you can swap. It looked ## Side by side - + - - TEXTBOOK - LEAN MEAN CLEAN - + TEXTBOOK @@ -43,35 +40,95 @@ What popped out was one shared middle and a thin outside you can swap. It looked - - Minimal - MCP - GraphQL - Web API - Lambda + Four or five projects, an interface per class + + LEAN MEAN CLEAN + + Minimal + MCP + GraphQL + Web API + Lambda + + Presentation: one front door per template + + + Application, the same in all five + Feature folders, one folder per use case + Command, handler and validator together + Plain records, no Domain project + No services, TimeProvider for time + Three repository interfaces + + + + Infrastructure, the same in all five + One class, LINQ straight on the DbContext + + + + + + Three projects, three interfaces - Presentation: one front door per template - - - Application, the same in all five - Feature folders, one folder per use case - Command, handler and validator together - Plain records, no Domain project - No services, TimeProvider for time - Three repository interfaces + + + + + + + TEXTBOOK + + + + + - - - Infrastructure, the same in all five - One class, LINQ straight on the DbContext + + Web + Controllers, DTOs, mapping profiles + Application + IThingService, IDateTime, IUnitOfWork... + Domain + Value objects, events, specifications + Infrastructure + IRepository<T> and a unit of work on DbSet<T> - - - + + + + - - Four or five projects, an interface per class - Three projects, three interfaces + Four or five projects, an interface per class + + LEAN MEAN CLEAN + + Minimal + MCP + GraphQL + Web API + Lambda + + Presentation: one front door per template + + + Application, the same in all five + Feature folders, one folder per use case + Command, handler and validator together + Plain records, no Domain project + No services, TimeProvider for time + Three repository interfaces + + + + Infrastructure, the same in all five + One class, LINQ straight on the DbContext + + + + + + Three projects, three interfaces diff --git a/src/styles/docs/theme.css b/src/styles/docs/theme.css index 56b2040..5a6da6e 100644 --- a/src/styles/docs/theme.css +++ b/src/styles/docs/theme.css @@ -382,3 +382,18 @@ pre { font-family: var(--lmca-font-display); color: var(--sl-color-white); } + +/* A wide diagram with a stacked twin for narrow screens, so its labels stay readable on a phone. */ +.cl-diagram-narrow { + display: none; +} + +@media (max-width: 40rem) { + .cl-diagram-wide { + display: none; + } + + .cl-diagram-narrow { + display: block; + } +}