A complete tutorial for building a REST API with Quarkus, covering a full identity/RBAC domain (users, roles, permissions, tokens) and an e-commerce domain (categories, products, customers, orders) as two independent data models behind one API.
This document is the complete specification of the project: it is meant to be followed step by step to implement each branch.
- What is Quarkus, and how does it compare to Spring Boot 4
- Build-time versus runtime: why Quarkus starts the way it does
- Dev Services: why there's no manual Testcontainers setup
- Permission checks with @PermissionsAllowed
- Configuration profiles, the Dev UI, and Continuous Testing
- Tech stack
- Data model
- Branching strategy
- Project structure
- Standard response format
- feature/core-architecture
- feature/auth
- feature/rbac
- feature/categories
- feature/products
- feature/customers
- feature/orders
- feature/native-build (bonus)
- feature/reactive-endpoints (bonus)
- Order of work
- Code conventions
- Concepts covered
- How to follow this tutorial
Quarkus is a Java framework created by Red Hat in 2019, built from the ground up for containers and Kubernetes rather than adapted to them afterward. It's marketed as "Supersonic Subatomic Java" - a nod to its two headline properties: very fast startup and a small memory footprint, achieved by doing at build time most of the work a typical framework does when the application actually boots. It reuses well-known Java standards under the hood - CDI for dependency injection, JAX-RS for REST, JPA for persistence, MicroProfile specifications for health/metrics/config - rather than inventing its own component model.
Spring Boot 4 and Quarkus solve the same class of problem (build a Java service quickly, without hand-wiring every bean) and will feel structurally familiar to anyone who knows the other: both have dependency injection, both have a curated-dependency-plus-auto-configuration mechanism (Spring Boot's starters, Quarkus's extensions), both have a live-reload dev mode, and both have an opinionated testing story. The differences are less about what each framework lets you build, and more about when the framework does its work and what that costs or saves you.
| Spring Boot 4 | Quarkus | |
|---|---|---|
| Dependency injection | Spring's own container, reflection-heavy, resolved mostly at runtime | CDI (via Quarkus's ArC implementation), resolved mostly at build time |
| How a dependency bundle works | A starter (spring-boot-starter-web) pulls in libraries; auto-configuration activates at runtime by scanning the classpath |
An extension (quarkus-rest) pulls in libraries; wiring is precomputed at build time by the extension's own build steps |
| Startup time (typical REST service) | Roughly 1–3 seconds on the JVM | Roughly 0.05–0.5 seconds on the JVM, and well under that natively |
| Memory footprint | Higher, largely from reflection metadata kept at runtime | Lower, since most of that metadata is resolved away at build time |
| Native compilation (GraalVM) | Possible (Spring Native effort continues under Spring Boot's own native support), but bolted onto a framework not originally designed around it | A first-class target from day one - the build-time model is what makes native compilation tractable in the first place |
| Local dev database | Manual (docker-compose up, or a manually configured Testcontainers extension) |
Dev Services: a database container is started automatically, with zero configuration, the moment a JDBC extension is present |
| Ecosystem size, maturity, hiring pool | Much larger - more Stack Overflow answers, more production case studies, more available developers | Smaller but growing fast, strongest specifically in the Kubernetes/serverless/cloud-native niche it was built for |
| Where each one tends to win | General-purpose enterprise applications, teams already deep in the Spring ecosystem, anything that leans on the sheer breadth of Spring's sub-projects (Batch, Integration, Modulith, Security's maturity) | Anything where startup time and memory genuinely matter at the deployment unit level: Kubernetes pods that scale to zero, AWS Lambda, CLI tools, edge/IoT workloads |
Nothing in this comparison makes one framework strictly better than the other - a Spring Boot 4 application deployed as a handful of long-running pods rarely notices a two-second startup cost, and a lot of what Quarkus optimizes for only pays off once cold-start time or memory-per-instance is actually on the critical path. This tutorial exists to teach Quarkus specifically, not to argue Spring Boot should be replaced - several of the concepts and conventions below (contract/implementation services, a generic ApiResponse<T>, Flyway-driven migrations) are deliberately the same ones a Spring Boot 4 project would use, so the parts that differ are the parts that are genuinely Quarkus-specific, not a wholesale reinvention of everything.
Most of what a typical framework figures out at application startup by scanning the classpath (which beans exist, which annotations apply, how dependency injection wires together), Quarkus figures out at build time, once, via its extension mechanism ("augmentation"). The result is bytecode that already knows its own wiring - nothing left to discover when the JVM actually boots.
This is why Quarkus applications start in milliseconds rather than seconds, why memory usage is low without any tuning, and why the same application can be compiled to a native executable (GraalVM) that starts even faster with a fraction of the memory - the build-time model is what makes native compilation possible at all, not just an optimization bolted onto a runtime-reflection framework afterward. feature/native-build in this tutorial demonstrates the difference directly, with real numbers.
Add quarkus-jdbc-postgresql to the project and run quarkus:dev or quarkus:test without configuring a datasource URL at all, and Quarkus notices there's no configured connection, starts a PostgreSQL container automatically (via Testcontainers under the hood), points the application at it, and tears it down when the process ends. This is Dev Services, and it's why this tutorial's test suite has no @Testcontainers/@Container boilerplate anywhere: the extension already does it, invisibly, for local development and for @QuarkusTest.
A real connection string is still configured for the packaged application (docker-compose.yml, production config) - Dev Services is a development/test convenience, not a replacement for a real deployment's database configuration.
Quarkus Security ships a declarative permission-check annotation, @PermissionsAllowed("CATEGORY:WRITE"), that goes further than @RolesAllowed: it checks whether the current SecurityIdentity holds a named permission, not just a role.
- A custom
SecurityIdentityAugmentorruns once per authenticated request, after the JWT is validated: it loads the user's roles and, through them, their permissions, and adds each one to theSecurityIdentityas aStringPermission @PermissionsAllowed("CATEGORY:WRITE")on a JAX-RS resource method then simply checks whether that permission is present on the identity - no database query at the point of the check, since the augmentor already resolved everything once for the request- This mirrors, in Quarkus's own idiom, the same underlying idea used elsewhere in this kind of system: permissions resolved once per authenticated context, then checked as a fast in-memory lookup rather than a query on every protected call
Three everyday Quarkus mechanics this tutorial relies on throughout, worth understanding once rather than re-explaining in every branch:
- Profiles:
application.propertieskeys can be prefixed%dev.,%test., or%prod.to scope a value to one profile (%prod.quarkus.datasource.jdbc.url=...), with an unprefixed key acting as the default for every profile that doesn't override it.mvn quarkus:devactivatesdev,mvn test/@QuarkusTestactivatetest, and a packaged jar activatesprodunless told otherwise - this is the direct equivalent of Spring'sapplication-{profile}.ymlfiles, just expressed as prefixes inside one file rather than several separate files. - The Dev UI (
http://localhost:8080/q/dev-uiwhilequarkus:devis running): a built-in web console listing every installed extension, letting you browse and edit configuration live, inspect Panache entities and run ad-hoc queries against them, view the endpoints exposed byquarkus-smallrye-openapi, and (oncefeature/rbacis in place) inspect the currentSecurityIdentityfor a request. Nothing here needs to be built by this project - it comes for free with every extension already in the tech stack. - Continuous Testing: pressing
rin the terminal runningmvn quarkus:devre-runs the test suite affected by the files just changed, on every save, without restarting the application. Combined with Dev Services (so the test database is already there), the practical effect is thatfeature/*branches in this tutorial can be developed with tests running continuously in the background rather than triggered by hand after each change.
| Component | Choice |
|---|---|
| Framework | Quarkus 3.33.x (LTS stream) |
| Language | Java 21 (LTS) |
| Build | Maven |
| REST layer | Quarkus REST (quarkus-rest, quarkus-rest-jackson) - the current name for what was previously branded "RESTEasy Reactive" |
| Database | PostgreSQL 16 (Dev Services in dev/test, Docker Compose for the packaged app) |
| ORM | Hibernate ORM with Panache, repository pattern (PanacheRepository<T>) |
| Migrations | Flyway (quarkus-flyway) |
| Validation | Hibernate Validator (quarkus-hibernate-validator) |
| Security | quarkus-smallrye-jwt (token issuance/validation), quarkus-security (@RolesAllowed, @PermissionsAllowed) |
| API documentation | quarkus-smallrye-openapi (Swagger UI) |
| Error handling | quarkus-http-problem (Quarkiverse, RFC 9457 Problem Details) |
| Monitoring | quarkus-smallrye-health (custom @Liveness/@Readiness checks) |
| Caching | quarkus-cache (@CacheResult/@CacheInvalidate) |
| Scheduling | quarkus-scheduler (@Scheduled) |
| Reactive programming (bonus) | SmallRye Mutiny (Uni/Multi), quarkus-hibernate-reactive-panache, quarkus-reactive-pg-client |
| Tests | quarkus-junit5, RestAssured, Dev Services (no manual Testcontainers setup) |
| CI/CD | GitHub Actions |
| Containerization | Docker, docker-compose; GraalVM native image (bonus branch) |
Two independent domains, one shared database, no cross-domain foreign key.
users (id, first_name, last_name, email, password, enabled, account_locked)
│ N──N (via role_user)
roles (id, role_name)
│ N──N (via role_permission)
permissions (id, resource, action)
activation_tokens (id, user_id, token, created_at, expires_at, validated_at)
blacklisted_tokens (id, user_id, token, jti, blacklisted_at, created_at, expires_at, validated_at)
password_reset_tokens (id, user_id, token, type, expiry_date)
audit_logs (id, actor_user_id, action, entity_type, entity_id, details, created_at)
categories (id, category_name)
│ 1
│
│ N
products (id, category_id, product_name, unit_price)
│ 1
│
│ N
orders (id, customer_id, product_id, quantity, total)
│ N
│
│ 1
customers (id, first_name, last_name, telephone, email, address)
| Branch | Role |
|---|---|
master |
Stable, production-ready code. No direct commits, only merges from develop. |
develop |
Integration branch. |
feature/core-architecture |
Project structure, Flyway/PostgreSQL configuration, exception mapping, Docker, CI. |
feature/auth |
User entity, registration, activation, login, JWT issuance, logout (blacklist), password reset. |
feature/rbac |
Roles/permissions, SecurityIdentityAugmentor, @PermissionsAllowed wiring, administration endpoints. |
feature/categories |
Category CRUD. |
feature/products |
Product CRUD, depends on categories. |
feature/customers |
Customer CRUD. |
feature/orders |
Order CRUD, depends on products/customers. |
feature/native-build |
Bonus: GraalVM native compilation, startup/memory comparison against JVM mode. |
quarkus-tutorial/
├── src/
│ ├── main/
│ │ ├── java/com/edgareldy/quarkustutorial/
│ │ │ ├── entity/
│ │ │ │ ├── User.java, Role.java, Permission.java
│ │ │ │ ├── ActivationToken.java, BlacklistedToken.java, PasswordResetToken.java
│ │ │ │ ├── Category.java, Product.java, Customer.java, Order.java
│ │ │ ├── repository/
│ │ │ │ ├── UserRepository.java, RoleRepository.java, PermissionRepository.java
│ │ │ │ ├── CategoryRepository.java, ProductRepository.java,
│ │ │ │ │ CustomerRepository.java, OrderRepository.java
│ │ │ │ └── (each: interface extending PanacheRepository<T>, plus a contract for custom query methods)
│ │ │ ├── dto/
│ │ │ │ ├── common/ (ApiResponse.java, PageResponse.java)
│ │ │ │ ├── auth/ (RegisterRequest, LoginRequest, AuthResponse, ...)
│ │ │ │ ├── rbac/ (RoleRequest, RoleResponse, PermissionRequest, PermissionResponse)
│ │ │ │ └── ecommerce/ (CategoryRequest/Response, ProductRequest/Response, ...)
│ │ │ ├── service/
│ │ │ │ ├── AuthService.java, RbacService.java, CategoryService.java, ProductService.java,
│ │ │ │ │ CustomerService.java, OrderService.java (contracts)
│ │ │ │ └── impl/ (one *ServiceImpl per interface, @ApplicationScoped)
│ │ │ ├── resource/
│ │ │ │ ├── AuthResource.java
│ │ │ │ ├── UserResource.java, RoleResource.java, PermissionResource.java
│ │ │ │ ├── CategoryResource.java, ProductResource.java,
│ │ │ │ │ CustomerResource.java, OrderResource.java
│ │ │ ├── security/
│ │ │ │ ├── JwtIssuer.java
│ │ │ │ └── PermissionSecurityIdentityAugmentor.java
│ │ │ └── exception/
│ │ │ ├── ResourceNotFoundException.java (extends HttpProblem)
│ │ │ └── BusinessRuleException.java (extends HttpProblem)
│ │ └── resources/
│ │ ├── application.properties
│ │ └── db/migration/
│ │ └── V1__init_schema.sql
│ └── test/
│ └── java/com/edgareldy/quarkustutorial/
│ ├── resource/ (@QuarkusTest + RestAssured)
│ ├── service/ (Mockito)
│ └── repository/ (@QuarkusTest, Dev Services-backed PostgreSQL, no manual container setup)
├── docker-compose.yml
├── Dockerfile.jvm
├── Dockerfile.native
├── .github/workflows/ci.yml
├── pom.xml
└── README.md
This project splits success and error responses the same way rather than forcing one shape to do both jobs:
Success: every 2xx response wraps its payload in a generic ApiResponse<T>.
public record ApiResponse<T>(
boolean success,
String message,
T data,
Instant timestamp
) {
public static <T> ApiResponse<T> success(T data, String message) {
return new ApiResponse<>(true, message, data, Instant.now());
}
}Errors: every non-2xx response is a Problem Details document (RFC 9457, which obsoletes RFC 7807 - same application/problem+json wire format), produced by the quarkus-http-problem Quarkiverse extension rather than a hand-written ExceptionMapper.
ResourceNotFoundExceptionandBusinessRuleExceptionextendio.quarkiverse.httpproblem.HttpProblemdirectly and are thrown normally from a service method -HttpProblemalready is aRuntimeException, built via its own builder (.withTitle(...),.withStatus(...),.withDetail(...)), so there's no separate DTO and no manual mapping step for these twoquarkus-http-problemships its own built-in mappers for the exceptions a project doesn't throw on purpose: Bean Validation failures become a Problem with aviolationsextension listing each field, and anything unmapped becomes a generic 500 Problem with implementation details stripped out before the response is sent - both without a single line of this project's own code- A response's
type/title/status/detailfields carry what anApiResponse<Void>used to carry inmessage, and any structured, field-level detail (like a validation error list) rides in the same document'sextensionsrather than a nesteddata
Example success response:
{
"success": true,
"message": "Product created successfully",
"data": { "id": 12, "productName": "Mechanical keyboard", "unitPrice": 79.99 },
"timestamp": "2026-09-18T10:15:30Z"
}Example error response (GET /api/v1/products/999 on a missing product):
{
"type": "https://api.example.com/problems/resource-not-found",
"title": "Resource Not Found",
"status": 404,
"detail": "Product 999 not found",
"instance": "/api/v1/products/999"
}- Generate the project (
mvn io.quarkus:quarkus-maven-plugin:create, or code.quarkus.io), Java 21, Maven - Extensions:
quarkus-rest,quarkus-rest-jackson,quarkus-hibernate-orm-panache,quarkus-jdbc-postgresql,quarkus-flyway,quarkus-hibernate-validator,quarkus-smallrye-jwt,quarkus-smallrye-jwt-build,quarkus-security,quarkus-smallrye-openapi,quarkus-smallrye-health,quarkus-cache,quarkus-scheduler,io.quarkiverse.httpproblem:quarkus-http-problem - A custom
@Readinesscheck (DatabaseHealthCheck, verifying a real connection can be obtained) alongside the default onequarkus-smallrye-healthalready provides, and a custom@Livenesscheck confirming the application isn't in a stuck state - both visible at/q/health, and individually at/q/health/ready//q/health/live - Test extensions:
quarkus-junit,quarkus-junit-mockito,rest-assured -
ApiResponse<T>,PageResponse<T> -
ResourceNotFoundException,BusinessRuleException(both extendingHttpProblem, built via its builder with the appropriate status/title); the problemtypeURI is a constant on each exception (this version ofquarkus-http-problemhas no type prefix option) and stack traces are never included in a response, in any profile - Flyway script
V1__init_schema.sql(all tables from both domains) -
application.properties: JWT signing key location, Flyway enabled,%test/%devprofiles left without a configured datasource (Dev Services provisions PostgreSQL automatically),%prodprofile with a real connection string -
docker-compose.yml(app + PostgreSQL, for the packaged application only - not used in dev/test),Dockerfile.jvm -
.github/workflows/ci.yml:mvn verify(Dev Services provisions PostgreSQL inside the CI runner automatically, same as locally)
| Method | URL | Description |
|---|---|---|
| POST | /api/v1/auth/register |
Register (creates a disabled user + activation token) |
| GET | /api/v1/auth/activate-account |
Activates a user account |
| POST | /api/v1/auth/login |
Returns a JWT |
| POST | /api/v1/auth/logout |
Blacklists the current JWT |
| GET | /api/v1/auth/me |
Current user profile |
| POST | /api/v1/auth/forgot-password |
Generates a password-reset token |
| POST | /api/v1/auth/reset-password |
Consumes the token, updates the password |
-
Userentity,ActivationToken,BlacklistedToken,PasswordResetToken -
UserRepository(PanacheRepository<User>) -
AuthService(interface) + implementation: registration, activation, login (password hashing/verification viaio.quarkus.elytron.security.common.BcryptUtil.bcryptHash/matches, fromquarkus-elytron-security-common, a Quarkus module declared explicitly in the pom becausequarkus-securitydoes not bring it in, not an external library), logout, forgot/reset password -
forgotPasswordreturns the exact same response - same status code, same body, roughly the same timing (no early return skipping the token-generation work) - whether or not the submitted email matches an existing account, so the endpoint can't be used to enumerate registered emails -
JwtIssuer: builds a signed JWT (io.smallrye.jwt.build.Jwt) with a uniquejticlaim, the user's id as subject -
@SecurityScheme(securitySchemeName = "jwt", type = SecuritySchemeType.HTTP, scheme = "bearer", bearerFormat = "JWT")declared once (e.g. onAuthResourceor a dedicatedOpenApiConfigclass) and referenced via@SecurityRequirement(name = "jwt")on protected resources, so Swagger UI's "Authorize" button actually works against@PermissionsAllowed-protected endpoints - A
ContainerRequestFilter(orSecurityIdentityAugmentor, same class introduced fully infeature/rbac) checking the incoming JWT'sjtiagainstBlacklistedTokenand rejecting the request if found -
AuthResource - Tests (
@QuarkusTest+ RestAssured): register → activate → login → access/me, logout followed by a rejected request with the same token, forgot/reset password flow
Full CRUD for users, roles, and permissions. Assignments always flow in one direction, never the other: permissions are assigned onto a role, never the reverse (a Permission is a fixed, catalog-like thing - CATEGORY:WRITE always means the same thing - a Role is what gets composed out of permissions); roles are assigned onto a user, never the reverse (a Role is the fixed thing here, a User is what's being granted access). Neither PermissionResource nor RoleResource ever gains an endpoint that manages the relationship from the other side.
| Method | URL | Description | Access |
|---|---|---|---|
| GET | /api/v1/users |
Paginated list | @PermissionsAllowed("USER:READ") |
| GET | /api/v1/users/{id} |
Detail, including assigned roles | @PermissionsAllowed("USER:READ") |
| PATCH | /api/v1/users/{id}/roles/{roleId} |
Assign a role to a user | @PermissionsAllowed("USER:WRITE") |
| DELETE | /api/v1/users/{id}/roles/{roleId} |
Remove a role from a user | @PermissionsAllowed("USER:WRITE") |
| GET | /api/v1/roles |
List, including permissions | @PermissionsAllowed("ROLE:READ") |
| POST | /api/v1/roles |
Create | @PermissionsAllowed("ROLE:WRITE") |
| PUT | /api/v1/roles/{id} |
Update (name only) | @PermissionsAllowed("ROLE:WRITE") |
| DELETE | /api/v1/roles/{id} |
Delete | @PermissionsAllowed("ROLE:WRITE") |
| POST | /api/v1/roles/{id}/permissions/{permissionId} |
Assign a permission to a role | @PermissionsAllowed("ROLE:WRITE") |
| DELETE | /api/v1/roles/{id}/permissions/{permissionId} |
Remove a permission from a role | @PermissionsAllowed("ROLE:WRITE") |
| GET | /api/v1/permissions |
List | @PermissionsAllowed("PERMISSION:READ") |
| POST | /api/v1/permissions |
Create | @PermissionsAllowed("PERMISSION:WRITE") |
| PUT | /api/v1/permissions/{id} |
Update | @PermissionsAllowed("PERMISSION:WRITE") |
| DELETE | /api/v1/permissions/{id} |
Delete | @PermissionsAllowed("PERMISSION:WRITE") |
-
Role,Permission,AuditLogentities,RoleRepository,PermissionRepository,AuditLogRepository -
RbacService(interface) + implementation:createRole/updateRole/deleteRole-deleteRolerejects if any user is still assigned this role (must be unassigned first)createPermission/updatePermission/deletePermission-deletePermissionrejects if any role still has this permission assignedassignPermissionToRole/removePermissionFromRole-removePermissionFromRolerejects removingROLE:WRITEfrom a role if doing so would leave zero users anywhere holding a role that grantsROLE:WRITEassignRoleToUser/removeRoleFromUser-removeRoleFromUserapplies the same last-admin check at the point of removal from a specific user, so a self-lockout is caught however it's attempted
-
AuditLogger: a singlelog(String action, String entityType, Long entityId, String details)method, called from every method above - every RBAC mutation is traceable (who did what, to what, when), not just the happy-path ones -
PermissionSecurityIdentityAugmentor(SecurityIdentityAugmentor): after JWT validation, loads the user's roles and permissions, adds eachRESOURCE:ACTIONstring to the identity as aStringPermission -
UserResource,RoleResource,PermissionResource, each method annotated@PermissionsAllowed("...")as listed above -UserResourceonly manages role assignment on existing users, it never creates a user directly (registration stays exclusivelyfeature/auth's job) - A seeding step (a
@Observes StartupEventmethod, or a Flyway data-migration): baseline permissions covering every resource/action this project defines, assigned to a seededADMINrole - without this, nobody could ever be grantedROLE:WRITE/PERMISSION:WRITEto create the first assignment (done as the Flyway migrationV2__seed_baseline_rbac.sql; an optionalAdminBootstrapstartup observer, active only whenapp.bootstrap-admin.emailandapp.bootstrap-admin.passwordare set and given dev-only defaults in%dev, creates the first administrator, since nobody can otherwise holdADMIN) -
ExpiredTokenCleanupJob(@Scheduled(cron = "0 0 3 * * ?"),quarkus-scheduler): daily job deletingBlacklistedToken/ActivationToken/PasswordResetTokenrows past their expiry, so both tables stay bounded over time - revocation and expiry checks never depend on the row still existing, so deleting it later is purely housekeeping, not a correctness concern - Tests: full CRUD on roles and permissions, the "still referenced" rejection on both
deleteRoleanddeletePermission, the augmentor granting the expected permissions for a multi-role user, a@PermissionsAllowed-protected endpoint accepting/rejecting correctly, and specifically the last-admin rejection triggered both ways (removing the role from the last user who has it, and removing the permission from the role that was their only source of it), plus an assertion that every mutation above produces a matchingAuditLogrow
| Method | URL | Description | Access |
|---|---|---|---|
| GET | /api/v1/categories |
Paginated list | @PermissionsAllowed("CATEGORY:READ") |
| GET | /api/v1/categories/{id} |
Detail | @PermissionsAllowed("CATEGORY:READ") |
| POST | /api/v1/categories |
Create | @PermissionsAllowed("CATEGORY:WRITE") |
| PUT | /api/v1/categories/{id} |
Update | @PermissionsAllowed("CATEGORY:WRITE") |
| DELETE | /api/v1/categories/{id} |
Delete | @PermissionsAllowed("CATEGORY:WRITE") |
-
Categoryentity, repository, contract/implementation service - Business rule: deleting a category that still has products is rejected (
BusinessRuleException→ 422) -
CategoryResource - Tests for every endpoint, including the rejection case and a permission-denied case
Depends on feature/categories existing, since every product references one.
| Method | URL | Description | Access |
|---|---|---|---|
| GET | /api/v1/products |
Paginated list, filterable by categoryId |
@PermissionsAllowed("PRODUCT:READ") |
| GET | /api/v1/products/{id} |
Detail | @PermissionsAllowed("PRODUCT:READ") |
| POST | /api/v1/products |
Create | @PermissionsAllowed("PRODUCT:WRITE") |
| PUT | /api/v1/products/{id} |
Update | @PermissionsAllowed("PRODUCT:WRITE") |
| DELETE | /api/v1/products/{id} |
Delete | @PermissionsAllowed("PRODUCT:WRITE") |
-
Productentity, repository, contract/implementation service -
ProductServiceImpl.findByIdannotated@CacheResult(cacheName = "product-cache");ProductServiceImpl.update/deleteannotated@CacheInvalidate(cacheName = "product-cache")on the same key (@CacheKeyon the id) - a product read hits Panache once and the cache for every subsequent read until it's changed, and every write explicitly clears its own entry rather than leaving a stale cached value silently served. The annotations sit on the implementation class, not on theProductServiceinterface: ArC does not apply interceptor bindings declared on an interface method -
ProductResource - Tests, including the category filter, a permission-denied case, and a cache test asserting a second read doesn't hit the repository while an update correctly invalidates the entry
| Method | URL | Description | Access |
|---|---|---|---|
| GET | /api/v1/customers |
Paginated list | @PermissionsAllowed("CUSTOMER:READ") |
| GET | /api/v1/customers/{id} |
Detail | @PermissionsAllowed("CUSTOMER:READ") |
| POST | /api/v1/customers |
Create | @PermissionsAllowed("CUSTOMER:WRITE") |
| PUT | /api/v1/customers/{id} |
Update | @PermissionsAllowed("CUSTOMER:WRITE") |
| DELETE | /api/v1/customers/{id} |
Delete | @PermissionsAllowed("CUSTOMER:WRITE") |
-
Customerentity, repository, contract/implementation service -
CustomerResource - Tests
| Method | URL | Description | Access |
|---|---|---|---|
| GET | /api/v1/orders |
Paginated list, filterable by customerId/productId |
@PermissionsAllowed("ORDER:READ") |
| GET | /api/v1/orders/{id} |
Detail | @PermissionsAllowed("ORDER:READ") |
| POST | /api/v1/orders |
Create (computes total) |
@PermissionsAllowed("ORDER:WRITE") |
-
Orderentity, repository, contract/implementation service: computestotal = quantity * product.unitPrice -
OrderResource - Tests, including the total computation
-
Dockerfile.native(multi-stage: GraalVM builder image, minimal runtime image) - Build a native executable locally (
mvn package -Dnative -Dquarkus.native.container-build=true, container build so a local GraalVM install isn't required). Built and run by the CI job, since the local Docker VM (1.4 GiB) is too small for it, seedocs/native-build.md - Measure and document, in this branch's own notes (
docs/native-build.md): startup time and resident memory of the JVM-mode application versus the native executable, under the same request load -
.github/workflows/ci.ymlextended with a native build verification job (can be slower/separate from the main test job)
Quarkus lets imperative (blocking, Panache-based) and reactive (Mutiny-based) code coexist in the same application, on the same underlying Vert.x event loop - unlike stacks where the two styles require committing to an entirely separate framework variant for the whole application. This branch adds exactly one reactive slice to an otherwise fully imperative project, to demonstrate that coexistence concretely rather than as a claim.
| Method | URL | Description |
|---|---|---|
| GET | /api/v1/orders/stream |
Server-Sent Events stream of newly created orders |
-
quarkus-hibernate-reactive-panache,quarkus-reactive-pg-clientadded alongside the existing blockingquarkus-jdbc-postgresqlstack - both drivers coexist against the same PostgreSQL database, Dev Services provisions the container either way -
OrderPanacheRepositoryReactive(PanacheRepositoryBasefrom the reactive variant), used only by the streaming endpoint - the rest offeature/orders' blocking repository and service stay untouched - A CDI event or a
Multi-backed broadcast:OrderServiceImpl.create(blocking) publishes a plain CDI event after a successful commit; a reactive listener adapts that into aMulti<Order>that the streaming endpoint subscribes to -
OrderResource.stream(): returnsMulti<Order>with@Produces(MediaType.SERVER_SENT_EVENTS)- no manual thread management, Mutiny's operators handle backpressure - Tests: a
Multiassertion subscriber (AssertSubscriber) verifying an event arrives on the stream after aPOST /api/v1/orders, run without blocking the test thread
feature/core-architecture→ Pull Request todevelopfeature/auth(depends oncore-architecture) → Pull Request todevelopfeature/rbac(depends onauth) → Pull Request todevelopfeature/categories(depends onrbac) → Pull Request todevelopfeature/products(depends oncategories) → Pull Request todevelopfeature/customers(depends onrbac) → Pull Request todevelopfeature/orders(depends onproducts,customers) → Pull Request todevelopfeature/native-build(bonus, depends on everything above) → Pull Request todevelopfeature/reactive-endpoints(bonus, depends onfeature/orders, independent offeature/native-build) → Pull Request todevelopdevelop→master
- Root package:
com.edgareldy.quarkustutorial - Contract/implementation services: interface at the root of
service/, implementation inservice/impl/, annotated@ApplicationScoped - Repositories extend
PanacheRepository<T>directly for standard operations; a custom interface is added only when a repository needs a query beyond what Panache already provides - Every endpoint returns an
ApiResponse<T>(orApiResponse<PageResponse<T>>for lists) - Permission checks are always declarative (
@PermissionsAllowed("RESOURCE:ACTION")on the resource method), never a manualifinside a method body - No JAX-RS resource method contains business logic - it validates via Bean Validation annotations on the request DTO, delegates to a service, and maps the result to an
ApiResponse<T> - Test naming convention: every test method is named
_NN_Should<Outcome>_When<Condition>, whereNNis a two-digit sequence number with a leading zero, restarting at_01_in each test class and following the order of the methods in the source (e.g._01_ShouldReturnCategory_WhenCategoryExists,_02_ShouldReturnEmpty_WhenCategoryDoesNotExist). This applies to every kind of test (unit, repository, resource, integration, parameterized). No other style (shouldX(),testX(),givenX_whenY_thenZ()) is accepted.
- Quarkus's build-time augmentation model, and why it enables both fast startup and native compilation
- Configuration profiles (
%dev/%test/%prod), the Dev UI, and Continuous Testing - Dev Services: automatic, zero-configuration database provisioning for development and tests
- Quarkus REST (JAX-RS) resources, request/response mapping, Bean Validation
- Hibernate ORM with Panache, repository pattern
- JWT issuance and validation with SmallRye JWT
- Token revocation via a blacklist checked on every request
- Declarative permission checks with
@PermissionsAllowed, backed by a customSecurityIdentityAugmentor - RFC 9457 Problem Details error responses (
quarkus-http-problem), kept separate from theApiResponse<T>success envelope - Generic
ApiResponse<T>DTO, contract/implementation pattern - Custom health checks (
@Liveness/@Readiness) alongside MicroProfile Health's defaults - Method-level caching (
@CacheResult/@CacheInvalidate) and explicit invalidation on write - Scheduled background jobs (
@Scheduled) for housekeeping tasks - Testing with
@QuarkusTestand RestAssured, without manual Testcontainers setup - GraalVM native compilation, and measuring its actual impact on startup/memory (bonus)
- Reactive programming with Mutiny (
Uni/Multi), Server-Sent Events, and imperative/reactive coexistence in one application (bonus) - Containerization (Docker, docker-compose)
- Continuous integration (GitHub Actions)
- Clone the repository : https://github.com/EdgarEldy/quarkus-tutorial.git and check out
develop - Follow the branches in order:
feature/core-architecture→feature/auth→feature/rbac→feature/categories→feature/products→feature/customers→feature/orders→ (bonus)feature/native-build→ (bonus)feature/reactive-endpoints - Run in dev mode:
mvn quarkus:dev(Dev Services starts PostgreSQL automatically, nodocker-compose upneeded for this) - open the Dev UI athttp://localhost:8080/q/dev-uialongside it, and pressrin the terminal to trigger Continuous Testing - Browse Swagger UI at
http://localhost:8080/q/swagger-ui - To run the packaged application instead:
docker-compose up