# fcwe1113/transport_alarm architecture

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

- Interactive diagram: https://gitdiagram.com/fcwe1113/transport_alarm
- Repository: https://github.com/fcwe1113/transport_alarm

## Overview

Transport Alarm is a Flutter app for notifying users as a bus approaches. The visible iOS workflow processes an incoming ping, checks shared alarm state and transit estimates, updates the alarm, and returns notification content; users can also acknowledge a ping to advance or stop it. Native iOS code provides AlarmKit scheduling and a countdown Live Activity, while an Android plugin supports live countdowns. The README and supplied tree do not expose the Flutter feature code, so initial alarm creation and the complete cross-platform workflow cannot be mapped. The backend is represented without inferred internals.

Main entry points: [`ios/NotificationServiceExtension/NativePingHandler.swift`](https://github.com/fcwe1113/transport_alarm/blob/master/ios/NotificationServiceExtension/NativePingHandler.swift) (Ping processing), [`ios/Shared/AppGroup.swift`](https://github.com/fcwe1113/transport_alarm/blob/master/ios/Shared/AppGroup.swift) (Shared alarm storage), [`ios/NotificationServiceExtension/NotificationService.swift`](https://github.com/fcwe1113/transport_alarm/blob/master/ios/NotificationServiceExtension/NotificationService.swift) (Notification service), [`ios/Shared/AlarmKitBridge.swift`](https://github.com/fcwe1113/transport_alarm/blob/master/ios/Shared/AlarmKitBridge.swift) (AlarmKit bridge)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ios_alarm["iOS Alarm Runtime"]
  node_app_delegate["iOS app entry<br/>[AppDelegate.swift]"]
  node_alarm_bridge["AlarmKit bridge"]
  node_alarm_scheduler["AlarmKit scheduler"]
  node_notification_service["Notification service"]
  node_ping_handler["Ping processing"]
  node_ack_handler["Ping acknowledgement"]
end

subgraph group_ios_support["iOS Shared Support"]
  node_shared_state[("Shared alarm storage<br/>[AppGroup.swift]")]
  node_localization["Native localization"]
  node_transit_locale["Transit locale rules"]
  node_alarm_metadata["Alarm metadata"]
end

subgraph group_services["Server and Transit"]
  node_eta_provider["Transit ETA provider"]
  node_backend["Alarm worker<br/>[index.ts]"]
end

subgraph group_countdown["Countdown UI"]
  node_live_activity["iOS Live Activity"]
  node_android_countdown["Android countdown plugin"]
  node_android_localization["Android localization"]
end

node_user(("App user"))

node_user -.->|"uses app"| node_app_delegate
node_app_delegate -->|"routes calls"| node_alarm_bridge
node_alarm_bridge -->|"schedules alarms"| node_alarm_scheduler
node_alarm_bridge -->|"reads alarm state"| node_shared_state
node_alarm_scheduler -->|"uses metadata"| node_alarm_metadata
node_notification_service -->|"processes ping"| node_ping_handler
node_notification_service -->|"gets container"| node_shared_state
node_notification_service -->|"formats fallback"| node_localization
node_ping_handler -->|"reads alarm data"| node_shared_state
node_ping_handler -->|"formats messages"| node_localization
node_ping_handler -->|"uses locale rules"| node_transit_locale
node_ping_handler -->|"sends ping requests"| node_backend
node_ack_handler -->|"updates alarm data"| node_shared_state
node_ack_handler -->|"reschedules or acknowledges"| node_backend
node_live_activity -->|"renders alarm state"| node_alarm_metadata
node_android_countdown -->|"uses localization"| node_android_localization

click node_app_delegate "https://github.com/fcwe1113/transport_alarm/blob/master/ios/Runner/AppDelegate.swift"
click node_alarm_bridge "https://github.com/fcwe1113/transport_alarm/blob/master/ios/Shared/AlarmKitBridge.swift"
click node_alarm_scheduler "https://github.com/fcwe1113/transport_alarm/blob/master/ios/Shared/AlarmKitScheduler.swift"
click node_notification_service "https://github.com/fcwe1113/transport_alarm/blob/master/ios/NotificationServiceExtension/NotificationService.swift"
click node_ping_handler "https://github.com/fcwe1113/transport_alarm/blob/master/ios/NotificationServiceExtension/NativePingHandler.swift"
click node_ack_handler "https://github.com/fcwe1113/transport_alarm/blob/master/ios/Runner/PingAcknowledgementHandler.swift"
click node_shared_state "https://github.com/fcwe1113/transport_alarm/blob/master/ios/Shared/AppGroup.swift"
click node_localization "https://github.com/fcwe1113/transport_alarm/blob/master/ios/Shared/NativeLocalization.swift"
click node_transit_locale "https://github.com/fcwe1113/transport_alarm/blob/master/ios/NotificationServiceExtension/NativeTransitLocale.swift"
click node_alarm_metadata "https://github.com/fcwe1113/transport_alarm/blob/master/ios/Shared/TransportAlarmMetadata.swift"
click node_eta_provider "https://github.com/fcwe1113/transport_alarm/blob/master/ios/NotificationServiceExtension/NativeTransitETAProvider.swift"
click node_backend "https://github.com/fcwe1113/transport_alarm/blob/master/backend/src/index.ts"
click node_live_activity "https://github.com/fcwe1113/transport_alarm/blob/master/ios/AlarmWidgetExtension/AlarmLiveActivity.swift"
click node_android_countdown "https://github.com/fcwe1113/transport_alarm/blob/master/packages/live_update_countdown/android/src/main/java/dev/fcwe1113/liveupdatecountdown/LiveUpdateCountdownPlugin.java"
click node_android_localization "https://github.com/fcwe1113/transport_alarm/blob/master/packages/live_update_countdown/android/src/main/java/dev/fcwe1113/liveupdatecountdown/NativeLocalization.java"

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_delegate,node_alarm_bridge,node_alarm_scheduler,node_notification_service,node_ping_handler,node_ack_handler,node_user toneBlue
class node_shared_state,node_localization,node_transit_locale,node_alarm_metadata toneAmber
class node_eta_provider,node_backend toneMint
class node_live_activity,node_android_countdown,node_android_localization toneRose
```

## Components

### iOS Alarm Runtime

- [iOS app entry](https://github.com/fcwe1113/transport_alarm/blob/master/ios/Runner/AppDelegate.swift): `ios/Runner/AppDelegate.swift`
- [AlarmKit bridge](https://github.com/fcwe1113/transport_alarm/blob/master/ios/Shared/AlarmKitBridge.swift): `ios/Shared/AlarmKitBridge.swift`
- [AlarmKit scheduler](https://github.com/fcwe1113/transport_alarm/blob/master/ios/Shared/AlarmKitScheduler.swift): `ios/Shared/AlarmKitScheduler.swift`
- [Notification service](https://github.com/fcwe1113/transport_alarm/blob/master/ios/NotificationServiceExtension/NotificationService.swift): `ios/NotificationServiceExtension/NotificationService.swift`
- [Ping processing](https://github.com/fcwe1113/transport_alarm/blob/master/ios/NotificationServiceExtension/NativePingHandler.swift): `ios/NotificationServiceExtension/NativePingHandler.swift`
- [Ping acknowledgement](https://github.com/fcwe1113/transport_alarm/blob/master/ios/Runner/PingAcknowledgementHandler.swift): `ios/Runner/PingAcknowledgementHandler.swift`

### iOS Shared Support

- [Shared alarm storage](https://github.com/fcwe1113/transport_alarm/blob/master/ios/Shared/AppGroup.swift): `ios/Shared/AppGroup.swift`
- [Native localization](https://github.com/fcwe1113/transport_alarm/blob/master/ios/Shared/NativeLocalization.swift): `ios/Shared/NativeLocalization.swift`
- [Transit locale rules](https://github.com/fcwe1113/transport_alarm/blob/master/ios/NotificationServiceExtension/NativeTransitLocale.swift): `ios/NotificationServiceExtension/NativeTransitLocale.swift`
- [Alarm metadata](https://github.com/fcwe1113/transport_alarm/blob/master/ios/Shared/TransportAlarmMetadata.swift): `ios/Shared/TransportAlarmMetadata.swift`

### Server and Transit

- [Transit ETA provider](https://github.com/fcwe1113/transport_alarm/blob/master/ios/NotificationServiceExtension/NativeTransitETAProvider.swift): `ios/NotificationServiceExtension/NativeTransitETAProvider.swift`
- [Alarm worker](https://github.com/fcwe1113/transport_alarm/blob/master/backend/src/index.ts): `backend/src/index.ts`

### Countdown UI

- [iOS Live Activity](https://github.com/fcwe1113/transport_alarm/blob/master/ios/AlarmWidgetExtension/AlarmLiveActivity.swift): `ios/AlarmWidgetExtension/AlarmLiveActivity.swift`
- [Android countdown plugin](https://github.com/fcwe1113/transport_alarm/blob/master/packages/live_update_countdown/android/src/main/java/dev/fcwe1113/liveupdatecountdown/LiveUpdateCountdownPlugin.java): `packages/live_update_countdown/android/src/main/java/dev/fcwe1113/liveupdatecountdown/LiveUpdateCountdownPlugin.java`
- [Android localization](https://github.com/fcwe1113/transport_alarm/blob/master/packages/live_update_countdown/android/src/main/java/dev/fcwe1113/liveupdatecountdown/NativeLocalization.java): `packages/live_update_countdown/android/src/main/java/dev/fcwe1113/liveupdatecountdown/NativeLocalization.java`

### Other components

- **App user**

## Connections

- App user → iOS app entry: uses app
- iOS app entry → AlarmKit bridge: routes calls (evidence: `ios/Runner/AppDelegate.swift`)
- AlarmKit bridge → AlarmKit scheduler: schedules alarms (evidence: `ios/Shared/AlarmKitBridge.swift`)
- AlarmKit bridge → Shared alarm storage: reads alarm state (evidence: `ios/Shared/AlarmKitBridge.swift`)
- AlarmKit scheduler → Alarm metadata: uses metadata (evidence: `ios/Shared/AlarmKitScheduler.swift`)
- Notification service → Ping processing: processes ping (evidence: `ios/NotificationServiceExtension/NotificationService.swift`)
- Notification service → Shared alarm storage: gets container (evidence: `ios/NotificationServiceExtension/NotificationService.swift`)
- Notification service → Native localization: formats fallback (evidence: `ios/NotificationServiceExtension/NotificationService.swift`)
- Ping processing → Shared alarm storage: reads alarm data (evidence: `ios/NotificationServiceExtension/NativePingHandler.swift`)
- Ping processing → Native localization: formats messages (evidence: `ios/NotificationServiceExtension/NativePingHandler.swift`)
- Ping processing → Transit locale rules: uses locale rules (evidence: `ios/NotificationServiceExtension/NativePingHandler.swift`)
- Ping processing → Alarm worker: sends ping requests (evidence: `ios/NotificationServiceExtension/NativePingHandler.swift`)
- Ping acknowledgement → Shared alarm storage: updates alarm data (evidence: `ios/Runner/PingAcknowledgementHandler.swift`)
- Ping acknowledgement → Alarm worker: reschedules or acknowledges (evidence: `ios/Runner/PingAcknowledgementHandler.swift`)
- iOS Live Activity → Alarm metadata: renders alarm state (evidence: `ios/AlarmWidgetExtension/AlarmLiveActivity.swift`)
- Android countdown plugin → Android localization: uses localization (evidence: `packages/live_update_countdown/android/src/main/java/dev/fcwe1113/liveupdatecountdown/LiveUpdateCountdownPlugin.java`)
