Defines software architecture, separates physical tiers from logical layers, and explains the presentation, business logic and data access layers of a classic three-layer .NET application.
Software architecture is the set of significant decisions about a system's structure β its parts, their responsibilities, how they depend on each other β that are expensive to change later.
The trade-off: more tiers give independent scaling and isolation, but every tier boundary costs a network hop, serialisation and a new way to fail.
"Software architecture is the set of decisions about a system that are hard to reverse: how it is split into parts, which part is responsible for what, which way the dependencies point, and which quality attributes β modifiability, performance, availability, cost β the structure is optimised for. Code inside a method can be rewritten in an afternoon; the shape of the system can't, so that's what we call architecture.
Two words get mixed up constantly: layers and tiers. A layer is logical β it's how I organise code, for example a
Webproject, aBusinessproject and aDataproject. A tier is physical β it's where code runs: the browser, the ASP.NET Core process in an Azure App Service, and Azure SQL. A classic .NET app has three layers deployed in one web tier plus a database tier. Its presentation layer β controllers or Razor Pages β handles HTTP and calls the business layer; the business layer holds the rules and calls the data access layer; the data access layer uses EF Core or Dapper to talk to SQL Server. Dependencies only point downwards.The mistake I see is treating layers as tiers: putting the business layer behind its own internal HTTP API 'for scalability', which doubles latency and adds a failure mode without a real scaling need. I keep layers in one process until a measured requirement forces a physical split. Layers are about organising change; tiers are about deployment, scale and security β choose each for its own reason."
| Layer (logical) | Tier (physical) | |
|---|---|---|
| What it is | A group of code with one responsibility | A process, container or machine |
| In .NET | A folder or project (Shop.Web, Shop.Business, Shop.Data) |
An App Service, a container, Azure SQL |
| Crossing it costs | A method call (nanoseconds) | A network call (β0.5β5 ms in one Azure region), serialisation, retries |
| Main reason to add one | Separate concerns, make change easier | Scale, isolate, secure or deploy independently |
| Layer | Responsibility | Typical .NET pieces |
|---|---|---|
| Presentation | HTTP, input validation, view models, status codes | Controllers, Minimal API endpoints, Razor Pages |
| Business logic | Rules, calculations, workflows | Service classes, domain classes |
| Data access | Queries and persistence | DbContext, repositories, Dapper queries |
| Layout | Example | When it fits |
|---|---|---|
| 2-tier | Desktop WinForms app talking straight to SQL Server | Internal tools, legacy |
| 3-tier | Browser β ASP.NET Core β Azure SQL | Most web apps |
| N-tier | Browser β API gateway β several services β databases and caches | Large scale or strict isolation needs |
| Use more layers when⦠| Avoid extra tiers when⦠|
|---|---|
| Rules are shared by several entry points (API, background job) | There's no measured scaling or security need |
| Several people work on different concerns | One team deploys everything together |
| You want to test business rules without HTTP or SQL | Latency budgets are tight (every hop adds milliseconds) |
An internal claims portal had its business layer deployed as a separate internal Web API "so it could scale". Each page made 6β10 calls across that boundary, adding about 40 ms per page. Folding the two tiers back into one App Service (keeping the three logical layers) cut p95 page time from 310 ms to 190 ms and removed a whole class of timeout errors.
Checks that the candidate can define architecture in terms of hard-to-change decisions and precisely distinguish logical layers from physical tiers.
Green flags
Red flags
A useful test: how expensive is it to change? Renaming a variable is cheap. Moving from one database to two, or from one deployable to ten, touches every team and every pipeline. Architecture covers:
+---------------------------+
| Presentation | controllers, endpoints, views
+---------------------------+
|
v
+---------------------------+
| Business logic | services, domain rules
+---------------------------+
|
v
+---------------------------+
| Data access | DbContext, queries
+---------------------------+
|
v
[ SQL Server ]
Each layer only calls the layer below. In .NET you usually enforce this with project references: Shop.Web references Shop.Business, which references Shop.Data. The compiler then refuses an upward reference, because it would create a circular project reference.
[ Browser ] --HTTPS--> [ App Service: Web + Business + Data layers ] --TDS--> [ Azure SQL ]
tier 1 tier 2 tier 3
All three layers live in tier 2 here. Crossing a tier means:
That is why tier boundaries are chosen for scale, isolation or security (for example, keeping the database in a private subnet), not for code organisation.
For GET /orders/42 in a three-layer ASP.NET Core app:
OrdersController.Get.IOrderService.GetAsync(42).Steps 2β4 are in-process method calls; only step 4's database call crosses a tier.
The three-layer model puts the database at the bottom, so business logic depends on data access. That works for CRUD apps but makes rules hard to test without a database, and tends to produce "database-centric" designs. Clean, Onion and Hexagonal architectures invert that dependency β the next questions in this topic.
dotnet new webapi, two classlibs), add references Web β Business β Data, then try adding a Data β Web reference and read the error.Stopwatch or Application Insights dependency tracking.A minimal three-layer slice: each layer is a separate project, and dependencies only point downwards.
// Shop.Data/OrderRepository.cs β data access layer
namespace Shop.Data;
public sealed record OrderRow(int Id, string CustomerEmail, decimal Total);
public interface IOrderRepository
{
Task<OrderRow?> FindAsync(int id, CancellationToken ct);
}
public sealed class OrderRepository(ShopDbContext db) : IOrderRepository
{
public Task<OrderRow?> FindAsync(int id, CancellationToken ct) =>
db.Orders
.Where(o => o.Id == id)
.Select(o => new OrderRow(o.Id, o.CustomerEmail, o.Total))
.SingleOrDefaultAsync(ct);
}
// Shop.Business/OrderService.cs β business logic layer (references Shop.Data)
namespace Shop.Business;
using Shop.Data;
public sealed record OrderSummary(int Id, decimal Total, bool QualifiesForFreeShipping);
public sealed class OrderService(IOrderRepository orders)
{
private const decimal FreeShippingThreshold = 100m; // a business rule lives here, not in the controller
public async Task<OrderSummary?> GetAsync(int id, CancellationToken ct)
{
var row = await orders.FindAsync(id, ct);
return row is null
? null
: new OrderSummary(row.Id, row.Total, row.Total >= FreeShippingThreshold);
}
}
// Shop.Web/Program.cs β presentation layer (references Shop.Business and, for registration only, Shop.Data)
using Microsoft.EntityFrameworkCore;
using Shop.Business;
using Shop.Data;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddDbContext<ShopDbContext>(o =>
o.UseSqlServer(builder.Configuration.GetConnectionString("Shop")));
builder.Services.AddScoped<IOrderRepository, OrderRepository>();
builder.Services.AddScoped<OrderService>();
var app = builder.Build();
// The endpoint only translates HTTP to a service call and back.
app.MapGet("/orders/{id:int}", async (int id, OrderService service, CancellationToken ct) =>
await service.GetAsync(id, ct) is { } order ? Results.Ok(order) : Results.NotFound());
app.Run();
DbContext directly "just this once". Why it is wrong: it bypasses the rules and couples the UI to the schema. Instead: go through the business layer, or make the exception explicit and documented.A senior answer separates logical from physical decisions and justifies each with a quality attribute. Logical layering is cheap and almost always worth it: it gives modularity, lets you test rules without HTTP or SQL, and keeps change local. Physical tiers are expensive and must be earned by a measured need β Application Insights showing one part needs different scaling, a security boundary, or a different release cadence β not by the assumption that "more tiers scale better". Most systems I see that are slow or fragile have too many tiers, not too few.
Every extra tier costs in three currencies: latency (0.5β2 ms per in-region hop, multiplied by chatty calls), money and operations (another App Service plan, pipeline, set of alerts and certificates), and complexity (timeouts, retries, partial failure, versioned contracts). The one place tiers clearly pay off early is security: keeping Azure SQL on a private endpoint reachable only from the web tier's managed identity, which also supports ACSC Essential Eight expectations around restricting access.
| Option | When it fits | Cost | When not to |
|---|---|---|---|
| Layers in one process | Almost every web app and API | Discipline to keep dependencies pointing one way | Never really "not" β even a script benefits from separation |
| Extra physical tier | Different scaling profile, security isolation, separate team | Network latency, serialisation, distributed failures, more pipelines and hosting cost | When one team deploys it all together and load fits one tier |
Measure before splitting: dependency timings, CPU profiles and cost per environment tell you whether one part actually needs to stand alone.
Over-engineering is complexity that today's requirements do not justify. I detect it through symptoms with numbers behind them: a one-field change touching many files, interfaces with one implementation, configuration options nobody sets, patterns like CQRS or event sourcing without the problems they solve, and microservices that always deploy together. I reverse it incrementally rather than with a rewrite: inline single-use abstractions, merge layers that only pass data through, consolidate services that share a release cycle, and delete unused options, each step behind tests. I also address why it happened, because otherwise it grows back.
Evolutionary architecture (Ford, Parsons and Kua) is architecture designed to support guided, incremental change, rather than a fixed upfront design. The key tool is fitness functions: automated checks that protect the characteristics you care about, such as dependency rules (architecture tests), latency budgets, or startup time, run in CI or production. Around that, I keep boundaries modular (often a modular monolith first), make decisions reversible where possible and defer irreversible ones to the last responsible moment, record decisions in ADRs, and rely on continuous delivery, feature flags and observability so each change is small and safe.
The core rule: a layer may only depend on layers below it β presentation β business β data β never upwards and never in a cycle.
IQueryable, EF entities, SqlException in controllers.The trade-off: layering is simple and familiar, but every feature cuts across all layers and the domain ends up depending on the database.
Last updated 23 Nov 2026.