Four-layer architecture separates an application’s responsibilities into Presentation, Application, Domain, and Infrastructure. It applies separation of concerns across the application, so each layer has a clearer job. section 4.2.3 section 4.10
Think of the layers as four different kinds of work:
- Presentation shows information and captures user input; it does not own the underlying business rules. section 4.2.3
- Application coordinates use cases, including calls to domain objects or services and transaction handling. section 4.2.3
- Domain holds the business rules, logic, and state, independently of presentation and storage. section 4.2.3
- Infrastructure handles external concerns such as database access, email, and third-party services. section 4.2.3
A layer may start as one broad bucket, but split it when it becomes a junk drawer, teams keep colliding in the same files, or no one can tell where a rule belongs. The goal is clearer responsibilities, not layers for their own sake. section 4.2.3
/my-project/src/
/api/ # Application Layer (part 1)
controllers.js
routes.js # Handles HTTP, validation, calls service
/app/ # Presentation layer
app.js # Main UI (React/Angular/Vue, etc) code
Index.html
/domain/ # Domain Layer
order.js
widget.js # Widget class with business logic
/lib/ # Infrastructure Layer (part 2)
emailClient.js # Other external services
/repositories/ # Infrastructure Layer (part 1)
widgetRepository.js # Database code
/services/ # Application Layer (part 2)
orderService.js # Orchestrates the “create order” use case
widgetService.jsThe project tree maps folders such as /app/, /services/, /domain/, and /repositories/ to the four layers. section 4.4.1
Folders are one way to represent layers; siblings within a layer should stay decoupled. For example, database and email components can both belong to Infrastructure without depending on each other—the Application Layer can coordinate their work. section 4.4.1

