What is layered architecture? Package by layer or by feature?
Short answer
Layered architecture splits the app by technical responsibility: controller → service → repository, and each layer calls only the one right below. At the controller boundary, data in and out is a DTO, not a JPA entity.
3 points to say:
- Controller → service → repository; layers are closed, no skipping (a controller never calls a repository directly).
- At the controller boundary use separate DTOs for request and response, never return JPA entities.
- Turn off open-in-view; prefer package-by-feature over package-by-layer.
Keep reading the deep dive
Create a free account to read the full explanation and follow-up questions, mark questions as studied and review them on a schedule.