# ashish-800/street-safe architecture

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

- Interactive diagram: https://gitdiagram.com/ashish-800/street-safe
- Repository: https://github.com/ashish-800/street-safe

## Overview

StreetSafe is a Kolkata-focused personal safety app. The user enters through a splash screen, signs in or signs up, then uses the dashboard to reach safe routing, nearby alerts, location sharing, emergency SOS, and safety tools. The route screen scores and presents routes; alerts support community incident reporting; profile and tools cover additional safety needs. The README documents Mapbox, Supabase, and emergency-contact capabilities, but the unsampled implementations and several external-service connections cannot be verified here.

Main entry points: [`src/lib/supabase.ts`](https://github.com/ashish-800/street-safe/blob/main/src/lib/supabase.ts) (Supabase client), [`app/(tabs)/index.tsx`](https://github.com/ashish-800/street-safe/blob/main/app/(tabs)/index.tsx) (Safety dashboard), [`src/theme/ThemeContext.tsx`](https://github.com/ashish-800/street-safe/blob/main/src/theme/ThemeContext.tsx) (Theme provider), [`app/(tabs)/route.tsx`](https://github.com/ashish-800/street-safe/blob/main/app/(tabs)/route.tsx) (Safe route scoring)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry and identity"]
  node_splash["Splash and auth check<br/>[index.tsx]"]
  node_login["Login and signup<br/>[login.tsx]"]
end

subgraph group_safety["Safety workflows"]
  node_home["Safety dashboard<br/>[index.tsx]"]
  node_routes["Safe route scoring<br/>[route.tsx]"]
  node_map["Map and location sharing<br/>[map.tsx]"]
  node_alerts["Community alerts<br/>[alerts.tsx]"]
  node_profile["Profile<br/>[profile.tsx]"]
  node_tools["Emergency safety tools<br/>[tools.tsx]"]
end

subgraph group_services["App services"]
  node_auth["Authentication context<br/>[AuthContext.tsx]"]
  node_supabase["Supabase client<br/>[supabase.ts]"]
  node_location["Location provider"]
  node_theme["Theme provider<br/>[ThemeContext.tsx]"]
  node_themecolors["Theme colors<br/>[colors.ts]"]
  node_mockdata["Offline mock data"]
end

subgraph group_ui["Shared UI"]
  node_routecard["Route card<br/>[RouteCard.tsx]"]
  node_mapview["Kolkata map view<br/>[KolkataMap.tsx]"]
  node_alertcard["Alert card<br/>[AlertCard.tsx]"]
  node_sosbutton["SOS button<br/>[SOSButton.tsx]"]
end

node_user(("App user"))
node_cloud[("Supabase backend")]
node_geocoding["Reverse geocoding"]
node_mapbox["Mapbox services"]

node_user -->|"opens"| node_splash
node_splash -->|"checks session"| node_supabase
node_splash -->|"routes unauthenticated"| node_login
node_login -->|"signs in or up"| node_auth
node_auth -->|"uses client"| node_supabase
node_supabase -.->|"connects when configured"| node_cloud
node_home -->|"offers safe walk"| node_routes
node_home -->|"opens sharing"| node_map
node_home -->|"opens alerts"| node_alerts
node_home -->|"opens tools"| node_tools
node_home -->|"reads alerts and logs SOS"| node_supabase
node_routes -->|"reads current position"| node_location
node_routes -->|"fetches active alerts"| node_supabase
node_routes -.->|"requests directions"| node_mapbox
node_routes -.->|"presents route choices"| node_routecard
node_map -->|"uses location"| node_location
node_map -.->|"renders map"| node_mapview
node_map -->|"uses client"| node_supabase
node_location -->|"reverse geocodes"| node_geocoding
node_geocoding -->|"web requests"| node_mapbox
node_alerts -->|"uses client"| node_supabase
node_alerts -.->|"presents alerts"| node_alertcard
node_tools -->|"uses location"| node_location
node_tools -.->|"SOS interaction"| node_sosbutton
node_profile -->|"uses identity"| node_auth
node_profile -->|"uses client"| node_supabase
node_supabase -.->|"offline fallback"| node_mockdata
node_theme -->|"selects theme colors"| node_themecolors
node_home -->|"reads theme"| node_theme
node_routes -->|"reads theme"| node_theme
node_map -->|"reads theme"| node_theme
node_alerts -->|"reads theme"| node_theme
node_profile -->|"reads theme"| node_theme
node_tools -->|"reads theme"| node_theme

click node_splash "https://github.com/ashish-800/street-safe/blob/main/app/index.tsx"
click node_login "https://github.com/ashish-800/street-safe/blob/main/app/auth/login.tsx"
click node_auth "https://github.com/ashish-800/street-safe/blob/main/src/context/AuthContext.tsx"
click node_supabase "https://github.com/ashish-800/street-safe/blob/main/src/lib/supabase.ts"
click node_home "https://github.com/ashish-800/street-safe/blob/main/app/(tabs)/index.tsx"
click node_routes "https://github.com/ashish-800/street-safe/blob/main/app/(tabs)/route.tsx"
click node_map "https://github.com/ashish-800/street-safe/blob/main/app/(tabs)/map.tsx"
click node_alerts "https://github.com/ashish-800/street-safe/blob/main/app/(tabs)/alerts.tsx"
click node_profile "https://github.com/ashish-800/street-safe/blob/main/app/(tabs)/profile.tsx"
click node_tools "https://github.com/ashish-800/street-safe/blob/main/app/(tabs)/tools.tsx"
click node_location "https://github.com/ashish-800/street-safe/blob/main/src/context/LocationContext.tsx"
click node_routecard "https://github.com/ashish-800/street-safe/blob/main/src/components/RouteCard.tsx"
click node_mapview "https://github.com/ashish-800/street-safe/blob/main/src/components/KolkataMap.tsx"
click node_alertcard "https://github.com/ashish-800/street-safe/blob/main/src/components/AlertCard.tsx"
click node_sosbutton "https://github.com/ashish-800/street-safe/blob/main/src/components/SOSButton.tsx"
click node_theme "https://github.com/ashish-800/street-safe/blob/main/src/theme/ThemeContext.tsx"
click node_themecolors "https://github.com/ashish-800/street-safe/blob/main/src/theme/colors.ts"
click node_mockdata "https://github.com/ashish-800/street-safe/tree/main/src/mock"

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_splash,node_login,node_user toneBlue
class node_home,node_routes,node_map,node_alerts,node_profile,node_tools,node_cloud toneAmber
class node_auth,node_supabase,node_location,node_theme,node_themecolors,node_mockdata toneMint
class node_routecard,node_mapview,node_alertcard,node_sosbutton toneRose
class node_geocoding,node_mapbox toneIndigo
```

## Components

### Entry and identity

- [Splash and auth check](https://github.com/ashish-800/street-safe/blob/main/app/index.tsx): `app/index.tsx`
- [Login and signup](https://github.com/ashish-800/street-safe/blob/main/app/auth/login.tsx): `app/auth/login.tsx`

### Safety workflows

- [Safety dashboard](https://github.com/ashish-800/street-safe/blob/main/app/(tabs)/index.tsx): `app/(tabs)/index.tsx`
- [Safe route scoring](https://github.com/ashish-800/street-safe/blob/main/app/(tabs)/route.tsx): `app/(tabs)/route.tsx`
- [Map and location sharing](https://github.com/ashish-800/street-safe/blob/main/app/(tabs)/map.tsx): `app/(tabs)/map.tsx`
- [Community alerts](https://github.com/ashish-800/street-safe/blob/main/app/(tabs)/alerts.tsx): `app/(tabs)/alerts.tsx`
- [Profile](https://github.com/ashish-800/street-safe/blob/main/app/(tabs)/profile.tsx): `app/(tabs)/profile.tsx`
- [Emergency safety tools](https://github.com/ashish-800/street-safe/blob/main/app/(tabs)/tools.tsx): `app/(tabs)/tools.tsx`

### App services

- [Authentication context](https://github.com/ashish-800/street-safe/blob/main/src/context/AuthContext.tsx): `src/context/AuthContext.tsx`
- [Supabase client](https://github.com/ashish-800/street-safe/blob/main/src/lib/supabase.ts): `src/lib/supabase.ts`
- [Location provider](https://github.com/ashish-800/street-safe/blob/main/src/context/LocationContext.tsx): `src/context/LocationContext.tsx`
- [Theme provider](https://github.com/ashish-800/street-safe/blob/main/src/theme/ThemeContext.tsx): `src/theme/ThemeContext.tsx`
- [Theme colors](https://github.com/ashish-800/street-safe/blob/main/src/theme/colors.ts): `src/theme/colors.ts`
- [Offline mock data](https://github.com/ashish-800/street-safe/tree/main/src/mock): `src/mock`

### Shared UI

- [Route card](https://github.com/ashish-800/street-safe/blob/main/src/components/RouteCard.tsx): `src/components/RouteCard.tsx`
- [Kolkata map view](https://github.com/ashish-800/street-safe/blob/main/src/components/KolkataMap.tsx): `src/components/KolkataMap.tsx`
- [Alert card](https://github.com/ashish-800/street-safe/blob/main/src/components/AlertCard.tsx): `src/components/AlertCard.tsx`
- [SOS button](https://github.com/ashish-800/street-safe/blob/main/src/components/SOSButton.tsx): `src/components/SOSButton.tsx`

### Other components

- **App user**
- **Supabase backend**
- **Reverse geocoding**
- **Mapbox services**

## Connections

- App user → Splash and auth check: opens (evidence: `README.md`)
- Splash and auth check → Supabase client: checks session (evidence: `app/index.tsx`)
- Splash and auth check → Login and signup: routes unauthenticated (evidence: `app/index.tsx`)
- Login and signup → Authentication context: signs in or up (evidence: `app/auth/login.tsx`)
- Authentication context → Supabase client: uses client (evidence: `src/context/AuthContext.tsx`)
- Supabase client → Supabase backend: connects when configured (evidence: `README.md`)
- Safety dashboard → Safe route scoring: offers safe walk (evidence: `app/(tabs)/index.tsx`)
- Safety dashboard → Map and location sharing: opens sharing (evidence: `app/(tabs)/index.tsx`)
- Safety dashboard → Community alerts: opens alerts (evidence: `app/(tabs)/index.tsx`)
- Safety dashboard → Emergency safety tools: opens tools (evidence: `app/(tabs)/index.tsx`)
- Safety dashboard → Supabase client: reads alerts and logs SOS (evidence: `app/(tabs)/index.tsx`)
- Safe route scoring → Location provider: reads current position (evidence: `app/(tabs)/route.tsx`)
- Safe route scoring → Supabase client: fetches active alerts (evidence: `app/(tabs)/route.tsx`)
- Safe route scoring → Mapbox services: requests directions (evidence: `README.md`)
- Safe route scoring → Route card: presents route choices (evidence: `README.md`)
- Map and location sharing → Location provider: uses location (evidence: `app/(tabs)/map.tsx`)
- Map and location sharing → Kolkata map view: renders map (evidence: `README.md`)
- Map and location sharing → Supabase client: uses client (evidence: `app/(tabs)/map.tsx`)
- Location provider → Reverse geocoding: reverse geocodes (evidence: `src/context/LocationContext.tsx`)
- Reverse geocoding → Mapbox services: web requests
- Community alerts → Supabase client: uses client (evidence: `app/(tabs)/alerts.tsx`)
- Community alerts → Alert card: presents alerts (evidence: `README.md`)
- Emergency safety tools → Location provider: uses location (evidence: `app/(tabs)/tools.tsx`)
- Emergency safety tools → SOS button: SOS interaction (evidence: `README.md`)
- Profile → Authentication context: uses identity (evidence: `app/(tabs)/profile.tsx`)
- Profile → Supabase client: uses client (evidence: `app/(tabs)/profile.tsx`)
- Supabase client → Offline mock data: offline fallback (evidence: `README.md`)
- Theme provider → Theme colors: selects theme colors (evidence: `src/theme/ThemeContext.tsx`)
- Safety dashboard → Theme provider: reads theme (evidence: `app/(tabs)/index.tsx`)
- Safe route scoring → Theme provider: reads theme (evidence: `app/(tabs)/route.tsx`)
- Map and location sharing → Theme provider: reads theme (evidence: `app/(tabs)/map.tsx`)
- Community alerts → Theme provider: reads theme (evidence: `app/(tabs)/alerts.tsx`)
- Profile → Theme provider: reads theme (evidence: `app/(tabs)/profile.tsx`)
- Emergency safety tools → Theme provider: reads theme (evidence: `app/(tabs)/tools.tsx`)
