Kotlin TodoMVC – full-stack Kotlin application demo

Overview

Kotlin full stack TodoMVC

This project is an example implementation of the TodoMVC app written in Kotlin. More specifically, it's the Kotlin port of the Vanilla JS version of TodoMVC (hence it doesn't use any JavaScript frameworks like Angular or React). The code intentionally follows closely the structure and conventions of the original, so you should be able to compare the two versions easily.

Note: I haven't implemented local storage yet. All items are stored in-memory for now.

Modules

The code is a full stack Kotlin example, so it consists of two modules: backend and frontend.

Backend

It is a very simple HTTP server serving requests on a single route (localhost:9000/). The response is an index page with minimal HTML DOM: html, head, empty body and a script tag referencing the compiled JavaScript app. It uses ktor, a web framework developed by JetBrains.

Frontend

All of the application logic is implemented in Kotlin and compiled to JavaScript with a tool called kotlinc-js. The app uses Gradle as a build tool and relies on the kotlin-frontend-plugin. This plugin takes care of a lot of things, so you don't have to interact with kotlinc-js directly. Once the page loaded and the docuemnt is ready, all HTML elements are rendered by JavaScript. For creating the DOM it uses kotlinx.html, a cross-platform library (works both on the JVM and in the browser) that provides a DSL for building/appending HTML elements in a type-safe manner.

Gradle kotlin-dsl

Being a full stack Kotlin example project, the build scripts are also written in Kotlin (build.gradle.kts). They are mostly in line with the ones from the reference kotlin-fullstack-sample.

Requirements

The kotlin-frontend-plugin is picky when it comes to version numbers and it's not really documented.

Make sure that you use the latest LTS version of Node.js (v6.11.2 as of writing) and the matching npm release (3.10.10).

As of kotlin-frontend-plugin version 0.0.20 you can use the latest node and npm versions.

How to run

First, you have to start the backend:

./gradlew backend:run

Note: ktor supports automatic reloading, which is configured in the project. This means that you don't have to restart the running application when you make changes, it's enough to recompile the files that you are editing. You have to run compile by hand though (e.g. from IntelliJ), Gradle doesn't pick up changes automatically for now.

Then you can run the frontend with:

./gradlew -t frontend:run

The kotlin-frontend-plugin will compile/assemble all resources into a module and start a webpack server running on: http://localhost:8080/.

As kotlin-frontend-plugin uses webpack under the hood Hot Module Replacement is available, so as you are editing the Kotlin code Gradle will automatically recompile changes and the plugin will replace modules in the background.

You might also like...
Demo Spting REST Service on Kotlin. Works with PostgreSQL via Spring Data. Data initialization provided by liquibase

Spring Boot REST API with Kotlin Spring Boot REST API service. Spring Data with PostgreSQL. Data initialization with Liquibase. Swagger UI Reference D

PageRoundDemo - Page Round Demo with kotlin
PageRoundDemo - Page Round Demo with kotlin

PageRoundDemo I don't like the mode of swiping to the bottom to load more, as it

A simple demo project based on MVVM clean architecture and material design & animations.
A simple demo project based on MVVM clean architecture and material design & animations.

GithubFollows A simple demo project based on MVVM clean architecture and material design & animations. Architecture Specs & Open-source libraries Mini

Android human matting demo infer by ncnn
Android human matting demo infer by ncnn

ncnn_Android_modnet Android human matting demo infer by ncnn the model from MODNet: Trimap-Free Portrait Matting in Real Time support model 1.mobilene

A seed and demo about how to do end-to-end testing of a Dataflow pipeline

dataflow-e2e-demo This is a demo and a seed project to show how you can end-to-end test a Dataflow pipeline. You can find more about by follwing this

Spring Boot KeyCloak Demo
Spring Boot KeyCloak Demo

Spring Boot(Kotlin) + Spring Security + Keycloak Demo Docker Keycloak + MariaDB 설정 및 기본 KeyCloak 사용법 Keycloak 이미지와 MariaDB 이미지를 다운 받는다. [root@~]# dock

Demo to show ongoing notification on Huawei P50 Pocket
Demo to show ongoing notification on Huawei P50 Pocket

Bali Demo Demo code to show different ongoing notification types on the Huawei P50 Pocket external screen. Currently the external screen provides THRE

A demo project which demonstrates the work of javax.servlet.Filter  capable of escaping / modifying / removing a part of JSON request based on specified criteria.
A demo project which demonstrates the work of javax.servlet.Filter capable of escaping / modifying / removing a part of JSON request based on specified criteria.

Replace Filter Demo A demo project which demonstrates the work of javax.servlet.Filter capable of escaping / modifying / removing a part of JSON reque

Kafka-hot-and-cold-retries - Demo project for elaborating how hot and cold retries can be applied in Kafka
Kafka-hot-and-cold-retries - Demo project for elaborating how hot and cold retries can be applied in Kafka

Apache Kafka® - Hot and Cold Retries A demo project for elaborating how hot and

Comments
  • Error: webpack.optimize.UglifyJsPlugin has been removed

    Error: webpack.optimize.UglifyJsPlugin has been removed

    After i cloned this repo I started the backend and the frontend as shown in the README file:

    $ ./gradlew backend:run
    $ ./gradlew -t frontend:run
    

    While the backend runs fine, the frontend raises an exception:

    > Task :frontend:webpack-run 
    webpack-dev-server exited with exit code 1, see /Users/mcpringle/GitHub/other/kotlin-todomvc/frontend/build/logs/webpack-dev-server.log
    /Users/mcpringle/GitHub/other/kotlin-todomvc/frontend/build/node_modules/webpack/lib/webpack.js:162
                            throw new RemovedPluginError(errorMessage);
                            ^
    
    Error: webpack.optimize.UglifyJsPlugin has been removed, please use config.optimization.minimize instead.
        at Object.get [as UglifyJsPlugin] (/Users/mcpringle/GitHub/other/kotlin-todomvc/frontend/build/node_modules/webpack/lib/webpack.js:162:10)
        at Object.<anonymous> (/Users/mcpringle/GitHub/other/kotlin-todomvc/frontend/build/webpack.config.js:42:44)
        at Module._compile (module.js:624:30)
        at Object.Module._extensions..js (module.js:635:10)
        at Module.load (module.js:545:32)
        at tryModuleLoad (module.js:508:12)
        at Function.Module._load (module.js:500:3)
        at Module.require (module.js:568:17)
        at require (internal/module.js:11:18)
        at Object.<anonymous> (/Users/mcpringle/GitHub/other/kotlin-todomvc/frontend/build/webpack-dev-server-run.js:22:14)
    
    
    FAILURE: Build failed with an exception.
    
    * What went wrong:
    Execution failed for task ':frontend:webpack-run'.
    > webpack-dev-server startup failed
    
    * Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
    
    * Get more help at https://help.gradle.org
    
    BUILD FAILED in 5s
    16 actionable tasks: 2 executed, 14 up-to-date
    

    I run macOS High Sierra 10.13.3 and tried Java 8u152 and 9.0.4.

    opened by McPringle 1
Owner
Gyula Voros
Gyula Voros
Michal Kubele 0 Jan 6, 2022
📒 NotyKT is a complete 💎Kotlin-stack (Backend + Android) 📱 application built to demonstrate the use of Modern development tools with best practices implementation🦸.

NotyKT ??️ NotyKT is the complete Kotlin-stack note taking ??️ application ?? built to demonstrate a use of Kotlin programming language in server-side

Shreyas Patil 1.4k Dec 26, 2022
Sample Ktor app using a functional stack

samstack This is a template project you can clone and use as a basis for your own Kotlin based microservices. This application structure is my persona

Sam 6 Nov 16, 2022
Sample Ktor app using a functional stack

samstack This is a template project you can clone and use as a basis for your own Kotlin based microservices. This application structure is my persona

Sam 18 Jul 21, 2022
Starter project with PEKK stack.

Running the project To run the project, you need to run the server and the frontend. Running the server In the terminal, run ./gradlew narcore-server:

Narbase Technologies 2 Sep 9, 2022
A repository full of Forge 1.8.9 Kotlin utilities

kotlin-forge-api kotlin-forge-api is a repository full of different APIs to be used by mods for Forge 1.8.9 to make modding easier! Warning! To use an

Shalom Ademuwagun 7 Sep 28, 2022
🧶 Full-fledged Kotlin client for MikaBot/cluster-operator as a separate package

?? Eri Full-fledged Kotlin client for MikaBot/cluster-operator as a separate package Usage Connecting to operator fun main(args: Array<String>) {

Nino 3 Nov 17, 2021
Lucilla - Fast, efficient, in-memory Full Text Search for Kotlin

Lucilla Lucilla is an in-memory Full Text Search library for Kotlin. It allows t

Kshitij Chauhan 111 Jan 6, 2023
AndroidIDE - an IDE for Android to develop full featured Android apps on Android smartphones.

AndroidIDE - an IDE for Android to develop full featured Android apps on Android smartphones.

Akash Yadav 615 Dec 27, 2022
TheMovies 🎬 A demo project for The Movie DB based on Kotlin MVVM architecture and material design & animations.

A simple project for The Movie DB based on Kotlin MVVM clean architecture and material design & animations. How to build on your environment

Jaewoong Eum 420 Nov 29, 2022