./mvnw clean packagewill compile the app, run the unit tests and produce an uber-jar in the target folder.
The following command will run the app from the compiled sources. You'll need a running postgres db as described in the next section.
./mvnw spring-boot:runThe following command will run a version of the application with a postgres db and a redis cache as a testcontainer. It will have sample books in the db.
./mvnw spring-boot:test-runYou will need running postgres and redis instances that you can spin up with docker-compose.
docker compose -f docker/docker-compose.yml up -dYou may stop the instance once you're finished.
docker compose -f docker/docker-compose.yml downOnce postgres is up, run the app itself:
java -jar target/books-api-0.0.1-SNAPSHOT.jarThe rest api services manages books using a Redis cache for search results. The app keeps a single copy of a book with the same title and author. It handles the add and update operations cleverly so that the unique constraint is not violated, e.g. by modifying an existing book rather than creating a new one. Similarly, the category names are kept unique. Refer to the javadoc and test cases for further details.
The following URL shows the Swagger / Open API documentation of the available end points. Here you may try out individual requests.
http://localhost:8080/swagger-ui/index.html
The next URL shows the definition of the end points in json format. It can be imported into a Postman collection, for example.
http://localhost:8080/v3/api-docs
The app reads its configuration from the src/main/resources/application.yml file.
You may override any of the parameters from the command line using the -D flag,