# ybunhong/habit-tracker-expo architecture

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

- Interactive diagram: https://gitdiagram.com/ybunhong/habit-tracker-expo
- Repository: https://github.com/ybunhong/habit-tracker-expo

## Overview

This Expo habit tracker routes users through a session-aware entry screen to sign-in or the habits screen. The habits screen manages habit creation, daily completion logs, deletion, and sharing, using Supabase for authentication and persistence. The repository also includes an Explore starter screen and shared theme-aware UI. Source excerpts establish the auth and habit-data calls; the login implementation is read but not excerpted, so its auth relationship is supported by the source index. Other unsampled route and component details are omitted.

Main entry points: [`src/app/habits.tsx`](https://github.com/ybunhong/habit-tracker-expo/blob/main/src/app/habits.tsx) (Habit manager), [`src/contexts/AuthContext.tsx`](https://github.com/ybunhong/habit-tracker-expo/blob/main/src/contexts/AuthContext.tsx) (Auth context), [`src/app/index.tsx`](https://github.com/ybunhong/habit-tracker-expo/blob/main/src/app/index.tsx) (Session redirect), [`src/components/ui/collapsible.tsx`](https://github.com/ybunhong/habit-tracker-expo/blob/main/src/components/ui/collapsible.tsx) (Collapsible panel)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_routing["App routing"]
  node_entry["Session redirect<br/>[index.tsx]"]
  node_login["Sign-in screen<br/>[login.tsx]"]
  node_explore["Explore screen<br/>[explore.tsx]"]
  node_layout["App layout<br/>[_layout.tsx]"]
end

subgraph group_habit["Habit tracking"]
  node_habits["Habit manager<br/>[habits.tsx]"]
end

subgraph group_identity["Identity and backend"]
  node_auth["Auth context<br/>[AuthContext.tsx]"]
  node_client["Supabase client<br/>[supabase.ts]"]
end

subgraph group_presentation["Shared UI"]
  node_themehook["Theme hook<br/>[use-theme.ts]"]
  node_theme["Theme tokens<br/>[theme.ts]"]
  node_themedtext["Themed text<br/>[themed-text.tsx]"]
  node_themedview["Themed view<br/>[themed-view.tsx]"]
  node_collapsible["Collapsible panel<br/>[collapsible.tsx]"]
  node_external["External link<br/>[external-link.tsx]"]
  node_webbadge["Web badge<br/>[web-badge.tsx]"]
  node_tabsweb["Web tab controls<br/>[app-tabs.web.tsx]"]
end

node_user(("App user"))
node_supabase[("Supabase service")]
node_habitdata[("Habit and log data")]

node_user -->|"opens app"| node_entry
node_entry -->|"reads session"| node_auth
node_entry -->|"routes signed-in"| node_habits
node_entry -->|"routes signed-out"| node_login
node_user -.->|"enters credentials"| node_login
node_login -->|"uses auth"| node_auth
node_layout -->|"provides context"| node_auth
node_auth -->|"calls auth API"| node_client
node_client -->|"connects"| node_supabase
node_habits -->|"reads user"| node_auth
node_habits -->|"queries records"| node_client
node_habits -->|"reads and writes"| node_habitdata
node_habitdata -.->|"hosted by"| node_supabase
node_user -.->|"manages habits"| node_habits
node_explore -->|"renders panels"| node_collapsible
node_explore -->|"renders links"| node_external
node_explore -->|"renders on web"| node_webbadge
node_collapsible -->|"renders text"| node_themedtext
node_collapsible -->|"renders view"| node_themedview
node_collapsible -->|"reads colors"| node_themehook
node_themedtext -->|"reads colors"| node_themehook
node_themedview -->|"reads colors"| node_themehook
node_themehook -->|"selects palette"| node_theme
node_tabsweb -->|"renders links"| node_external
node_tabsweb -->|"renders text"| node_themedtext
node_tabsweb -->|"renders view"| node_themedview

click node_entry "https://github.com/ybunhong/habit-tracker-expo/blob/main/src/app/index.tsx"
click node_login "https://github.com/ybunhong/habit-tracker-expo/blob/main/src/app/login.tsx"
click node_explore "https://github.com/ybunhong/habit-tracker-expo/blob/main/src/app/explore.tsx"
click node_layout "https://github.com/ybunhong/habit-tracker-expo/blob/main/src/app/_layout.tsx"
click node_habits "https://github.com/ybunhong/habit-tracker-expo/blob/main/src/app/habits.tsx"
click node_auth "https://github.com/ybunhong/habit-tracker-expo/blob/main/src/contexts/AuthContext.tsx"
click node_client "https://github.com/ybunhong/habit-tracker-expo/blob/main/src/lib/supabase.ts"
click node_themehook "https://github.com/ybunhong/habit-tracker-expo/blob/main/src/hooks/use-theme.ts"
click node_theme "https://github.com/ybunhong/habit-tracker-expo/blob/main/src/constants/theme.ts"
click node_themedtext "https://github.com/ybunhong/habit-tracker-expo/blob/main/src/components/themed-text.tsx"
click node_themedview "https://github.com/ybunhong/habit-tracker-expo/blob/main/src/components/themed-view.tsx"
click node_collapsible "https://github.com/ybunhong/habit-tracker-expo/blob/main/src/components/ui/collapsible.tsx"
click node_external "https://github.com/ybunhong/habit-tracker-expo/blob/main/src/components/external-link.tsx"
click node_webbadge "https://github.com/ybunhong/habit-tracker-expo/blob/main/src/components/web-badge.tsx"
click node_tabsweb "https://github.com/ybunhong/habit-tracker-expo/blob/main/src/components/app-tabs.web.tsx"

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_entry,node_login,node_explore,node_layout,node_user toneBlue
class node_habits,node_supabase,node_habitdata toneAmber
class node_auth,node_client toneMint
class node_themehook,node_theme,node_themedtext,node_themedview,node_collapsible,node_external,node_webbadge,node_tabsweb toneRose
```

## Components

### App routing

- [Session redirect](https://github.com/ybunhong/habit-tracker-expo/blob/main/src/app/index.tsx): `src/app/index.tsx`
- [Sign-in screen](https://github.com/ybunhong/habit-tracker-expo/blob/main/src/app/login.tsx): `src/app/login.tsx`
- [Explore screen](https://github.com/ybunhong/habit-tracker-expo/blob/main/src/app/explore.tsx): `src/app/explore.tsx`
- [App layout](https://github.com/ybunhong/habit-tracker-expo/blob/main/src/app/_layout.tsx): `src/app/_layout.tsx`

### Habit tracking

- [Habit manager](https://github.com/ybunhong/habit-tracker-expo/blob/main/src/app/habits.tsx): `src/app/habits.tsx`

### Identity and backend

- [Auth context](https://github.com/ybunhong/habit-tracker-expo/blob/main/src/contexts/AuthContext.tsx): `src/contexts/AuthContext.tsx`
- [Supabase client](https://github.com/ybunhong/habit-tracker-expo/blob/main/src/lib/supabase.ts): `src/lib/supabase.ts`

### Shared UI

- [Theme hook](https://github.com/ybunhong/habit-tracker-expo/blob/main/src/hooks/use-theme.ts): `src/hooks/use-theme.ts`
- [Theme tokens](https://github.com/ybunhong/habit-tracker-expo/blob/main/src/constants/theme.ts): `src/constants/theme.ts`
- [Themed text](https://github.com/ybunhong/habit-tracker-expo/blob/main/src/components/themed-text.tsx): `src/components/themed-text.tsx`
- [Themed view](https://github.com/ybunhong/habit-tracker-expo/blob/main/src/components/themed-view.tsx): `src/components/themed-view.tsx`
- [Collapsible panel](https://github.com/ybunhong/habit-tracker-expo/blob/main/src/components/ui/collapsible.tsx): `src/components/ui/collapsible.tsx`
- [External link](https://github.com/ybunhong/habit-tracker-expo/blob/main/src/components/external-link.tsx): `src/components/external-link.tsx`
- [Web badge](https://github.com/ybunhong/habit-tracker-expo/blob/main/src/components/web-badge.tsx): `src/components/web-badge.tsx`
- [Web tab controls](https://github.com/ybunhong/habit-tracker-expo/blob/main/src/components/app-tabs.web.tsx): `src/components/app-tabs.web.tsx`

### Other components

- **App user**
- **Supabase service**
- **Habit and log data**

## Connections

- App user → Session redirect: opens app (evidence: `src/app/index.tsx`)
- Session redirect → Auth context: reads session (evidence: `src/app/index.tsx`)
- Session redirect → Habit manager: routes signed-in (evidence: `src/app/index.tsx`)
- Session redirect → Sign-in screen: routes signed-out (evidence: `src/app/index.tsx`)
- App user → Sign-in screen: enters credentials
- Sign-in screen → Auth context: uses auth (evidence: `src/contexts/AuthContext.tsx`)
- App layout → Auth context: provides context (evidence: `src/app/_layout.tsx`)
- Auth context → Supabase client: calls auth API (evidence: `src/contexts/AuthContext.tsx`)
- Supabase client → Supabase service: connects (evidence: `src/lib/supabase.ts`)
- Habit manager → Auth context: reads user (evidence: `src/app/habits.tsx`)
- Habit manager → Supabase client: queries records (evidence: `src/app/habits.tsx`)
- Habit manager → Habit and log data: reads and writes (evidence: `src/app/habits.tsx`)
- Habit and log data → Supabase service: hosted by
- App user → Habit manager: manages habits
- Explore screen → Collapsible panel: renders panels (evidence: `src/app/explore.tsx`)
- Explore screen → External link: renders links (evidence: `src/app/explore.tsx`)
- Explore screen → Web badge: renders on web (evidence: `src/app/explore.tsx`)
- Collapsible panel → Themed text: renders text (evidence: `src/components/ui/collapsible.tsx`)
- Collapsible panel → Themed view: renders view (evidence: `src/components/ui/collapsible.tsx`)
- Collapsible panel → Theme hook: reads colors (evidence: `src/components/ui/collapsible.tsx`)
- Themed text → Theme hook: reads colors (evidence: `src/components/themed-text.tsx`)
- Themed view → Theme hook: reads colors (evidence: `src/components/themed-view.tsx`)
- Theme hook → Theme tokens: selects palette (evidence: `src/hooks/use-theme.ts`)
- Web tab controls → External link: renders links (evidence: `src/components/app-tabs.web.tsx`)
- Web tab controls → Themed text: renders text (evidence: `src/components/app-tabs.web.tsx`)
- Web tab controls → Themed view: renders view (evidence: `src/components/app-tabs.web.tsx`)
