# aokruan/massage architecture

> Architecture diagram of the GitHub repository aokruan/massage, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/aokruan/massage
- Repository: https://github.com/aokruan/massage

## Overview

This Kotlin Multiplatform app combines a massage-service catalog with medical-device monitoring. Users enter the shared Compose app, browse service pages loaded from the service API, or use device tools to scan a QR code, connect over BLE, and observe status and alarms. Android keeps monitoring in a foreground service; iOS has a separate BLE bridge. The graph preserves both product branches and their principal layers. Some subsystem links are dashed because their wiring was not shown in the supplied excerpts.

Main entry points: [`feature/device/data/src/commonMain/kotlin/MedicalDeviceRepositoryImpl.kt`](https://github.com/aokruan/massage/blob/main/feature/device/data/src/commonMain/kotlin/MedicalDeviceRepositoryImpl.kt) (Device repository), [`core/bluetooth/src/androidMain/kotlin/ru/aokruan/hmlkbi/android/BleSessionManager.kt`](https://github.com/aokruan/massage/blob/main/core/bluetooth/src/androidMain/kotlin/ru/aokruan/hmlkbi/android/BleSessionManager.kt) (BLE session), [`composeApp/src/androidMain/kotlin/ru/aokruan/hmlkbi/device/service/BleForegroundService.kt`](https://github.com/aokruan/massage/blob/main/composeApp/src/androidMain/kotlin/ru/aokruan/hmlkbi/device/service/BleForegroundService.kt) (Android BLE service), [`composeApp/src/commonMain/kotlin/ru/aokruan/hmlkbi/RootTabScreens.kt`](https://github.com/aokruan/massage/blob/main/composeApp/src/commonMain/kotlin/ru/aokruan/hmlkbi/RootTabScreens.kt) (Tab screens)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["App and navigation"]
  node_app["Shared app<br/>[App.kt]"]
  node_root["App root<br/>[AppRoot.kt]"]
  node_tabs["Tab screens<br/>[RootTabScreens.kt]"]
end

subgraph group_services["Service catalog"]
  node_serviceui["Service screens"]
  node_listvm["Service list state"]
  node_detailui["Service details"]
  node_detailvm["Detail state"]
  node_serviceusecases["Catalog use cases"]
  node_servicerepo["Service repository"]
  node_serviceimpl["Remote catalog"]
  node_serviceapi["Service API<br/>[KtorServiceApi.kt]"]
  node_http["HTTP client"]
end

subgraph group_device["Medical device"]
  node_deviceui["Device tools"]
  node_monitor["Device monitor"]
  node_devvm["Monitor state"]
  node_devrepo["Device repository"]
  node_qrparse["BLE QR parser<br/>[BleQrParser.kt]"]
  node_session["BLE session"]
  node_blemodels["BLE state and data<br/>[BleSessionState.kt]"]
  node_bleparams["Connection parameters"]
  node_alarm["Alarm events<br/>[AlarmEvent.kt]"]
  node_status["Medical status"]
end

subgraph group_platform["Platform integrations"]
  node_bleplatform["Android BLE service"]
  node_blecontroller["Service controller"]
  node_iosbridge["iOS BLE bridge"]
  node_notifier["User notifications"]
end

node_user(("App user"))
node_backend["Service backend"]

node_user -.->|"opens"| node_app
node_app -->|"renders"| node_root
node_root -.->|"routes"| node_tabs
node_tabs -.->|"offers tools"| node_deviceui
node_tabs -.->|"shows catalog"| node_serviceui
node_deviceui -.->|"observes"| node_devvm
node_devvm -.->|"uses"| node_devrepo
node_devrepo -->|"parses QR"| node_qrparse
node_devrepo -.->|"starts monitoring"| node_bleplatform
node_devrepo -->|"notifies"| node_notifier
node_monitor -.->|"observes"| node_devvm
node_blecontroller -->|"starts service"| node_bleplatform
node_bleplatform -->|"connects"| node_session
node_session -->|"accepts"| node_bleparams
node_session -->|"publishes state"| node_blemodels
node_bleplatform -->|"alerts"| node_notifier
node_iosbridge -.->|"bridges BLE"| node_session
node_serviceui -.->|"displays state"| node_listvm
node_listvm -->|"loads pages"| node_serviceusecases
node_detailui -->|"renders"| node_detailvm
node_detailvm -->|"loads details"| node_serviceusecases
node_serviceusecases -.->|"requests data"| node_servicerepo
node_serviceimpl -.->|"implements"| node_servicerepo
node_serviceapi -.->|"uses client"| node_http
node_serviceapi -.->|"requests catalog"| node_backend

click node_app "https://github.com/aokruan/massage/blob/main/composeApp/src/commonMain/kotlin/ru/aokruan/hmlkbi/App.kt"
click node_root "https://github.com/aokruan/massage/blob/main/composeApp/src/commonMain/kotlin/ru/aokruan/hmlkbi/AppRoot.kt"
click node_tabs "https://github.com/aokruan/massage/blob/main/composeApp/src/commonMain/kotlin/ru/aokruan/hmlkbi/RootTabScreens.kt"
click node_deviceui "https://github.com/aokruan/massage/blob/main/feature/device/ui/src/commonMain/kotlin/DeviceToolsScreen.kt"
click node_monitor "https://github.com/aokruan/massage/blob/main/feature/device/ui/src/commonMain/kotlin/DeviceMonitorScreen.kt"
click node_devvm "https://github.com/aokruan/massage/blob/main/feature/device/ui/src/commonMain/kotlin/DeviceMonitorViewModel.kt"
click node_devrepo "https://github.com/aokruan/massage/blob/main/feature/device/data/src/commonMain/kotlin/MedicalDeviceRepositoryImpl.kt"
click node_qrparse "https://github.com/aokruan/massage/blob/main/core/qr/src/commonMain/kotlin/ru/aokruan/qr/BleQrParser.kt"
click node_session "https://github.com/aokruan/massage/blob/main/core/bluetooth/src/androidMain/kotlin/ru/aokruan/hmlkbi/android/BleSessionManager.kt"
click node_blemodels "https://github.com/aokruan/massage/blob/main/core/bluetooth/src/commonMain/kotlin/ru/aokruan/hmlkbi/BleSessionState.kt"
click node_bleparams "https://github.com/aokruan/massage/blob/main/core/bluetooth/src/commonMain/kotlin/ru/aokruan/hmlkbi/BleConnectParams.kt"
click node_alarm "https://github.com/aokruan/massage/blob/main/core/bluetooth/src/commonMain/kotlin/ru/aokruan/hmlkbi/model/AlarmEvent.kt"
click node_status "https://github.com/aokruan/massage/blob/main/core/bluetooth/src/commonMain/kotlin/ru/aokruan/hmlkbi/model/MedicalCurrentStatus.kt"
click node_bleplatform "https://github.com/aokruan/massage/blob/main/composeApp/src/androidMain/kotlin/ru/aokruan/hmlkbi/device/service/BleForegroundService.kt"
click node_blecontroller "https://github.com/aokruan/massage/blob/main/composeApp/src/androidMain/kotlin/ru/aokruan/hmlkbi/device/service/BleServiceController.kt"
click node_iosbridge "https://github.com/aokruan/massage/blob/main/composeApp/src/iosMain/kotlin/ru/aokruan/hmlkbi/device/service/IosMedicalDeviceSessionBridge.kt"
click node_notifier "https://github.com/aokruan/massage/blob/main/core/notification/src/commonMain/kotlin/ru/aokruan/notification/UserNotificationGateway.kt"
click node_serviceui "https://github.com/aokruan/massage/blob/main/feature/service/ui/src/commonMain/kotlin/ru/aokruan/ui/screens/ServiceListScreen.kt"
click node_listvm "https://github.com/aokruan/massage/blob/main/feature/service/ui/src/commonMain/kotlin/ru/aokruan/ui/vm/ServiceListViewModel.kt"
click node_detailui "https://github.com/aokruan/massage/blob/main/feature/service/ui/src/commonMain/kotlin/ru/aokruan/ui/screens/ServiceDetailScreen.kt"
click node_detailvm "https://github.com/aokruan/massage/blob/main/feature/service/ui/src/commonMain/kotlin/ru/aokruan/ui/vm/ServiceDetailViewModel.kt"
click node_serviceusecases "https://github.com/aokruan/massage/blob/main/feature/service/domain/src/commonMain/kotlin/ru/aokruan/service/domain/GetMassagesPageUseCase.kt"
click node_servicerepo "https://github.com/aokruan/massage/blob/main/feature/service/domain/src/commonMain/kotlin/ru/aokruan/service/domain/ServiceRepository.kt"
click node_serviceimpl "https://github.com/aokruan/massage/blob/main/feature/service/data/src/commonMain/kotlin/ru/aokruan/service/data/repository/DefaultServiceRepository.kt"
click node_serviceapi "https://github.com/aokruan/massage/blob/main/feature/service/data/src/commonMain/kotlin/ru/aokruan/service/data/remote/api/KtorServiceApi.kt"
click node_http "https://github.com/aokruan/massage/blob/main/core/network/src/commonMain/kotlin/ru/aokruan/network/HttpClientFactory.kt"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app,node_root,node_tabs,node_user toneBlue
class node_serviceui,node_listvm,node_detailui,node_detailvm,node_serviceusecases,node_servicerepo,node_serviceimpl,node_serviceapi,node_http toneAmber
class node_deviceui,node_monitor,node_devvm,node_devrepo,node_qrparse,node_session,node_blemodels,node_bleparams,node_alarm,node_status toneMint
class node_bleplatform,node_blecontroller,node_iosbridge,node_notifier toneRose
class node_backend toneIndigo
```

## Components

### App and navigation

- [Shared app](https://github.com/aokruan/massage/blob/main/composeApp/src/commonMain/kotlin/ru/aokruan/hmlkbi/App.kt): `composeApp/src/commonMain/kotlin/ru/aokruan/hmlkbi/App.kt`
- [App root](https://github.com/aokruan/massage/blob/main/composeApp/src/commonMain/kotlin/ru/aokruan/hmlkbi/AppRoot.kt): `composeApp/src/commonMain/kotlin/ru/aokruan/hmlkbi/AppRoot.kt`
- [Tab screens](https://github.com/aokruan/massage/blob/main/composeApp/src/commonMain/kotlin/ru/aokruan/hmlkbi/RootTabScreens.kt): `composeApp/src/commonMain/kotlin/ru/aokruan/hmlkbi/RootTabScreens.kt`

### Service catalog

- [Service screens](https://github.com/aokruan/massage/blob/main/feature/service/ui/src/commonMain/kotlin/ru/aokruan/ui/screens/ServiceListScreen.kt): `feature/service/ui/src/commonMain/kotlin/ru/aokruan/ui/screens/ServiceListScreen.kt`
- [Service list state](https://github.com/aokruan/massage/blob/main/feature/service/ui/src/commonMain/kotlin/ru/aokruan/ui/vm/ServiceListViewModel.kt): `feature/service/ui/src/commonMain/kotlin/ru/aokruan/ui/vm/ServiceListViewModel.kt`
- [Service details](https://github.com/aokruan/massage/blob/main/feature/service/ui/src/commonMain/kotlin/ru/aokruan/ui/screens/ServiceDetailScreen.kt): `feature/service/ui/src/commonMain/kotlin/ru/aokruan/ui/screens/ServiceDetailScreen.kt`
- [Detail state](https://github.com/aokruan/massage/blob/main/feature/service/ui/src/commonMain/kotlin/ru/aokruan/ui/vm/ServiceDetailViewModel.kt): `feature/service/ui/src/commonMain/kotlin/ru/aokruan/ui/vm/ServiceDetailViewModel.kt`
- [Catalog use cases](https://github.com/aokruan/massage/blob/main/feature/service/domain/src/commonMain/kotlin/ru/aokruan/service/domain/GetMassagesPageUseCase.kt): `feature/service/domain/src/commonMain/kotlin/ru/aokruan/service/domain/GetMassagesPageUseCase.kt`
- [Service repository](https://github.com/aokruan/massage/blob/main/feature/service/domain/src/commonMain/kotlin/ru/aokruan/service/domain/ServiceRepository.kt): `feature/service/domain/src/commonMain/kotlin/ru/aokruan/service/domain/ServiceRepository.kt`
- [Remote catalog](https://github.com/aokruan/massage/blob/main/feature/service/data/src/commonMain/kotlin/ru/aokruan/service/data/repository/DefaultServiceRepository.kt): `feature/service/data/src/commonMain/kotlin/ru/aokruan/service/data/repository/DefaultServiceRepository.kt`
- [Service API](https://github.com/aokruan/massage/blob/main/feature/service/data/src/commonMain/kotlin/ru/aokruan/service/data/remote/api/KtorServiceApi.kt): `feature/service/data/src/commonMain/kotlin/ru/aokruan/service/data/remote/api/KtorServiceApi.kt`
- [HTTP client](https://github.com/aokruan/massage/blob/main/core/network/src/commonMain/kotlin/ru/aokruan/network/HttpClientFactory.kt): `core/network/src/commonMain/kotlin/ru/aokruan/network/HttpClientFactory.kt`

### Medical device

- [Device tools](https://github.com/aokruan/massage/blob/main/feature/device/ui/src/commonMain/kotlin/DeviceToolsScreen.kt): `feature/device/ui/src/commonMain/kotlin/DeviceToolsScreen.kt`
- [Device monitor](https://github.com/aokruan/massage/blob/main/feature/device/ui/src/commonMain/kotlin/DeviceMonitorScreen.kt): `feature/device/ui/src/commonMain/kotlin/DeviceMonitorScreen.kt`
- [Monitor state](https://github.com/aokruan/massage/blob/main/feature/device/ui/src/commonMain/kotlin/DeviceMonitorViewModel.kt): `feature/device/ui/src/commonMain/kotlin/DeviceMonitorViewModel.kt`
- [Device repository](https://github.com/aokruan/massage/blob/main/feature/device/data/src/commonMain/kotlin/MedicalDeviceRepositoryImpl.kt): `feature/device/data/src/commonMain/kotlin/MedicalDeviceRepositoryImpl.kt`
- [BLE QR parser](https://github.com/aokruan/massage/blob/main/core/qr/src/commonMain/kotlin/ru/aokruan/qr/BleQrParser.kt): `core/qr/src/commonMain/kotlin/ru/aokruan/qr/BleQrParser.kt`
- [BLE session](https://github.com/aokruan/massage/blob/main/core/bluetooth/src/androidMain/kotlin/ru/aokruan/hmlkbi/android/BleSessionManager.kt): `core/bluetooth/src/androidMain/kotlin/ru/aokruan/hmlkbi/android/BleSessionManager.kt`
- [BLE state and data](https://github.com/aokruan/massage/blob/main/core/bluetooth/src/commonMain/kotlin/ru/aokruan/hmlkbi/BleSessionState.kt): `core/bluetooth/src/commonMain/kotlin/ru/aokruan/hmlkbi/BleSessionState.kt`
- [Connection parameters](https://github.com/aokruan/massage/blob/main/core/bluetooth/src/commonMain/kotlin/ru/aokruan/hmlkbi/BleConnectParams.kt): `core/bluetooth/src/commonMain/kotlin/ru/aokruan/hmlkbi/BleConnectParams.kt`
- [Alarm events](https://github.com/aokruan/massage/blob/main/core/bluetooth/src/commonMain/kotlin/ru/aokruan/hmlkbi/model/AlarmEvent.kt): `core/bluetooth/src/commonMain/kotlin/ru/aokruan/hmlkbi/model/AlarmEvent.kt`
- [Medical status](https://github.com/aokruan/massage/blob/main/core/bluetooth/src/commonMain/kotlin/ru/aokruan/hmlkbi/model/MedicalCurrentStatus.kt): `core/bluetooth/src/commonMain/kotlin/ru/aokruan/hmlkbi/model/MedicalCurrentStatus.kt`

### Platform integrations

- [Android BLE service](https://github.com/aokruan/massage/blob/main/composeApp/src/androidMain/kotlin/ru/aokruan/hmlkbi/device/service/BleForegroundService.kt): `composeApp/src/androidMain/kotlin/ru/aokruan/hmlkbi/device/service/BleForegroundService.kt`
- [Service controller](https://github.com/aokruan/massage/blob/main/composeApp/src/androidMain/kotlin/ru/aokruan/hmlkbi/device/service/BleServiceController.kt): `composeApp/src/androidMain/kotlin/ru/aokruan/hmlkbi/device/service/BleServiceController.kt`
- [iOS BLE bridge](https://github.com/aokruan/massage/blob/main/composeApp/src/iosMain/kotlin/ru/aokruan/hmlkbi/device/service/IosMedicalDeviceSessionBridge.kt): `composeApp/src/iosMain/kotlin/ru/aokruan/hmlkbi/device/service/IosMedicalDeviceSessionBridge.kt`
- [User notifications](https://github.com/aokruan/massage/blob/main/core/notification/src/commonMain/kotlin/ru/aokruan/notification/UserNotificationGateway.kt): `core/notification/src/commonMain/kotlin/ru/aokruan/notification/UserNotificationGateway.kt`

### Other components

- **App user**
- **Service backend**

## Connections

- App user → Shared app: opens
- Shared app → App root: renders (evidence: `composeApp/src/commonMain/kotlin/ru/aokruan/hmlkbi/App.kt`)
- App root → Tab screens: routes
- Tab screens → Device tools: offers tools
- Tab screens → Service screens: shows catalog
- Device tools → Monitor state: observes
- Monitor state → Device repository: uses
- Device repository → BLE QR parser: parses QR (evidence: `feature/device/data/src/commonMain/kotlin/MedicalDeviceRepositoryImpl.kt`)
- Device repository → Android BLE service: starts monitoring
- Device repository → User notifications: notifies (evidence: `feature/device/data/src/commonMain/kotlin/MedicalDeviceRepositoryImpl.kt`)
- Device monitor → Monitor state: observes
- Service controller → Android BLE service: starts service (evidence: `composeApp/src/androidMain/kotlin/ru/aokruan/hmlkbi/device/service/BleServiceController.kt`)
- Android BLE service → BLE session: connects (evidence: `composeApp/src/androidMain/kotlin/ru/aokruan/hmlkbi/device/service/BleForegroundService.kt`)
- BLE session → Connection parameters: accepts (evidence: `core/bluetooth/src/androidMain/kotlin/ru/aokruan/hmlkbi/android/BleSessionManager.kt`)
- BLE session → BLE state and data: publishes state (evidence: `core/bluetooth/src/androidMain/kotlin/ru/aokruan/hmlkbi/android/BleSessionManager.kt`)
- Android BLE service → User notifications: alerts (evidence: `composeApp/src/androidMain/kotlin/ru/aokruan/hmlkbi/device/service/BleForegroundService.kt`)
- iOS BLE bridge → BLE session: bridges BLE
- Service screens → Service list state: displays state
- Service list state → Catalog use cases: loads pages (evidence: `feature/service/ui/src/commonMain/kotlin/ru/aokruan/ui/vm/ServiceListViewModel.kt`)
- Service details → Detail state: renders (evidence: `feature/service/ui/src/commonMain/kotlin/ru/aokruan/ui/screens/ServiceDetailScreen.kt`)
- Detail state → Catalog use cases: loads details
- Catalog use cases → Service repository: requests data (evidence: `feature/service/domain/src/commonMain/kotlin/ru/aokruan/service/domain/GetMassagesPageUseCase.kt`)
- Remote catalog → Service repository: implements
- Service API → HTTP client: uses client
- Service API → Service backend: requests catalog
