# splendo/kaluga architecture

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

- Interactive diagram: https://gitdiagram.com/splendo/kaluga
- Repository: https://github.com/splendo/kaluga

## Overview

##### Main Components

a. Core Architecture Layer:
- Base Module (foundation layer)
- Architecture Module (MVVM implementation)
- Resources Module
- Logging Module

b. Feature Modules Layer:
- UI Components (Alerts, HUD, Keyboard)
- Device Features (Bluetooth, Location, Media)
- System Services (Network, Battery)
- Permissions Management

c. Testing Infrastructure Layer:
- Test Utils Modules
- Mock Implementations

##### Relationships and Flow

- Platform-specific implementations (Android/iOS) branching from common modules
- Integration points with external systems (Firebase, SQLDelight)
- Permission management flow
- MVVM architecture pattern implementation

##### Detailed Components

a. Base Layer:
**[Base Module]**
- Threading
- Flow Management
- Localization
- Core Utilities

b. Architecture Layer:
**[Architecture Module]**
- MVVM Implementation
- Lifecycle Management
- Navigation
- State Management

c. Feature Modules:
**[Feature Modules]**
- UI Components
- Alerts
- HUD
- Keyboard
- Device Features
- Bluetooth
- Location
- Media
- System Services
- Network
- Battery

##### Implementation Details

- Coroutines and Flow usage throughout the system
- Platform-specific implementations using Kotlin Multiplatform
- Integration with Compose and SwiftUI
- Test utilities and mock implementations
- Permission management system

##### Notes

Annotations for:
- Kotlin Multiplatform specific features
- Platform-specific considerations
- Integration points with native UI frameworks
- Testing approach
- Permission handling

Remember to emphasize:
- The cold streams approach using Flow
- Cross-platform nature of the implementation
- Modular architecture allowing selective module usage
- Integration with native UI frameworks
- Comprehensive testing infrastructure

This system design will help developers understand both the high-level architecture and the detailed implementation patterns used throughout Kaluga.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Style Definitions
    classDef core fill:#b3d1ff,stroke:#333
    classDef feature fill:#90EE90,stroke:#333
    classDef platform fill:#FFB366,stroke:#333
    classDef testing fill:#DDA0DD,stroke:#333
    classDef external fill:#D3D3D3,stroke:#333
    
    subgraph Core["Core Architecture Layer"]
        Base["Base Module"]:::core
        Arch["Architecture Module"]:::core
        Resources["Resources Module"]:::core
        Logging["Logging Module"]:::core
    end

    subgraph ArchDetails["Architecture Implementation"]
        MVVM["MVVM Implementation"]:::core
        Lifecycle["Lifecycle Management"]:::core
        Navigation["Navigation System"]:::core
        State["State Management"]:::core
    end

    subgraph Features["Feature Modules Layer"]
        subgraph UI["UI Components"]
            Alerts["Alerts"]:::feature
            HUD["HUD"]:::feature
            Keyboard["Keyboard"]:::feature
        end

        subgraph Device["Device Features"]
            BT["Bluetooth"]:::feature
            Loc["Location"]:::feature
            Media["Media"]:::feature
        end

        subgraph System["System Services"]
            Network["Network"]:::feature
            Battery["Battery"]:::feature
        end
    end

    subgraph Platform["Platform-Specific"]
        Android["Android Implementation"]:::platform
        iOS["iOS Implementation"]:::platform
        ComposeUI["Compose UI Support"]:::platform
        SwiftUI["SwiftUI Support"]:::platform
    end

    subgraph Testing["Testing Infrastructure"]
        TestUtils["Test Utils"]:::testing
        Mocks["Mock Implementations"]:::testing
    end

    %% Relationships
    Base --> Arch
    Base --> Resources
    Base --> Logging
    
    Arch --> MVVM
    Arch --> Lifecycle
    Arch --> Navigation
    Arch --> State

    Base --> Features
    Resources --> UI
    
    Features --> Platform
    
    %% Click Events
    click Base "https://github.com/splendo/kaluga/tree/develop/base"
    click Arch "https://github.com/splendo/kaluga/tree/develop/architecture"
    click Resources "https://github.com/splendo/kaluga/tree/develop/resources"
    click Logging "https://github.com/splendo/kaluga/tree/develop/logging"
    click Alerts "https://github.com/splendo/kaluga/tree/develop/alerts"
    click HUD "https://github.com/splendo/kaluga/tree/develop/hud"
    click Keyboard "https://github.com/splendo/kaluga/tree/develop/keyboard"
    click BT "https://github.com/splendo/kaluga/tree/develop/bluetooth"
    click Loc "https://github.com/splendo/kaluga/tree/develop/location"
    click Media "https://github.com/splendo/kaluga/tree/develop/media"
    click System "https://github.com/splendo/kaluga/tree/develop/system"
    click TestUtils "https://github.com/splendo/kaluga/tree/develop/test-utils-base"
    click ComposeUI "https://github.com/splendo/kaluga/tree/develop/resources-compose"
    click Navigation "https://github.com/splendo/kaluga/tree/develop/architecture/src/commonMain/kotlin/navigation"
    click State "https://github.com/splendo/kaluga/tree/develop/architecture/src/commonMain/kotlin/observable"
    click Lifecycle "https://github.com/splendo/kaluga/tree/develop/architecture/src/commonMain/kotlin/lifecycle"
    click MVVM "https://github.com/splendo/kaluga/tree/develop/architecture/src/commonMain/kotlin/viewmodel"

    %% Legend
    subgraph Legend
        L1["Core Modules"]:::core
        L2["Feature Modules"]:::feature
        L3["Platform-Specific"]:::platform
        L4["Testing"]:::testing
    end
```
