# researchhub24/research-hub-kmp architecture

> Architecture diagram of the GitHub repository researchhub24/research-hub-kmp, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-08-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/researchhub24/research-hub-kmp
- Repository: https://github.com/researchhub24/research-hub-kmp

## Overview

##### 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

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Common Module"
        UI_Shared["UI Layer (Compose)"]:::common
        Theme["UI Theme"]:::common
        ViewModels["Presentation Layer – ViewModels"]:::common
        UseCases["Domain Layer – Use Cases"]:::common
        ResearchHubClient["ResearchHubClient (interface)"]:::common
        ResearchHubClientImp["ResearchHubClientImp"]:::common
        API_Models["API Models"]:::common
        NotificationModel["NotificationModel"]:::common
        createHttpClient_common["createHttpClient (expect)"]:::common
        DI_Shared["Koin Modules (CommanModule)"]:::common
        KoinInitializer_common["KoinInitializer"]:::common
        Utils["Utilities"]:::common
    end

    subgraph "Android Specific"    
        UI_Android["UI Layer (Android)"]:::android
        Android_Modules["Android DI (Modules.kt)"]:::android
        KoinInitializer_android["KoinInitializer.android"]:::android
        createHttpClient_android["createHttpClient.android"]:::android
        PrefManagerImp_android["PrefManagerImp.android"]:::android
        NotificationService["NotificationService"]:::android
        GoogleAuthUiClient["GoogleAuthUiClient"]:::android
        MainActivity["MainActivity"]:::android
    end

    subgraph "Desktop Specific"
        UI_Desktop["UI Layer (Desktop)"]:::desktop
        Desktop_Module["Desktop DI (Module.kt)"]:::desktop
        KoinInitializer_desktop["KoinInitializer.desktop"]:::desktop
        createHttpClient_desktop["createHttpClient.desktop"]:::desktop
        createDataStore["createDataStore"]:::desktop
        PrefManagerImp_desktop["PrefManagerImp.desktop"]:::desktop
        DesktopMain["main.kt"]:::desktop
    end

    subgraph "External Systems"
        ExternalAPI["ResearchHub Backend API"]:::external
        GoogleAuthSDK["Google Auth SDK"]:::external
        OSNotification["OS Notification System"]:::external
    end

    UI_Shared -->|"renders"| ViewModels
    UI_Android -->|"renders"| ViewModels
    UI_Desktop -->|"renders"| ViewModels
    ViewModels -->|"calls"| UseCases
    UseCases -->|"uses client"| ResearchHubClient
    ResearchHubClientImp -->|"implements"| ResearchHubClient
    ResearchHubClientImp -->|"calls"| ExternalAPI
    ExternalAPI -->|"response"| ResearchHubClientImp
    UseCases -->|"injects"| PrefManagerImp_android
    UseCases -->|"injects"| PrefManagerImp_desktop
    ViewModels -->|"calls"| NotificationService
    NotificationService -->|"uses"| OSNotification
    ViewModels -->|"uses"| GoogleAuthUiClient
    GoogleAuthUiClient -->|"SDK calls"| GoogleAuthSDK
    createHttpClient_common -->|"bound by DI to"| createHttpClient_android
    createHttpClient_common -->|"bound by DI to"| createHttpClient_desktop
    DI_Shared -->|"wires"| ResearchHubClientImp
    DI_Shared -->|"wires"| UseCases
    DI_Shared -->|"wires"| ViewModels
    Android_Modules -->|"imports"| DI_Shared
    Desktop_Module -->|"imports"| DI_Shared
    KoinInitializer_common -->|"initializes"| DI_Shared
    KoinInitializer_android -->|"initializes"| Android_Modules
    KoinInitializer_desktop -->|"initializes"| Desktop_Module
    MainActivity -->|"starts"| KoinInitializer_android
    DesktopMain -->|"starts"| KoinInitializer_desktop

    classDef common fill:#cbd5e1,stroke:#333,stroke-width:1px
    classDef android fill:#a7f3d0,stroke:#333,stroke-width:1px
    classDef desktop fill:#fed7aa,stroke:#333,stroke-width:1px
    classDef external fill:#e2e8f0,stroke:#333,stroke-width:1px

    click UI_Shared "https://github.com/researchhub24/research-hub-kmp/tree/master/composeApp/src/commonMain/kotlin/com/atech/research/ui/compose"
    click Theme "https://github.com/researchhub24/research-hub-kmp/blob/master/composeApp/src/commonMain/kotlin/com/atech/research/ui/theme/Theme.kt"
    click UI_Android "https://github.com/researchhub24/research-hub-kmp/tree/master/composeApp/src/androidMain/kotlin/com/atech/research/ui/compose"
    click UI_Desktop "https://github.com/researchhub24/research-hub-kmp/tree/master/composeApp/src/desktopMain/kotlin/com/atech/research/ui/compose"
    click ViewModels "https://github.com/researchhub24/research-hub-kmp/blob/master/composeApp/src/commonMain/kotlin/com/atech/research/ui/compose/**/**/*ViewModel.kt"
    click UseCases "https://github.com/researchhub24/research-hub-kmp/tree/master/composeApp/src/commonMain/kotlin/com/atech/research/core/usecase"
    click ResearchHubClient "https://github.com/researchhub24/research-hub-kmp/blob/master/composeApp/src/commonMain/kotlin/com/atech/research/core/ktor/ResearchHubClient.kt"
    click ResearchHubClientImp "https://github.com/researchhub24/research-hub-kmp/blob/master/composeApp/src/commonMain/kotlin/com/atech/research/core/ktor/ResearchHubClientImp.kt"
    click API_Models "https://github.com/researchhub24/research-hub-kmp/tree/master/composeApp/src/commonMain/kotlin/com/atech/research/core/ktor/model"
    click createHttpClient_common "https://github.com/researchhub24/research-hub-kmp/blob/master/composeApp/src/commonMain/kotlin/com/atech/research/core/ktor/createHttpClient.kt"
    click createHttpClient_android "https://github.com/researchhub24/research-hub-kmp/blob/master/composeApp/src/androidMain/kotlin/com/atech/research/core/ktor/createHttpClient.android.kt"
    click createHttpClient_desktop "https://github.com/researchhub24/research-hub-kmp/blob/master/composeApp/src/desktopMain/kotlin/com/atech/research/core/ktor/createHttpClient.desktop.kt"
    click DI_Shared "https://github.com/researchhub24/research-hub-kmp/blob/master/composeApp/src/commonMain/kotlin/com/atech/research/module/CommanModule.kt"
    click KoinInitializer_common "https://github.com/researchhub24/research-hub-kmp/blob/master/composeApp/src/commonMain/kotlin/com/atech/research/module/KoinInitializer.kt"
    click Android_Modules "https://github.com/researchhub24/research-hub-kmp/blob/master/composeApp/src/androidMain/kotlin/com/atech/research/module/Modules.kt"
    click KoinInitializer_android "https://github.com/researchhub24/research-hub-kmp/blob/master/composeApp/src/androidMain/kotlin/com/atech/research/module/KoinInitializer.android.kt"
    click Desktop_Module "https://github.com/researchhub24/research-hub-kmp/blob/master/composeApp/src/desktopMain/kotlin/com/atech/research/module/Module.kt"
    click KoinInitializer_desktop "https://github.com/researchhub24/research-hub-kmp/blob/master/composeApp/src/desktopMain/kotlin/com/atech/research/module/KoinInitializer.desktop.kt"
    click PrefManagerImp_android "https://github.com/researchhub24/research-hub-kmp/blob/master/composeApp/src/androidMain/kotlin/com/atech/research/utils/PrefManagerImp.android.kt"
    click createDataStore "https://github.com/researchhub24/research-hub-kmp/blob/master/composeApp/src/desktopMain/kotlin/com/atech/research/core/pref/createDataStore.kt"
    click PrefManagerImp_desktop "https://github.com/researchhub24/research-hub-kmp/blob/master/composeApp/src/desktopMain/kotlin/com/atech/research/utils/PrefManagerImp.desktop.kt"
    click NotificationService "https://github.com/researchhub24/research-hub-kmp/blob/master/composeApp/src/androidMain/kotlin/com/atech/research/notification/NotificationService.kt"
    click GoogleAuthUiClient "https://github.com/researchhub24/research-hub-kmp/blob/master/composeApp/src/androidMain/kotlin/com/atech/research/ui/compose/login/compose/util/GoogleAuthUiClient.kt"
    click NotificationModel "https://github.com/researchhub24/research-hub-kmp/blob/master/composeApp/src/commonMain/kotlin/com/atech/research/core/notification/NotificationModel.kt"
    click Utils "https://github.com/researchhub24/research-hub-kmp/tree/master/composeApp/src/commonMain/kotlin/com/atech/research/utils/**/*"
    click MainActivity "https://github.com/researchhub24/research-hub-kmp/blob/master/composeApp/src/androidMain/kotlin/com/atech/research/MainActivity.kt"
    click DesktopMain "https://github.com/researchhub24/research-hub-kmp/blob/master/composeApp/src/desktopMain/kotlin/com/atech/research/main.kt"
```
