A comprehensive Kotlin Multiplatform E-Commerce Application built with Compose Multiplatform, targeting Android, iOS, Desktop, and Web platforms.
This project follows Clean Architecture principles with clear separation of concerns:
- Entities: Core business models (
Product,Cart,User,Category, etc.) - Use Cases: Business logic operations (Login, Product fetching, Cart management)
- Repositories: Abstract interfaces for data access
- Utils: Common utilities like
Resultwrapper for error handling
- Remote API: HTTP client implementations using Ktor
- Local Storage: Platform-specific secure storage implementations
- Repository Implementations: Concrete implementations of domain repositories
- DTOs & Converters: Data transfer objects and mapping logic
- Screens: Compose UI screens for different features
- ViewModels: State management using Compose ViewModel
- Navigation: Type-safe navigation using Compose Navigation
- UI Components: Reusable UI components
- Native Android app with Material Design 3
- Uses Android-specific dependencies like
ktor-client-android - Secure storage via
androidx.security.crypto
- Native iOS app framework
- Uses Darwin-specific Ktor client
- Platform-specific secure storage implementation
- Desktop application using Compose Desktop
- Supports Windows (MSI), macOS (DMG), and Linux (DEB) distributions
- Uses Java-based Ktor client
- Web application compiled to WebAssembly
- Modern web deployment with Kotlin/Wasm
- Accessible via browser
- Kotlin Multiplatform (2.2.0): Cross-platform development
- Compose Multiplatform (1.8.2): Declarative UI framework
- Compose Hot Reload (1.0.0-alpha11): Development productivity
- Ktor Client (3.0.3): HTTP client for API communication
ktor-client-core: Core HTTP functionalityktor-client-content-negotiation: JSON serializationktor-serialization-kotlinx-json: Kotlinx serializationktor-client-logging: Request/response logging- Platform-specific engines: Android, Darwin, Java
- Kotlinx Serialization (1.7.3): JSON serialization
- Androidx Lifecycle (2.9.1): ViewModel and lifecycle management
- Androidx Navigation (2.9.0-beta03): Type-safe navigation
- Kotlinx Coroutines (1.10.2): Asynchronous programming
- Koin (4.1.0): Lightweight dependency injection
koin-core: Core DI functionalitykoin-compose: Compose integrationkoin-android: Android-specific features
- Coil (3.0.x): Async image loading
coil-compose: Compose integrationcoil-network-ktor3: Ktor networkingcoil-svg: SVG support
- Androidx Security Crypto (1.1.0-alpha06): Encrypted storage for Android
- Platform-specific secure storage: Custom implementations per platform
- JUnit (4.13.2): Unit testing framework
- Mockito (5.14.2): Mocking framework
- Turbine (1.2.0): Flow testing utilities
- Kotlinx Coroutines Test (1.10.2): Coroutine testing
- Android Gradle Plugin (8.7.3)
- Kotlin Gradle Plugin (2.2.0)
- Compose Compiler Plugin: Integrated with Kotlin compiler
- User login with session management
- Secure token storage across platforms
- Session validation and auto-logout
- Product listing with pagination
- Category-based filtering
- Product search functionality
- Detailed product views with images and reviews
- Add/remove items from cart
- Quantity management
- Cart persistence across sessions
- Real-time cart updates
- Type-safe navigation between screens
- Deep linking support
- Back stack management
- Material Design 3 theming
- Responsive layouts for different screen sizes
- Loading states and error handling
- SVG icon support
KMP-ECommerce/
โโโ composeApp/ # Shared Compose Multiplatform module
โ โโโ src/
โ โ โโโ commonMain/ # Shared code for all platforms
โ โ โ โโโ kotlin/azl/kmp/ecommerce/
โ โ โ โ โโโ data/ # Data layer
โ โ โ โ โ โโโ local/ # Local storage implementations
โ โ โ โ โ โโโ remote/ # API services and DTOs
โ โ โ โ โ โโโ repository/ # Repository implementations
โ โ โ โ โโโ domain/ # Domain layer
โ โ โ โ โ โโโ entity/ # Business entities
โ โ โ โ โ โโโ repository/ # Repository interfaces
โ โ โ โ โ โโโ usecase/ # Business use cases
โ โ โ โ โ โโโ util/ # Domain utilities
โ โ โ โ โโโ presentation/ # Presentation layer
โ โ โ โ โ โโโ cart/ # Cart feature
โ โ โ โ โ โโโ dashboard/ # Home/Dashboard
โ โ โ โ โ โโโ login/ # Authentication
โ โ โ โ โ โโโ navigation/ # Navigation logic
โ โ โ โ โ โโโ productdetail/ # Product details
โ โ โ โ โ โโโ search/ # Product search
โ โ โ โ โ โโโ splash/ # Splash screen
โ โ โ โ โโโ di/ # Dependency injection
โ โ โ โโโ composeResources/ # Shared resources
โ โ โ โโโ drawable/ # Vector drawables
โ โ โ โโโ files/ # SVG icons
โ โ โโโ androidMain/ # Android-specific code
โ โ โโโ iosMain/ # iOS-specific code
โ โ โโโ desktopMain/ # Desktop-specific code
โ โ โโโ wasmJsMain/ # Web-specific code
โ โโโ build.gradle.kts # Module build configuration
โโโ iosApp/ # iOS application wrapper
โโโ gradle/ # Gradle configuration
โ โโโ libs.versions.toml # Version catalog
โโโ build.gradle.kts # Root build configuration
โโโ settings.gradle.kts # Project settings
Centralized dependency management with version catalogs for:
- Platform versions (Android SDK levels, compilation targets)
- Library versions (Ktor, Compose, Koin, etc.)
- Plugin versions (AGP, Kotlin, etc.)
- Android:
minSdk 24,targetSdk 35,compileSdk 35 - iOS:
iosX64,iosArm64,iosSimulatorArm64 - Desktop: JVM target with Java 11 compatibility
- Web: WebAssembly with modern browser support
- Compose Compiler: Integrated Kotlin compiler plugin
- Kotlin Serialization: JSON serialization plugin
- Hot Reload: Development productivity enhancement
- Resource Management: Compose resources for shared assets
The app integrates with DummyJSON for:
- Authentication:
/auth/login - Products:
/products,/products/categories,/products/search - Cart Management:
/carts,/carts/user/{id}
- Content Negotiation: Automatic JSON serialization/deserialization
- Logging: Request/response logging for debugging
- Platform Engines: Optimized HTTP engines per platform
- Error Handling: Comprehensive error handling with Result wrapper
- Android: EncryptedSharedPreferences with AES encryption
- iOS: Keychain Services integration
- Desktop: Platform-specific secure storage
- Web: Secure browser storage APIs
- Certificate Pinning: Custom certificate validation
- HTTPS Enforcement: Secure communication only
- Network Security Config: Android network security policies
- Domain Layer: Use case testing with mocked repositories
- Repository Testing: API integration testing with mocked services
- ViewModel Testing: State management and business logic testing
- Mockito: Mocking framework for dependencies
- Turbine: Flow testing for reactive streams
- Coroutine Testing: Async operation testing
./gradlew :composeApp:assembleDebugOpen iosApp/iosApp.xcodeproj in Xcode and run
./gradlew :composeApp:run./gradlew :composeApp:wasmJsBrowserDevelopmentRunPurpose: App initialization and session validation
-
Components:
SplashScreen.kt: UI with app logo and loading indicatorSplashViewModel.kt: Session validation logicSplashUiState.kt: Loading, navigation, and user statesSplashNavigation.kt: Navigation setup
-
Key Features:
- Session Check: Validates existing user sessions on app start
- Auto Navigation: Routes to Dashboard (valid session) or Login (no session)
- Loading States: Shows progress indicator during session validation
- Error Handling: Gracefully handles session validation failures
-
Flow: App Start โ Session Check โ Navigate to Login/Dashboard
Purpose: User authentication and session creation
-
Components:
LoginScreen.kt: Material Design 3 login formLoginViewModel.kt: Authentication logic with validationLoginUiState.kt: Form state, loading, and error managementLoginNavigation.kt: Navigation integration
-
Key Features:
- Form Validation: Email and password input validation
- Secure Authentication: Integration with DummyJSON API
- Session Creation: Establishes user session after successful login
- Error Handling: Displays authentication errors to users
- Loading States: Shows progress during login process
-
Flow: Enter Credentials โ Validate โ Create Session โ Navigate to Dashboard
Purpose: Main product catalog with categories and navigation
-
Components:
DashboardScreen.kt: Main product listing interfaceDashboardViewModel.kt: Complex state management for products and categoriesDashboardUiState.kt: Categories, products, pagination, and user stateDashboardNavigation.kt: Navigation hubcomponents/CategoryTabBarSimple.kt: Category selection tabscomponents/ProductItem.kt: Individual product card component
-
Key Features:
- Category Filtering: "All" + dynamic categories from API
- Product Grid: Responsive grid layout with product cards
- Pagination: Infinite scroll with load more functionality
- Search Integration: Quick access to search functionality
- Cart Badge: Real-time cart item count display
- User Session: Displays current user information
- Logout Functionality: Session termination
-
Flow: Load Categories โ Display Products โ Filter by Category โ Navigate to Details/Search/Cart
Purpose: Product search with real-time results
-
Components:
SearchProductScreen.kt: Search interface with resultsSearchProductViewModel.kt: Search logic and state managementSearchProductUiState.kt: Search query, results, and paginationSearchProductNavigation.kt: Search navigation setup
-
Key Features:
- Real-time Search: Dynamic search as user types
- Paginated Results: Infinite scroll for search results
- Search History: Maintains search state across navigation
- Empty States: Handles no results scenarios
- Loading States: Shows search progress indicators
- Product Navigation: Direct navigation to product details
-
Flow: Enter Search Query โ API Search โ Display Results โ Navigate to Product Details
Purpose: Detailed product information and cart operations
-
Components:
ProductDetailScreen.kt: Comprehensive product displayProductDetailViewModel.kt: Product loading and cart operationsProductDetailUiState.kt: Product data, cart operations, and loading statesProductDetailsNavigation.kt: Detail screen navigationcomponents/ProductImageSlider.kt: Image carousel componentcomponents/MultiImageViewer.kt: Advanced image viewing
-
Key Features:
- Image Gallery: Multiple product images with slider
- Product Information: Price, description, ratings, reviews
- Quantity Selection: Adjustable quantity picker
- Add to Cart: Direct cart integration with feedback
- Stock Information: Availability and stock levels
- Product Reviews: Customer reviews and ratings display
- Related Information: Shipping, warranty, return policy
-
Flow: Load Product โ Display Details โ Select Quantity โ Add to Cart โ Success Feedback
Purpose: Shopping cart management and checkout preparation
-
Components:
CartScreen.kt: Cart items list and summaryCartViewModel.kt: Cart operations and state managementCartUiState.kt: Cart data, totals, and operation statesCartNavigation.kt: Cart navigation setupcomponents/CartItemComponent.kt: Individual cart item with controlscomponents/CartSummaryComponent.kt: Order summary and totals
-
Key Features:
- Cart Items List: Displays all products in cart
- Quantity Management: Increase/decrease item quantities
- Item Removal: Remove products from cart
- Price Calculations: Subtotal, discounts, and total calculations
- Empty Cart State: Handles empty cart scenarios
- Checkout Navigation: Proceeds to checkout process
- Real-time Updates: Instant cart updates across the app
-
Flow: View Cart Items โ Modify Quantities โ Remove Items โ View Totals โ Proceed to Checkout
PaginationState.kt: Centralized pagination logic- Features: Load more, refresh, error handling, page management
- Usage: Dashboard and Search screens for infinite scrolling
- Type-Safe Navigation: Using Compose Navigation with serializable destinations
- Deep Linking: Support for direct navigation to specific screens
- Back Stack Management: Proper navigation history handling
- Unidirectional Data Flow: ViewModel โ UiState โ UI
- Reactive Updates: StateFlow for reactive state management
- Error Handling: Consistent error state management across screens
- Koin Integration: Lightweight DI for ViewModels and Use Cases
- Scoped ViewModels: Proper lifecycle management
- Platform-Specific Implementations: Different implementations per platform
- Session Management: Persistent login across app restarts
- Product Browsing: Category filtering and pagination
- Search: Real-time product search with pagination
- Cart Operations: Add, remove, update quantities with real-time sync
- Image Loading: Async image loading with caching and SVG support
- Error Handling: Comprehensive error states and retry mechanisms
- Offline Handling: Graceful degradation when network is unavailable
- Loading States: Skeleton loading and progress indicators throughout
- Unidirectional Data Flow: Clear state management pattern
- Compose State: Reactive UI updates
- Lifecycle Awareness: Proper state preservation
- Error States: Comprehensive error handling
- Type-Safe Navigation: Compile-time route validation
- Deep Linking: URL-based navigation support
- Back Stack Management: Proper navigation history
- Dynamic Theming: Adaptive color schemes
- Component Library: Consistent UI components
- Responsive Design: Multi-screen size support
- Product Cards: Reusable product display components
- Loading States: Skeleton loading and progress indicators
- Error States: User-friendly error messages
- Coil Integration: Efficient image caching and loading
- SVG Support: Vector graphics for scalable icons
- Memory Management: Optimized image memory usage
- Request Caching: HTTP response caching
- Pagination: Efficient data loading
- Connection Pooling: Optimized network connections
- Order Management: Complete checkout and order tracking
- User Profiles: Enhanced user account management
- Offline Support: Local data caching and sync
- Push Notifications: Order updates and promotions
- Payment Integration: Multiple payment gateway support
- Database Integration: Local SQLite database with Room
- Advanced Testing: UI testing and integration tests
- Performance Monitoring: Analytics and crash reporting
- CI/CD Pipeline: Automated build and deployment
We appreciate feedback on Compose/Web and Kotlin/Wasm in the public Slack channel #compose-web.
If you face any issues, please report them on YouTrack.
Built with โค๏ธ using Kotlin Multiplatform and Compose Multiplatform