How datepollsystems/waiterrobot-shared-android works
Main Architectural Components
• Android Application (androidApp directory)
– Built using Jetpack Compose for declarative UI (with Material components, Compose Destinations for navigation, etc.).
– Contains application-specific code (activities, UI components, view models, and integrations such as Stripe and barcode scanning).
– Uses Gradle (kts scripts) for build and configuration.
• Shared Module (shared directory)
– Written in Kotlin with multiplatform support (commonMain, androidMain, iosMain).
– Implements core business logic such as repositories, network API calls (using Ktor), local persistence (Realm for Kotlin), and error logging (Sentry integration).
– Uses dependency injection via Koin (platform- and shared-specific DI modules).
– Follows an MVI/MVVM pattern (Orbit MVI and Moko MVVM for viewModelScope) that underpins state management and view models.
– Provides components for features like authentication, billing, order management, settings, table management, and switch event handling.
• External Services and Integrations:
– Payment processing via Stripe.
– Remote API endpoints through Ktor.
– Sentry for dynamic error logging and performance monitoring.
– CI/CD services (GitHub Actions workflows) that automate testing, release tagging, and deploying to Google Play and the GitHub Package Registry.
Relationships and Interactions
• The Android app (UI layer) communicates mainly with the shared module, calling into its use cases, view models, and repositories.
• The Shared module encapsulates:
– API clients that handle remote calls (secured via Ktor with authentication).
– A local database layer (Realm and other abstractions) for offline and persistent data.
– Domain-specific logic handling events from various features (such as login/authentication, ordering, and billing).
– DI containers to wire dependencies via Koin, tailored for each platform.
• The shared business logic is provided to the iOS application as a Swift Package (via the SPM package published through GitHub Package Registry).
Architectural Patterns and Key Design Principles
• Separation of concerns is evident in the distinct boundary between the Android-specific UI code and the cross-platform shared module.
• The project follows modern mobile architectural patterns such as MVVM/MVI to clearly separate UI, state management, and business logic.
• Use of Dependency Injection (Koin) to promote modularity and testability.
• Emphasis on reusability via Kotlin Multiplatform, enabling the central business logic to be maintained in one place.
• The CI/CD pipelines are designed to automate release processes and ensure that versioning and deployments for Android and shared modules follow a consistent strategy.
Relevant Technologies and Frameworks
• For the Shared Module:
– Kotlin Multiplatform, KMMBridge, Ktor (with content negotiation, client auth, and logging), Realm (Kotlin) for the database, KotlinX Serialization and DateTime.
– Libraries like Koin for dependency injection, Orbit MVI for UI state handling, and Moko MVVM.
• For the Android App:
– Jetpack Compose (UI), Material components, Compose Destinations, and Accompanist Permissions.
– Integration libraries for barcode scanning, Stripe payment processing, and Gradle Play Publisher.
– Android App (with sub-components like UI, ViewModels, and Android-specific utilities).
– Shared Module (with divisions for common, androidMain, iosMain source sets).
– External Services (e.g., Stripe, Sentry, remote API endpoints).
– CI/CD Workflows that handle builds and releases.
– From UI components to shared view models and business logic.
– From the shared module to external API services, and vice versa.
– Platform-specific layers (Android, iOS) versus cross-platform/shared code.
– Build/infrastructure components (CI workflows) versus application-level layers.
• Component is clearly labeled with its purpose, technology choices (e.g., “Jetpack Compose” for Android UI, “Ktor” for network client), and any interconnection details.