How researchhub24/research-hub-kmp works
Project Type and Purpose
• This is a Kotlin Multiplatform (MPP) client application using Compose Multiplatform.
• It targets two platforms: Android and Desktop.
• It provides a front-end for a “ResearchHub” service, featuring login/verification, forum browsing, student/teacher dashboards, notifications, etc.
File Structure Analysis
• Top-level: build scripts (Gradle Kotlin DSL), CI workflows, documentation.
• /composeApp/src/commonMain:
• Core business logic (use cases, models).
• Shared Compose UI components (buttons, screens, theming).
• Networking client interfaces (Ktor).
• Dependency-injection bootstrap (KoinInitializer).
• /composeApp/src/androidMain & desktopMain:
• Platform-specific implementations: HTTP client, preferences, notifications.
• Entry points (MainActivity.kt, main.kt).
• Platform variants of Compose UI where needed.
• Modules reflect a Clean/MVVM architecture:
• UI layer (Compose + ViewModels)
• Domain/use-case layer
• Data layer (Ktor client)
• Platform services (Auth, Prefs, Notifications)
Key Architecture Insights from README
• commonMain is 100% shared.
• Other source sets provide platform bindings.
• Uses Kotlin MPP patterns: expect/actual for platform abstractions.
• Koin is used for DI across all modules.
1. UI Layer (Compose Multiplatform)
• Shared screens & components (commonMain/ui/compose)
• Platform-specific UI tweaks (androidMain/ui, desktopMain/ui)
2. Presentation Layer
• ViewModels & Event Handlers (commonMain/ui/…ViewModel.kt)
3. Domain Layer (Use Cases)
• ApplicationUseCases, ForumUseCases, UserUseCases, etc.
4. Data/Network Layer
• ResearchHubClient interface & implementation
• Models for API payloads
5. Dependency Injection
• Koin modules (CommanModule.kt, Modules.kt)
6. Platform Services
• HTTP client factories (createHttpClient.android/desktop)
• Preferences (PrefManagerImp.android/desktop)
• NotificationService (Android)
• GoogleAuthUiClient (Android)
7. External Systems
• ResearchHub Backend API (REST over HTTP)
• Google Auth SDK
• OS notification system
• UI → ViewModel (user events)
• ViewModel ↔ Use Cases (invoke domain logic)
• Use Cases → ResearchHubClient (network calls)
• ResearchHubClient → External API (request/response)
• Responses propagate back through layers to UI
• DI container wires implementations to interfaces
• Platform Service calls (Auth, Prefs, Notifications) injected into Use Cases or ViewModels
c. Architectural Patterns & Principles
• MVVM: View (Compose) + ViewModel + Model (domain/data)
• Clean separation: UI, domain, data
• Dependency inversion via Koin
• Expect/Actual for platform abstractions
d. Key Technologies & Frameworks
• Kotlin Multiplatform (commonMain, androidMain, desktopMain)
• Compose Multiplatform for UI
• Koin for dependency injection
• Ktor client for REST calls
• GoogleAuthUiClient for OAuth
• Platform-specific DataStore/PrefManager for persistent storage