All projects

Developer tool · Windows

Clean Architecture Generator

Starting a new ASP.NET Core API usually means rebuilding the same layers, security plumbing and test projects by hand. This Windows app does it in one click: choose a name and a few options, preview every file before it's written, and get a security-first .NET 10 solution that builds and passes its own tests right away.

  • C#
  • .NET 10
  • WinForms
  • ASP.NET Core
  • Clean Architecture
  • xUnit

Windows 10/11 with the .NET 10 SDK. Unzip the release and run CleanArchitectureGenerator.exe.

The generator window: solution options on the left, a file tree and code preview on the right

What it generates

For a solution called Firma.Proje with the default options:

Solution layout
Firma.Proje/
├── src/
│   ├── Firma.Proje.Domain/          entities, rules, events
│   │   ├── Common/                  Entity, Result, Error
│   │   └── TodoItems/               sample entity
│   ├── Firma.Proje.Application/     use cases
│   │   ├── Abstractions/            ports to the outside
│   │   ├── Behaviors/               logging, validation
│   │   ├── Authentication/, Account/
│   │   └── TodoItems/               command + validator + handler
│   ├── Firma.Proje.Infrastructure/  EF Core, Identity, JWT
│   └── Firma.Proje.Api/             minimal APIs, security
├── tests/
│   ├── Firma.Proje.UnitTests/
│   ├── Firma.Proje.ArchitectureTests/
│   └── Firma.Proje.IntegrationTests/
├── Directory.Build.props            analyzers, NuGet Audit
├── Directory.Packages.props         central versions
├── nuget.config                     nuget.org only
├── README.md, SECURITY.md
└── Firma.Proje.sln

Dependencies only point inward: Api → Infrastructure → Application → Domain, and the architecture tests check it on every run.

Layers that stay clean

A rich domain model whose state only changes through its own methods, version 7 GUIDs, domain events handled in the same save, and audit fields filled in on the server. Reflection-based tests fail if a layer references the wrong one.

CQRS without MediatR

A small, readable sender instead of a paid library. Every request goes through logging and FluentValidation; expected errors come back as Result values and become RFC 9457 ProblemDetails in the API.

Sign-in done properly

E-mail confirmation, lockout after 5 failures, TOTP two-factor with recovery codes and password reset. A 10-minute JWT plus a refresh token in an HttpOnly; Secure; SameSite=Strict cookie that rotates on every use; replaying an old one revokes the whole session.

Secure by default

Every endpoint needs a signed-in user unless marked otherwise, other users' records return 404, unknown JSON fields are rejected, and there are rate limits, security headers, body/time/page limits and error responses that never leak internals. Sign-in, sign-up and password reset don't reveal whether an e-mail is registered, not even through response times.

No secrets in the repo

The random JWT signing key (and the PostgreSQL connection string) goes into dotnet user-secrets while the solution is generated, never into a file in the repository. Outside Development the app refuses to start if a setting is missing or weak.

A guarded supply chain

Central Package Management with transitive pinning, lock files, NuGet Audit that stops Release builds on known vulnerabilities, package source mapping, and every .NET security analyzer turned on with warnings as errors in Release.

Options

The right-hand preview shows every file that will be created, with its content, before anything is written to disk.

OptionWhat changes
Solution nameRoot namespace, folder and project names. Invalid names get a suggestion (“Mağaza Yönetimi” → MagazaYonetimi), and names that would clash with generated types (Firma.Result) are rejected.
DatabaseSQL Server (LocalDB), PostgreSQL or SQLite: the NuGet package, the UseXxx call and the development connection string.
Solution fileThe classic .sln or the newer .slnx.
AuthenticationBuilt-in (ASP.NET Core Identity + JWT with every flow above) or an external OpenID Connect provider such as Entra ID, Auth0 or Keycloak, where the API only validates tokens and accepts asymmetric signatures only.
Sample featureTodoItems, which walks through every layer, a domain event and the ownership check. When it's off, the skeleton comes empty.
Test projectsUnit, architecture and integration tests. The integration tests run the whole app in memory on SQLite, whichever database you picked.
After generatinggit init, dotnet build and opening the folder; build output streams into the app's log.

How it works

A template engine that has nothing to do with WinForms, with the window as a thin layer on top.

  1. Templates are a real solution

    The Templates folder is an exact copy of the generated solution, embedded in the DLL as resources along with their folder paths. Copy it next to the exe to change templates without rebuilding.

  2. Tokens and conditional blocks

    Tokens like __Name__ are replaced in contents and paths. Option-dependent parts are marked with comment-style blocks for each file type — //#if LocalAuth, <!--#if Sample-->, @*#if Sample*@ — with #elif, #else, !, &&, || and parentheses. An unknown symbol is treated as a typo and reported as an error.

  3. Plan first, then write

    The whole plan is built in memory, which is what the preview shows, and only then written to disk. Files whose entire content is conditional are skipped when their option is off, and dot_gitignore / X.csproj.template become .gitignore / X.csproj so IDEs don't mistake templates for real projects.

  4. Secrets stay outside

    The JWT signing key, the user-secrets ID and the ports are random for every solution. Secrets are written to %APPDATA%\Microsoft\UserSecrets\<id>\secrets.json, not into the solution folder; everything else is deterministic, so the same options produce the same files.

Templates/src/__Name__.Infrastructure/DependencyInjection.cs
public static IServiceCollection AddInfrastructure(…)
{
    services.TryAddSingleton(TimeProvider.System);
    services.AddPersistence();
//#if LocalAuth
    services.AddIdentityServices(configuration, environment);
//#else
    services.AddExternalAuthentication(configuration, environment);
//#endif
    return services;
}

Tested across every combination

Unit tests generate the plan for 3 databases × 2 sign-in modes × sample and tests on/off × 2 solution formats — 48 combinations — and check that no token or directive is left over, JSON and XML files are valid, the projects and solution file agree, and no secret ends up in any file.

Separate build tests generate five scenarios from scratch, fail on a single compiler warning and run the generated tests: sign-up and sign-in flows, lockout, refresh-token rotation and theft detection, two-factor, access to other users' records, security headers, rate limits and an algorithm-confusion attack. A generated SQLite API was also run end to end with migrations and Swagger UI.

PowerShell
dotnet test
$env:CAG_BUILD_TESTS = "1"; dotnet test

Setup

Windows 10/11 and the .NET 10 SDK, which also brings the Desktop Runtime the app needs.

  1. Download a release

    Unzip the archive from the Releases page and run CleanArchitectureGenerator.exe.

  2. Or run from source

    PowerShell
    dotnet run --project src/CleanArchitectureGenerator.App
  3. Build a single-file exe

    The output is publish\CleanArchitectureGenerator.exe; add -SelfContained for machines without .NET.

    PowerShell
    .\publish.ps1

Remembers your choices

The last used options are saved in %LOCALAPPDATA%\CleanArchitectureGenerator\settings.json.

Code layout

CleanArchitectureGenerator.Engine handles templates, solution generation and name validation; CleanArchitectureGenerator.App is the WinForms window; CleanArchitectureGenerator.Engine.Tests holds the xUnit tests.

Known limitations

More projects