Kotlin Multiplatform project: Sharing code between iOS, MacOS, WatchOS, Android (phone and watch - Wear OS), and JVM Web Server (Ktor)
KInsight Alpha Capture is a proof of concept project currently being developed for our annual CodeWeek event (where you pitch business or technology ideas). Alpha Capture app is intended for Sales to create and distribute trade ideas to our institutional clients. The app will track the performance of each idea relative to the performance of the benchmark, and alert users when the idea has reached the price objective or stop loss value so that the user can then close the idea. This is proof of concept only, and as such will have the following limitations: 1) there will be only limited live market data availability (when creating an idea, current stock price - for this we use https://iexcloud.io/docs/api/ - if you clone this project, make sure to get your own api key - it's free!); b) there will be no permanent storage for newly created ideas, they will be stored in memory on the server until the next server reload. However, there will be a number of “prefabricated” ideas along with their historical (mocked) performance. As we cannot control the market (alas), some market data manipulation is in order. The server will provide an API to update prices for ideas so that an alert can be triggered. These price updates will flow into the app via websockets, updating UI in real time and triggering notification alerts when price objective or stop loss thresholds are met.
Part 1 |
---|
![]() |
Part 2 |
---|
![]() |
Part 3 |
---|
![]() |
IPhone | Android |
---|---|
![]() |
![]() |
Wear OS | Watch OS |
---|---|
![]() |
![]() |
https://github.com/dmitrish/kinsight-multiplatform/blob/master/wearos-alpha.mp4
Switching server between thee possible builds: google app angine, netty, and netty with fatjar - settings.gradle:
If you want to run the google appengine locally, remember to change the engine path to your path!
To run appengine locally, execute this gradle task
Note - if you want websockets enabled, you need to run one of the netty builds (regular netty or fatjar netty). Change settings.gradle as described above and execute this gradle task for the regular netty build:
To run the fatjar build, first build with this build task:
Then navigate to the libs folder in the terminal and execute: libs % java -jar server-all.jar
- Compile the shared code module in Android Studio (see snapshot below).
- Move to Kotlin ios Folder
- Do a 'pod install'
- Open .xcworkspace file
- Compile the shared code module in Android Studio (see snapshot below)
- In Android's build.gradle, in Android -> DefaultConfig -> change this build config field to be: buildConfigField("String", "url", '"https://10.0.2.2:8081"')
Prerequisite install Google Cloud SDK and Docker(optional)
Create Google Project:
- gcloud init
- gcloud projects create kinsight-multiplatform
- gcloud app create
- gcloud config set project kinsight-multiplatform
- gcloud auth configure-docker
Create Docker Image and Run:
- Navigate to \server folder
- docker build -t server-all .
- docker run -m512M --cpus 1 --expose 8081 -p 8081:8081 -it server-all
Other Docker Commands: docker images docker ps docker stop instance_id docker rmi image_name
Uploading Docker Image to Google Cloud Registry:
- Add Tag to Image (V3 is the tag here) docker tag server-all gcr.io/project-kinsight/server-all-image:V3
- Push Image to cloud registry docker push gcr.io/project-kinsight/server-all-image:V3
Next follow below to deploy Docker image into Google Kubernetes Engine: https://cloud.google.com/kubernetes-engine/docs/quickstart