Architecture Review
2 min read · Updated November 7, 2026
Table of Contents
1. The Final Structure

task-management-api/
├── build.gradle
├── docker-compose.yml
└── src/main/
├── java/com/example/taskapi/
│ ├── TaskManagementApiApplication.java
│ ├── config/OpenApiConfig.java
│ └── tasks/
│ ├── Task.java # JPA entity
│ ├── TaskRepository.java # talks to the database
│ ├── TaskService.java # the task rules
│ ├── TaskController.java # HTTP in, HTTP out
│ └── dto/
│ ├── CreateTaskRequest.java
│ ├── UpdateTaskRequest.java
│ └── TaskResponse.java
└── resources/
├── application.properties
└── db/migration/V1__create_task.sql
2. Following One Request
POST /tasks with {"title": "Ship it"}:
- Spring's embedded Tomcat receives the request and routes it to
TaskController.create. - The JSON body becomes a
CreateTaskRequest, and@Validchecks it (Part 5) — invalid input is a400before any of our code runs. - The controller calls
TaskService.create, which Spring injected (Part 4). - The service checks the title is free — a duplicate throws a
409(Part 7) — and saves aTaskthroughTaskRepository. - Hibernate writes the row to PostgreSQL, in a transaction (Part 6).
- The saved entity is mapped to a
TaskResponseand returned with status201.
Every layer has one job and only talks to the next one down.
3. What You Built, Layer by Layer
| Layer | Part | Rule you followed |
|---|---|---|
| Package-by-feature | 2 | A feature is a package; Spring finds beans by scanning |
| Controller | 3 | Thin: map the route, call the service |
| Service | 4 | Business rules; dependencies arrive by constructor |
| DTOs | 5 | Records at the boundary, @Valid on input |
| Repository + Flyway | 6 | An interface for queries; schema only via migrations |
| Errors | 7 | The right status code, thrown from the service |
| Docs | 8 | Generated from code, so it can't go stale |
4. What's Next
This crash course covers the ground you need for one working API, not the whole
framework. The reference app in examples/task-management-api/
is the finished version to compare against. Beyond it: authentication and
authorization with Spring Security, automated testing (unit and integration),
production concerns like rate limiting and configuration, containers and deployment,
and payments — everything a real application needs. The paid, live cohort builds a full
e-commerce API covering exactly that.
Official docs:
Was this chapter helpful?
You reached the end of this series
Well done. Pick what to learn next from the roadmap, or browse every series.
Get new tutorials
Join the Telegram channel to hear when a new chapter or series is published, or follow the feeds.
Buy Me a Coffee
Found this tutorial helpful? Consider buying me a coffee to support more free content!