Bite-sized, standalone interview questions and answers for Software Architecture. Read 5-10 per sitting. Each answer is 2-4 sentences max and stands on its own.

76 questions shown. Filter by keyword or difficulty below.

Topic: Layered (N-tier) architecture (Order 1)

Domain defines an interface like IOrderRepository, and Infrastructure implements it. The compile-time reference points inward (Infrastructure → Domain) even though the runtime call flows outward (Domain → persistence), decoupling business logic from infrastructure technology.

The textbook diagram shows every layer depending strictly on the layer below it. In reality, Domain depends on nothing — it declares interfaces — and Infrastructure depends inward on Domain. The compiled dependency direction is opposite to the conceptual layer ordering at the Domain/Infrastructure seam.

The whole point of layering collapses: business logic becomes coupled to Entity Framework or RabbitMQ, making it impossible to unit-test without a real database and impossible to swap persistence technology without touching core logic.

The interface lives in the Domain project (the consumer of the capability), not Infrastructure (the provider). This placement is what forces the compiled dependency arrow to point inward — Infrastructure must reference Domain to implement the contract, not the reverse.

Treating “layered” as meaning every layer’s compiled reference points physically downward. The real rule is that the core defines the contracts it needs; infrastructure implements them. Strict downward references break the moment Domain needs a capability only the edge can provide.

Topic: Hexagonal architecture (ports & adapters) (Order 2)

A port is an interface declared inside the domain project — the domain’s own vocabulary for a capability it needs (e.g., IOrderRepository). An adapter is the infrastructure-layer implementation that satisfies a port using a specific technology (e.g., EF Core + Postgres).

An interface alone doesn’t prevent a domain project from also referencing the database package. The real enforcement is project-level: the domain’s .csproj has zero package or project references to EF Core or the infrastructure project, so using Microsoft.EntityFrameworkCore; fails to compile.

The build fails immediately — the assembly isn’t referenced from that project at all. This is the core enforcement mechanism: the violation is impossible to compile, not merely easy to spot in review.

A test project referencing only Domain inherits that project’s restricted reference list. Tests can construct domain objects and call methods with no database, no EF Core, and no infrastructure reference — the project graph makes touching the database structurally impossible.

People treat “the domain depends on an interface, not a concrete class” as sufficient. But an interface can live in a project that also references infrastructure packages — a future edit could import infrastructure types directly into domain code. The stronger version requires a genuine assembly boundary with a restricted reference list.

When you need to swap database providers or test domain logic without any infrastructure spinning up — and you want the compiler to enforce that boundary, not rely on discipline or code review.

Topic: Clean architecture (Order 3)

Application needs DbSet<T> to describe a provider-agnostic persistence shape inside its own IApplicationDbContext interface. The base EF Core package provides that abstraction; the actual database provider packages (Npgsql, SQLite) are referenced only from Infrastructure.

Instead of horizontal folders (Commands/, Handlers/, Validators/) shared by every use case, clean architecture uses vertical slices — each use case (e.g., CreateTodoItem) gets its own folder containing its command, handler, and validator together.

No specific database engine package (Npgsql, SQLite, SQL Server) exists outside Infrastructure. Application carries a narrow ORM-shaped dependency (base EF Core for DbSet<T>), but zero provider packages. Swapping PostgreSQL for SQL Server touches only Infrastructure’s .csproj and its concrete DbContext.