/ktor-sandbox

This repository contain sandbox projects to showcase features of the Ktor framework.

Primary LanguageKotlinApache License 2.0Apache-2.0

Ktor Sandbox

Kotlin Ktor TypeScript React Gradle Gradle GitHub license

This repository contain sandbox projects to showcase features of the Ktor framework.

All examples are written in Kotlin and built using Gradle.

Examples

Read details about the examples in their respective project roots.

Architecture

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
Loading

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
Loading

Use case

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