An Example Web App to get you booted quickly with Kotlin+JooQ+Quarkus
- Make sure JDK 17 is installed and JAVA_HOME is pointing to JDK 17 Home
java -version
should say 17- docker must be installed and running (use docker desktop on Windows)
- Run Postgres in docker if you don't have dedicated postgres:
docker run -d --rm --name pg -ePOSTGRES_PASSWORD=postgres -p5432:5432 -t postgres
- Make sure you can connect to Postgres instance: username/password/database are all
postgres
- Run on command line: ./gradlew quarkusDev
- Application is running on http://localhost:8080/users
- You can make code changes and refresh the browser. Usually
quarkusDev
picks up code changes without need to restart the app.
Jooq works by generating Kotlin Code from a database schema. It examines postgres and creates corresponding DTOs and POJOs. In order
to do so, it needs access to a working postgres schema. We provide this via a testcontainer. A gradle task called generateJooqClasses
is provided to generate code.
You can simply run this task whenever you make changes to database schema: ./gradlew generateJooqClasses
- you must have docker service running before running this task.
This task does the following:
- Instantiate a new postgres docker container (using TestContainer)
- Runs the database (Liquibase) migration from
src/main/resources/db/changelog
folder against this container - Connects Jooq to this database and generates Kotlin code. The generated code is in
src/main/kotlin/my/starter/jooq
folder. You are advised against changing anything in this folder by hand.
The Project uses Freemarker templates to build HTML UI pages. It's not a single page app that one would build using React or Angular. This is on purpose since Page Based HTML is simpler to understand and modify and you can get started without React or Typescript expertise. On the other hand, the architecture allows for gradual introduction of React/Angular.
Sitewide layout is applied via a Freemarker macro called layout. Any page that needs this layout can 'include' it on-demand:
<@layout.layout>
This is the page content with header and footer and other common elements applied from layout macro.
</@layout.layout>
Note that this is different from other templating engines where common layout is applied site wide in code. Our approach is more versatile since the page decides which layout to use and a page can decide to use another layout with a simple change.
Common styles (bootstrap css) and js (e.g. jquery) are included in the layout and available to any page utilizing this layout.
Page specific javascript can be included by introducing a pageJS
variable in each page. Please see new-user.ftl for an example.
Another cool feature is how simple it is to handle release specific static assets (javascript/images/css etc). Every static url on these pages follows a pattern like
/static/0.0.1/bootstrap.min.css
where 0.0.1
is a release version. This generates an URL like 'http://host/static/0.0.1/bootstrap.min.js' . Once a
new application is deployed (e.g. 0.0.2), simple modify the property release.version
in application.properties. This will generate a new URL forcing Browsers to
download the resource fresh bypassing it's cache. ALL static resources are served with a big cache timeout like 1 year which essentially means it'll be cached
indefinitely. This is safe since next app release would force a new URL as described, forcing a new download. Please see StaticController for details.