# s4njeee/smartcane architecture

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

- Interactive diagram: https://gitdiagram.com/s4njeee/smartcane
- Repository: https://github.com/s4njeee/smartcane

## Overview

SmartCane is a mobile companion for an assistive cane. Its intended user workflow is account access, cane monitoring and location tracking, then reviewing or responding to alerts; the README also describes obstacle voice alerts, SOS, guardian monitoring and cloud synchronization. The sampled code confirms authentication setup, GPS route collection, cane-state synchronization and obstacle-alert creation. Other screens and integrations are represented only where their paths or capabilities are documented, so their runtime wiring is not inferred.

Main entry points: [`context/CaneStatusContext.tsx`](https://github.com/s4njeee/smartcane/blob/main/context/CaneStatusContext.tsx) (Cane status state), [`firebase/appData.ts`](https://github.com/s4njeee/smartcane/blob/main/firebase/appData.ts) (Cane and alert data), [`app/index.tsx`](https://github.com/s4njeee/smartcane/blob/main/app/index.tsx) (Welcome screen), [`hooks/useGoogleSignIn.ts`](https://github.com/s4njeee/smartcane/blob/main/hooks/useGoogleSignIn.ts) (Google sign-in)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Account access"]
  node_landing["Welcome screen<br/>[index.tsx]"]
  node_login["Login<br/>[login.tsx]"]
  node_signup["Sign up<br/>[signup.tsx]"]
  node_googlehook["Google sign-in<br/>[useGoogleSignIn.ts]"]
  node_clientstore["OAuth ID storage"]
  node_googleconfig["OAuth configuration<br/>[googleAuth.ts]"]
  node_profile["Profile management<br/>[profile.tsx]"]
  node_editprofile["Edit profile<br/>[editprofile.tsx]"]
  node_password["Password change<br/>[changepassword.tsx]"]
end

subgraph group_monitor["Cane monitoring"]
  node_home["Home dashboard<br/>[home.tsx]"]
  node_status["Cane status state"]
  node_map["Cane map<br/>[CaneMap.tsx]"]
end

subgraph group_alerts["Alerts and response"]
  node_messages["Alerts screen<br/>[messages.tsx]"]
end

subgraph group_services["Cloud services"]
  node_firebaseauth["Firebase authentication<br/>[firebaseConfig.ts]"]
  node_canedata["Cane and alert data<br/>[appData.ts]"]
  node_firestore[("Cloud data store<br/>[firebaseConfig.ts]")]
  node_supabase["Supabase service<br/>[supabase.ts]"]
end

node_user(("User"))
node_gps(("Device location"))
node_hardware(("SmartCane device"))
node_guardian(("Guardian"))
node_push["Push notifications"]

node_user -->|"opens"| node_landing
node_landing -->|"routes to"| node_login
node_landing -->|"routes to"| node_signup
node_landing -->|"starts sign-in"| node_googlehook
node_login -->|"authenticates"| node_firebaseauth
node_signup -->|"authenticates"| node_firebaseauth
node_googlehook -->|"loads client ID"| node_clientstore
node_googlehook -->|"builds OAuth config"| node_googleconfig
node_googlehook -->|"signs in"| node_firebaseauth
node_user -->|"uses"| node_home
node_home -->|"reads status"| node_status
node_gps -->|"provides coordinates"| node_status
node_status -->|"subscribes and syncs"| node_canedata
node_status -->|"creates or deletes cane"| node_canedata
node_status -->|"creates obstacle alert"| node_canedata
node_status -->|"shares location"| node_map
node_hardware -.->|"cane state"| node_status
node_canedata -->|"reads and writes"| node_firestore
node_user -->|"reviews alerts"| node_messages
node_messages -.->|"subscribes to alerts"| node_canedata
node_user -->|"manages account"| node_profile
node_profile -.->|"edits details"| node_editprofile
node_profile -.->|"changes password"| node_password
node_canedata -.->|"syncs cloud data"| node_supabase
node_push -.->|"notifies"| node_guardian

click node_landing "https://github.com/s4njeee/smartcane/blob/main/app/index.tsx"
click node_login "https://github.com/s4njeee/smartcane/blob/main/app/login.tsx"
click node_signup "https://github.com/s4njeee/smartcane/blob/main/app/signup.tsx"
click node_googlehook "https://github.com/s4njeee/smartcane/blob/main/hooks/useGoogleSignIn.ts"
click node_clientstore "https://github.com/s4njeee/smartcane/blob/main/utils/googleClientStore.ts"
click node_googleconfig "https://github.com/s4njeee/smartcane/blob/main/constants/googleAuth.ts"
click node_firebaseauth "https://github.com/s4njeee/smartcane/blob/main/firebase/firebaseConfig.ts"
click node_home "https://github.com/s4njeee/smartcane/blob/main/app/home.tsx"
click node_status "https://github.com/s4njeee/smartcane/blob/main/context/CaneStatusContext.tsx"
click node_map "https://github.com/s4njeee/smartcane/blob/main/components/ui/CaneMap.tsx"
click node_canedata "https://github.com/s4njeee/smartcane/blob/main/firebase/appData.ts"
click node_firestore "https://github.com/s4njeee/smartcane/blob/main/firebase/firebaseConfig.ts"
click node_messages "https://github.com/s4njeee/smartcane/blob/main/app/messages.tsx"
click node_profile "https://github.com/s4njeee/smartcane/blob/main/app/profile.tsx"
click node_editprofile "https://github.com/s4njeee/smartcane/blob/main/app/editprofile.tsx"
click node_password "https://github.com/s4njeee/smartcane/blob/main/app/changepassword.tsx"
click node_supabase "https://github.com/s4njeee/smartcane/blob/main/firebase/supabase.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_landing,node_login,node_signup,node_googlehook,node_clientstore,node_googleconfig,node_profile,node_editprofile,node_password,node_user toneBlue
class node_home,node_status,node_map toneAmber
class node_messages toneMint
class node_firebaseauth,node_canedata,node_firestore,node_supabase toneRose
class node_gps,node_hardware,node_guardian,node_push toneIndigo
```

## Components

### Account access

- [Welcome screen](https://github.com/s4njeee/smartcane/blob/main/app/index.tsx): `app/index.tsx`
- [Login](https://github.com/s4njeee/smartcane/blob/main/app/login.tsx): `app/login.tsx`
- [Sign up](https://github.com/s4njeee/smartcane/blob/main/app/signup.tsx): `app/signup.tsx`
- [Google sign-in](https://github.com/s4njeee/smartcane/blob/main/hooks/useGoogleSignIn.ts): `hooks/useGoogleSignIn.ts`
- [OAuth ID storage](https://github.com/s4njeee/smartcane/blob/main/utils/googleClientStore.ts): `utils/googleClientStore.ts`
- [OAuth configuration](https://github.com/s4njeee/smartcane/blob/main/constants/googleAuth.ts): `constants/googleAuth.ts`
- [Profile management](https://github.com/s4njeee/smartcane/blob/main/app/profile.tsx): `app/profile.tsx`
- [Edit profile](https://github.com/s4njeee/smartcane/blob/main/app/editprofile.tsx): `app/editprofile.tsx`
- [Password change](https://github.com/s4njeee/smartcane/blob/main/app/changepassword.tsx): `app/changepassword.tsx`

### Cane monitoring

- [Home dashboard](https://github.com/s4njeee/smartcane/blob/main/app/home.tsx): `app/home.tsx`
- [Cane status state](https://github.com/s4njeee/smartcane/blob/main/context/CaneStatusContext.tsx): `context/CaneStatusContext.tsx`
- [Cane map](https://github.com/s4njeee/smartcane/blob/main/components/ui/CaneMap.tsx): `components/ui/CaneMap.tsx`

### Alerts and response

- [Alerts screen](https://github.com/s4njeee/smartcane/blob/main/app/messages.tsx): `app/messages.tsx`

### Cloud services

- [Firebase authentication](https://github.com/s4njeee/smartcane/blob/main/firebase/firebaseConfig.ts): `firebase/firebaseConfig.ts`
- [Cane and alert data](https://github.com/s4njeee/smartcane/blob/main/firebase/appData.ts): `firebase/appData.ts`
- [Cloud data store](https://github.com/s4njeee/smartcane/blob/main/firebase/firebaseConfig.ts): `firebase/firebaseConfig.ts`
- [Supabase service](https://github.com/s4njeee/smartcane/blob/main/firebase/supabase.ts): `firebase/supabase.ts`

### Other components

- **User**
- **Device location**
- **SmartCane device**
- **Guardian**
- **Push notifications**

## Connections

- User → Welcome screen: opens
- Welcome screen → Login: routes to
- Welcome screen → Sign up: routes to
- Welcome screen → Google sign-in: starts sign-in
- Login → Firebase authentication: authenticates
- Sign up → Firebase authentication: authenticates
- Google sign-in → OAuth ID storage: loads client ID
- Google sign-in → OAuth configuration: builds OAuth config
- Google sign-in → Firebase authentication: signs in
- User → Home dashboard: uses
- Home dashboard → Cane status state: reads status
- Device location → Cane status state: provides coordinates
- Cane status state → Cane and alert data: subscribes and syncs
- Cane status state → Cane and alert data: creates or deletes cane
- Cane status state → Cane and alert data: creates obstacle alert
- Cane status state → Cane map: shares location
- SmartCane device → Cane status state: cane state
- Cane and alert data → Cloud data store: reads and writes
- User → Alerts screen: reviews alerts
- Alerts screen → Cane and alert data: subscribes to alerts
- User → Profile management: manages account
- Profile management → Edit profile: edits details
- Profile management → Password change: changes password
- Cane and alert data → Supabase service: syncs cloud data
- Push notifications → Guardian: notifies
