This project uses Quarkus, the Supersonic Subatomic Java Framework.
If you want to learn more about Quarkus, please visit its website: https://quarkus.io/.
library-catalog/
├── .mvn/ # Maven wrapper configuration
├── src/
│ ├── main/
│ │ ├── docker/ # Dockerfiles (JVM, native, legacy-jar, native-micro)
│ │ ├── java/org/acme/library/
│ │ │ ├── config/ # Dev data seeding (DevDataSeeder)
│ │ │ ├── dto/ # Request/response DTOs (Book, User, Checkout, ApiToken, etc.)
│ │ │ ├── entity/ # JPA entities (Book, User, Checkout, ApiToken, UserRole)
│ │ │ ├── exception/ # Global exception mapping (GlobalExceptionMapper)
│ │ │ ├── filter/ # HTTP filters (RateLimitFilter, RequestLoggingFilter)
│ │ │ ├── openapi/ # OpenAPI definition (LibraryOpenAPIDefinition)
│ │ │ ├── resource/ # REST endpoints (Auth, Book, Checkout, User)
│ │ │ ├── security/ # Auth (API key, Basic, password hashing)
│ │ │ └── service/ # Business logic (ApiToken, Book, Checkout, User)
│ │ └── resources/
│ │ ├── META-INF/ # OpenAPI YAML spec
│ │ ├── application*.properties
│ │ └── import.sql # Initial DB data (dev)
│ └── test/
│ ├── java/.../resource/ # REST resource tests (Auth, Book)
│ ├── java/.../security/ # PasswordUtil tests
│ ├── java/.../service/ # UserService tests
│ └── resources/ # Test application config
├── docker-compose.yml # App + PostgreSQL
├── pom.xml # Maven / Quarkus dependencies
├── mvnw, mvnw.cmd # Maven wrapper scripts
└── README.md
| Layer | Purpose |
|---|---|
| resource | REST API controllers (auth, books, checkouts, users). |
| service | Business logic and persistence. |
| entity | JPA entities for PostgreSQL. |
| dto | API request/response models. |
| security | API key and Basic auth, password hashing. |
| filter | Cross-cutting (rate limiting, request logging). |
| exception | Centralized error handling and response shape. |
Build the app, then start the application and PostgreSQL:
./mvnw package
docker compose up --buildThe API will be at http://localhost:8080. The database runs in a container and data is stored in a Docker volume (postgres_data).
- OpenAPI (JSON): http://localhost:8080/q/openapi — machine-readable API spec.
- Swagger UI: http://localhost:8080/q/swagger-ui — interactive docs (available in dev/test; set
quarkus.swagger-ui.always-include=truefor production).
Use Authorize in Swagger UI to send credentials:
- API Key: header
X-API-Keywith a token fromPOST /users/me/api-tokens(after logging in with Basic). - Basic: email + password for the registered user.
To run in the background: docker compose up -d --build.
You can run your application in dev mode that enables live coding using:
./mvnw quarkus:devNOTE: Quarkus now ships with a Dev UI, which is available in dev mode only at http://localhost:8080/q/dev/.
The application can be packaged using:
./mvnw packageIt produces the quarkus-run.jar file in the target/quarkus-app/ directory.
Be aware that it’s not an über-jar as the dependencies are copied into the target/quarkus-app/lib/ directory.
The application is now runnable using java -jar target/quarkus-app/quarkus-run.jar.
If you want to build an über-jar, execute the following command:
./mvnw package -Dquarkus.package.jar.type=uber-jarThe application, packaged as an über-jar, is now runnable using java -jar target/*-runner.jar.
You can create a native executable using:
./mvnw package -DnativeOr, if you don't have GraalVM installed, you can run the native executable build in a container using:
./mvnw package -Dnative -Dquarkus.native.container-build=trueYou can then execute your native executable with: ./target/library-catalog-1.0.0-SNAPSHOT-runner
If you want to learn more about building native executables, please consult https://quarkus.io/guides/maven-tooling.
- REST (guide): A Jakarta REST implementation utilizing build time processing and Vert.x. This extension is not compatible with the quarkus-resteasy extension, or any of the extensions that depend on it.
- REST Jackson (guide): Jackson serialization support for Quarkus REST. This extension is not compatible with the quarkus-resteasy extension, or any of the extensions that depend on it
- Hibernate ORM with Panache (guide): Simplify your persistence code for Hibernate ORM via the active record or the repository pattern
- JDBC Driver - PostgreSQL (guide): Connect to the PostgreSQL database via JDBC
Create your first JPA entity
Related Hibernate with Panache section...
Easily start your REST Web Services