How ryanw-mobile/octometer works
Main Components of the System
• Shared ComposeApp Module – This is the core of the application where code is organized for multiplatform targets. Within ComposeApp, you have:
• commonMain: Contains shared business logic, UI components (via Compose), domain models, use cases, repository interfaces, and common utilities.
• androidMain, desktopMain, iosMain: Platform-specific code that connects to native APIs while reusing most of the shared common logic.
• Additional layers such as “data” (repositories, network data sources, local databases via Room/SQLite, and preferences via Multiplatform Settings) and “ui” (components, navigation, view models).
• BaselineProfile Module – A dedicated module (found under “baselineprofile”) to generate Android baseline profiles for improving startup performance. This module likely helps in benchmarking and optimizing when running on Android.
• Platform-specific Modules:
• iosApp: Contains the native iOS wrapper (with Swift entry-points, Assets, Xcode project configuration) that bootstraps the shared Kotlin code.
• Desktop (and any additional wrappers): The desktop target under desktopMain provides the JVM application entry.
• External Services / Dependencies – These include:
• Network Layer: Uses Ktor for REST calls, Apollo GraphQL for GraphQL endpoints, and corresponding DTOs for interfacing with Octopus Energy APIs.
• Local Storage: Room database for Android (and multiplatform SQLite implementations) and Multiplatform Preferences.
• Dependency Injection: Handled by Koin and/or DI modules in the “di” packages.
• Logging, testing, and additional libraries (e.g., Kermit, KoalaPlot, Material3 Window Size Class, etc.).
Architectural Patterns and Relationships
• Layered Architecture:
• Presentation Layer: Compose UI components, Navigation (in ui/navigation) and view models.
• Domain Layer: Use cases, business logic, and abstract repository interfaces defined in the “domain” folders.
• Data Layer: Concrete implementations in the “data” source directories (network, local database, preferences) which interact with external APIs and caching/local persistence.
• Clear Separation between Platform-specific and Shared Code:
• Demonstrate how platform-specific code (androidMain, iosMain, desktopMain) extends or calls shared functionalities from commonMain.
• Integration with External APIs: