# jlenteria/wakeguard architecture

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

- Interactive diagram: https://gitdiagram.com/jlenteria/wakeguard
- Repository: https://github.com/jlenteria/wakeguard

## Overview

WakeGuard is an offline-first alarm app whose native platform engines deliver alarms and challenges independently of Flutter. The main workflow is configuring an alarm, scheduling it on-device, completing a wake challenge, and optionally confirming a later Stay Awake check-in. The graph also preserves documented readiness, history, settings, onboarding, and QR capabilities. Flutter wiring and several feature implementations were not sampled; those relationships are shown only where the README or source index supports them.

Main entry points: [`lib/features/alarms/alarm_controller.dart`](https://github.com/jlenteria/wakeguard/blob/main/lib/features/alarms/alarm_controller.dart) (Alarm controller), [`android/app/src/main/kotlin/app/wakeguard/MainActivity.kt`](https://github.com/jlenteria/wakeguard/blob/main/android/app/src/main/kotlin/app/wakeguard/MainActivity.kt) (Android channel), [`lib/platform/alarm_engine.dart`](https://github.com/jlenteria/wakeguard/blob/main/lib/platform/alarm_engine.dart) (Alarm engine), [`android/app/src/main/kotlin/app/wakeguard/NativeAlarmScheduler.kt`](https://github.com/jlenteria/wakeguard/blob/main/android/app/src/main/kotlin/app/wakeguard/NativeAlarmScheduler.kt) (Alarm scheduler)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_flutter["Flutter app"]
  node_app["App shell<br/>[app.dart]"]
  node_alarm_ui["Alarm screens"]
  node_alarm_controller["Alarm controller"]
  node_alarm_repository["Alarm repository"]
end

subgraph group_domain["Alarm domain"]
  node_alarm_models["Alarm models<br/>[alarm.dart]"]
  node_reconcile["Alarm reconciliation<br/>[reconcile.dart]"]
  node_engine_contract["Alarm engine<br/>[alarm_engine.dart]"]
end

subgraph group_android["Android engine"]
  node_android_channel["Android channel<br/>[MainActivity.kt]"]
  node_android_store[("Alarm store<br/>[AlarmStore.kt]")]
  node_android_scheduler["Alarm scheduler"]
  node_android_receiver["Alarm receiver<br/>[AlarmReceiver.kt]"]
  node_android_sessions[("Alarm sessions<br/>[AlarmSessions.kt]")]
  node_android_service["Ringing service<br/>[RingingService.kt]"]
  node_android_challenge["Native challenge"]
  node_android_dismissal["Dismissal handler<br/>[AlarmDismissal.kt]"]
  node_android_checkin["Stay Awake<br/>[StayAwake.kt]"]
  node_android_health["Health checks<br/>[HealthChecker.kt]"]
end

subgraph group_ios["iOS engine"]
  node_ios_channel["iOS channel"]
  node_ios_scheduler["Ladder scheduler"]
  node_ios_actions["Alarm actions"]
  node_ios_challenge["Native challenge"]
  node_ios_health["Health checks"]
end

subgraph group_support["Supporting features"]
  node_settings["Settings"]
  node_health_ui["Readiness screen"]
  node_history_ui["History screen"]
  node_onboarding["Onboarding"]
  node_qr_feature["Wake-up QR"]
end

node_person(("User"))

node_person -->|"uses"| node_app
node_app -->|"presents"| node_alarm_ui
node_person -->|"configures alarms"| node_alarm_ui
node_alarm_ui -->|"uses"| node_alarm_controller
node_alarm_controller -->|"uses"| node_alarm_repository
node_alarm_controller -->|"manages"| node_alarm_models
node_alarm_repository -->|"reconciles"| node_reconcile
node_alarm_controller -->|"requests scheduling"| node_engine_contract
node_settings -->|"checks readiness"| node_engine_contract
node_person -->|"configures"| node_settings
node_person -->|"reviews readiness"| node_health_ui
node_person -->|"reviews history"| node_history_ui
node_person -->|"sets up"| node_onboarding
node_person -->|"creates or scans"| node_qr_feature
node_engine_contract -->|"bridges platform calls"| node_android_channel
node_android_channel -->|"reads and writes"| node_android_store
node_android_channel -->|"schedules alarms"| node_android_scheduler
node_android_scheduler -->|"persists schedule"| node_android_store
node_android_scheduler -->|"fires trigger"| node_android_receiver
node_android_receiver -->|"starts session"| node_android_sessions
node_android_receiver -->|"starts ringing"| node_android_service
node_android_sessions -->|"arms watchdogs"| node_android_scheduler
node_android_service -->|"checks session"| node_android_sessions
node_android_service -->|"launches challenge"| node_android_challenge
node_android_challenge -->|"completes alarm"| node_android_dismissal
node_android_dismissal -->|"finishes session"| node_android_sessions
node_android_dismissal -->|"schedules check-in"| node_android_checkin
node_android_channel -->|"checks readiness"| node_android_health
node_engine_contract -->|"bridges platform calls"| node_ios_channel
node_ios_channel -->|"schedules alarms"| node_ios_scheduler
node_ios_channel -->|"checks readiness"| node_ios_health
node_ios_actions -->|"cancels and reschedules"| node_ios_scheduler
node_ios_actions -->|"presents challenge"| node_ios_challenge
node_ios_challenge -->|"completes alarm"| node_ios_actions

click node_app "https://github.com/jlenteria/wakeguard/blob/main/lib/app.dart"
click node_alarm_ui "https://github.com/jlenteria/wakeguard/tree/main/lib/features/alarms"
click node_alarm_controller "https://github.com/jlenteria/wakeguard/blob/main/lib/features/alarms/alarm_controller.dart"
click node_alarm_repository "https://github.com/jlenteria/wakeguard/blob/main/lib/features/alarms/alarm_repository.dart"
click node_alarm_models "https://github.com/jlenteria/wakeguard/blob/main/lib/models/alarm.dart"
click node_reconcile "https://github.com/jlenteria/wakeguard/blob/main/lib/models/reconcile.dart"
click node_engine_contract "https://github.com/jlenteria/wakeguard/blob/main/lib/platform/alarm_engine.dart"
click node_settings "https://github.com/jlenteria/wakeguard/tree/main/lib/features/settings"
click node_health_ui "https://github.com/jlenteria/wakeguard/tree/main/lib/features/health"
click node_history_ui "https://github.com/jlenteria/wakeguard/tree/main/lib/features/history"
click node_onboarding "https://github.com/jlenteria/wakeguard/tree/main/lib/features/onboarding"
click node_qr_feature "https://github.com/jlenteria/wakeguard/tree/main/lib/features/challenges"
click node_android_channel "https://github.com/jlenteria/wakeguard/blob/main/android/app/src/main/kotlin/app/wakeguard/MainActivity.kt"
click node_android_store "https://github.com/jlenteria/wakeguard/blob/main/android/app/src/main/kotlin/app/wakeguard/AlarmStore.kt"
click node_android_scheduler "https://github.com/jlenteria/wakeguard/blob/main/android/app/src/main/kotlin/app/wakeguard/NativeAlarmScheduler.kt"
click node_android_receiver "https://github.com/jlenteria/wakeguard/blob/main/android/app/src/main/kotlin/app/wakeguard/AlarmReceiver.kt"
click node_android_sessions "https://github.com/jlenteria/wakeguard/blob/main/android/app/src/main/kotlin/app/wakeguard/AlarmSessions.kt"
click node_android_service "https://github.com/jlenteria/wakeguard/blob/main/android/app/src/main/kotlin/app/wakeguard/RingingService.kt"
click node_android_challenge "https://github.com/jlenteria/wakeguard/blob/main/android/app/src/main/kotlin/app/wakeguard/AlarmRingActivity.kt"
click node_android_dismissal "https://github.com/jlenteria/wakeguard/blob/main/android/app/src/main/kotlin/app/wakeguard/AlarmDismissal.kt"
click node_android_checkin "https://github.com/jlenteria/wakeguard/blob/main/android/app/src/main/kotlin/app/wakeguard/StayAwake.kt"
click node_android_health "https://github.com/jlenteria/wakeguard/blob/main/android/app/src/main/kotlin/app/wakeguard/HealthChecker.kt"
click node_ios_channel "https://github.com/jlenteria/wakeguard/blob/main/ios/Runner/AlarmEngineChannel.swift"
click node_ios_scheduler "https://github.com/jlenteria/wakeguard/blob/main/ios/Runner/LadderScheduler.swift"
click node_ios_actions "https://github.com/jlenteria/wakeguard/blob/main/ios/Runner/AlarmActionHandler.swift"
click node_ios_challenge "https://github.com/jlenteria/wakeguard/blob/main/ios/Runner/WakeChallengeViewController.swift"
click node_ios_health "https://github.com/jlenteria/wakeguard/blob/main/ios/Runner/HealthChecker.swift"

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_alarm_ui,node_alarm_controller,node_alarm_repository,node_person toneBlue
class node_alarm_models,node_reconcile,node_engine_contract toneAmber
class node_android_channel,node_android_store,node_android_scheduler,node_android_receiver,node_android_sessions,node_android_service,node_android_challenge,node_android_dismissal,node_android_checkin,node_android_health toneMint
class node_ios_channel,node_ios_scheduler,node_ios_actions,node_ios_challenge,node_ios_health toneRose
class node_settings,node_health_ui,node_history_ui,node_onboarding,node_qr_feature toneIndigo
```

## Components

### Flutter app

- [App shell](https://github.com/jlenteria/wakeguard/blob/main/lib/app.dart): `lib/app.dart`
- [Alarm screens](https://github.com/jlenteria/wakeguard/tree/main/lib/features/alarms): `lib/features/alarms`
- [Alarm controller](https://github.com/jlenteria/wakeguard/blob/main/lib/features/alarms/alarm_controller.dart): `lib/features/alarms/alarm_controller.dart`
- [Alarm repository](https://github.com/jlenteria/wakeguard/blob/main/lib/features/alarms/alarm_repository.dart): `lib/features/alarms/alarm_repository.dart`

### Alarm domain

- [Alarm models](https://github.com/jlenteria/wakeguard/blob/main/lib/models/alarm.dart): `lib/models/alarm.dart`
- [Alarm reconciliation](https://github.com/jlenteria/wakeguard/blob/main/lib/models/reconcile.dart): `lib/models/reconcile.dart`
- [Alarm engine](https://github.com/jlenteria/wakeguard/blob/main/lib/platform/alarm_engine.dart): `lib/platform/alarm_engine.dart`

### Android engine

- [Android channel](https://github.com/jlenteria/wakeguard/blob/main/android/app/src/main/kotlin/app/wakeguard/MainActivity.kt): `android/app/src/main/kotlin/app/wakeguard/MainActivity.kt`
- [Alarm store](https://github.com/jlenteria/wakeguard/blob/main/android/app/src/main/kotlin/app/wakeguard/AlarmStore.kt): `android/app/src/main/kotlin/app/wakeguard/AlarmStore.kt`
- [Alarm scheduler](https://github.com/jlenteria/wakeguard/blob/main/android/app/src/main/kotlin/app/wakeguard/NativeAlarmScheduler.kt): `android/app/src/main/kotlin/app/wakeguard/NativeAlarmScheduler.kt`
- [Alarm receiver](https://github.com/jlenteria/wakeguard/blob/main/android/app/src/main/kotlin/app/wakeguard/AlarmReceiver.kt): `android/app/src/main/kotlin/app/wakeguard/AlarmReceiver.kt`
- [Alarm sessions](https://github.com/jlenteria/wakeguard/blob/main/android/app/src/main/kotlin/app/wakeguard/AlarmSessions.kt): `android/app/src/main/kotlin/app/wakeguard/AlarmSessions.kt`
- [Ringing service](https://github.com/jlenteria/wakeguard/blob/main/android/app/src/main/kotlin/app/wakeguard/RingingService.kt): `android/app/src/main/kotlin/app/wakeguard/RingingService.kt`
- [Native challenge](https://github.com/jlenteria/wakeguard/blob/main/android/app/src/main/kotlin/app/wakeguard/AlarmRingActivity.kt): `android/app/src/main/kotlin/app/wakeguard/AlarmRingActivity.kt`
- [Dismissal handler](https://github.com/jlenteria/wakeguard/blob/main/android/app/src/main/kotlin/app/wakeguard/AlarmDismissal.kt): `android/app/src/main/kotlin/app/wakeguard/AlarmDismissal.kt`
- [Stay Awake](https://github.com/jlenteria/wakeguard/blob/main/android/app/src/main/kotlin/app/wakeguard/StayAwake.kt): `android/app/src/main/kotlin/app/wakeguard/StayAwake.kt`
- [Health checks](https://github.com/jlenteria/wakeguard/blob/main/android/app/src/main/kotlin/app/wakeguard/HealthChecker.kt): `android/app/src/main/kotlin/app/wakeguard/HealthChecker.kt`

### iOS engine

- [iOS channel](https://github.com/jlenteria/wakeguard/blob/main/ios/Runner/AlarmEngineChannel.swift): `ios/Runner/AlarmEngineChannel.swift`
- [Ladder scheduler](https://github.com/jlenteria/wakeguard/blob/main/ios/Runner/LadderScheduler.swift): `ios/Runner/LadderScheduler.swift`
- [Alarm actions](https://github.com/jlenteria/wakeguard/blob/main/ios/Runner/AlarmActionHandler.swift): `ios/Runner/AlarmActionHandler.swift`
- [Native challenge](https://github.com/jlenteria/wakeguard/blob/main/ios/Runner/WakeChallengeViewController.swift): `ios/Runner/WakeChallengeViewController.swift`
- [Health checks](https://github.com/jlenteria/wakeguard/blob/main/ios/Runner/HealthChecker.swift): `ios/Runner/HealthChecker.swift`

### Supporting features

- [Settings](https://github.com/jlenteria/wakeguard/tree/main/lib/features/settings): `lib/features/settings`
- [Readiness screen](https://github.com/jlenteria/wakeguard/tree/main/lib/features/health): `lib/features/health`
- [History screen](https://github.com/jlenteria/wakeguard/tree/main/lib/features/history): `lib/features/history`
- [Onboarding](https://github.com/jlenteria/wakeguard/tree/main/lib/features/onboarding): `lib/features/onboarding`
- [Wake-up QR](https://github.com/jlenteria/wakeguard/tree/main/lib/features/challenges): `lib/features/challenges`

### Other components

- **User**

## Connections

- User → App shell: uses (evidence: `README.md`)
- App shell → Alarm screens: presents (evidence: `README.md`)
- User → Alarm screens: configures alarms (evidence: `README.md`)
- Alarm screens → Alarm controller: uses (evidence: `README.md`)
- Alarm controller → Alarm repository: uses (evidence: `README.md`)
- Alarm controller → Alarm models: manages (evidence: `README.md`)
- Alarm repository → Alarm reconciliation: reconciles (evidence: `README.md`)
- Alarm controller → Alarm engine: requests scheduling (evidence: `README.md`)
- Settings → Alarm engine: checks readiness (evidence: `README.md`)
- User → Settings: configures (evidence: `README.md`)
- User → Readiness screen: reviews readiness (evidence: `README.md`)
- User → History screen: reviews history (evidence: `README.md`)
- User → Onboarding: sets up (evidence: `README.md`)
- User → Wake-up QR: creates or scans (evidence: `README.md`)
- Alarm engine → Android channel: bridges platform calls (evidence: `README.md`)
- Android channel → Alarm store: reads and writes (evidence: `android/app/src/main/kotlin/app/wakeguard/MainActivity.kt`)
- Android channel → Alarm scheduler: schedules alarms (evidence: `android/app/src/main/kotlin/app/wakeguard/MainActivity.kt`)
- Alarm scheduler → Alarm store: persists schedule (evidence: `android/app/src/main/kotlin/app/wakeguard/NativeAlarmScheduler.kt`)
- Alarm scheduler → Alarm receiver: fires trigger (evidence: `android/app/src/main/kotlin/app/wakeguard/NativeAlarmScheduler.kt`)
- Alarm receiver → Alarm sessions: starts session (evidence: `android/app/src/main/kotlin/app/wakeguard/AlarmReceiver.kt`)
- Alarm receiver → Ringing service: starts ringing (evidence: `android/app/src/main/kotlin/app/wakeguard/AlarmReceiver.kt`)
- Alarm sessions → Alarm scheduler: arms watchdogs (evidence: `android/app/src/main/kotlin/app/wakeguard/AlarmSessions.kt`)
- Ringing service → Alarm sessions: checks session (evidence: `android/app/src/main/kotlin/app/wakeguard/RingingService.kt`)
- Ringing service → Native challenge: launches challenge (evidence: `android/app/src/main/kotlin/app/wakeguard/RingingService.kt`)
- Native challenge → Dismissal handler: completes alarm (evidence: `android/app/src/main/kotlin/app/wakeguard/AlarmRingActivity.kt`)
- Dismissal handler → Alarm sessions: finishes session (evidence: `android/app/src/main/kotlin/app/wakeguard/AlarmDismissal.kt`)
- Dismissal handler → Stay Awake: schedules check-in (evidence: `android/app/src/main/kotlin/app/wakeguard/AlarmDismissal.kt`)
- Android channel → Health checks: checks readiness (evidence: `android/app/src/main/kotlin/app/wakeguard/MainActivity.kt`)
- Alarm engine → iOS channel: bridges platform calls (evidence: `README.md`)
- iOS channel → Ladder scheduler: schedules alarms (evidence: `ios/Runner/AlarmEngineChannel.swift`)
- iOS channel → Health checks: checks readiness (evidence: `ios/Runner/AlarmEngineChannel.swift`)
- Alarm actions → Ladder scheduler: cancels and reschedules (evidence: `ios/Runner/AlarmActionHandler.swift`)
- Alarm actions → Native challenge: presents challenge (evidence: `ios/Runner/AlarmActionHandler.swift`)
- Native challenge → Alarm actions: completes alarm (evidence: `ios/Runner/WakeChallengeViewController.swift`)
