Skip to content

samuelmoorec/library-catalog

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

library-catalog

This project uses Quarkus, the Supersonic Subatomic Java Framework.

If you want to learn more about Quarkus, please visit its website: https://quarkus.io/.

Project structure

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.

Running with Docker Compose

Build the app, then start the application and PostgreSQL:

./mvnw package
docker compose up --build

The API will be at http://localhost:8080. The database runs in a container and data is stored in a Docker volume (postgres_data).

API documentation

Use Authorize in Swagger UI to send credentials:

  • API Key: header X-API-Key with a token from POST /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.

Running the application in dev mode

You can run your application in dev mode that enables live coding using:

./mvnw quarkus:dev

NOTE: Quarkus now ships with a Dev UI, which is available in dev mode only at http://localhost:8080/q/dev/.

Packaging and running the application

The application can be packaged using:

./mvnw package

It 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-jar

The application, packaged as an über-jar, is now runnable using java -jar target/*-runner.jar.

Creating a native executable

You can create a native executable using:

./mvnw package -Dnative

Or, 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=true

You 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.

Related Guides

  • 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

Provided Code

Hibernate ORM

Create your first JPA entity

Related guide section...

Related Hibernate with Panache section...

REST

Easily start your REST Web Services

Related guide section...

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages