Skip to content

Latest commit

ย 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿช™ CoinRoutine

CoinRoutine is a cross-platform cryptocurrency portfolio application built with Kotlin Multiplatform (KMP) and Compose Multiplatform (CMP).

The project demonstrates how to build a production-style mobile application while sharing business logic, data, and UI between Android and iOS. It follows Clean Architecture + MVI, uses dependency injection, local persistence, networking, biometric authentication, and includes both unit tests and Compose UI tests.

๐Ÿšง This project is actively being developed and serves as a practical demonstration of modern Kotlin Multiplatform development.


โœจ Features

๐Ÿ“Š Cryptocurrency

  • Browse cryptocurrency information
  • View coin details
  • Display cryptocurrency market data
  • Network-based data fetching
  • Image loading for cryptocurrency assets
  • Loading and error states

๐Ÿ’ผ Portfolio

  • Create and manage a cryptocurrency portfolio
  • Track portfolio holdings
  • Calculate portfolio-related values
  • Combine portfolio data with current coin information
  • Persist portfolio data locally
  • Reactive portfolio updates

๐Ÿ’ฐ Trading

  • Buy cryptocurrency
  • Sell cryptocurrency
  • Track trade-related information
  • Validate trade input
  • Update portfolio after trades

๐Ÿ” Biometric Authentication

The feature/biometric branch introduces biometric authentication to protect the application.

  • Android biometric authentication
  • Platform-specific biometric implementation
  • Authentication state management
  • Secure access to protected application content
  • Multiplatform architecture using platform-specific implementations where required

๐Ÿงช Testing

The project places a strong emphasis on automated testing.

  • Unit tests
  • ViewModel tests
  • Repository/domain logic tests
  • Coroutine testing
  • Flow testing with Turbine
  • Assertion testing with AssertK
  • Compose UI tests
  • Android host tests
  • iOS simulator tests
  • Fake implementations for testing

๐Ÿ—๏ธ Architecture

CoinRoutine follows Clean Architecture combined with the MVI (Modelโ€“Viewโ€“Intent) pattern.

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚              Compose UI             โ”‚
โ”‚       Android + iOS (CMP)           โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                  โ”‚
                  โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚           Presentation Layer         โ”‚
โ”‚       MVI / ViewModel / State        โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                  โ”‚
                  โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚             Domain Layer             โ”‚
โ”‚      Use Cases / Models / Logic      โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                  โ”‚
                  โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚              Data Layer              โ”‚
โ”‚ Repository / Remote / Local Storage  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                โ”‚           โ”‚
                โ–ผ           โ–ผ
             Ktor         Room
            Network       Database

Why MVI?

MVI provides a predictable unidirectional data flow:

User Action
     โ”‚
     โ–ผ
   Intent
     โ”‚
     โ–ผ
 ViewModel
     โ”‚
     โ–ผ
 Use Case
     โ”‚
     โ–ผ
 Repository
     โ”‚
     โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บ Remote Data
     โ”‚
     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บ Local Database
     โ”‚
     โ–ผ
 New State
     โ”‚
     โ–ผ
 Compose UI

This makes state management predictable and makes presentation logic easier to test.


๐Ÿ“ Project Structure

CoinRoutine/
โ”‚
โ”œโ”€โ”€ androidApp/
โ”‚   โ””โ”€โ”€ Android application entry point
โ”‚
โ”œโ”€โ”€ iosApp/
โ”‚   โ””โ”€โ”€ iOS application entry point
โ”‚
โ”œโ”€โ”€ shared/
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ commonMain/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ kotlin/
โ”‚   โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ com/ahmad/raza/coinroutine/
โ”‚   โ”‚   โ”‚   โ”‚       โ”‚
โ”‚   โ”‚   โ”‚   โ”‚       โ”œโ”€โ”€ biometric/
โ”‚   โ”‚   โ”‚   โ”‚       โ”‚
โ”‚   โ”‚   โ”‚   โ”‚       โ”œโ”€โ”€ coins/
โ”‚   โ”‚   โ”‚   โ”‚       โ”‚   โ”œโ”€โ”€ data/
โ”‚   โ”‚   โ”‚   โ”‚       โ”‚   โ”œโ”€โ”€ domain/
โ”‚   โ”‚   โ”‚   โ”‚       โ”‚   โ””โ”€โ”€ presentation/
โ”‚   โ”‚   โ”‚   โ”‚       โ”‚
โ”‚   โ”‚   โ”‚   โ”‚       โ”œโ”€โ”€ portfolio/
โ”‚   โ”‚   โ”‚   โ”‚       โ”‚   โ”œโ”€โ”€ data/
โ”‚   โ”‚   โ”‚   โ”‚       โ”‚   โ”œโ”€โ”€ domain/
โ”‚   โ”‚   โ”‚   โ”‚       โ”‚   โ””โ”€โ”€ presentation/
โ”‚   โ”‚   โ”‚   โ”‚       โ”‚
โ”‚   โ”‚   โ”‚   โ”‚       โ”œโ”€โ”€ trade/
โ”‚   โ”‚   โ”‚   โ”‚       โ”‚   โ”œโ”€โ”€ domain/
โ”‚   โ”‚   โ”‚   โ”‚       โ”‚   โ””โ”€โ”€ presentation/
โ”‚   โ”‚   โ”‚   โ”‚       โ”‚
โ”‚   โ”‚   โ”‚   โ”‚       โ”œโ”€โ”€ core/
โ”‚   โ”‚   โ”‚   โ”‚       โ”œโ”€โ”€ di/
โ”‚   โ”‚   โ”‚   โ”‚       โ”œโ”€โ”€ navigation/
โ”‚   โ”‚   โ”‚   โ”‚       โ””โ”€โ”€ theme/
โ”‚   โ”‚   โ”‚   โ”‚
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ composeResources/
โ”‚   โ”‚   โ”‚
โ”‚   โ”‚   โ”œโ”€โ”€ androidMain/
โ”‚   โ”‚   โ”œโ”€โ”€ iosMain/
โ”‚   โ”‚   โ””โ”€โ”€ commonTest/
โ”‚   โ”‚
โ”‚   โ””โ”€โ”€ schemas/
โ”‚       โ””โ”€โ”€ Room database schemas
โ”‚
โ”œโ”€โ”€ build.gradle.kts
โ”œโ”€โ”€ settings.gradle.kts
โ””โ”€โ”€ gradle/

The repository currently separates coins, portfolio, trade, biometric, core, dependency injection, navigation, and theme functionality inside the shared module.


๐Ÿ› ๏ธ Tech Stack

Kotlin Multiplatform

  • Kotlin
  • Kotlin Multiplatform
  • Kotlin Coroutines
  • Kotlinx Serialization
  • Kotlinx DateTime

UI

  • Compose Multiplatform
  • Jetpack Compose
  • Material 3
  • Compose Resources
  • Coil
  • Compose UI Testing

Architecture

  • Clean Architecture
  • MVI
  • ViewModel
  • Unidirectional Data Flow
  • Repository Pattern
  • Use Case Pattern
  • Dependency Injection

Networking

  • Ktor Client
  • Kotlinx Serialization
  • Platform-specific Ktor engines

Local Storage

  • Room for Kotlin Multiplatform
  • Bundled SQLite
  • Database schema management

Dependency Injection

  • Koin
  • Koin Compose
  • Koin ViewModel integration

Security

  • Android BiometricPrompt
  • Multiplatform biometric abstraction
  • Platform-specific authentication implementation

Testing

  • Kotlin Test
  • Kotlin Coroutines Test
  • Turbine
  • AssertK
  • Compose UI Test
  • Android host tests
  • iOS simulator tests

The current shared Gradle configuration includes Compose, Ktor, Room, SQLite, Koin, Coil, biometric support, Kotlin serialization, and the testing libraries listed above.


๐ŸŒ Supported Platforms

Platform Status
Android โœ…
iOS โœ…

The shared module currently configures Android plus iosArm64 and iosSimulatorArm64 targets, while the iOS application lives in the dedicated iosApp module.


๐Ÿงฉ Kotlin Multiplatform Structure

CoinRoutine uses Kotlin Multiplatform to maximize code sharing between Android and iOS.

commonMain

Contains code shared between platforms:

  • Domain models
  • Use cases
  • Repositories
  • ViewModels
  • MVI state
  • MVI intents
  • Networking abstractions
  • Database access
  • Compose UI
  • Navigation
  • Themes
  • Business logic

androidMain

Contains Android-specific implementations such as:

  • Android biometric authentication
  • Android Ktor engine
  • Android-specific integrations
  • Android Compose configuration

iosMain

Contains iOS-specific implementations such as:

  • iOS networking engine
  • iOS platform integrations
  • iOS-specific implementations required by Kotlin/Native

๐Ÿงช Testing Strategy

Testing is an important part of CoinRoutine's architecture.

Unit Tests

Business and presentation logic can be tested independently from the UI.

Examples include:

ViewModel
   โ†“
Fake Repository
   โ†“
Test Data
   โ†“
Expected MVI State

The project uses:

  • kotlin.test
  • kotlinx-coroutines-test
  • Turbine
  • AssertK

UI Tests

Compose UI tests verify important user interactions and rendered states.

Examples:

  • Verify UI elements are displayed
  • Verify text content
  • Verify user interactions
  • Verify loading states
  • Verify error states
  • Verify portfolio/trading flows

Android Tests

Run Android shared tests with:

./gradlew :shared:testAndroidHostTest

iOS Tests

Run iOS simulator tests with:

./gradlew :shared:iosSimulatorArm64Test

These are also the test tasks currently documented by the project.


๐Ÿ”‘ API Configuration

CoinRoutine uses an API key loaded from local.properties during the build.

Create:

local.properties

and add:

API_KEY=your_api_key_here

The project uses BuildKonfig to expose the API key to shared Kotlin code without committing the secret into the repository.

โš ๏ธ Never commit your real API key to Git.


๐Ÿš€ Getting Started

Requirements

  • Android Studio
  • Kotlin Multiplatform support
  • Xcode
  • JDK
  • Android SDK
  • iOS Simulator or physical iOS device
  • CocoaPods if required by the selected dependencies

Clone the Repository

git clone https://github.com/chle0/CoinRoutine.git
cd CoinRoutine

Checkout the Biometric Feature

git checkout feature/biometric

Configure API Key

Create local.properties:

API_KEY=your_api_key_here

Run Android

Build the Android application:

./gradlew :androidApp:assembleDebug

Then install/run the generated APK on an Android device or emulator.

Run iOS

Open:

iosApp/

in Xcode and run the application on an iOS Simulator or physical device.

The repository also documents Xcode as the entry point for running the iOS application.


๐Ÿ” Biometric Authentication

The feature/biometric branch demonstrates adding biometric authentication while keeping the application architecture multiplatform.

The architecture separates the shared authentication contract from platform-specific implementations.

             Shared Code
                 โ”‚
        Biometric Abstraction
           โ”Œโ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”
           โ”‚           โ”‚
           โ–ผ           โ–ผ
       Android        iOS
     BiometricPrompt  Local Auth

This allows the application to keep its business and presentation logic shared while delegating platform-specific authentication to the appropriate platform APIs.


๐ŸŽฏ Project Goals

CoinRoutine was created to demonstrate practical experience with:

  • Kotlin Multiplatform
  • Compose Multiplatform
  • Android + iOS development
  • Clean Architecture
  • MVI architecture
  • Reactive state management
  • Ktor networking
  • Room Multiplatform
  • Koin dependency injection
  • Local persistence
  • Biometric authentication
  • Unit testing
  • Coroutine testing
  • Flow testing
  • Compose UI testing
  • Platform-specific implementations
  • Shared UI and business logic

๐Ÿ“š What This Project Demonstrates

This project is more than a cryptocurrency application. It is a practical example of how a modern mobile application can be structured to share a significant amount of code between Android and iOS while still allowing platform-specific functionality when necessary.

The architecture emphasizes:

Shared Code โ†’ Clean Boundaries โ†’ Predictable State โ†’ Testable Logic โ†’ Platform-specific Integrations


๐Ÿ”ฎ Future Improvements

Potential improvements include:

  • More comprehensive UI test coverage
  • Additional portfolio analytics
  • Advanced cryptocurrency charts
  • More robust offline-first behavior
  • Improved biometric fallback handling
  • CI/CD pipeline
  • Code coverage reporting
  • Automated release builds
  • More comprehensive integration tests

๐Ÿ‘จโ€๐Ÿ’ป Author

Ahmad Raza

Senior Android Developer | Kotlin Multiplatform | Compose Multiplatform


๐Ÿ“„ License

This project is intended primarily as a demonstration and learning project for modern Kotlin Multiplatform and Compose Multiplatform development.

About

CoinRoutine is a cross-platform cryptocurrency app built with Kotlin Multiplatform and Compose Multiplatform, demonstrating modern architecture, shared business logic, networking, local storage, and reactive UI.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors