How c4lopsitta/mir-controller works
Architectural Components
• Shared Module (composeApp/commonMain): This is where all platform-agnostic code lives. It includes:
• Core application logic such as API definitions (MirApi), business models, view models, and UI components.
• Shared UI resources (Compose code, Material 3 components) that can be rendered on multiple platforms.
• Platform-Specific Modules (composeApp/androidMain, iosMain, desktopMain):
• Android: Contains Android-specific entry points (e.g., MainActivity.kt, AndroidManifest.xml) and implementations (Platform.android.kt).
• iOS: Has the iOS-specific portion of the Kotlin code (Platform.ios.kt, MainViewController.kt) along with a separate native iOS project (iosApp) set up with SwiftUI.
• Desktop: Contains JVM-specific code (Platform.jvm.kt, main.kt) for desktop deployment.
• Build and Configuration: Gradle build scripts (build.gradle.kts, settings.gradle.kts, gradle configuration files) and environment-specific configuration (e.g., iosApp/Configuration/Config.xcconfig for iOS) which manage the build process and integration for different platforms.
• External Libraries and Frameworks:
• Kotlin Multiplatform framework for sharing code.
• Jetpack Compose leveraging Material 3 for UI.
• Platform-specific libraries (Android SDK, iOS native frameworks, etc.)
Relationships & Interactions
• The Shared Module acts as the core of the application where business logic and UI definitions are abstracted.
• Each Platform-Specific Module consumes the shared logic but provides its own UI entry points and adaptations:
• On Android, the data flow starts at MainActivity (and other Android-specific components) then interacts with common view models and UI components.
• On iOS, the native Swift app (iosApp) initializes the shared Kotlin code via bridging code (like App.ios.kt and MainViewController.kt) and handles platform-specific rendering.
• The Desktop module has its own main entry (main.kt) that invokes the shared application logic.
• Build system dependencies (Gradle) compile and bundle the modules accordingly for each target platform.
• External APIs or internal routing/flow systems (defined in definitions/Routes.kt and api/MirApi.kt) direct how different modules interact.
Architectural Patterns & Design Principles to Highlight
• Code Reusability & Separation of Concerns: Emphasize how the commonMain directory isolates shared logic, while platform-specific directories only contain the necessary adaptation code.
• Multiplatform Abstraction: Showcase the use of platform-specific implementations (e.g., Platform.android.kt, Platform.ios.kt, Platform.jvm.kt) that abstract each environment’s peculiarities from the common code.
• Modularization: Different layers of the app are neatly separated (UI components, API abstraction, data models, view models) to maintain clarity and ease future enhancements.