# khairulhafis/tempa architecture

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

- Interactive diagram: https://gitdiagram.com/khairulhafis/tempa
- Repository: https://github.com/khairulhafis/tempa

## Overview

Tempa is an iOS pull-up workout tracker. The main flow is to choose a rep goal, mark the bar in camera setup, align wrists, count reps during the live workout, and review the result; stats and history provide a separate progress branch. Authenticated workout history is cached locally and synced with Supabase. The graph follows documented capabilities and indexed references; where implementation excerpts were unavailable, it avoids inferring camera-pose wiring or other unshown calls.

Main entry points: [`Tempa/Features/WorkoutSession/WorkoutSessionView.swift`](https://github.com/khairulhafis/tempa/blob/main/Tempa/Features/WorkoutSession/WorkoutSessionView.swift) (Live Session UI), [`Tempa/Domain/WorkoutSessionStore.swift`](https://github.com/khairulhafis/tempa/blob/main/Tempa/Domain/WorkoutSessionStore.swift) (Workout History Store), [`Tempa/App/ContentView.swift`](https://github.com/khairulhafis/tempa/blob/main/Tempa/App/ContentView.swift) (Home Navigation), [`Tempa/Features/CameraSetup/CameraSetupView.swift`](https://github.com/khairulhafis/tempa/blob/main/Tempa/Features/CameraSetup/CameraSetupView.swift) (Bar Setup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["App Navigation"]
  node_root["Root Routing<br/>[RootView.swift]"]
  node_home["Home Navigation<br/>[ContentView.swift]"]
end

subgraph group_workout["Workout Flow"]
  node_goal["Goal Selection<br/>[WorkoutView.swift]"]
  node_bar_setup["Bar Setup"]
  node_camera["Camera Capture<br/>[CameraView.swift]"]
  node_preview["Camera Preview<br/>[PreviewView.swift]"]
  node_pose_detection["Pose Detection"]
  node_live_session["Live Session UI"]
  node_session_vm["Session Lifecycle"]
  node_rep_counter["Rep Counter<br/>[RepCounter.swift]"]
  node_pose_overlay["Pose Overlay"]
  node_bar_overlay["Bar Overlay"]
end

subgraph group_history["History and Stats"]
  node_summary["Workout Summary"]
  node_stats["Stats and History<br/>[StatsView.swift]"]
  node_session_store["Workout History Store"]
  node_local_cache[("Local Session Cache")]
end

subgraph group_identity["Identity and Sync"]
  node_auth_ui["Sign-in UI<br/>[AuthView.swift]"]
  node_auth_store["Auth State<br/>[AuthStore.swift]"]
  node_auth_service["Supabase Auth Client"]
  node_supabase_config["Supabase Configuration"]
  node_cloud_history["Cloud Workout Service"]
end

node_user(("Athlete"))
node_supabase[("Supabase")]

node_user -->|"opens app"| node_root
node_root -->|"routes when signed in"| node_home
node_root -->|"routes when signed out"| node_auth_ui
node_user -->|"chooses workout or stats"| node_home
node_home -->|"opens workout"| node_goal
node_home -->|"opens stats"| node_stats
node_user -->|"marks bar ends"| node_bar_setup
node_goal -->|"continues setup"| node_bar_setup
node_bar_setup -->|"starts session"| node_live_session
node_bar_setup -->|"renders preview"| node_preview
node_camera -->|"renders feed"| node_preview
node_live_session -->|"shows camera"| node_camera
node_live_session -->|"binds session state"| node_session_vm
node_session_vm -->|"updates rep count"| node_rep_counter
node_live_session -->|"renders pose"| node_pose_overlay
node_live_session -->|"renders bar"| node_bar_overlay
node_live_session -->|"saves completed session"| node_session_store
node_live_session -->|"navigates to summary"| node_summary
node_stats -->|"reads history"| node_session_store
node_summary -->|"reads session data"| node_session_store
node_session_store -->|"loads and saves"| node_local_cache
node_session_store -->|"syncs sessions"| node_cloud_history
node_auth_ui -->|"submits credentials"| node_auth_store
node_auth_store -->|"authenticates and refreshes"| node_auth_service
node_auth_service -->|"uses credentials"| node_supabase_config
node_cloud_history -->|"uses credentials"| node_supabase_config
node_auth_service -->|"uses auth API"| node_supabase
node_cloud_history -->|"reads and syncs history"| node_supabase

click node_root "https://github.com/khairulhafis/tempa/blob/main/Tempa/App/RootView.swift"
click node_home "https://github.com/khairulhafis/tempa/blob/main/Tempa/App/ContentView.swift"
click node_auth_ui "https://github.com/khairulhafis/tempa/blob/main/Tempa/Features/Auth/AuthView.swift"
click node_goal "https://github.com/khairulhafis/tempa/blob/main/Tempa/Features/Workout/WorkoutView.swift"
click node_bar_setup "https://github.com/khairulhafis/tempa/blob/main/Tempa/Features/CameraSetup/CameraSetupView.swift"
click node_camera "https://github.com/khairulhafis/tempa/blob/main/Tempa/Services/Camera/CameraView.swift"
click node_preview "https://github.com/khairulhafis/tempa/blob/main/Tempa/Services/Camera/PreviewView.swift"
click node_pose_detection "https://github.com/khairulhafis/tempa/blob/main/Tempa/Services/Camera/BodyPoseService.swift"
click node_live_session "https://github.com/khairulhafis/tempa/blob/main/Tempa/Features/WorkoutSession/WorkoutSessionView.swift"
click node_session_vm "https://github.com/khairulhafis/tempa/blob/main/Tempa/Features/WorkoutSession/WorkoutSessionViewModel.swift"
click node_rep_counter "https://github.com/khairulhafis/tempa/blob/main/Tempa/Domain/RepCounter.swift"
click node_pose_overlay "https://github.com/khairulhafis/tempa/blob/main/Tempa/Features/Overlays/PoseOverlayView.swift"
click node_bar_overlay "https://github.com/khairulhafis/tempa/blob/main/Tempa/Features/Overlays/BarOverlayView.swift"
click node_summary "https://github.com/khairulhafis/tempa/blob/main/Tempa/Features/Summary/WorkoutSummaryView.swift"
click node_stats "https://github.com/khairulhafis/tempa/blob/main/Tempa/Features/Stats/StatsView.swift"
click node_session_store "https://github.com/khairulhafis/tempa/blob/main/Tempa/Domain/WorkoutSessionStore.swift"
click node_local_cache "https://github.com/khairulhafis/tempa/blob/main/Tempa/Persistence/WorkoutSessionRepository.swift"
click node_auth_store "https://github.com/khairulhafis/tempa/blob/main/Tempa/State/AuthStore.swift"
click node_auth_service "https://github.com/khairulhafis/tempa/blob/main/Tempa/Services/Supabase/SupabaseAuthService.swift"
click node_supabase_config "https://github.com/khairulhafis/tempa/blob/main/Tempa/Services/Supabase/SupabaseConfiguration.swift"
click node_cloud_history "https://github.com/khairulhafis/tempa/blob/main/Tempa/Services/Supabase/SupabaseWorkoutSessionService.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_root,node_home toneBlue
class node_goal,node_bar_setup,node_camera,node_preview,node_pose_detection,node_live_session,node_session_vm,node_rep_counter,node_pose_overlay,node_bar_overlay,node_supabase toneAmber
class node_summary,node_stats,node_session_store,node_local_cache toneMint
class node_auth_ui,node_auth_store,node_auth_service,node_supabase_config,node_cloud_history toneRose
class node_user toneIndigo
```

## Components

### App Navigation

- [Root Routing](https://github.com/khairulhafis/tempa/blob/main/Tempa/App/RootView.swift): `Tempa/App/RootView.swift`
- [Home Navigation](https://github.com/khairulhafis/tempa/blob/main/Tempa/App/ContentView.swift): `Tempa/App/ContentView.swift`

### Workout Flow

- [Goal Selection](https://github.com/khairulhafis/tempa/blob/main/Tempa/Features/Workout/WorkoutView.swift): `Tempa/Features/Workout/WorkoutView.swift`
- [Bar Setup](https://github.com/khairulhafis/tempa/blob/main/Tempa/Features/CameraSetup/CameraSetupView.swift): `Tempa/Features/CameraSetup/CameraSetupView.swift`
- [Camera Capture](https://github.com/khairulhafis/tempa/blob/main/Tempa/Services/Camera/CameraView.swift): `Tempa/Services/Camera/CameraView.swift`
- [Camera Preview](https://github.com/khairulhafis/tempa/blob/main/Tempa/Services/Camera/PreviewView.swift): `Tempa/Services/Camera/PreviewView.swift`
- [Pose Detection](https://github.com/khairulhafis/tempa/blob/main/Tempa/Services/Camera/BodyPoseService.swift): `Tempa/Services/Camera/BodyPoseService.swift`
- [Live Session UI](https://github.com/khairulhafis/tempa/blob/main/Tempa/Features/WorkoutSession/WorkoutSessionView.swift): `Tempa/Features/WorkoutSession/WorkoutSessionView.swift`
- [Session Lifecycle](https://github.com/khairulhafis/tempa/blob/main/Tempa/Features/WorkoutSession/WorkoutSessionViewModel.swift): `Tempa/Features/WorkoutSession/WorkoutSessionViewModel.swift`
- [Rep Counter](https://github.com/khairulhafis/tempa/blob/main/Tempa/Domain/RepCounter.swift): `Tempa/Domain/RepCounter.swift`
- [Pose Overlay](https://github.com/khairulhafis/tempa/blob/main/Tempa/Features/Overlays/PoseOverlayView.swift): `Tempa/Features/Overlays/PoseOverlayView.swift`
- [Bar Overlay](https://github.com/khairulhafis/tempa/blob/main/Tempa/Features/Overlays/BarOverlayView.swift): `Tempa/Features/Overlays/BarOverlayView.swift`

### History and Stats

- [Workout Summary](https://github.com/khairulhafis/tempa/blob/main/Tempa/Features/Summary/WorkoutSummaryView.swift): `Tempa/Features/Summary/WorkoutSummaryView.swift`
- [Stats and History](https://github.com/khairulhafis/tempa/blob/main/Tempa/Features/Stats/StatsView.swift): `Tempa/Features/Stats/StatsView.swift`
- [Workout History Store](https://github.com/khairulhafis/tempa/blob/main/Tempa/Domain/WorkoutSessionStore.swift): `Tempa/Domain/WorkoutSessionStore.swift`
- [Local Session Cache](https://github.com/khairulhafis/tempa/blob/main/Tempa/Persistence/WorkoutSessionRepository.swift): `Tempa/Persistence/WorkoutSessionRepository.swift`

### Identity and Sync

- [Sign-in UI](https://github.com/khairulhafis/tempa/blob/main/Tempa/Features/Auth/AuthView.swift): `Tempa/Features/Auth/AuthView.swift`
- [Auth State](https://github.com/khairulhafis/tempa/blob/main/Tempa/State/AuthStore.swift): `Tempa/State/AuthStore.swift`
- [Supabase Auth Client](https://github.com/khairulhafis/tempa/blob/main/Tempa/Services/Supabase/SupabaseAuthService.swift): `Tempa/Services/Supabase/SupabaseAuthService.swift`
- [Supabase Configuration](https://github.com/khairulhafis/tempa/blob/main/Tempa/Services/Supabase/SupabaseConfiguration.swift): `Tempa/Services/Supabase/SupabaseConfiguration.swift`
- [Cloud Workout Service](https://github.com/khairulhafis/tempa/blob/main/Tempa/Services/Supabase/SupabaseWorkoutSessionService.swift): `Tempa/Services/Supabase/SupabaseWorkoutSessionService.swift`

### Other components

- **Athlete**
- **Supabase**

## Connections

- Athlete → Root Routing: opens app (evidence: `README.md`)
- Root Routing → Home Navigation: routes when signed in (evidence: `Tempa/App/RootView.swift`)
- Root Routing → Sign-in UI: routes when signed out (evidence: `Tempa/App/RootView.swift`)
- Athlete → Home Navigation: chooses workout or stats (evidence: `Tempa/App/ContentView.swift`)
- Home Navigation → Goal Selection: opens workout (evidence: `Tempa/App/ContentView.swift`)
- Home Navigation → Stats and History: opens stats (evidence: `Tempa/App/ContentView.swift`)
- Athlete → Bar Setup: marks bar ends (evidence: `README.md`)
- Goal Selection → Bar Setup: continues setup (evidence: `Tempa/Features/Workout/WorkoutView.swift`)
- Bar Setup → Live Session UI: starts session (evidence: `Tempa/Features/CameraSetup/CameraSetupView.swift`)
- Bar Setup → Camera Preview: renders preview (evidence: `Tempa/Features/CameraSetup/CameraSetupView.swift`)
- Camera Capture → Camera Preview: renders feed (evidence: `Tempa/Services/Camera/CameraView.swift`)
- Live Session UI → Camera Capture: shows camera (evidence: `Tempa/Features/WorkoutSession/WorkoutSessionView.swift`)
- Live Session UI → Session Lifecycle: binds session state (evidence: `Tempa/Features/WorkoutSession/WorkoutSessionView.swift`)
- Session Lifecycle → Rep Counter: updates rep count (evidence: `Tempa/Features/WorkoutSession/WorkoutSessionViewModel.swift`)
- Live Session UI → Pose Overlay: renders pose (evidence: `Tempa/Features/WorkoutSession/WorkoutSessionView.swift`)
- Live Session UI → Bar Overlay: renders bar (evidence: `Tempa/Features/WorkoutSession/WorkoutSessionView.swift`)
- Live Session UI → Workout History Store: saves completed session (evidence: `Tempa/Features/WorkoutSession/WorkoutSessionView.swift`)
- Live Session UI → Workout Summary: navigates to summary (evidence: `Tempa/Features/WorkoutSession/WorkoutSessionView.swift`)
- Stats and History → Workout History Store: reads history (evidence: `Tempa/Features/Stats/StatsView.swift`)
- Workout Summary → Workout History Store: reads session data (evidence: `Tempa/Features/Summary/WorkoutSummaryView.swift`)
- Workout History Store → Local Session Cache: loads and saves (evidence: `Tempa/Domain/WorkoutSessionStore.swift`)
- Workout History Store → Cloud Workout Service: syncs sessions (evidence: `Tempa/Domain/WorkoutSessionStore.swift`)
- Sign-in UI → Auth State: submits credentials (evidence: `Tempa/Features/Auth/AuthView.swift`)
- Auth State → Supabase Auth Client: authenticates and refreshes (evidence: `Tempa/State/AuthStore.swift`)
- Supabase Auth Client → Supabase Configuration: uses credentials (evidence: `Tempa/Services/Supabase/SupabaseAuthService.swift`)
- Cloud Workout Service → Supabase Configuration: uses credentials (evidence: `Tempa/Services/Supabase/SupabaseWorkoutSessionService.swift`)
- Supabase Auth Client → Supabase: uses auth API (evidence: `README.md`)
- Cloud Workout Service → Supabase: reads and syncs history (evidence: `README.md`)
