Kotlin Jooby Svelte Template screenshot

Kotlin Jooby Svelte Template

Author Avatar Theme by Angryziber
Updated: 20 Feb 2022
56 Stars

App template using Kotlin + Jooby + Svelte + Selenide, including how to write tests and run everything in Docker

Categories

Overview

Jooby/Kotlin + Svelte/Bootstrap app template is a relatively lightweight modern app template that combines the Jooby framework for server-side API development with Kotlin, and the Svelte framework for building the user interface on the client side. The template also utilizes Bootstrap for styling and layout. This template is no longer actively used for new projects, but the author recommends Klite framework for server-side development with Kotlin and Vite for client-side development with Svelte.

Features

  • Server API using Jooby
  • Postgres database integration (runnable using docker-compose)
  • Liquibase for database migration
  • Server unit tests using JUnit5 and Mockk
  • Repository integration tests run on the same database instance but a different schema
  • UI built with Svelte and Snowpack
  • TypeScript support for UI development
  • UI tests using Web Test Runner and TypeScript
  • End-to-end tests using Selenide to drive the actual browser backed by H2 database
  • Efficient Docker usage with cached layers and Gradle dependency downloads
  • Static server-side rendered pages using Pebble templates
  • Automatic TypeScript types from Kotlin classes in UI API
  • Minimal dependency injection (30 lines)
  • Minimal JDBC extensions instead of ORM and transaction management (100 lines)
  • Simple client-side router used in the root component
  • Three layers of testing: UI (client-side components), server-side (unit tests + repositories), and end-to-end using Selenide
  • Rollback of repository tests to avoid recreating the database each time
  • E2E tests perform login once and then use fake login for quicker navigation

Installation

To use the Jooby/Kotlin + Svelte/Bootstrap app template, follow these steps:

  1. Install Java 8 or higher, Kotlin, and Gradle on your system.
  2. Clone the repository.
  3. Install Postgres and Docker if not already installed.
  4. Run docker-compose up to start the Postgres database.
  5. Configure the database connection in the application.properties file.
  6. Run the Gradle build script to download dependencies and build the project.
  7. Start the application by running the main class.

Summary

Jooby/Kotlin + Svelte/Bootstrap app template is a lightweight and modern app template that combines the Jooby framework with Kotlin on the server-side and Svelte on the client-side. It offers features such as efficient Docker usage, internationalization support, and three layers of testing. The template also provides a simple client-side router and minimal dependency injection and JDBC extensions instead of using ORM and transaction management frameworks. Though no longer used for new projects, the template serves as a good reference for implementing similar app structures.