Create an application with Kotlin/JVM and Kotlin/JS, and explore features around code sharing, serialization, server- and client

Overview

Practical Kotlin Multiplatform on the Web

본 저장소는 코틀린 멀티플랫폼 기반 웹 프로그래밍 워크숍(강좌)을 위해 작성된 템플릿 프로젝트가 있는 곳입니다.

워크숍 과정에서 코틀린 멀티플랫폼을 기반으로 프론트엔드(front-end)는 Kotlin/JS와 리액트(React), 백엔드(back-end)는 Kotlin/JVM과 스프링(Spring)을 사용해 풀스택 웹 애플리케이션이 만듭니다.

코틀린 멀티플랫폼

코틀린은 멀티플랫폼을 지원하는 언어로 JVM 기반 Server-side 및 Android 뿐만이 아니라 JavaScript 엔진이 있는 브라우저나 Node.js, 그리고 iOS, Linux, Windows 등 여러가지 Native 플랫폼에서도 쓸 수 있습니다. 이를 이용해 코틀린 코드를 공유하는 단일 코드베이스로 모바일부터 웹과 데스크톱, 서버에 이르기까지 멀티플랫폼 애플리케이션을 작성할 수 있습니다.

코틀린 멀티플랫폼 프로젝트는 아직 알파 버전이지만 실용적인 가능성에 기대어 기업에서 여러가지 시도를 하고 있습니다. 넷플릭스에서는 TV프로그램과 영화의 제작을 혁신적으로 제공하기 위해 Prodicle 앱을 개발하면서 코틀린으로 작성한 비즈니스 로직을 Kotlin/Native를 통해 Android용 Kotlin 라이브러리와 iOS용 기본 유니버설 프레임워크로 컴파일함해서 사용하고 있으며, 필립스는 자사의 제품들이 클라우드를 기반으로 통합되어 제품간의 검색, 연결 및 상호 작용을 위해 Android 및 iOS, 그리고 임베디드 Linux를 지원하는 SDK를 개발하며 코틀린 멀티플랫폼을 사용했습니다.

프로젝트 구성

├── gradle
├── gradle.properties
├── gradlew
├── gradlew.bat
├── settings.gradle.kts
├── build.gradle.kts                             # Gradle build script
└── src
    ├── commonMain                               # Common Kotlin, application code
    │   ├── kotlin
    │   │   └── todoapp
    │   │       ├── application                  # use-case module
    │   │       ├── domain                       # domain module
    │   │       ├── support
    │   │       └── web                          # web adapter module
    │   └── resources
    ├── commonTest                               # Common Kotlin, test code
    │   ├── kotlin
    │   │   ├── test
    │   │   └── todoapp    
    │   └── resources
    ├── jsMain                                   # Kotlin/JS, application code
    │   ├── kotlin
    │   │   └── todoapp
    │   │       ├── application                  # use-case module
    │   │       ├── ui                           # react-app module
    │   │       └── TodoClientApplication.kt     # client entry-point
    │   └── resources
    ├── jsTest                                   # Kotlin/JS, test code
    │   ├── kotlin
    │   │   ├── test
    │   │   └── todoapp
    │   └── resources
    ├── jvmMain                                  # Kotlin/JVM, application code
    │   ├── kotlin
    │   │   └── todoapp
    │   │       ├── application                  # use-case module
    │   │       ├── data                         # data adapter module
    │   │       ├── web                          # web adapter module
    │   │       └── TodoServerApplication.kt     # server entry-point
    │   └── resources
    │       ├── static                           # static resources (images)
    │       ├── application.yml                  # spring-boot externalized configuration
    │       ├── schema.sql                       # database schema create script
    │       └── data.sql                         # database data init script
    └── jvmTest                                  # Kotlin/JVM, test code
        ├── kotlin
        │   ├── test
        │   └── todoapp
        └── resources

개발 환경

빌드 및 실행

저장소 코드를 내려받은 후 터미널에서 다음 명령어를 입력하고, 애플리케이션이 실행되면 브라우저에서 http://localhost:8080/?mode=remote 로 접속합니다.

❯ ./gradlew clean bootRun

> Configure project :
Kotlin Multiplatform Projects are an Alpha feature. See: https://kotlinlang.org/docs/reference/evolution/components-stability.html. To hide this message, add 'kotlin.mpp.stability.nowarn=true' to the Gradle properties.

> Task :bootRun

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v2.6.8)
 ...
todoapp.TodoServerApplicationKt      : Started TodoServerApplicationKt in 1.349 seconds (JVM running for 1.504)
o.s.b.f.s.DefaultListableBeanFactory : Returning cached instance of singleton bean 'applicationAvailability'
o.s.b.a.ApplicationAvailabilityBean  : Application availability state LivenessState changed to CORRECT
o.s.b.f.s.DefaultListableBeanFactory : Returning cached instance of singleton bean 'applicationAvailability'
o.s.b.a.ApplicationAvailabilityBean  : Application availability state ReadinessState changed to ACCEPTING_TRAFFIC
<============-> 96% EXECUTING [34s]
> :bootRun
You might also like...
A Kotlin DSL wrapper around the mikepenz/MaterialDrawer library.
A Kotlin DSL wrapper around the mikepenz/MaterialDrawer library.

MaterialDrawerKt Create navigation drawers in your Activities and Fragments without having to write any XML, in pure Kotlin code, with access to all t

A simple Kotlin wrapper around Anvil.

AnvilKotlin A simple Kotlin wrapper around Anvil. The only purpose of this library is to provide type safety to Anvil through Kotlin. Nothing more, no

A lightweight Kotlin friendly wrapper around Couchbase lite for Android.

CouchBaseKtx 🚧 Work In-Progress 🚧 A lightweight Kotlin friendly wrapper around Couchbase-lite for Android Read up a little bit of documentation abou

A simple Kotlin multi-platform abstraction around the javax.inject annotations.

Inject A simple Kotlin multi-platform abstraction around the javax.inject annotations. This allows using the annotations in Kotlin common code so that

SavedStateFlow - A Kotlin StateFlow wrapper around SavedStateHandle
SavedStateFlow - A Kotlin StateFlow wrapper around SavedStateHandle

SavedStateFlow SavedStateFlow is a Kotlin StateFlow wrapper around SavedStateHan

Small Kafka Playground to play around with Test Containers, and KotlinX Coroutines bindings while reading Kafka Definite Guide V2

KafkaPlayground Small playground where I'm playing around with Kafka in Kotlin and the Kafka SDK whilst reading the Kafka book Definite Guide from Con

DocuBox is a cloud based file storing app where you can securely store and access your documents from anywhere around the world
DocuBox is a cloud based file storing app where you can securely store and access your documents from anywhere around the world

DocuBox is an android app 📱in which you can securely upload your files on the cloud– from family pictures and audio recordings to spreadsheets, presentations and other confidential documents.

A Lightweight PDF Viewer Android library which only occupies around 125kb while most of the Pdf viewer occupies up to 16MB space.
A Lightweight PDF Viewer Android library which only occupies around 125kb while most of the Pdf viewer occupies up to 16MB space.

Pdf Viewer For Android A Simple PDF Viewer library which only occupies around 125kb while most of the Pdf viewer occupies upto 16MB space. How to inte

Develop an API that moves a rover around on a grid

Mars Rover Kata Develop an API that moves a rover around on a grid. Rules: You are given the initial starting 2D point (x,y) of a rover and the direct

Owner
SpringRunner
스프링러너는 스프링 기반 애플리케이션을 개발하는데 필요한 지식과 경험을 쌓을 수 있도록 돕는 트레이닝 팀입니다.
SpringRunner
Kotlin tooling for generating kotlinx.serialization serializers for serializing a class as a bitmask

kotlinx-serialization-bitmask Kotlin tooling for generating kotlinx.serialization serializers for serializing a class as a bitmask. Example @Serializa

marie 2 May 29, 2022
CSV and FixedLength Formats for kotlinx-serialization

Module kotlinx-serialization-csv Serialize and deserialize ordered CSV and Fixed Length Format Files with kotlinx-serialization. Source code Docs Inst

Philip Wedemann 12 Dec 16, 2022
Android Bundle format support for Kotlinx Serialization.

Bundlizer Android Bundle format support for Kotlinx Serialization. Usage Annotate your data models with @Serializable: import kotlinx.serialization.Se

Ahmed Mourad 69 Nov 9, 2022
Minecraft NBT support for kotlinx.serialization

knbt An implementation of Minecraft's NBT format for kotlinx.serialization. Technical information about NBT can be found here. Using the same version

Ben Woodworth 41 Dec 21, 2022
Android Parcelable support for the Kotlinx Serialization library.

Android Parcelable support for the Kotlinx Serialization library.

Christopher 50 Nov 20, 2022
Type-safe arguments for JetPack Navigation Compose using Kotlinx.Serialization

Navigation Compose Typed Compile-time type-safe arguments for JetPack Navigation Compose library. Based on KotlinX.Serialization. Major features: Comp

Kiwi.com 32 Jan 4, 2023
KotlinX Serialization Standard Serializers (KS3)

KotlinX Serialization Standard Serializers (KS3) This project aims to provide a set of serializers for common types. ⚠️ Consider this project to be Al

Emil Kantis 3 Nov 5, 2022
Account-Touch is a simple account-sharing service.

account-touch A-Touch is a simple account-sharing service. feature user & permission Create an user with a nickname and emoji account You can see the

Euphony 2 Aug 4, 2022
🐘 Mastodon client for Android, iOS and Desktop (JVM)

MastodonX A multiplatform Mastodon client written in Kotlin for the amazing androiddev.social community and everyone else who enjoys #Fediverse Join o

null 372 Dec 28, 2022
Server Sent Events (SSE) client multiplatform library made with Kotlin and backed by coroutines

OkSSE OkSSE is an client for Server Sent events protocol written in Kotlin Multiplatform. The implementation is written according to W3C Recommendatio

BioWink GmbH 39 Nov 4, 2022