# lakshay1800/tabpet architecture

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

- Interactive diagram: https://gitdiagram.com/lakshay1800/tabpet
- Repository: https://github.com/lakshay1800/tabpet

## Overview

tabpet is an iOS companion overlay for Expo tab bars. The host mounts a provider and perch, supplies the active tab, and the perch seats, animates, and renders the selected animal as tabs change or the bar is dragged. Separate runtime branches support busy-state behavior, animal selection/registration, and native tab measurement and pan events. The graph follows README capabilities where source excerpts were unavailable; those links are limited to documented behavior rather than inferred implementation details.

Main entry points: [`packages/tabpet/src/companion-perch.tsx`](https://github.com/lakshay1800/tabpet/blob/main/packages/tabpet/src/companion-perch.tsx) (Companion perch), [`packages/tabpet/src/registry.ts`](https://github.com/lakshay1800/tabpet/blob/main/packages/tabpet/src/registry.ts) (Profile registry), [`packages/tabpet/src/companion-provider.tsx`](https://github.com/lakshay1800/tabpet/blob/main/packages/tabpet/src/companion-provider.tsx) (Companion provider), [`packages/tabpet/ios/GlassPanModule.swift`](https://github.com/lakshay1800/tabpet/blob/main/packages/tabpet/ios/GlassPanModule.swift) (Expo pan module)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_integration["Host integration"]
  node_provider["Companion provider"]
  node_perch["Companion perch"]
  node_state["Companion state<br/>[companion-state.ts]"]
  node_storage["Storage seam<br/>[storage.ts]"]
  node_picker["Companion identity<br/>[companion-id.ts]"]
end

subgraph group_motion["Perch motion"]
  node_geometry["Perch geometry<br/>[perch-geometry.ts]"]
  node_around["Around routing<br/>[perch-around.ts]"]
  node_handoff["Perch handoff<br/>[perch-handoff.ts]"]
  node_reentry["Route reentry<br/>[perch-reentry.ts]"]
  node_remeasure["Seat remeasure<br/>[perch-remeasure.ts]"]
end

subgraph group_animals["Animal profiles"]
  node_sprite["Sprite renderer"]
  node_registry["Profile registry<br/>[registry.ts]"]
  node_builtin["Built-in animals<br/>[all.ts]"]
  node_custom["Custom profiles<br/>[bare.ts]"]
  node_profiles["Animal profile<br/>[panda.ts]"]
end

subgraph group_native["iOS bar support"]
  node_nativebridge["Glass pan bridge<br/>[glass-pan.ts]"]
  node_glassmodule["Expo pan module"]
  node_measurer["Tab bar measurer"]
  node_panobserver["Pan observer"]
end

node_host(("Expo host app"))

node_host -->|"mounts"| node_provider
node_host -->|"sets active tab"| node_perch
node_provider -->|"provides config"| node_state
node_state -->|"persists state"| node_storage
node_provider -->|"selects identity"| node_picker
node_perch -->|"calculates motion"| node_geometry
node_perch -->|"plans long route"| node_around
node_perch -->|"tracks handoff"| node_handoff
node_perch -->|"resumes route"| node_reentry
node_perch -->|"remeasures seat"| node_remeasure
node_perch -->|"renders companion"| node_sprite
node_sprite -->|"resolves profile"| node_registry
node_builtin -->|"registers profiles"| node_registry
node_custom -->|"registers profile"| node_registry
node_registry -->|"stores profile"| node_profiles
node_perch -->|"reads layout; subscribes to pan"| node_nativebridge
node_nativebridge -->|"calls native module"| node_glassmodule
node_glassmodule -->|"measures tab bar"| node_measurer
node_glassmodule -->|"attaches pan observer"| node_panobserver
node_panobserver -->|"emits drag events"| node_nativebridge

click node_provider "https://github.com/lakshay1800/tabpet/blob/main/packages/tabpet/src/companion-provider.tsx"
click node_perch "https://github.com/lakshay1800/tabpet/blob/main/packages/tabpet/src/companion-perch.tsx"
click node_state "https://github.com/lakshay1800/tabpet/blob/main/packages/tabpet/src/companion-state.ts"
click node_storage "https://github.com/lakshay1800/tabpet/blob/main/packages/tabpet/src/storage.ts"
click node_picker "https://github.com/lakshay1800/tabpet/blob/main/packages/tabpet/src/companion-id.ts"
click node_geometry "https://github.com/lakshay1800/tabpet/blob/main/packages/tabpet/src/perch-geometry.ts"
click node_around "https://github.com/lakshay1800/tabpet/blob/main/packages/tabpet/src/perch-around.ts"
click node_handoff "https://github.com/lakshay1800/tabpet/blob/main/packages/tabpet/src/perch-handoff.ts"
click node_reentry "https://github.com/lakshay1800/tabpet/blob/main/packages/tabpet/src/perch-reentry.ts"
click node_remeasure "https://github.com/lakshay1800/tabpet/blob/main/packages/tabpet/src/perch-remeasure.ts"
click node_sprite "https://github.com/lakshay1800/tabpet/blob/main/packages/tabpet/src/companion-sprite.tsx"
click node_registry "https://github.com/lakshay1800/tabpet/blob/main/packages/tabpet/src/registry.ts"
click node_builtin "https://github.com/lakshay1800/tabpet/blob/main/packages/tabpet/src/animals/all.ts"
click node_custom "https://github.com/lakshay1800/tabpet/blob/main/packages/tabpet/src/bare.ts"
click node_nativebridge "https://github.com/lakshay1800/tabpet/blob/main/packages/tabpet/src/native/glass-pan.ts"
click node_glassmodule "https://github.com/lakshay1800/tabpet/blob/main/packages/tabpet/ios/GlassPanModule.swift"
click node_measurer "https://github.com/lakshay1800/tabpet/blob/main/swift/Sources/TabPetUIKit/TabBarMeasurer.swift"
click node_panobserver "https://github.com/lakshay1800/tabpet/blob/main/swift/Sources/TabPetUIKit/TabBarPanObserver.swift"
click node_profiles "https://github.com/lakshay1800/tabpet/blob/main/packages/tabpet/src/animals/panda.ts"

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_provider,node_perch,node_state,node_storage,node_picker toneBlue
class node_geometry,node_around,node_handoff,node_reentry,node_remeasure toneAmber
class node_sprite,node_registry,node_builtin,node_custom,node_profiles toneMint
class node_nativebridge,node_glassmodule,node_measurer,node_panobserver toneRose
class node_host toneIndigo
```

## Components

### Host integration

- [Companion provider](https://github.com/lakshay1800/tabpet/blob/main/packages/tabpet/src/companion-provider.tsx): `packages/tabpet/src/companion-provider.tsx`
- [Companion perch](https://github.com/lakshay1800/tabpet/blob/main/packages/tabpet/src/companion-perch.tsx): `packages/tabpet/src/companion-perch.tsx`
- [Companion state](https://github.com/lakshay1800/tabpet/blob/main/packages/tabpet/src/companion-state.ts): `packages/tabpet/src/companion-state.ts`
- [Storage seam](https://github.com/lakshay1800/tabpet/blob/main/packages/tabpet/src/storage.ts): `packages/tabpet/src/storage.ts`
- [Companion identity](https://github.com/lakshay1800/tabpet/blob/main/packages/tabpet/src/companion-id.ts): `packages/tabpet/src/companion-id.ts`

### Perch motion

- [Perch geometry](https://github.com/lakshay1800/tabpet/blob/main/packages/tabpet/src/perch-geometry.ts): `packages/tabpet/src/perch-geometry.ts`
- [Around routing](https://github.com/lakshay1800/tabpet/blob/main/packages/tabpet/src/perch-around.ts): `packages/tabpet/src/perch-around.ts`
- [Perch handoff](https://github.com/lakshay1800/tabpet/blob/main/packages/tabpet/src/perch-handoff.ts): `packages/tabpet/src/perch-handoff.ts`
- [Route reentry](https://github.com/lakshay1800/tabpet/blob/main/packages/tabpet/src/perch-reentry.ts): `packages/tabpet/src/perch-reentry.ts`
- [Seat remeasure](https://github.com/lakshay1800/tabpet/blob/main/packages/tabpet/src/perch-remeasure.ts): `packages/tabpet/src/perch-remeasure.ts`

### Animal profiles

- [Sprite renderer](https://github.com/lakshay1800/tabpet/blob/main/packages/tabpet/src/companion-sprite.tsx): `packages/tabpet/src/companion-sprite.tsx`
- [Profile registry](https://github.com/lakshay1800/tabpet/blob/main/packages/tabpet/src/registry.ts): `packages/tabpet/src/registry.ts`
- [Built-in animals](https://github.com/lakshay1800/tabpet/blob/main/packages/tabpet/src/animals/all.ts): `packages/tabpet/src/animals/all.ts`
- [Custom profiles](https://github.com/lakshay1800/tabpet/blob/main/packages/tabpet/src/bare.ts): `packages/tabpet/src/bare.ts`
- [Animal profile](https://github.com/lakshay1800/tabpet/blob/main/packages/tabpet/src/animals/panda.ts): `packages/tabpet/src/animals/panda.ts`

### iOS bar support

- [Glass pan bridge](https://github.com/lakshay1800/tabpet/blob/main/packages/tabpet/src/native/glass-pan.ts): `packages/tabpet/src/native/glass-pan.ts`
- [Expo pan module](https://github.com/lakshay1800/tabpet/blob/main/packages/tabpet/ios/GlassPanModule.swift): `packages/tabpet/ios/GlassPanModule.swift`
- [Tab bar measurer](https://github.com/lakshay1800/tabpet/blob/main/swift/Sources/TabPetUIKit/TabBarMeasurer.swift): `swift/Sources/TabPetUIKit/TabBarMeasurer.swift`
- [Pan observer](https://github.com/lakshay1800/tabpet/blob/main/swift/Sources/TabPetUIKit/TabBarPanObserver.swift): `swift/Sources/TabPetUIKit/TabBarPanObserver.swift`

### Other components

- **Expo host app**

## Connections

- Expo host app → Companion provider: mounts
- Expo host app → Companion perch: sets active tab
- Companion provider → Companion state: provides config
- Companion state → Storage seam: persists state
- Companion provider → Companion identity: selects identity
- Companion perch → Perch geometry: calculates motion
- Companion perch → Around routing: plans long route
- Companion perch → Perch handoff: tracks handoff
- Companion perch → Route reentry: resumes route
- Companion perch → Seat remeasure: remeasures seat
- Companion perch → Sprite renderer: renders companion
- Sprite renderer → Profile registry: resolves profile
- Built-in animals → Profile registry: registers profiles
- Custom profiles → Profile registry: registers profile
- Profile registry → Animal profile: stores profile
- Companion perch → Glass pan bridge: reads layout; subscribes to pan
- Glass pan bridge → Expo pan module: calls native module
- Expo pan module → Tab bar measurer: measures tab bar
- Expo pan module → Pan observer: attaches pan observer
- Pan observer → Glass pan bridge: emits drag events
