# julianclemot/buzzerbeater architecture

> Architecture diagram of the GitHub repository julianclemot/buzzerbeater, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/julianclemot/buzzerbeater
- Repository: https://github.com/julianclemot/buzzerbeater

## Overview

##### Main Components

a. Cross-Platform Components:
- Shared Module (Core Business Logic)
- Bluetooth Communication Layer
- Common Platform Interfaces
- Shared Game Logic

b. Platform-Specific Components:
- Android Application
- UI Layer (Compose)
- Platform-specific Bluetooth Implementation
- Navigation System

- iOS Application
- SwiftUI Interface
- Platform-specific Bluetooth Implementation

##### Architecture Pattern Representation

**┌─────────────────────────────────────────────────────────┐**
- Platform-Specific UI                   │
- ┌───────────────────┐           ┌───────────────────┐  │
- Android App     │           │     iOS App       │  │
- (Compose UI)    │           │    (SwiftUI)      │  │
- ┬──────────┘           └────────┬──────────┘  │

- ┌────────┴──────────┐           ┌───────┴───────────┐  │
- Android-Specific  │           │   iOS-Specific    │  │
- Implementation   │           │  Implementation    │  │
- ┬──────────┘           └────────┬──────────┘  │
- ┼────────────────────────────────┼────────────┘

**┌───────────┴────────────────────────────────┴────────────┐**
- Shared Module                         │
- ┌─────────────────────────────────────────────────┐    │
- Business Logic                      │    │
- ┌─────────────────┐    ┌───────────────────┐   │    │
- Game Logic     │    │ Bluetooth Helper  │   │    │
- ┘    └───────────────────┘   │    │
- ┘    │
- ┘

##### Key Elements to Highlight

- Blue: Platform-specific UI components
- Green: Shared business logic
- Yellow: Platform-specific implementations
- Gray: External interfaces (Bluetooth)

##### Additional Details

- Permission handling for Bluetooth
- Navigation flow in the Android app
- State management (HomeScreenUiState)
- Theme and styling systems for both platforms

##### Technical Stack Indicators

- Kotlin Multiplatform Mobile
- Jetpack Compose for Android UI
- SwiftUI for iOS UI
- Bluetooth Low Energy for device communication

This system design should effectively communicate how the application maintains a shared codebase while providing platform-specific implementations where necessary, particularly for the Bluetooth functionality and UI components.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Platform-Specific UI Layer
    subgraph AndroidUI[Android UI Layer]
        MA[MainActivity]:::android
        HS[HomeScreen]:::android
        VM[HomeViewModel]:::android
        US[HomeScreenUiState]:::android
        TH[Theme System]:::android
        NAV[Navigation System]:::android
        PERM[Bluetooth Permissions]:::android
    end

    subgraph iOSUI[iOS UI Layer]
        IMA[iOSApp]:::ios
        IMV[ContentView]:::ios
    end

    %% Platform-Specific Implementations
    subgraph AndroidImpl[Android Implementation]
        ABI[Bluetooth Implementation]:::android
        API[Platform Implementation]:::android
        BSR[Bluetooth State Receiver]:::android
    end

    subgraph iOSImpl[iOS Implementation]
        IBI[Bluetooth Implementation]:::ios
        IPI[Platform Implementation]:::ios
    end

    %% Shared Module
    subgraph Shared[Shared Module]
        subgraph BL[Business Logic]
            GL[Game Logic]:::shared
            BH[Bluetooth Helper]:::shared
            PI[Platform Interfaces]:::shared
        end
    end

    %% Relationships
    MA --> HS
    HS --> VM
    VM --> US
    MA --> NAV
    MA --> TH
    MA --> PERM
    
    IMA --> IMV

    HS --> ABI
    IMV --> IBI

    ABI --> BH
    IBI --> BH
    
    API --> PI
    IPI --> PI

    BSR --> ABI

    %% Bluetooth Communication
    ABI <--> IBI

    %% Styles
    classDef android fill:#4285F4,color:white
    classDef ios fill:#000000,color:white
    classDef shared fill:#34A853,color:white

    %% Click Events
    click MA "https://github.com/JulianClemot/BuzzerBeater/blob/main/androidApp/src/main/java/com/julian/buzzerbeater/android/MainActivity.kt"
    click HS "https://github.com/JulianClemot/BuzzerBeater/blob/main/androidApp/src/main/java/com/julian/buzzerbeater/android/home/HomeScreen.kt"
    click VM "https://github.com/JulianClemot/BuzzerBeater/blob/main/androidApp/src/main/java/com/julian/buzzerbeater/android/home/HomeViewModel.kt"
    click US "https://github.com/JulianClemot/BuzzerBeater/blob/main/androidApp/src/main/java/com/julian/buzzerbeater/android/home/HomeScreenUiState.kt"
    click NAV "https://github.com/JulianClemot/BuzzerBeater/blob/main/androidApp/src/main/java/com/julian/buzzerbeater/android/routes/AppNavHost.kt"
    click TH "https://github.com/JulianClemot/BuzzerBeater/blob/main/androidApp/src/main/java/com/julian/buzzerbeater/android/theme/Theme.kt"
    click PERM "https://github.com/JulianClemot/BuzzerBeater/blob/main/androidApp/src/main/java/com/julian/buzzerbeater/android/composables/BluetoothPermissionCheck.kt"
    click IMA "https://github.com/JulianClemot/BuzzerBeater/blob/main/iosApp/iosApp/iOSApp.swift"
    click IMV "https://github.com/JulianClemot/BuzzerBeater/blob/main/iosApp/iosApp/ContentView.swift"
    click ABI "https://github.com/JulianClemot/BuzzerBeater/blob/main/shared/src/androidMain/kotlin/com/julian/buzzerbeater/BluetoothHelper.kt"
    click IBI "https://github.com/JulianClemot/BuzzerBeater/blob/main/shared/src/iosMain/kotlin/com/julian/buzzerbeater/BluetoothHelper.kt"
    click API "https://github.com/JulianClemot/BuzzerBeater/blob/main/shared/src/androidMain/kotlin/com/julian/buzzerbeater/Platform.kt"
    click IPI "https://github.com/JulianClemot/BuzzerBeater/blob/main/shared/src/iosMain/kotlin/com/julian/buzzerbeater/Platform.kt"
    click BH "https://github.com/JulianClemot/BuzzerBeater/blob/main/shared/src/commonMain/kotlin/com/julian/buzzerbeater/BluetoothHelper.kt"
    click PI "https://github.com/JulianClemot/BuzzerBeater/blob/main/shared/src/commonMain/kotlin/com/julian/buzzerbeater/Platform.kt"
    click BSR "https://github.com/JulianClemot/BuzzerBeater/blob/main/shared/src/androidMain/kotlin/com/julian/buzzerbeater/BluetoothStateReceiver.kt"
    click Shared "https://github.com/JulianClemot/BuzzerBeater/tree/main/shared/src/commonMain/kotlin/com/julian/buzzerbeater/"
```
