Kotlin Multiplatform sample with SwiftUI, Jetpack Compose, Compose for Wear, Compose for Desktop, and Compose for Web clients along with Ktor backend.
Kotlin Multiplatform project with SwiftUI, Jetpack Compose, Compose for Wear OS, Compose for Desktop and Compose for Web clients along with Ktor backend. Currently running on
Main.kt
in common
module)It makes use of Open Notify PeopleInSpace API to show list of people currently in
space and also the position of the International Space Station (inspired by https://kousenit.org/2019/12/19/a-few-astronomical-examples-in-kotlin/)!
The project is included as sample in the official Kotlin Multiplatform Mobile docs and also the Google Dev Library
Related posts:
Note that this repository very much errs on the side of minimalism to help more clearly illustrate key moving parts of a Kotlin
Multiplatform project and also to hopefully help someone just starting to explore KMP to get up and running for first time (and is of course
primarily focused on use of Jetpack Compose and SwiftUI). If you're at the stage of moving
beyond this then I'd definitely recommend checking out KaMPKit from Touchlab.
I also have the following samples that demonstrate the use of a variety of Kotlin Multiplatform libraries (and also use Jetpack Compose and SwiftUI).
You need to use at least Android Studio Flamingo (note: Java 17 is now the minimum version required). Requires Xcode 13.2 or later (due to use of new Swift 5.5 concurrency APIs).
Open `PeopleInSpaceSwiftUI' for iOS projects.
To exercise (React based) web client run ./gradlew :web:browserDevelopmentRun
.
To run backend you can either run ./gradlew :backend:run
or run Server.kt
directly from Android Studio. After doing that you should then for example be able to open http://localhost:9090/astros_local.json
in a browser.
Similarly for Kotlin/Wasm based version./gradlew :compose-web:wasmBrowserDevelopmentRun
This client is available in compose-desktop
module and can be run using ./gradlew :compose-desktop:run
. Note that you
need to use appropriate version of JVM when running (works for example with Java 11)
Can be run using for example ./gradlew :compose-ios:iosDeployIPhone13ProDebug
Have tested this out in Google App Engine deployment. Using shadowJar plugin to create an "uber" jar and then deploying it as shown below. Should be possible to deploy this jar to other services as well.
./gradlew :backend:shadowJar
gcloud app deploy backend/build/libs/backend-all.jar --appyaml=backend/src/jvmMain/appengine/app.yaml
There's a GraphQL module (graphql-server
) which can be run locally using ./gradlew :graphql-server:bootRun
with "playground" then available at http://localhost:8080/playground
iOS (SwiftUI)
<br/>
<img width="546" alt="Screenshot 2021-02-27 at 12 09 02" src="https://user-images.githubusercontent.com/6302/109386736-ac1f0700-78f4-11eb-812e-4bf971a8c2a7.png">
Android (Jetpack Compose)
<br/>
Wear OS (Wear Compose)
<br/>
<img width="250" alt="Wear Compose Screenshot 1" src="https://user-images.githubusercontent.com/6302/137623548-ac51ca72-572e-4009-8b34-315defdf93a5.png">
<img width="250" alt="Wear Compose Screenshot 2" src="https://user-images.githubusercontent.com/6302/137640396-851489bb-e41d-47ef-badb-e2d22454eee4.png">
<img width="250" alt="Wear Compose Screenshot 3" src="https://user-images.githubusercontent.com/6302/139468900-16ad4e95-41dc-427f-977c-b893b1751c78.png">
Compose for Desktop
<br/>
<img width="912" alt="Screenshot 2021-10-01 at 16 45 06" src="https://user-images.githubusercontent.com/6302/135652185-4ce9d8e3-f06e-4e9d-9930-3e900267f8bd.png">
Compose for Web (Wasm based)
<br/>
<img width="1156" alt="Screenshot 2024-03-02 at 21 03 23" src="https://github.com/joreilly/PeopleInSpace/assets/6302/8e4bfb36-e417-4db8-824b-563953e0d9ac">
MCP
The mcp-server
module uses the Kotlin MCP SDK to expose an MCP tools endpoint (returning list of people in space) that
can for example be plugged in to Claude Desktop as shown below. That module uses same KMP shared code (that uses for example Ktor, SQLDelight and Koin)
To integrate the MCP server with Claude Desktop you need to firstly run gradle shadowJar
task and then select "Edit Config" under Developer Settings and add something
like the following (update with your path)
{
"mcpServers": {
"kotlin-peopleinspace": {
"command": "java",
"args": [
"-jar",
"/Users/john.oreilly/github/PeopleInSpace/mcp-server/build/libs/serverAll.jar",
"--stdio"
]
}
}
}
joreilly/PeopleInSpace
December 22, 2019
July 6, 2025
Kotlin