Kotlin Multiplatform — Details

Pradyot Prakash
4 min readJun 15, 2024

--

In this part, I will be sharing what we are going to make using Kotlin Multiplatform and what other things we will be using to achieve the project development.

Project Details

We will be making a X clone, but not just UI with static data. We will be using backend service, realtime updates, offline capability, authentication using JWT and many more.

Project can run on Android, iOS and Desktop (checked only on MacOS) for now.

Project update and videos can be checked at

https://x.com/pradyotprksh4/status/1799002745414004997

Setup

  1. Install kdoctor to see if your system has all the required software to start with the Kotlin Multiplatform development. Find the steps available at https://www.jetbrains.com/help/kotlin-multiplatform-dev/multiplatform-setup.html
  2. MongoDB, but will be running locally. I will be using the community edition. Based on your requirement you can choose the Enterprise edition as well. Setup guide is available https://www.mongodb.com/docs/manual/installation/
  3. Optional — MongoDB compass, this will be needed to see the MongoDB data. It will connect to your local DB instance and show the details and each collection. Installation details can be found at https://www.mongodb.com/try/download/compass. In the site, check the MongoDB Compass Download (GUI) section.
  4. Optional — Realm Studio, for local storage in our project we will be using Realm so to check the realm file we will be using this. This helps when you are seeing some data issues and can be verified. Installation details can be found at https://docs.realm.io/sync/realm-studio.
  5. Optional — Bruno, to check our API implementation before we integrate into our application. Details can be found here https://www.usebruno.com/.
  6. We will be using Android Studio for Kotlin Multiplatform, so download the plugin as well for it. Plugin details can be found at https://plugins.jetbrains.com/plugin/14936-kotlin-multiplatform

If you face any problem with setting up any of the softwares mentioned above, feel free to ask.

These are the softwares which I will be using, but it’s not compulsory that only these can used, you can use any other software available.

As we move forward and if we need any other software, this list will be updated based on that.

Dependencies

We will be using dependencies as well to create the projects

  1. Compose Multiplatform, for making the shared UI across platforms. Details can be found at https://www.jetbrains.com/lp/compose-multiplatform/
  2. Realm Kotlin, for local storage. Details can be found at https://github.com/realm/realm-kotlin?tab=readme-ov-file
  3. Kamel image, for showing the network images. Details ca be found at https://github.com/Kamel-Media/Kamel
  4. Kodien for dependency injection. Details can be found at https://github.com/kosi-libs/Kodein
  5. Kotlinx DateTime, since we will be working with time in this project it will be helpful. Details can be found at https://github.com/Kotlin/kotlinx-datetime
  6. Ktor, both server and client. The server side will be connecting with the MongoDB. And client will be connecting to the server side. Details can be found at https://ktor.io/
  7. Navigation, well we need this. X cannot be a one page application. Details can be found at https://www.jetbrains.com/help/kotlin-multiplatform-dev/compose-navigation-routing.html

As we move forward and the project needs other dependencies, this list will be updated based on that. And these are just some of the main dependencies which I have highlighted.

Project Creation

We will be using https://kmp.jetbrains.com/ for downloading the project template to get started with.

Kotlin Multiplatform Wizard https://kmp.jetbrains.com/

I am selecting, Android, iOS (with Shared UI), Desktop and Server for this project. You can select any based on your requirement.

Web was having some issue running the project with K2 compiler, while I was migrating my project to K2. You can give it a try with lower Kotlin versions.

Codebase Status

Just like any other projects of mine, this is also available for others to use. And I have started working on the project already and developed some of the features already.

Feel free to download the codebase and play around with it. Share the feedback and suggestions which can help me to make this project better.

Codebase can be found at

For the next part we will be starting with Registration on server side. Check at

Other parts

If you have any questions or suggestions please provide it in the comments, will try to answer or implement it.

Follow for getting the notification when new articles are published.

Follow me on Twitter and GitHub.

--

--