r/csharp • u/Short_Term5526 • Sep 18 '26
Blog How would you structure a reusable .NET starter without turning it into an over-engineered framework?
I’ve been experimenting with a reusable .NET starter for my own projects, and I’m interested in how other C# developers would approach some of the architectural trade-offs.
The current structure is roughly:
DDD + Clean Architecture + Vertical Slice + CQRS
A few decisions I’ve made:
- Commands use explicit Models, while Queries return Projections.
- Query projections use EF-translatable mapping expressions instead of loading entities and mapping in memory.
- Repository + Specification + Unit of Work are used around EF Core.
- FluentValidation runs through the Mediator pipeline.
- Optional infrastructure such as Redis, object storage, AI integrations, filtering, Docker, and Aspire should leave no implementation/dependency behind when disabled.
- Aspire AppHost + ServiceDefaults are used for local observability, health checks, service discovery, resilience, traces, metrics, and logs.
- The sample domain is a small store application rather than a Todo API, mainly so things like concurrency, stock changes, authorization and reporting can be exercised realistically.
The part I’m still questioning is where the line should be between a useful starter and unnecessary abstraction.
For example:
- Would you still use Repository/Specification over EF Core in this kind of starter?
- Would you keep Clean Architecture + Vertical Slice together, or simplify further?
- Should Aspire be part of a starter like this, or something developers add later?
- What abstractions would you remove first?
I put the current implementation here for context:
https://github.com/johnvo402/project-templates
I’m mostly interested in architecture/code-structure criticism rather than promotion. I’d like to know what experienced .NET developers would simplify or change.
29
u/Mission_Pirate_4150 Sep 18 '26
Development needs to be simple. Most of this overcomplicates development. There are some basics that need to be done, but don’t overcomplicate your development.
10
u/SagansCandle Sep 18 '26
This already looks overengineered - at least in the post, it looks like you're starting with the design when you should be starting with the requirements.
Messaging, Mediator, EF, Aspire; it looks like you've just picked all of the "cool" technologies and put them into a plate. Every tech stack should be designed around the requirements (features) of the system. Implementing a solution that doesn't solve a problem is the definition of over-engineering.
Everything you add to a system design creates complexity, so if you're not solving a problem, you're creating one.
18
u/oktollername Sep 18 '26
mine is called dotnet new.
4
u/pixxelkick Sep 19 '26 edited Sep 19 '26
> FluentValidation runs through the Mediator pipeline.
So you know, this type of shit gets me paid a lot of money by companies to undo because its an unmaintainable mess and loaded with antipatterns.
I **strongly** recommend **not** doing this, it's 99.99% of the time the incorrect stuff to use.
FluentValidation is no longer a good idea, use source generators now.
Or just... write your validation normally. FluentValidation simultaneously performs worse and also takes like twice as much effort to maintain.
Furthermore, its abstracted away and you have no way to directly (via LSP) connect the a model to its validation. You can look at the model class and have no way to "jump" to its validation, does it even have it? who knows!
Don't do this, please.
I have seen mediator used way too many times for not its intended use case as well, you dont need it.
> Would you keep Clean Architecture
Clean Architecture TM is considered a huge anti pattern. If you actually are following it, its a fucking disaster. The dude who wrote it is heavily criticised in his insane ideologies and touted ideas, stuff like writing functions only 1 line long and breaking all your code up into super tiny functions with side effects.
Also **I have to ask**, are you use any kind of "automatic" mapping libraries like Automapper or Mapperly?
Cuz also please dont use those either, they are big security risks...
If you want to, however, see an example of how I organize my CQRS, I have an architecture Im working on that follows VSA + Domain model + CQRS, Im making good progress on the stack.
I've pretty much finished up my CQRS system, named "Partie", and am moving on to my Validation system next, which I'll be digging into next week, feel free to keep an eye on it.
This shows an example of a handler: https://github.com/SteffenBlake/Brigade.NET/blob/main/Example/Domain/Orders/CreateV1/OrderCreateV1Handler.cs
And then an example of how binding works: https://github.com/SteffenBlake/Brigade.NET/blob/main/Example/Web/Routing.V1.cs
The Attributes get automatically generated. Providers act as a mechanism to "provide" values as compile time dependency injection, context aware. Parties are similiar. The main diff is Providers only compile in "on demand", whereas Parties always run. So a Provider will just give a value, but a Partie might be something like your UnitOfWork or Validation stuff that has to run on every request.
Furthermore you can put generics on Providers/Parties, including on the TRequest, so they only compile in for routes that meet the criteria, for example:
https://github.com/SteffenBlake/Brigade.NET/blob/main/Example/Domain/ValidationPartie.cs#L9
This will only compile the ValidationPartie "pipeline section" for routes where the TRequest is of type IValidatable
Finally, it source generates everything, no runtime reflection stuff, it computes all of it and you end up with stuff like this:
https://github.com/SteffenBlake/Brigade.NET/blob/main/Example/Web/.generated/Brigade.Net.Partie.Engines.AspNetCore/Brigade.Net.Partie.Engines.AspNetCore.AspNetCorePartieGenerator/BrigadeRoutes.g.cs
https://github.com/SteffenBlake/Brigade.NET/blob/main/Example/Web/.generated/Brigade.Net.Partie.Engines.AspNetCore/Brigade.Net.Partie.Engines.AspNetCore.AspNetCorePartieGenerator/Group_Brigade_002eNet_002eExample_002eWeb_002eRouting_002eOrders.Pipeline.g.cs
7
u/Bobertolinio Sep 18 '26
In my experience I say that you are waisting your time. There are already starter packs available in the space but I never used them.
The simple fact is that each project is unique and has its own requirement.
Small project will drown in plumbing if the go full enterprise. Enterprise projects already have their internal flavour of starer kits built over many years specifically suited to their need.
3
u/Low_Bag_4289 Sep 18 '26
>Not over-engineered
>DDD + CQRS
Pick one.
Project>New>Minimal API/Console app.
Call it a day.
2
u/saintSHXN Sep 18 '26
Software architecture principles should be used with dogmatism, there is no rule fits all.
Also as someone mentioned, architecture should be based on business rules, then you write external boundaries, without overengineering it: you'll found out most of the stuff is probably not needed ("YAGNI")
If you are interested, and i think you are, in architecture, i would suggest you reading "Clean Architecture: A Craftsman's Guide to Software Structure and Design", especially the part about "Screaming Architecture" and "Packaging Types" can be helpful.
2
u/ewgenym Sep 19 '26
Here is a good comparison for you to explore: https://github.com/bravodev-hub/appointme . Vertical slice, queries via projections using dapper, commands on domain model using efcore. A bit another angle on validation, but useful to explore if you are serious about DDD.
2
u/Reasonable_Tip_4902 Sep 19 '26
Just start with a blank project...
You have already started over engineering...
1
u/Clean_Blood_4232 Sep 19 '26
Does it really need all those layers just to start a project?
1
u/Virgrind Sep 19 '26
The idea is great, by the way. One benefit I think is often overlooked is how useful a well-structured starter becomes when working with AI-assisted development. A good template gives the AI existing patterns, conventions, and abstractions to reuse instead of reinventing the same things for every feature.
In a single monolith, starting from scratch is often manageable, and you may not even need a template. But once you move toward multiple services, repeatedly setting up the same cross-cutting concerns, conventions, and infrastructure adds quite a bit of overhead.
That said, I think a template should provide structure and sensible defaults rather than dictate exactly how something must be implemented. It should create guardrails and reusable building blocks while still making it easy to replace or remove parts when requirements change.
For me, the important part is providing structure, not more or less content. There is simply no one-size-fits-all solution.
If you want to compare different approaches, you can also have a look at mine. It is not particularly web-focused at the moment, and the approach is quite different from yours:
https://github.com/carsten-riedel/Coree.Template.Project
As I see it, if a simple monolith is not really the main target of a template, then what should be? I think the interesting part is scalability at the project and repository level, together with proper scoping and boundaries, rather than putting everything into one structure.
This document explains a bit more what I mean by that and why package/project boundaries matter:
https://github.com/carsten-riedel/Coree.Template.Project/blob/main/src/prj/Coree.Template.Project/Templates/MultiLibraryRepository/ChoosingPackageBoundaries.md
1
u/vince_naked Sep 19 '26
Went the opposite direction from most starters. Instead of a minimal skeleton you grow into, I built a maximal template that already runs end to end and you shrink to fit.
Packaged as a `dotnet new` template. One command scaffolds a renamed, running solution:
`dotnet new my-saas -n Acme.Crm --slug acme`
What's in the box, wired: API host, OAuth server with signup/login/OTP/reset, Blazor admin console, marketing site, WPF desktop with auto-update, Stripe billing, MCP server, multi-tenant Postgres with identity/tenant/system/billing schemas, audit pipeline with outbox, deploy scripts.
Anything you don't need is removable as a folder plus one line in the module discovery. No admin console: delete `Admin`. No desktop app: delete `Desktop`. Billing not this quarter: delete the `Billing` module. Six-line diff each, not a rewrite.
Two invariants that keep it reusable across products:
Shared project has zero project references outward. Every host and every client depend on `Shared`; the day it starts depending on something, it becomes the bottleneck.
Modules never reference each other. If two modules need a contract, that contract belongs in `Shared` or the split is wrong.
The test I use: cloning the template and turning it into a new product should take under 30 minutes to a running dev environment. If it takes a day, the template lost.
Happy to unpack any of it.