Sefism is free for learners. We are here to help you grow, one step at a time.Join for free
Sefism.

Project structure · Backend

ASP.NET Core Web API project structure

Opens with credits

A REST API in C# on .NET 10 with minimal API endpoints grouped by feature, EF Core and PostgreSQL, JWT auth with policies, xUnit and Testcontainers tests, and everything production needs: health checks, OpenTelemetry, rate limits, versioning, caching and a CI pipeline. It shows the popular clean architecture split (Api, Application, Domain, Infrastructure) honestly, and at Expert grows into Aspire, a modular monolith and enforced boundaries.

Curated by Tauseef FayyazIntermediate218 files and folders.NET 10 (LTS), ASP.NET Core 10, EF Core 10Checked October 2026
Explore the filesPick any file to see what it is, why it exists and when you add it.

How it grows

Each stage opens the explorer there

  1. 1Day 1What the scaffold and your first hour give you16 files and folders
  2. 2GrowingWhat a real app with features and tests adds+94 files and folders
  3. ProductionWhat running it for real users adds+44 files and foldersOpens with credits
  4. ExpertWhat a team needs to keep it healthy for years+64 files and foldersOpens with credits

How it is organised

  • One solution, with production code in src/ and tests in tests/. The .slnx file is how the IDE, `dotnet build` and CI see the whole project, and Directory.Build.props, Directory.Packages.props and global.json keep every project on the same settings, package versions and SDK.
  • Keep Program.cs a short list of registrations and endpoint mappings. Each feature maps its own endpoints from its own file as a route group, and each concern (auth, rate limiting, observability) registers itself from an extension method.
  • Clean architecture (Api, Application, Domain, Infrastructure) keeps the business rules free of web and database code. It pays off in large, long-lived codebases with several teams; for a small API it is ceremony, and one Api project with a folder per feature is the better start. Inside every layer, group by feature (Orders, Products), never by file type.
  • Dependencies point inwards: Api references Application and Infrastructure, Infrastructure references Application, Application references Domain, and Domain references nothing. At Expert an architecture test fails the build when someone breaks that rule.
  • Secure by default: a fallback authorization policy requires a signed-in user on every endpoint, so a forgotten attribute means 401, not an open endpoint. Anonymous routes opt out on purpose.
  • The database schema is owned by EF Core migrations that are committed, reviewed and applied by the pipeline as a separate step, never created on the fly in production.
  • Configuration layers from appsettings.json to appsettings.{Environment}.json to user-secrets to environment variables, bound to options classes that are validated at startup. Secrets live in user-secrets locally and in Key Vault in production.
  • Errors leave the API as RFC 9457 problem details from IExceptionHandler classes, never as stack traces, and every response carries a trace id that links it to the logs.
  • Tests grow with the app: fast xUnit unit tests for the rules, WebApplicationFactory integration tests against a real PostgreSQL in Testcontainers, then architecture, contract, load and mutation tests once the codebase and team are big enough to need them.

At the top of the project

Open one in the explorer for the full story

Learn more on Sefism

Roadmaps, cheat sheets and projects that go with ASP.NET Core Web API.

See 10 more
Checked against 16 official sources, October 2026. If something has changed, the docs win.Show sources

Picked from the other libraries by shared topics.

Work with me

Stuck on something specific?

Writing only gets you so far. If you want an answer to your situation rather than the general case, book a session and we will work through it together. Sessions are free for approved Sefism members, and a few slots open each week.

  • 1:1 Mentorship
  • Fresh Graduate Mentorship
  • Career Guidance

Brand deals, promos and partnerships: tauseeffayyaz@gmail.com