# robertguss/expo-supabase-starter-kit architecture

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

- Interactive diagram: https://gitdiagram.com/robertguss/expo-supabase-starter-kit
- Repository: https://github.com/robertguss/expo-supabase-starter-kit

## Overview

This is an Expo mobile starter kit for authenticated apps. The main user journey is email OTP sign-in, verification and session establishment, then access to protected Home, Profile, and Settings tabs. Profile demonstrates fetching Supabase data with locally persisted query caching; Settings provides theme selection and logout. Shared providers initialize authentication, query persistence, theming, analytics, and error tracking. Some route and feature implementations were not excerpted, so those connections rely on README statements and SOURCE INDEX references rather than inspected route code.

Main entry points: [`app/_layout.tsx`](https://github.com/robertguss/expo-supabase-starter-kit/blob/main/app/_layout.tsx) (Root layout), [`features/auth/auth-api.ts`](https://github.com/robertguss/expo-supabase-starter-kit/blob/main/features/auth/auth-api.ts) (Auth operations), [`lib/supabase.ts`](https://github.com/robertguss/expo-supabase-starter-kit/blob/main/lib/supabase.ts) (Supabase client), [`app/(tabs)/_layout.tsx`](https://github.com/robertguss/expo-supabase-starter-kit/blob/main/app/(tabs)/_layout.tsx) (Protected tabs)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_navigation["App navigation"]
  node_root["Root layout<br/>[_layout.tsx]"]
  node_tabs["Protected tabs<br/>[_layout.tsx]"]
end

subgraph group_auth["Authentication"]
  node_login["Login screen<br/>[login-screen.tsx]"]
  node_verify["OTP verification"]
  node_auth_api["Auth operations<br/>[auth-api.ts]"]
  node_auth_store["Auth state<br/>[auth-store.ts]"]
  node_auth_provider["Auth provider<br/>[auth-provider.tsx]"]
end

subgraph group_features["App features"]
  node_home["Home screen<br/>[home-screen.tsx]"]
  node_profile_screen["Profile screen<br/>[profile-screen.tsx]"]
  node_profile_query["Profile query<br/>[use-profile.ts]"]
  node_profile_api["Profile data access<br/>[profile-api.ts]"]
  node_settings["Settings screen"]
  node_theme["Theme preference<br/>[use-theme.ts]"]
end

subgraph group_platform["Shared platform"]
  node_supabase["Supabase client<br/>[supabase.ts]"]
  node_secure_storage[("Secure token storage<br/>[storage.ts]")]
  node_theme_provider["Theme provider<br/>[theme-provider.tsx]"]
  node_query_provider["Query provider<br/>[query-provider.tsx]"]
  node_query_client["Query cache<br/>[query-client.ts]"]
  node_storage[("MMKV storage<br/>[storage.ts]")]
  node_posthog_provider["Analytics provider"]
  node_posthog["PostHog client<br/>[posthog.ts]"]
  node_sentry["Sentry setup<br/>[sentry.ts]"]
  node_ui["Shared UI and forms"]
end

node_user(("App user"))
node_supabase_service[("Supabase service")]
node_analytics_service["PostHog service"]
node_error_service["Sentry service"]

node_user -->|"opens app"| node_root
node_root -->|"wraps"| node_auth_provider
node_root -->|"wraps"| node_query_provider
node_root -->|"wraps"| node_theme_provider
node_root -->|"wraps"| node_posthog_provider
node_root -->|"protects"| node_tabs
node_user -->|"starts sign-in"| node_login
node_login -->|"requests code"| node_auth_api
node_verify -->|"verifies code"| node_auth_api
node_auth_api -->|"auth requests"| node_supabase
node_auth_api -->|"updates session"| node_auth_store
node_auth_provider -->|"listens for auth"| node_supabase
node_auth_provider -->|"updates state"| node_auth_store
node_supabase -->|"persists tokens"| node_secure_storage
node_supabase -->|"auth and data requests"| node_supabase_service
node_tabs -->|"shows"| node_home
node_tabs -->|"shows"| node_profile_screen
node_tabs -->|"shows"| node_settings
node_profile_screen -->|"loads profile"| node_profile_query
node_profile_query -->|"fetches through"| node_profile_api
node_profile_api -->|"reads profile"| node_supabase
node_profile_screen -->|"reads user ID"| node_auth_store
node_settings -->|"selects preference"| node_theme
node_settings -->|"logs out"| node_auth_api
node_theme_provider -->|"loads preference"| node_theme
node_theme -->|"persists choice"| node_storage
node_query_provider -->|"configures persistence"| node_query_client
node_query_client -->|"persists cache"| node_storage
node_posthog_provider -->|"tracks identity state"| node_auth_store
node_posthog_provider -->|"uses client"| node_posthog
node_posthog -->|"sends events"| node_analytics_service
node_root -->|"initializes"| node_sentry
node_auth_provider -->|"sets user context"| node_sentry
node_auth_api -->|"reports errors"| node_sentry
node_sentry -->|"reports errors"| node_error_service
node_login -.->|"uses shared controls"| node_ui
node_verify -->|"uses shared controls"| node_ui
node_settings -->|"uses shared controls"| node_ui

click node_root "https://github.com/robertguss/expo-supabase-starter-kit/blob/main/app/_layout.tsx"
click node_tabs "https://github.com/robertguss/expo-supabase-starter-kit/blob/main/app/(tabs)/_layout.tsx"
click node_login "https://github.com/robertguss/expo-supabase-starter-kit/blob/main/features/auth/login-screen.tsx"
click node_verify "https://github.com/robertguss/expo-supabase-starter-kit/blob/main/features/auth/verify-otp-screen.tsx"
click node_auth_api "https://github.com/robertguss/expo-supabase-starter-kit/blob/main/features/auth/auth-api.ts"
click node_auth_store "https://github.com/robertguss/expo-supabase-starter-kit/blob/main/features/auth/auth-store.ts"
click node_auth_provider "https://github.com/robertguss/expo-supabase-starter-kit/blob/main/providers/auth-provider.tsx"
click node_supabase "https://github.com/robertguss/expo-supabase-starter-kit/blob/main/lib/supabase.ts"
click node_secure_storage "https://github.com/robertguss/expo-supabase-starter-kit/blob/main/lib/storage.ts"
click node_home "https://github.com/robertguss/expo-supabase-starter-kit/blob/main/features/home/home-screen.tsx"
click node_profile_screen "https://github.com/robertguss/expo-supabase-starter-kit/blob/main/features/profile/profile-screen.tsx"
click node_profile_query "https://github.com/robertguss/expo-supabase-starter-kit/blob/main/features/profile/use-profile.ts"
click node_profile_api "https://github.com/robertguss/expo-supabase-starter-kit/blob/main/features/profile/profile-api.ts"
click node_settings "https://github.com/robertguss/expo-supabase-starter-kit/blob/main/features/settings/settings-screen.tsx"
click node_theme "https://github.com/robertguss/expo-supabase-starter-kit/blob/main/features/settings/use-theme.ts"
click node_theme_provider "https://github.com/robertguss/expo-supabase-starter-kit/blob/main/providers/theme-provider.tsx"
click node_query_provider "https://github.com/robertguss/expo-supabase-starter-kit/blob/main/providers/query-provider.tsx"
click node_query_client "https://github.com/robertguss/expo-supabase-starter-kit/blob/main/lib/query-client.ts"
click node_storage "https://github.com/robertguss/expo-supabase-starter-kit/blob/main/lib/storage.ts"
click node_posthog_provider "https://github.com/robertguss/expo-supabase-starter-kit/blob/main/providers/posthog-provider.tsx"
click node_posthog "https://github.com/robertguss/expo-supabase-starter-kit/blob/main/lib/posthog.ts"
click node_sentry "https://github.com/robertguss/expo-supabase-starter-kit/blob/main/lib/sentry.ts"
click node_ui "https://github.com/robertguss/expo-supabase-starter-kit/tree/main/components"

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_tabs,node_user toneBlue
class node_login,node_verify,node_auth_api,node_auth_store,node_auth_provider,node_supabase_service toneAmber
class node_home,node_profile_screen,node_profile_query,node_profile_api,node_settings,node_theme toneMint
class node_supabase,node_secure_storage,node_theme_provider,node_query_provider,node_query_client,node_storage,node_posthog_provider,node_posthog,node_sentry,node_ui toneRose
class node_analytics_service,node_error_service toneIndigo
```

## Components

### App navigation

- [Root layout](https://github.com/robertguss/expo-supabase-starter-kit/blob/main/app/_layout.tsx): `app/_layout.tsx`
- [Protected tabs](https://github.com/robertguss/expo-supabase-starter-kit/blob/main/app/(tabs)/_layout.tsx): `app/(tabs)/_layout.tsx`

### Authentication

- [Login screen](https://github.com/robertguss/expo-supabase-starter-kit/blob/main/features/auth/login-screen.tsx): `features/auth/login-screen.tsx`
- [OTP verification](https://github.com/robertguss/expo-supabase-starter-kit/blob/main/features/auth/verify-otp-screen.tsx): `features/auth/verify-otp-screen.tsx`
- [Auth operations](https://github.com/robertguss/expo-supabase-starter-kit/blob/main/features/auth/auth-api.ts): `features/auth/auth-api.ts`
- [Auth state](https://github.com/robertguss/expo-supabase-starter-kit/blob/main/features/auth/auth-store.ts): `features/auth/auth-store.ts`
- [Auth provider](https://github.com/robertguss/expo-supabase-starter-kit/blob/main/providers/auth-provider.tsx): `providers/auth-provider.tsx`

### App features

- [Home screen](https://github.com/robertguss/expo-supabase-starter-kit/blob/main/features/home/home-screen.tsx): `features/home/home-screen.tsx`
- [Profile screen](https://github.com/robertguss/expo-supabase-starter-kit/blob/main/features/profile/profile-screen.tsx): `features/profile/profile-screen.tsx`
- [Profile query](https://github.com/robertguss/expo-supabase-starter-kit/blob/main/features/profile/use-profile.ts): `features/profile/use-profile.ts`
- [Profile data access](https://github.com/robertguss/expo-supabase-starter-kit/blob/main/features/profile/profile-api.ts): `features/profile/profile-api.ts`
- [Settings screen](https://github.com/robertguss/expo-supabase-starter-kit/blob/main/features/settings/settings-screen.tsx): `features/settings/settings-screen.tsx`
- [Theme preference](https://github.com/robertguss/expo-supabase-starter-kit/blob/main/features/settings/use-theme.ts): `features/settings/use-theme.ts`

### Shared platform

- [Supabase client](https://github.com/robertguss/expo-supabase-starter-kit/blob/main/lib/supabase.ts): `lib/supabase.ts`
- [Secure token storage](https://github.com/robertguss/expo-supabase-starter-kit/blob/main/lib/storage.ts): `lib/storage.ts`
- [Theme provider](https://github.com/robertguss/expo-supabase-starter-kit/blob/main/providers/theme-provider.tsx): `providers/theme-provider.tsx`
- [Query provider](https://github.com/robertguss/expo-supabase-starter-kit/blob/main/providers/query-provider.tsx): `providers/query-provider.tsx`
- [Query cache](https://github.com/robertguss/expo-supabase-starter-kit/blob/main/lib/query-client.ts): `lib/query-client.ts`
- [MMKV storage](https://github.com/robertguss/expo-supabase-starter-kit/blob/main/lib/storage.ts): `lib/storage.ts`
- [Analytics provider](https://github.com/robertguss/expo-supabase-starter-kit/blob/main/providers/posthog-provider.tsx): `providers/posthog-provider.tsx`
- [PostHog client](https://github.com/robertguss/expo-supabase-starter-kit/blob/main/lib/posthog.ts): `lib/posthog.ts`
- [Sentry setup](https://github.com/robertguss/expo-supabase-starter-kit/blob/main/lib/sentry.ts): `lib/sentry.ts`
- [Shared UI and forms](https://github.com/robertguss/expo-supabase-starter-kit/tree/main/components): `components`

### Other components

- **App user**
- **Supabase service**
- **PostHog service**
- **Sentry service**

## Connections

- App user → Root layout: opens app (evidence: `README.md`)
- Root layout → Auth provider: wraps (evidence: `app/_layout.tsx`)
- Root layout → Query provider: wraps (evidence: `app/_layout.tsx`)
- Root layout → Theme provider: wraps (evidence: `app/_layout.tsx`)
- Root layout → Analytics provider: wraps (evidence: `app/_layout.tsx`)
- Root layout → Protected tabs: protects (evidence: `app/_layout.tsx`)
- App user → Login screen: starts sign-in (evidence: `README.md`)
- Login screen → Auth operations: requests code (evidence: `README.md`)
- OTP verification → Auth operations: verifies code (evidence: `features/auth/verify-otp-screen.tsx`)
- Auth operations → Supabase client: auth requests (evidence: `features/auth/auth-api.ts`)
- Auth operations → Auth state: updates session (evidence: `features/auth/auth-api.ts`)
- Auth provider → Supabase client: listens for auth (evidence: `providers/auth-provider.tsx`)
- Auth provider → Auth state: updates state (evidence: `providers/auth-provider.tsx`)
- Supabase client → Secure token storage: persists tokens (evidence: `lib/supabase.ts`)
- Supabase client → Supabase service: auth and data requests (evidence: `README.md`)
- Protected tabs → Home screen: shows (evidence: `README.md`)
- Protected tabs → Profile screen: shows (evidence: `README.md`)
- Protected tabs → Settings screen: shows (evidence: `README.md`)
- Profile screen → Profile query: loads profile (evidence: `features/profile/profile-screen.tsx`)
- Profile query → Profile data access: fetches through (evidence: `features/profile/use-profile.ts`)
- Profile data access → Supabase client: reads profile (evidence: `features/profile/profile-api.ts`)
- Profile screen → Auth state: reads user ID (evidence: `features/profile/profile-screen.tsx`)
- Settings screen → Theme preference: selects preference (evidence: `features/settings/settings-screen.tsx`)
- Settings screen → Auth operations: logs out (evidence: `features/settings/settings-screen.tsx`)
- Theme provider → Theme preference: loads preference (evidence: `providers/theme-provider.tsx`)
- Theme preference → MMKV storage: persists choice (evidence: `features/settings/use-theme.ts`)
- Query provider → Query cache: configures persistence (evidence: `providers/query-provider.tsx`)
- Query cache → MMKV storage: persists cache (evidence: `lib/query-client.ts`)
- Analytics provider → Auth state: tracks identity state (evidence: `providers/posthog-provider.tsx`)
- Analytics provider → PostHog client: uses client (evidence: `providers/posthog-provider.tsx`)
- PostHog client → PostHog service: sends events (evidence: `README.md`)
- Root layout → Sentry setup: initializes (evidence: `app/_layout.tsx`)
- Auth provider → Sentry setup: sets user context (evidence: `providers/auth-provider.tsx`)
- Auth operations → Sentry setup: reports errors (evidence: `features/auth/auth-api.ts`)
- Sentry setup → Sentry service: reports errors (evidence: `README.md`)
- Login screen → Shared UI and forms: uses shared controls
- OTP verification → Shared UI and forms: uses shared controls (evidence: `features/auth/verify-otp-screen.tsx`)
- Settings screen → Shared UI and forms: uses shared controls (evidence: `features/settings/settings-screen.tsx`)
