This repository contain sandbox projects to showcase features of the Ktor framework.
All examples are written in Kotlin and built using Gradle.
Read details about the examples in their respective project roots.
- REST API
- CRUD Exposed JDBC
- CRUD Exposed DAO
- CRUD Ktorm
- CRUD JOOQ
- OAuth2 Token Relay
- OTEL Observability
- Kafka CQRS
Ktor is a lightweight framework for building applications for the JVM runtime. Ktor was created by JetBrains to champion the features of the Kotlin programing language and the asynchronous programing model based on their Coroutines framework.
Ktor is a very modular framework with an explicit configuration style where you are in full control of the setup of your application. It has a plugin based configuration model where features are enabled by adding the corresponding plugin to the application setup. Unlike similar frameworks it does not have an IoC-container by default. This means it does not support traditional Dependency Injection out of the box, though there are plugins to enable Dependency Injection functionality (e.g. the Kion framework).
The examples typically consists of a Frontend
and a Backend
application.
graph TD
A[Ktor Frontend]:::ktor
B[Ktor Backend]:::ktor
A --> B
classDef react fill: #58c4dc, stroke: #000000, color: #000000
classDef ktor fill: #8d53f9, stroke: #000000, color: #000000
If the frontend is a JavaScript application then there is often also a Frontend API
application.
graph TD
A[React Frontend]:::react
B[Ktor Frontend API]:::ktor
C[Ktor Backend]:::ktor
A --> B
B --> C
classDef react fill: #58c4dc, stroke: #000000, color: #000000
classDef ktor fill: #8d53f9, stroke: #000000, color: #000000
Most examples implement a "hello world" style logic that returns a greeting message when the user inputs a name.
- A user inputs the name "John" and clicks "Submit"
- The system generates a greeting "Hello John!" back to the user