If you like this project, please consider supporting me โค๏ธ
This monorepo is a minimal CRUD service exposing a couple of endpoints over REST, with a front-end based on React so you can play with it from your browser.
While the code is surprisingly simple, under the hood this is using:
- RESTEasy to expose the REST endpoints and documented with OpenAPI
- Hibernate ORM with Panache to perform the CRUD operations on the database
- PostgreSQL database; automatically starts an embedded DB
- Liquibase to automatically update database
- Quinoa to handle allowing this monorepo to serve React and Java code
- React + PrimeReact for a top notch user interface including lazy datatable
- TanStack Query for powerful asynchronous state management for TypeScript
- Orval to generate TanStack Query client Typescript from OpenAPI definition
- React Hook Forms to validate user input data
To compile and run this demo you will need:
- JDK 17+
- Docker
In addition, you will need either a PostgreSQL database, or Docker to run one.
The Maven Quarkus plugin provides a development mode that supports live coding. To try this out:
$ ./mvnw quarkus:dev
Watch as it starts up a temporary PostreSQL database just for this session. In this mode you can make changes to the code and have the changes immediately applied, by just refreshing your browser.
๐ก Hot reload works add a new REST endpoint and see it update in realtime. Try it!
Now open your web browser to http://localhost:8080/ to see it in action.
When you're done iterating in developer mode, you can run the application as a conventional jar file.
First compile it:
$ ./mvnw package
Connection properties for the Agroal datasource are defined in the standard Quarkus configuration file,
src/main/resources/application.properties
.
Then run it with:
$ java -jar ./target/quarkus-app/quarkus-run.jar
Navigate to: http://localhost:8080/
๐ก Have a look at how fast it boots. Or measure total native memory consumption...
You can also create a native executable from this application without making any source code changes. A native executable removes the dependency on the JVM: everything needed to run the application on the target platform is included in the executable, allowing the application to run with minimal resource overhead.
Compiling a native executable takes a bit longer, as GraalVM performs additional
steps to remove unnecessary codepaths. Use the native
profile to compile a
native executable:
$ mvn -Pnative
After getting a cup of coffee, you'll be able to run this binary directly where ${version} is the current project version:
$ docker run -i --rm -p 8080:8080 melloware/quarkus-primereact:${version}
๐ก Please brace yourself: don't choke on that fresh cup of coffee you just got. Now observe the time it took to boot, and remember: that time was mostly spent to generate the tables in your database and import the initial data.
Navigate to: http://localhost:8080/index.html