# zeppyx13/snapwake-expo architecture

> Architecture diagram of the GitHub repository zeppyx13/snapwake-expo, 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/zeppyx13/snapwake-expo
- Repository: https://github.com/zeppyx13/snapwake-expo

## Overview

SnapWake is an alarm app whose wake-up flow requires the user to scan a configured object. Users create or edit alarms, then the app supports waking through object detection and presents a wake result; authentication and account features support that experience. The sampled API client also exposes subscriptions, custom alarm sounds, logs, and gamification/leaderboard operations, so these remain visible as product capabilities. The Android alarm implementation is represented separately: available excerpts establish only a limited relationship within it, so unverified native dispatch links are omitted.

Main entry points: [`src/app/scan.tsx`](https://github.com/zeppyx13/snapwake-expo/blob/main/src/app/scan.tsx) (Object scan), [`src/services/api.ts`](https://github.com/zeppyx13/snapwake-expo/blob/main/src/services/api.ts) (API client), [`src/app/edit-alarm/[id].tsx`](https://github.com/zeppyx13/snapwake-expo/blob/main/src/app/edit-alarm/%5Bid%5D.tsx) (Create and edit alarms), [`src/hooks/use-auth.tsx`](https://github.com/zeppyx13/snapwake-expo/blob/main/src/hooks/use-auth.tsx) (Authentication state)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_account["Account and engagement"]
  node_authscreens["Sign in and register<br/>[register.tsx]"]
  node_auth["Authentication state<br/>[use-auth.tsx]"]
  node_accountpages["Profile and plans<br/>[profile.tsx]"]
  node_leaderboard["Leaderboard<br/>[leaderboard.tsx]"]
  node_gamification["Gamification mapping<br/>[gamification.ts]"]
end

subgraph group_alarm["Alarm setup"]
  node_alarmform["Alarm form<br/>[AlarmForm.tsx]"]
  node_alarmedit["Create and edit alarms<br/>[&#91;id&#93;.tsx]"]
  node_soundselector["Sound selection"]
  node_alarmtypes["Alarm data types<br/>[alarm.ts]"]
  node_alarmutils["Alarm conversion<br/>[alarm.ts]"]
end

subgraph group_wake["Wake experience"]
  node_scan["Object scan<br/>[scan.tsx]"]
  node_detection["Detection status"]
  node_challenge["Math challenge"]
  node_wakestorage[("Wake result storage<br/>[storage.ts]")]
  node_wakepage["Wake result screen<br/>[wake-result.tsx]"]
  node_history["Alarm history<br/>[history.tsx]"]
end

subgraph group_platform["Services and platform"]
  node_api["API client<br/>[api.ts]"]
  node_backend{{"SnapWake backend"}}
  node_nativebridge["Native alarm bridge<br/>[native-alarm.ts]"]
  node_nativemodule["Android alarm module"]
  node_ringservice["Alarm ringing service"]
  node_alarmconstants["Native alarm constants"]
end

node_person(("User"))

node_person -->|"signs in"| node_authscreens
node_authscreens -->|"uses auth state"| node_auth
node_auth -->|"authenticates"| node_api
node_auth -->|"persists credentials"| node_wakestorage
node_person -->|"configures alarm"| node_alarmedit
node_alarmedit -->|"renders form"| node_alarmform
node_alarmedit -->|"loads and saves"| node_api
node_alarmedit -->|"converts alarm"| node_alarmutils
node_alarmform -->|"offers sound selection"| node_soundselector
node_soundselector -->|"manages custom sounds"| node_api
node_alarmutils -->|"uses alarm types"| node_alarmtypes
node_person -->|"completes wake scan"| node_scan
node_scan -->|"shows detection status"| node_detection
node_scan -->|"presents challenge"| node_challenge
node_scan -->|"submits wake data"| node_api
node_scan -->|"uses alarm bridge"| node_nativebridge
node_scan -->|"saves wake result"| node_wakestorage
node_wakestorage -->|"hands off result"| node_wakepage
node_person -.->|"views history"| node_history
node_person -.->|"views account"| node_accountpages
node_person -.->|"views rankings"| node_leaderboard
node_accountpages -->|"formats statistics"| node_gamification
node_api -->|"normalizes responses"| node_gamification
node_api -->|"sends HTTP requests"| node_backend
node_ringservice -->|"uses constants"| node_alarmconstants

click node_authscreens "https://github.com/zeppyx13/snapwake-expo/blob/main/src/app/(auth)/register.tsx"
click node_auth "https://github.com/zeppyx13/snapwake-expo/blob/main/src/hooks/use-auth.tsx"
click node_accountpages "https://github.com/zeppyx13/snapwake-expo/blob/main/src/app/(tabs)/profile.tsx"
click node_leaderboard "https://github.com/zeppyx13/snapwake-expo/blob/main/src/app/leaderboard.tsx"
click node_alarmform "https://github.com/zeppyx13/snapwake-expo/blob/main/src/components/alarm/AlarmForm.tsx"
click node_alarmedit "https://github.com/zeppyx13/snapwake-expo/blob/main/src/app/edit-alarm/%5Bid%5D.tsx"
click node_soundselector "https://github.com/zeppyx13/snapwake-expo/blob/main/src/components/alarm/AlarmSoundSelector.tsx"
click node_alarmtypes "https://github.com/zeppyx13/snapwake-expo/blob/main/src/types/alarm.ts"
click node_alarmutils "https://github.com/zeppyx13/snapwake-expo/blob/main/src/utils/alarm.ts"
click node_scan "https://github.com/zeppyx13/snapwake-expo/blob/main/src/app/scan.tsx"
click node_detection "https://github.com/zeppyx13/snapwake-expo/blob/main/src/components/DetectionStatusCard.tsx"
click node_challenge "https://github.com/zeppyx13/snapwake-expo/blob/main/src/components/MathChallengeCard.tsx"
click node_wakestorage "https://github.com/zeppyx13/snapwake-expo/blob/main/src/utils/storage.ts"
click node_wakepage "https://github.com/zeppyx13/snapwake-expo/blob/main/src/app/wake-result.tsx"
click node_history "https://github.com/zeppyx13/snapwake-expo/blob/main/src/app/(tabs)/history.tsx"
click node_gamification "https://github.com/zeppyx13/snapwake-expo/blob/main/src/utils/gamification.ts"
click node_api "https://github.com/zeppyx13/snapwake-expo/blob/main/src/services/api.ts"
click node_nativebridge "https://github.com/zeppyx13/snapwake-expo/blob/main/src/native/native-alarm.ts"
click node_nativemodule "https://github.com/zeppyx13/snapwake-expo/blob/main/android/app/src/main/java/com/anonymous/SnapWake/nativealarm/NativeAlarmModule.kt"
click node_ringservice "https://github.com/zeppyx13/snapwake-expo/blob/main/android/app/src/main/java/com/anonymous/SnapWake/nativealarm/NativeAlarmRingingService.kt"
click node_alarmconstants "https://github.com/zeppyx13/snapwake-expo/blob/main/android/app/src/main/java/com/anonymous/SnapWake/nativealarm/NativeAlarmConstants.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_authscreens,node_auth,node_accountpages,node_leaderboard,node_gamification,node_person toneBlue
class node_alarmform,node_alarmedit,node_soundselector,node_alarmtypes,node_alarmutils toneAmber
class node_scan,node_detection,node_challenge,node_wakestorage,node_wakepage,node_history toneMint
class node_api,node_backend,node_nativebridge,node_nativemodule,node_ringservice,node_alarmconstants toneRose
```

## Components

### Account and engagement

- [Sign in and register](https://github.com/zeppyx13/snapwake-expo/blob/main/src/app/(auth)/register.tsx): `src/app/(auth)/register.tsx`
- [Authentication state](https://github.com/zeppyx13/snapwake-expo/blob/main/src/hooks/use-auth.tsx): `src/hooks/use-auth.tsx`
- [Profile and plans](https://github.com/zeppyx13/snapwake-expo/blob/main/src/app/(tabs)/profile.tsx): `src/app/(tabs)/profile.tsx`
- [Leaderboard](https://github.com/zeppyx13/snapwake-expo/blob/main/src/app/leaderboard.tsx): `src/app/leaderboard.tsx`
- [Gamification mapping](https://github.com/zeppyx13/snapwake-expo/blob/main/src/utils/gamification.ts): `src/utils/gamification.ts`

### Alarm setup

- [Alarm form](https://github.com/zeppyx13/snapwake-expo/blob/main/src/components/alarm/AlarmForm.tsx): `src/components/alarm/AlarmForm.tsx`
- [Create and edit alarms](https://github.com/zeppyx13/snapwake-expo/blob/main/src/app/edit-alarm/%5Bid%5D.tsx): `src/app/edit-alarm/[id].tsx`
- [Sound selection](https://github.com/zeppyx13/snapwake-expo/blob/main/src/components/alarm/AlarmSoundSelector.tsx): `src/components/alarm/AlarmSoundSelector.tsx`
- [Alarm data types](https://github.com/zeppyx13/snapwake-expo/blob/main/src/types/alarm.ts): `src/types/alarm.ts`
- [Alarm conversion](https://github.com/zeppyx13/snapwake-expo/blob/main/src/utils/alarm.ts): `src/utils/alarm.ts`

### Wake experience

- [Object scan](https://github.com/zeppyx13/snapwake-expo/blob/main/src/app/scan.tsx): `src/app/scan.tsx`
- [Detection status](https://github.com/zeppyx13/snapwake-expo/blob/main/src/components/DetectionStatusCard.tsx): `src/components/DetectionStatusCard.tsx`
- [Math challenge](https://github.com/zeppyx13/snapwake-expo/blob/main/src/components/MathChallengeCard.tsx): `src/components/MathChallengeCard.tsx`
- [Wake result storage](https://github.com/zeppyx13/snapwake-expo/blob/main/src/utils/storage.ts): `src/utils/storage.ts`
- [Wake result screen](https://github.com/zeppyx13/snapwake-expo/blob/main/src/app/wake-result.tsx): `src/app/wake-result.tsx`
- [Alarm history](https://github.com/zeppyx13/snapwake-expo/blob/main/src/app/(tabs)/history.tsx): `src/app/(tabs)/history.tsx`

### Services and platform

- [API client](https://github.com/zeppyx13/snapwake-expo/blob/main/src/services/api.ts): `src/services/api.ts`
- **SnapWake backend**
- [Native alarm bridge](https://github.com/zeppyx13/snapwake-expo/blob/main/src/native/native-alarm.ts): `src/native/native-alarm.ts`
- [Android alarm module](https://github.com/zeppyx13/snapwake-expo/blob/main/android/app/src/main/java/com/anonymous/SnapWake/nativealarm/NativeAlarmModule.kt): `android/app/src/main/java/com/anonymous/SnapWake/nativealarm/NativeAlarmModule.kt`
- [Alarm ringing service](https://github.com/zeppyx13/snapwake-expo/blob/main/android/app/src/main/java/com/anonymous/SnapWake/nativealarm/NativeAlarmRingingService.kt): `android/app/src/main/java/com/anonymous/SnapWake/nativealarm/NativeAlarmRingingService.kt`
- [Native alarm constants](https://github.com/zeppyx13/snapwake-expo/blob/main/android/app/src/main/java/com/anonymous/SnapWake/nativealarm/NativeAlarmConstants.kt): `android/app/src/main/java/com/anonymous/SnapWake/nativealarm/NativeAlarmConstants.kt`

### Other components

- **User**

## Connections

- User → Sign in and register: signs in (evidence: `src/app/(auth)/register.tsx`)
- Sign in and register → Authentication state: uses auth state (evidence: `src/app/(auth)/register.tsx`)
- Authentication state → API client: authenticates (evidence: `src/hooks/use-auth.tsx`)
- Authentication state → Wake result storage: persists credentials (evidence: `src/hooks/use-auth.tsx`)
- User → Create and edit alarms: configures alarm (evidence: `src/app/edit-alarm/[id].tsx`)
- Create and edit alarms → Alarm form: renders form (evidence: `src/app/edit-alarm/[id].tsx`)
- Create and edit alarms → API client: loads and saves (evidence: `src/app/edit-alarm/[id].tsx`)
- Create and edit alarms → Alarm conversion: converts alarm (evidence: `src/app/edit-alarm/[id].tsx`)
- Alarm form → Sound selection: offers sound selection (evidence: `src/components/alarm/AlarmForm.tsx`)
- Sound selection → API client: manages custom sounds (evidence: `src/components/alarm/AlarmSoundSelector.tsx`)
- Alarm conversion → Alarm data types: uses alarm types (evidence: `src/utils/alarm.ts`)
- User → Object scan: completes wake scan (evidence: `src/app/scan.tsx`)
- Object scan → Detection status: shows detection status (evidence: `src/app/scan.tsx`)
- Object scan → Math challenge: presents challenge (evidence: `src/app/scan.tsx`)
- Object scan → API client: submits wake data (evidence: `src/app/scan.tsx`)
- Object scan → Native alarm bridge: uses alarm bridge (evidence: `src/app/scan.tsx`)
- Object scan → Wake result storage: saves wake result (evidence: `src/utils/storage.ts`)
- Wake result storage → Wake result screen: hands off result (evidence: `src/utils/storage.ts`)
- User → Alarm history: views history
- User → Profile and plans: views account
- User → Leaderboard: views rankings
- Profile and plans → Gamification mapping: formats statistics (evidence: `src/app/(tabs)/profile.tsx`)
- API client → Gamification mapping: normalizes responses (evidence: `src/services/api.ts`)
- API client → SnapWake backend: sends HTTP requests (evidence: `src/services/api.ts`)
- Alarm ringing service → Native alarm constants: uses constants (evidence: `android/app/src/main/java/com/anonymous/SnapWake/nativealarm/NativeAlarmRingingService.kt`)
