Skip to main content

Employee Layered Architecture

Summary

The service separates presentation, application coordination, domain behavior, infrastructure adapters, persistence, and host configuration while keeping them in one executable project.

Audience

  • Backend developers
  • QA engineers and solution architects

Purpose

Use this dependency model to place new code without reversing domain boundaries or coupling application logic to infrastructure details.

Layer responsibilities

LayerConfirmed responsibility
PresentationBind requests, invoke application services or CQRS handlers, and translate results. Detailed routes are deferred.
ApplicationDefine commands, queries, handlers, DTOs, mappings, validation, search contracts, audit/unit-of-work ports, and use-case coordination.
DomainDefine aggregate consistency boundaries, entities, value objects, invariants, domain events, and repository ports.
InfrastructureImplement repositories, tenant context, search, audit, unit of work, outbox store, and EF Core integration.
PersistenceImplemented inside Infrastructure through the context, repositories, migrations, no-tracking queries, and transactional save behavior.
ConfigurationImplemented in the composition root and host configuration; supplies persistence, token validation, messaging, observability, startup, and health categories.

Layer dependencies

Domain code does not reference presentation, infrastructure, EF Core, or shared integration contracts. The web project physically contains every layer, so the dependency rule is a namespace/source convention rather than separate project enforcement.

Source References

  • microservices/src/employee-service/Api/
  • microservices/src/employee-service/Application/
  • microservices/src/employee-service/Domain/
  • microservices/src/employee-service/Infrastructure/
  • microservices/src/employee-service/Program.cs

See Also

Keywords

  • Dependency direction
  • Layer responsibilities
  • Separation of concerns

Revision Information

  • Status: Draft
  • Last reviewed: 2026-07-15
  • Review cycle: Quarterly