# nsh07/tomato architecture

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

- Interactive diagram: https://gitdiagram.com/nsh07/tomato
- Repository: https://github.com/nsh07/tomato

## Overview

Tomato is a Pomodoro focus timer with shared Kotlin Multiplatform application logic and Android and desktop entry points. On Android, the user opens the app, which restores a persisted timer session when needed and presents the shared UI; timer controls drive interval timing and recorded focus/break statistics. The product also includes configurable timer and topic settings, statistics, backup/restore, Android widgets and Quick Settings access, and Plus billing. Several feature links below are based on README descriptions and indexed references rather than inspected implementations.

Main entry points: [`shared/src/commonMain/kotlin/org/nsh07/pomodoro/service/TimerManager.kt`](https://github.com/nsh07/tomato/blob/dev/shared/src/commonMain/kotlin/org/nsh07/pomodoro/service/TimerManager.kt) (Timer engine), [`shared/src/commonMain/kotlin/org/nsh07/pomodoro/ui/AppScreen.kt`](https://github.com/nsh07/tomato/blob/dev/shared/src/commonMain/kotlin/org/nsh07/pomodoro/ui/AppScreen.kt) (App navigation UI), [`androidApp/src/main/java/org/nsh07/pomodoro/service/TimerService.kt`](https://github.com/nsh07/tomato/blob/dev/androidApp/src/main/java/org/nsh07/pomodoro/service/TimerService.kt) (Android timer service), [`shared/src/commonMain/kotlin/org/nsh07/pomodoro/data/StateRepository.kt`](https://github.com/nsh07/tomato/blob/dev/shared/src/commonMain/kotlin/org/nsh07/pomodoro/data/StateRepository.kt) (Timer state repository)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["App and interface"]
  node_android["Android activity<br/>[MainActivity.kt]"]
  node_desktop["Desktop window<br/>[AppWindow.kt]"]
  node_screen["App navigation UI<br/>[AppScreen.kt]"]
  node_timerui["Timer screen<br/>[TimerMainPane.kt]"]
  node_settings["Timer and topic settings"]
  node_statsui["Statistics views<br/>[StatsScreen.kt]"]
end

subgraph group_timing["Timer runtime"]
  node_timer["Timer engine<br/>[TimerManager.kt]"]
  node_timerstate["Timer state<br/>[TimerState.kt]"]
end

subgraph group_data["Persistence and insights"]
  node_state["Timer state repository<br/>[StateRepository.kt]"]
  node_database[("App database<br/>[AppDatabase.kt]")]
  node_stats["Focus statistics repository<br/>[StatRepository.kt]"]
  node_backup["Backup and restore"]
end

subgraph group_platform["Platform integrations"]
  node_androidservice["Android timer service<br/>[TimerService.kt]"]
  node_quicktile["Quick Settings tile"]
  node_widgets["Android widgets<br/>[TimerAppWidget.kt]"]
end

subgraph group_premium["Plus billing"]
  node_billing["Billing capability<br/>[BillingManager.kt]"]
  node_playbilling["Play billing"]
  node_fossbilling["FOSS billing"]
end

node_user(("User"))
node_playstore["RevenueCat purchases"]
node_backupfile["Backup file"]

node_user -->|"opens app"| node_android
node_android -->|"renders"| node_screen
node_android -->|"restores session"| node_timer
node_user -->|"opens app"| node_desktop
node_desktop -->|"shows shared UI"| node_screen
node_screen -.->|"presents timer"| node_timerui
node_screen -.->|"presents settings"| node_settings
node_screen -.->|"presents statistics"| node_statsui
node_timerui -.->|"controls"| node_timer
node_timer -->|"updates"| node_timerstate
node_timer -->|"reads and persists"| node_state
node_timer -->|"records focus time"| node_stats
node_settings -.->|"configures timer"| node_state
node_statsui -.->|"shows summaries"| node_stats
node_androidservice -->|"runs timer loop"| node_timer
node_androidservice -->|"reads timer state"| node_state
node_quicktile -->|"reads timer state"| node_state
node_quicktile -->|"dispatches action"| node_androidservice
node_widgets -.->|"starts service"| node_androidservice
node_database -->|"backs up data"| node_backup
node_backup -->|"writes or restores"| node_backupfile
node_playbilling -->|"implements"| node_billing
node_playbilling -->|"fetches entitlements"| node_playstore
node_fossbilling -->|"implements"| node_billing

click node_android "https://github.com/nsh07/tomato/blob/dev/androidApp/src/main/java/org/nsh07/pomodoro/MainActivity.kt"
click node_desktop "https://github.com/nsh07/tomato/blob/dev/shared/src/jvmMain/kotlin/org/nsh07/pomodoro/AppWindow.kt"
click node_screen "https://github.com/nsh07/tomato/blob/dev/shared/src/commonMain/kotlin/org/nsh07/pomodoro/ui/AppScreen.kt"
click node_timerui "https://github.com/nsh07/tomato/blob/dev/shared/src/commonMain/kotlin/org/nsh07/pomodoro/ui/timerScreen/TimerMainPane.kt"
click node_statsui "https://github.com/nsh07/tomato/blob/dev/shared/src/commonMain/kotlin/org/nsh07/pomodoro/ui/statsScreen/StatsScreen.kt"
click node_timer "https://github.com/nsh07/tomato/blob/dev/shared/src/commonMain/kotlin/org/nsh07/pomodoro/service/TimerManager.kt"
click node_timerstate "https://github.com/nsh07/tomato/blob/dev/shared/src/commonMain/kotlin/org/nsh07/pomodoro/ui/timerScreen/viewModel/TimerState.kt"
click node_androidservice "https://github.com/nsh07/tomato/blob/dev/androidApp/src/main/java/org/nsh07/pomodoro/service/TimerService.kt"
click node_quicktile "https://github.com/nsh07/tomato/blob/dev/androidApp/src/main/java/org/nsh07/pomodoro/qsTile/TomatoQSTileService.kt"
click node_widgets "https://github.com/nsh07/tomato/blob/dev/androidApp/src/main/java/org/nsh07/pomodoro/widget/TimerAppWidget.kt"
click node_state "https://github.com/nsh07/tomato/blob/dev/shared/src/commonMain/kotlin/org/nsh07/pomodoro/data/StateRepository.kt"
click node_database "https://github.com/nsh07/tomato/blob/dev/shared/src/commonMain/kotlin/org/nsh07/pomodoro/data/AppDatabase.kt"
click node_stats "https://github.com/nsh07/tomato/blob/dev/shared/src/commonMain/kotlin/org/nsh07/pomodoro/data/StatRepository.kt"
click node_backup "https://github.com/nsh07/tomato/blob/dev/shared/src/commonMain/kotlin/org/nsh07/pomodoro/data/BackupRestoreManager.kt"
click node_billing "https://github.com/nsh07/tomato/blob/dev/shared/src/commonMain/kotlin/org/nsh07/pomodoro/billing/BillingManager.kt"
click node_playbilling "https://github.com/nsh07/tomato/blob/dev/androidApp/src/play/java/org/nsh07/pomodoro/billing/PlayBillingManager.kt"
click node_fossbilling "https://github.com/nsh07/tomato/blob/dev/androidApp/src/foss/java/org/nsh07/pomodoro/billing/FossBillingManager.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,node_desktop,node_screen,node_timerui,node_settings,node_statsui,node_user toneBlue
class node_timer,node_timerstate toneAmber
class node_state,node_database,node_stats,node_backup toneMint
class node_androidservice,node_quicktile,node_widgets toneRose
class node_billing,node_playbilling,node_fossbilling,node_playstore,node_backupfile toneIndigo
```

## Components

### App and interface

- [Android activity](https://github.com/nsh07/tomato/blob/dev/androidApp/src/main/java/org/nsh07/pomodoro/MainActivity.kt): `androidApp/src/main/java/org/nsh07/pomodoro/MainActivity.kt`
- [Desktop window](https://github.com/nsh07/tomato/blob/dev/shared/src/jvmMain/kotlin/org/nsh07/pomodoro/AppWindow.kt): `shared/src/jvmMain/kotlin/org/nsh07/pomodoro/AppWindow.kt`
- [App navigation UI](https://github.com/nsh07/tomato/blob/dev/shared/src/commonMain/kotlin/org/nsh07/pomodoro/ui/AppScreen.kt): `shared/src/commonMain/kotlin/org/nsh07/pomodoro/ui/AppScreen.kt`
- [Timer screen](https://github.com/nsh07/tomato/blob/dev/shared/src/commonMain/kotlin/org/nsh07/pomodoro/ui/timerScreen/TimerMainPane.kt): `shared/src/commonMain/kotlin/org/nsh07/pomodoro/ui/timerScreen/TimerMainPane.kt`
- **Timer and topic settings**
- [Statistics views](https://github.com/nsh07/tomato/blob/dev/shared/src/commonMain/kotlin/org/nsh07/pomodoro/ui/statsScreen/StatsScreen.kt): `shared/src/commonMain/kotlin/org/nsh07/pomodoro/ui/statsScreen/StatsScreen.kt`

### Timer runtime

- [Timer engine](https://github.com/nsh07/tomato/blob/dev/shared/src/commonMain/kotlin/org/nsh07/pomodoro/service/TimerManager.kt): `shared/src/commonMain/kotlin/org/nsh07/pomodoro/service/TimerManager.kt`
- [Timer state](https://github.com/nsh07/tomato/blob/dev/shared/src/commonMain/kotlin/org/nsh07/pomodoro/ui/timerScreen/viewModel/TimerState.kt): `shared/src/commonMain/kotlin/org/nsh07/pomodoro/ui/timerScreen/viewModel/TimerState.kt`

### Persistence and insights

- [Timer state repository](https://github.com/nsh07/tomato/blob/dev/shared/src/commonMain/kotlin/org/nsh07/pomodoro/data/StateRepository.kt): `shared/src/commonMain/kotlin/org/nsh07/pomodoro/data/StateRepository.kt`
- [App database](https://github.com/nsh07/tomato/blob/dev/shared/src/commonMain/kotlin/org/nsh07/pomodoro/data/AppDatabase.kt): `shared/src/commonMain/kotlin/org/nsh07/pomodoro/data/AppDatabase.kt`
- [Focus statistics repository](https://github.com/nsh07/tomato/blob/dev/shared/src/commonMain/kotlin/org/nsh07/pomodoro/data/StatRepository.kt): `shared/src/commonMain/kotlin/org/nsh07/pomodoro/data/StatRepository.kt`
- [Backup and restore](https://github.com/nsh07/tomato/blob/dev/shared/src/commonMain/kotlin/org/nsh07/pomodoro/data/BackupRestoreManager.kt): `shared/src/commonMain/kotlin/org/nsh07/pomodoro/data/BackupRestoreManager.kt`

### Platform integrations

- [Android timer service](https://github.com/nsh07/tomato/blob/dev/androidApp/src/main/java/org/nsh07/pomodoro/service/TimerService.kt): `androidApp/src/main/java/org/nsh07/pomodoro/service/TimerService.kt`
- [Quick Settings tile](https://github.com/nsh07/tomato/blob/dev/androidApp/src/main/java/org/nsh07/pomodoro/qsTile/TomatoQSTileService.kt): `androidApp/src/main/java/org/nsh07/pomodoro/qsTile/TomatoQSTileService.kt`
- [Android widgets](https://github.com/nsh07/tomato/blob/dev/androidApp/src/main/java/org/nsh07/pomodoro/widget/TimerAppWidget.kt): `androidApp/src/main/java/org/nsh07/pomodoro/widget/TimerAppWidget.kt`

### Plus billing

- [Billing capability](https://github.com/nsh07/tomato/blob/dev/shared/src/commonMain/kotlin/org/nsh07/pomodoro/billing/BillingManager.kt): `shared/src/commonMain/kotlin/org/nsh07/pomodoro/billing/BillingManager.kt`
- [Play billing](https://github.com/nsh07/tomato/blob/dev/androidApp/src/play/java/org/nsh07/pomodoro/billing/PlayBillingManager.kt): `androidApp/src/play/java/org/nsh07/pomodoro/billing/PlayBillingManager.kt`
- [FOSS billing](https://github.com/nsh07/tomato/blob/dev/androidApp/src/foss/java/org/nsh07/pomodoro/billing/FossBillingManager.kt): `androidApp/src/foss/java/org/nsh07/pomodoro/billing/FossBillingManager.kt`

### Other components

- **User**
- **RevenueCat purchases**
- **Backup file**

## Connections

- User → Android activity: opens app (evidence: `androidApp/src/main/java/org/nsh07/pomodoro/MainActivity.kt`)
- Android activity → App navigation UI: renders (evidence: `androidApp/src/main/java/org/nsh07/pomodoro/MainActivity.kt`)
- Android activity → Timer engine: restores session (evidence: `androidApp/src/main/java/org/nsh07/pomodoro/MainActivity.kt`)
- User → Desktop window: opens app
- Desktop window → App navigation UI: shows shared UI
- App navigation UI → Timer screen: presents timer
- App navigation UI → Timer and topic settings: presents settings
- App navigation UI → Statistics views: presents statistics (evidence: `README.md`)
- Timer screen → Timer engine: controls
- Timer engine → Timer state: updates (evidence: `shared/src/commonMain/kotlin/org/nsh07/pomodoro/service/TimerManager.kt`)
- Timer engine → Timer state repository: reads and persists (evidence: `shared/src/commonMain/kotlin/org/nsh07/pomodoro/service/TimerManager.kt`)
- Timer engine → Focus statistics repository: records focus time (evidence: `shared/src/commonMain/kotlin/org/nsh07/pomodoro/service/TimerManager.kt`)
- Timer and topic settings → Timer state repository: configures timer
- Statistics views → Focus statistics repository: shows summaries (evidence: `README.md`)
- Android timer service → Timer engine: runs timer loop (evidence: `androidApp/src/main/java/org/nsh07/pomodoro/service/TimerService.kt`)
- Android timer service → Timer state repository: reads timer state (evidence: `androidApp/src/main/java/org/nsh07/pomodoro/service/TimerService.kt`)
- Quick Settings tile → Timer state repository: reads timer state (evidence: `androidApp/src/main/java/org/nsh07/pomodoro/qsTile/TomatoQSTileService.kt`)
- Quick Settings tile → Android timer service: dispatches action (evidence: `androidApp/src/main/java/org/nsh07/pomodoro/qsTile/TomatoQSTileService.kt`)
- Android widgets → Android timer service: starts service (evidence: `androidApp/src/main/java/org/nsh07/pomodoro/service/TimerService.kt`)
- App database → Backup and restore: backs up data (evidence: `shared/src/androidMain/kotlin/org/nsh07/pomodoro/data/AndroidBackupRestoreManager.kt`)
- Backup and restore → Backup file: writes or restores
- Play billing → Billing capability: implements (evidence: `androidApp/src/play/java/org/nsh07/pomodoro/billing/PlayBillingManager.kt`)
- Play billing → RevenueCat purchases: fetches entitlements (evidence: `androidApp/src/play/java/org/nsh07/pomodoro/billing/PlayBillingManager.kt`)
- FOSS billing → Billing capability: implements (evidence: `androidApp/src/foss/java/org/nsh07/pomodoro/billing/FossBillingManager.kt`)
