# kongquan98/mobiletypist architecture

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

- Interactive diagram: https://gitdiagram.com/kongquan98/mobiletypist
- Repository: https://github.com/kongquan98/mobiletypist

## Overview

#### Purpose and module layout
Keyboard Typist is an offline Kotlin Multiplatform typing-practice app for Android and iOS. The primary product module is `composeApp`; `shared` appears to be a separate minimal KMP template module, not part of the app’s core feature architecture. Gradle project setup is rooted at `settings.gradle.kts` and `build.gradle.kts`.

#### Platform entry points
Android launches the shared Compose UI from `composeApp/src/androidMain/kotlin/org/example/project/MainActivity.kt`. iOS exposes the Compose controller through `composeApp/src/iosMain/kotlin/org/example/project/MainViewController.kt`, while the native Xcode host starts in `iosApp/iosApp/iOSApp.swift`. Shared application composition begins at `composeApp/src/commonMain/kotlin/org/example/project/App.kt`.

#### Shared UI shell and navigation
`App.kt` applies the app theme and establishes the screen-level UI. A custom, screen-based navigation stack is defined by:
- `composeApp/src/commonMain/kotlin/org/example/project/navigation/NavigationManager.kt`
- `composeApp/src/commonMain/kotlin/org/example/project/navigation/Navigation.kt`
- `composeApp/src/commonMain/kotlin/org/example/project/navigation/model/Screen.kt`

`composeApp/src/commonMain/kotlin/org/example/project/ui/MainScaffold.kt` provides the common scaffold/bottom-level layout. Platform-specific back handling is an expect/actual boundary in `navigation/BackHandler.kt`, with Android and iOS implementations.

#### Typing-test execution flow
The principal interactive flow is the typing screen and its state holder:
- `composeApp/src/commonMain/kotlin/org/example/project/screens/TypingScreen.kt`
- `composeApp/src/commonMain/kotlin/org/example/project/viewModel/TypingViewModel.kt`
- `composeApp/src/commonMain/kotlin/org/example/project/ui/TypingComponents.kt`

The view model manages typing-session state for timed, word-count, and quote modes: input comparison, character/word progress, accuracy, WPM, completion, and result presentation. `ResultBottomSheet.kt` forms the result boundary back into persisted statistics. Source text comes from repositories, especially `WordsRepository.kt` and `QuotesRepository.kt`; English word data is bundled at `composeApp/src/commonMain/composeResources/files/typing_words_en.json`.

#### Local persistence and domain data
All user data is designed to remain on device. Shared models cover profiles, settings, results, achievements, and daily activity:
- `composeApp/src/commonMain/kotlin/org/example/project/data/model/TypingTestResult.kt`
- `composeApp/src/commonMain/kotlin/org/example/project/data/model/AppSettings.kt`
- `composeApp/src/commonMain/kotlin/org/example/project/data/model/DailyActivityDurations.kt`

`StorageManager.kt` is the shared persistence façade, backed by the platform abstraction in `PlatformStorage.kt`. Actual implementations use Android-specific storage and iOS UserDefaults:
- `composeApp/src/androidMain/kotlin/org/example/project/data/storage/PlatformStorage.android.kt`
- `composeApp/src/iosMain/kotlin/org/example/project/data/storage/PlatformStorage.ios.kt`

#### Home, statistics, and profile surfaces
`HomeViewModel.kt` aggregates persisted results/settings into the home experience. Screens for home, statistics, achievements, profile/account, avatar, and settings consume that state and repositories. Activity visualization is separated into `ActivityHeatmapRepository.kt` and `ui/ActivityHeatmap.kt`, creating a clear flow from saved test history to calendar-style display.

#### Platform effects and runtime boundaries
The shared Compose runtime targets Android API 24+ and iOS. Expect/actual implementations isolate platform services: storage, date formatting, audio, haptic feedback, device/platform metadata, and back navigation. Relevant boundaries include `utils/AudioPlayer.kt`, `utils/TypingHapticFeedback.kt`, and their Android/iOS counterparts. Android sound assets live under `composeApp/src/androidMain/res/raw`. The declared stack includes Compose Multiplatform, Material 3, MultiplatformSettings, Kotlinx Serialization, and Ktor; README describes Ktor as reserved for future features rather than a current service integration.

Main entry points: [`composeApp/src/commonMain/kotlin/org/example/project/viewModel/TypingViewModel.kt`](https://github.com/kongquan98/mobiletypist/blob/master/composeApp/src/commonMain/kotlin/org/example/project/viewModel/TypingViewModel.kt) (Typing session state), [`composeApp/src/commonMain/kotlin/org/example/project/data/storage/StorageManager.kt`](https://github.com/kongquan98/mobiletypist/blob/master/composeApp/src/commonMain/kotlin/org/example/project/data/storage/StorageManager.kt) (Storage manager), [`composeApp/src/commonMain/kotlin/org/example/project/App.kt`](https://github.com/kongquan98/mobiletypist/blob/master/composeApp/src/commonMain/kotlin/org/example/project/App.kt) (App composition), [`composeApp/src/commonMain/kotlin/org/example/project/navigation/NavigationManager.kt`](https://github.com/kongquan98/mobiletypist/blob/master/composeApp/src/commonMain/kotlin/org/example/project/navigation/NavigationManager.kt) (Navigation stack)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_platform["Platform hosts"]
  node_android_host["Android activity<br/>Android entry point<br/>[MainActivity.kt]"]
  node_ios_host["iOS SwiftUI host<br/>iOS entry point<br/>[iOSApp.swift]"]
  node_ios_controller["Compose view controller<br/>iOS bridge"]
  node_back_handler["Back handler<br/>expect/actual service<br/>[BackHandler.kt]"]
  node_platform_storage[("Platform storage<br/>expect/actual storage<br/>[PlatformStorage.kt]")]
  node_platform_effects["Audio and haptics<br/>expect/actual effects<br/>[AudioPlayer.kt]"]
end

subgraph group_ui["Shared UI and navigation"]
  node_app["App composition<br/>shared Compose root<br/>[App.kt]"]
  node_navigation["Navigation stack<br/>screen navigation"]
  node_scaffold["Main scaffold<br/>shared layout<br/>[MainScaffold.kt]"]
  node_home_vm["Home state<br/>view model<br/>[HomeViewModel.kt]"]
  node_activity_heatmap["Activity heatmap<br/>visualization UI<br/>[ActivityHeatmap.kt]"]
end

subgraph group_typing["Typing workflow"]
  node_typing_screen["Typing screen<br/>feature screen<br/>[TypingScreen.kt]"]
  node_typing_vm["Typing session state<br/>view model<br/>[TypingViewModel.kt]"]
  node_typing_components["Typing components<br/>feature UI"]
  node_result_sheet["Result bottom sheet<br/>result UI"]
end

subgraph group_data["Offline data and services"]
  node_text_repositories["Words and quotes<br/>content repositories<br/>[WordsRepository.kt]"]
  node_word_data["English word corpus<br/>bundled content"]
  node_storage_manager["Storage manager<br/>persistence facade<br/>[StorageManager.kt]"]
  node_activity_repository["Activity history<br/>activity repository"]
end

node_gradle["Gradle project<br/>build setup"]

node_gradle -->|"builds"| node_android_host
node_gradle -->|"builds"| node_ios_host
node_android_host -->|"launches"| node_app
node_ios_host -->|"starts"| node_ios_controller
node_ios_controller -->|"hosts"| node_app
node_app -->|"establishes"| node_navigation
node_app -->|"renders"| node_scaffold
node_navigation -->|"routes to"| node_typing_screen
node_navigation -.->|"handles back"| node_back_handler
node_typing_screen -->|"observes and sends input"| node_typing_vm
node_typing_screen -->|"composes"| node_typing_components
node_typing_vm -->|"loads prompts"| node_text_repositories
node_text_repositories -->|"reads"| node_word_data
node_typing_vm -.->|"triggers feedback"| node_platform_effects
node_typing_vm -->|"presents completion"| node_result_sheet
node_result_sheet -->|"saves result"| node_storage_manager
node_storage_manager -->|"persists through"| node_platform_storage
node_storage_manager -->|"provides results and settings"| node_home_vm
node_storage_manager -->|"provides history"| node_activity_repository
node_home_vm -->|"supplies activity state"| node_activity_heatmap
node_activity_repository -->|"derives activity data"| node_activity_heatmap

click node_gradle "https://github.com/kongquan98/mobiletypist/blob/master/settings.gradle.kts"
click node_android_host "https://github.com/kongquan98/mobiletypist/blob/master/composeApp/src/androidMain/kotlin/org/example/project/MainActivity.kt"
click node_ios_host "https://github.com/kongquan98/mobiletypist/blob/master/iosApp/iosApp/iOSApp.swift"
click node_ios_controller "https://github.com/kongquan98/mobiletypist/blob/master/composeApp/src/iosMain/kotlin/org/example/project/MainViewController.kt"
click node_app "https://github.com/kongquan98/mobiletypist/blob/master/composeApp/src/commonMain/kotlin/org/example/project/App.kt"
click node_navigation "https://github.com/kongquan98/mobiletypist/blob/master/composeApp/src/commonMain/kotlin/org/example/project/navigation/NavigationManager.kt"
click node_scaffold "https://github.com/kongquan98/mobiletypist/blob/master/composeApp/src/commonMain/kotlin/org/example/project/ui/MainScaffold.kt"
click node_back_handler "https://github.com/kongquan98/mobiletypist/blob/master/composeApp/src/commonMain/kotlin/org/example/project/navigation/BackHandler.kt"
click node_typing_screen "https://github.com/kongquan98/mobiletypist/blob/master/composeApp/src/commonMain/kotlin/org/example/project/screens/TypingScreen.kt"
click node_typing_vm "https://github.com/kongquan98/mobiletypist/blob/master/composeApp/src/commonMain/kotlin/org/example/project/viewModel/TypingViewModel.kt"
click node_typing_components "https://github.com/kongquan98/mobiletypist/blob/master/composeApp/src/commonMain/kotlin/org/example/project/ui/TypingComponents.kt"
click node_result_sheet "https://github.com/kongquan98/mobiletypist/blob/master/composeApp/src/commonMain/kotlin/org/example/project/ui/ResultBottomSheet.kt"
click node_text_repositories "https://github.com/kongquan98/mobiletypist/blob/master/composeApp/src/commonMain/kotlin/org/example/project/data/repo/WordsRepository.kt"
click node_word_data "https://github.com/kongquan98/mobiletypist/blob/master/composeApp/src/commonMain/composeResources/files/typing_words_en.json"
click node_storage_manager "https://github.com/kongquan98/mobiletypist/blob/master/composeApp/src/commonMain/kotlin/org/example/project/data/storage/StorageManager.kt"
click node_platform_storage "https://github.com/kongquan98/mobiletypist/blob/master/composeApp/src/commonMain/kotlin/org/example/project/data/storage/PlatformStorage.kt"
click node_home_vm "https://github.com/kongquan98/mobiletypist/blob/master/composeApp/src/commonMain/kotlin/org/example/project/viewModel/HomeViewModel.kt"
click node_activity_repository "https://github.com/kongquan98/mobiletypist/blob/master/composeApp/src/commonMain/kotlin/org/example/project/data/repo/ActivityHeatmapRepository.kt"
click node_activity_heatmap "https://github.com/kongquan98/mobiletypist/blob/master/composeApp/src/commonMain/kotlin/org/example/project/ui/ActivityHeatmap.kt"
click node_platform_effects "https://github.com/kongquan98/mobiletypist/blob/master/composeApp/src/commonMain/kotlin/org/example/project/utils/AudioPlayer.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_android_host,node_ios_host,node_ios_controller,node_back_handler,node_platform_storage,node_platform_effects toneBlue
class node_app,node_navigation,node_scaffold,node_home_vm,node_activity_heatmap toneAmber
class node_typing_screen,node_typing_vm,node_typing_components,node_result_sheet toneMint
class node_text_repositories,node_word_data,node_storage_manager,node_activity_repository toneRose
class node_gradle toneNeutral
```

## Components

### Platform hosts

- [Android activity](https://github.com/kongquan98/mobiletypist/blob/master/composeApp/src/androidMain/kotlin/org/example/project/MainActivity.kt): Android entry point · `composeApp/src/androidMain/kotlin/org/example/project/MainActivity.kt`
- [iOS SwiftUI host](https://github.com/kongquan98/mobiletypist/blob/master/iosApp/iosApp/iOSApp.swift): iOS entry point · `iosApp/iosApp/iOSApp.swift`
- [Compose view controller](https://github.com/kongquan98/mobiletypist/blob/master/composeApp/src/iosMain/kotlin/org/example/project/MainViewController.kt): iOS bridge · `composeApp/src/iosMain/kotlin/org/example/project/MainViewController.kt`
- [Back handler](https://github.com/kongquan98/mobiletypist/blob/master/composeApp/src/commonMain/kotlin/org/example/project/navigation/BackHandler.kt): expect/actual service · Android and iOS implementations isolate back behavior. · `composeApp/src/commonMain/kotlin/org/example/project/navigation/BackHandler.kt`
- [Platform storage](https://github.com/kongquan98/mobiletypist/blob/master/composeApp/src/commonMain/kotlin/org/example/project/data/storage/PlatformStorage.kt): expect/actual storage · Uses Android storage or iOS UserDefaults. · `composeApp/src/commonMain/kotlin/org/example/project/data/storage/PlatformStorage.kt`
- [Audio and haptics](https://github.com/kongquan98/mobiletypist/blob/master/composeApp/src/commonMain/kotlin/org/example/project/utils/AudioPlayer.kt): expect/actual effects · Platform feedback for typing interactions. · `composeApp/src/commonMain/kotlin/org/example/project/utils/AudioPlayer.kt`

### Shared UI and navigation

- [App composition](https://github.com/kongquan98/mobiletypist/blob/master/composeApp/src/commonMain/kotlin/org/example/project/App.kt): shared Compose root · `composeApp/src/commonMain/kotlin/org/example/project/App.kt`
- [Navigation stack](https://github.com/kongquan98/mobiletypist/blob/master/composeApp/src/commonMain/kotlin/org/example/project/navigation/NavigationManager.kt): screen navigation · Manages screen transitions and screen model. · `composeApp/src/commonMain/kotlin/org/example/project/navigation/NavigationManager.kt`
- [Main scaffold](https://github.com/kongquan98/mobiletypist/blob/master/composeApp/src/commonMain/kotlin/org/example/project/ui/MainScaffold.kt): shared layout · `composeApp/src/commonMain/kotlin/org/example/project/ui/MainScaffold.kt`
- [Home state](https://github.com/kongquan98/mobiletypist/blob/master/composeApp/src/commonMain/kotlin/org/example/project/viewModel/HomeViewModel.kt): view model · Aggregates saved results and settings for home surfaces. · `composeApp/src/commonMain/kotlin/org/example/project/viewModel/HomeViewModel.kt`
- [Activity heatmap](https://github.com/kongquan98/mobiletypist/blob/master/composeApp/src/commonMain/kotlin/org/example/project/ui/ActivityHeatmap.kt): visualization UI · `composeApp/src/commonMain/kotlin/org/example/project/ui/ActivityHeatmap.kt`

### Typing workflow

- [Typing screen](https://github.com/kongquan98/mobiletypist/blob/master/composeApp/src/commonMain/kotlin/org/example/project/screens/TypingScreen.kt): feature screen · `composeApp/src/commonMain/kotlin/org/example/project/screens/TypingScreen.kt`
- [Typing session state](https://github.com/kongquan98/mobiletypist/blob/master/composeApp/src/commonMain/kotlin/org/example/project/viewModel/TypingViewModel.kt): view model · Calculates progress, accuracy, WPM, completion, and results. · `composeApp/src/commonMain/kotlin/org/example/project/viewModel/TypingViewModel.kt`
- [Typing components](https://github.com/kongquan98/mobiletypist/blob/master/composeApp/src/commonMain/kotlin/org/example/project/ui/TypingComponents.kt): feature UI · `composeApp/src/commonMain/kotlin/org/example/project/ui/TypingComponents.kt`
- [Result bottom sheet](https://github.com/kongquan98/mobiletypist/blob/master/composeApp/src/commonMain/kotlin/org/example/project/ui/ResultBottomSheet.kt): result UI · Commits completed sessions to statistics. · `composeApp/src/commonMain/kotlin/org/example/project/ui/ResultBottomSheet.kt`

### Offline data and services

- [Words and quotes](https://github.com/kongquan98/mobiletypist/blob/master/composeApp/src/commonMain/kotlin/org/example/project/data/repo/WordsRepository.kt): content repositories · Supplies prompts for typing modes. · `composeApp/src/commonMain/kotlin/org/example/project/data/repo/WordsRepository.kt`
- [English word corpus](https://github.com/kongquan98/mobiletypist/blob/master/composeApp/src/commonMain/composeResources/files/typing_words_en.json): bundled content · `composeApp/src/commonMain/composeResources/files/typing_words_en.json`
- [Storage manager](https://github.com/kongquan98/mobiletypist/blob/master/composeApp/src/commonMain/kotlin/org/example/project/data/storage/StorageManager.kt): persistence facade · Shared access to on-device user data. · `composeApp/src/commonMain/kotlin/org/example/project/data/storage/StorageManager.kt`
- [Activity history](https://github.com/kongquan98/mobiletypist/blob/master/composeApp/src/commonMain/kotlin/org/example/project/data/repo/ActivityHeatmapRepository.kt): activity repository · Derives calendar activity from saved test history. · `composeApp/src/commonMain/kotlin/org/example/project/data/repo/ActivityHeatmapRepository.kt`

### Other components

- [Gradle project](https://github.com/kongquan98/mobiletypist/blob/master/settings.gradle.kts): build setup · `settings.gradle.kts`

## Connections

- Gradle project → Android activity: builds
- Gradle project → iOS SwiftUI host: builds
- Android activity → App composition: launches
- iOS SwiftUI host → Compose view controller: starts
- Compose view controller → App composition: hosts
- App composition → Navigation stack: establishes
- App composition → Main scaffold: renders
- Navigation stack → Typing screen: routes to
- Navigation stack → Back handler: handles back
- Typing screen → Typing session state: observes and sends input
- Typing screen → Typing components: composes
- Typing session state → Words and quotes: loads prompts
- Words and quotes → English word corpus: reads
- Typing session state → Audio and haptics: triggers feedback
- Typing session state → Result bottom sheet: presents completion
- Result bottom sheet → Storage manager: saves result
- Storage manager → Platform storage: persists through
- Storage manager → Home state: provides results and settings
- Storage manager → Activity history: provides history
- Home state → Activity heatmap: supplies activity state
- Activity history → Activity heatmap: derives activity data
