# tusharqlab/joyful-database-buddy architecture

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

- Interactive diagram: https://gitdiagram.com/tusharqlab/joyful-database-buddy
- Repository: https://github.com/tusharqlab/joyful-database-buddy

## Overview

Fuelio is a fuel-station discovery and status-sharing app, with separate driver and station-manager experiences. Drivers browse live station availability, search or map stations, plan routes, inspect station details, save favorites, and submit status reports; managers authenticate, access their assigned station, and publish official updates. Supabase provides authentication and application data, while route lookup uses OpenStreetMap geocoding and OSRM. The graph follows relationships visible in excerpts or the SOURCE INDEX; unsampled subsystems are represented by their known paths without assuming internal calls.

Main entry points: [`src/integrations/supabase/client.ts`](https://github.com/tusharqlab/joyful-database-buddy/blob/main/src/integrations/supabase/client.ts) (Supabase client), [`src/components/map/MapPanel.tsx`](https://github.com/tusharqlab/joyful-database-buddy/blob/main/src/components/map/MapPanel.tsx) (Map and search panel), [`src/lib/stations.ts`](https://github.com/tusharqlab/joyful-database-buddy/blob/main/src/lib/stations.ts) (Station data and status), [`src/routes/_authenticated/station.$stationId.tsx`](https://github.com/tusharqlab/joyful-database-buddy/blob/main/src/routes/_authenticated/station.%24stationId.tsx) (Station details page)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_navigation["App and access"]
  node_app["Station browser<br/>[app.tsx]"]
  node_auth["Authentication<br/>[auth.tsx]"]
  node_authstate["Auth state<br/>[useAuth.tsx]"]
  node_guard["Manager access guard"]
end

subgraph group_discovery["Station discovery"]
  node_map["Map and search panel<br/>[MapPanel.tsx]"]
  node_stationmap["Station map<br/>[StationMap.tsx]"]
  node_stationsearch["Station search"]
  node_routesearch["Route search"]
  node_route["Geocoding and routing<br/>[route.ts]"]
  node_routepage["Route view<br/>[route.tsx]"]
  node_stationpage["Station details page"]
  node_stationdetails["Station details card"]
end

subgraph group_updates["Status and management"]
  node_favoritespage["Favorites page<br/>[favorites.tsx]"]
  node_favorites["Favorite actions<br/>[favorites.ts]"]
  node_favoritebutton["Favorite control<br/>[FavoriteButton.tsx]"]
  node_reportform["Driver status report"]
  node_reports["Report data<br/>[reports.ts]"]
  node_managerpage["Manager area<br/>[manager.tsx]"]
  node_managerform["Official report form"]
  node_managerfunctions["Manager operations"]
end

subgraph group_services["Data and services"]
  node_stationdata["Station data and status<br/>[stations.ts]"]
  node_supabaseclient["Supabase client<br/>[client.ts]"]
  node_previewstorage["Preview auth storage"]
  node_database[("Supabase")]
  node_nominatim["Nominatim"]
  node_osrm["OSRM routing"]
end

node_driver(("Driver"))
node_manager(("Station manager"))

node_driver -->|"browses stations"| node_app
node_driver -->|"signs in"| node_auth
node_manager -->|"signs in"| node_auth
node_app -->|"reads session"| node_authstate
node_auth -->|"uses auth state"| node_authstate
node_authstate -->|"reads auth session"| node_supabaseclient
node_guard -->|"checks access"| node_managerfunctions
node_app -->|"renders"| node_map
node_app -->|"loads stations"| node_stationdata
node_map -->|"renders"| node_stationmap
node_map -->|"renders"| node_stationsearch
node_map -->|"renders"| node_routesearch
node_map -->|"fetches station data"| node_stationdata
node_map -->|"uses route helpers"| node_route
node_routesearch -->|"geocodes and routes"| node_route
node_route -->|"geocodes with"| node_nominatim
node_route -->|"requests routes"| node_osrm
node_routepage -->|"uses client"| node_supabaseclient
node_stationpage -->|"renders"| node_stationdetails
node_stationpage -->|"renders"| node_reportform
node_stationpage -->|"renders"| node_favoritebutton
node_stationpage -->|"loads station"| node_stationdata
node_stationpage -->|"checks access"| node_guard
node_favoritespage -->|"renders"| node_favoritebutton
node_favoritespage -->|"uses favorites"| node_favorites
node_favoritespage -->|"loads stations"| node_stationdata
node_favoritespage -->|"checks access"| node_guard
node_reportform -->|"uses user session"| node_authstate
node_reportform -->|"submits reports"| node_reports
node_reports -->|"reads and writes"| node_supabaseclient
node_managerpage -->|"loads manager data"| node_managerfunctions
node_managerpage -->|"renders"| node_managerform
node_managerpage -->|"formats station data"| node_stationdata
node_managerpage -->|"uses session"| node_authstate
node_managerform -->|"loads and submits reports"| node_managerfunctions
node_managerfunctions -.->|"queries via auth context"| node_supabaseclient
node_stationdata -->|"queries station data"| node_supabaseclient
node_supabaseclient -->|"configures auth storage"| node_previewstorage
node_supabaseclient -->|"connects to"| node_database

click node_app "https://github.com/tusharqlab/joyful-database-buddy/blob/main/src/routes/_authenticated/app.tsx"
click node_auth "https://github.com/tusharqlab/joyful-database-buddy/blob/main/src/routes/auth.tsx"
click node_authstate "https://github.com/tusharqlab/joyful-database-buddy/blob/main/src/hooks/useAuth.tsx"
click node_guard "https://github.com/tusharqlab/joyful-database-buddy/blob/main/src/hooks/useManagerGuard.tsx"
click node_map "https://github.com/tusharqlab/joyful-database-buddy/blob/main/src/components/map/MapPanel.tsx"
click node_stationmap "https://github.com/tusharqlab/joyful-database-buddy/blob/main/src/components/map/StationMap.tsx"
click node_stationsearch "https://github.com/tusharqlab/joyful-database-buddy/blob/main/src/components/map/StationSearchPanel.tsx"
click node_routesearch "https://github.com/tusharqlab/joyful-database-buddy/blob/main/src/components/map/RouteSearchPanel.tsx"
click node_route "https://github.com/tusharqlab/joyful-database-buddy/blob/main/src/lib/route.ts"
click node_routepage "https://github.com/tusharqlab/joyful-database-buddy/blob/main/src/routes/_authenticated/route.tsx"
click node_stationpage "https://github.com/tusharqlab/joyful-database-buddy/blob/main/src/routes/_authenticated/station.%24stationId.tsx"
click node_stationdetails "https://github.com/tusharqlab/joyful-database-buddy/blob/main/src/components/station/StationDetailsCard.tsx"
click node_stationdata "https://github.com/tusharqlab/joyful-database-buddy/blob/main/src/lib/stations.ts"
click node_favoritespage "https://github.com/tusharqlab/joyful-database-buddy/blob/main/src/routes/_authenticated/favorites.tsx"
click node_favorites "https://github.com/tusharqlab/joyful-database-buddy/blob/main/src/lib/favorites.ts"
click node_favoritebutton "https://github.com/tusharqlab/joyful-database-buddy/blob/main/src/components/station/FavoriteButton.tsx"
click node_reportform "https://github.com/tusharqlab/joyful-database-buddy/blob/main/src/components/station/ReportStatusForm.tsx"
click node_reports "https://github.com/tusharqlab/joyful-database-buddy/blob/main/src/lib/reports.ts"
click node_managerpage "https://github.com/tusharqlab/joyful-database-buddy/blob/main/src/routes/_authenticated/manager.tsx"
click node_managerform "https://github.com/tusharqlab/joyful-database-buddy/blob/main/src/components/manager/ManagerReportForm.tsx"
click node_managerfunctions "https://github.com/tusharqlab/joyful-database-buddy/blob/main/src/lib/manager.functions.ts"
click node_supabaseclient "https://github.com/tusharqlab/joyful-database-buddy/blob/main/src/integrations/supabase/client.ts"
click node_previewstorage "https://github.com/tusharqlab/joyful-database-buddy/blob/main/src/integrations/supabase/previewAuthStorage.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_app,node_auth,node_authstate,node_guard toneBlue
class node_map,node_stationmap,node_stationsearch,node_routesearch,node_route,node_routepage,node_stationpage,node_stationdetails toneAmber
class node_favoritespage,node_favorites,node_favoritebutton,node_reportform,node_reports,node_managerpage,node_managerform,node_managerfunctions toneMint
class node_stationdata,node_supabaseclient,node_previewstorage,node_database,node_nominatim,node_osrm toneRose
class node_driver,node_manager toneIndigo
```

## Components

### App and access

- [Station browser](https://github.com/tusharqlab/joyful-database-buddy/blob/main/src/routes/_authenticated/app.tsx): `src/routes/_authenticated/app.tsx`
- [Authentication](https://github.com/tusharqlab/joyful-database-buddy/blob/main/src/routes/auth.tsx): `src/routes/auth.tsx`
- [Auth state](https://github.com/tusharqlab/joyful-database-buddy/blob/main/src/hooks/useAuth.tsx): `src/hooks/useAuth.tsx`
- [Manager access guard](https://github.com/tusharqlab/joyful-database-buddy/blob/main/src/hooks/useManagerGuard.tsx): `src/hooks/useManagerGuard.tsx`

### Station discovery

- [Map and search panel](https://github.com/tusharqlab/joyful-database-buddy/blob/main/src/components/map/MapPanel.tsx): `src/components/map/MapPanel.tsx`
- [Station map](https://github.com/tusharqlab/joyful-database-buddy/blob/main/src/components/map/StationMap.tsx): `src/components/map/StationMap.tsx`
- [Station search](https://github.com/tusharqlab/joyful-database-buddy/blob/main/src/components/map/StationSearchPanel.tsx): `src/components/map/StationSearchPanel.tsx`
- [Route search](https://github.com/tusharqlab/joyful-database-buddy/blob/main/src/components/map/RouteSearchPanel.tsx): `src/components/map/RouteSearchPanel.tsx`
- [Geocoding and routing](https://github.com/tusharqlab/joyful-database-buddy/blob/main/src/lib/route.ts): `src/lib/route.ts`
- [Route view](https://github.com/tusharqlab/joyful-database-buddy/blob/main/src/routes/_authenticated/route.tsx): `src/routes/_authenticated/route.tsx`
- [Station details page](https://github.com/tusharqlab/joyful-database-buddy/blob/main/src/routes/_authenticated/station.%24stationId.tsx): `src/routes/_authenticated/station.$stationId.tsx`
- [Station details card](https://github.com/tusharqlab/joyful-database-buddy/blob/main/src/components/station/StationDetailsCard.tsx): `src/components/station/StationDetailsCard.tsx`

### Status and management

- [Favorites page](https://github.com/tusharqlab/joyful-database-buddy/blob/main/src/routes/_authenticated/favorites.tsx): `src/routes/_authenticated/favorites.tsx`
- [Favorite actions](https://github.com/tusharqlab/joyful-database-buddy/blob/main/src/lib/favorites.ts): `src/lib/favorites.ts`
- [Favorite control](https://github.com/tusharqlab/joyful-database-buddy/blob/main/src/components/station/FavoriteButton.tsx): `src/components/station/FavoriteButton.tsx`
- [Driver status report](https://github.com/tusharqlab/joyful-database-buddy/blob/main/src/components/station/ReportStatusForm.tsx): `src/components/station/ReportStatusForm.tsx`
- [Report data](https://github.com/tusharqlab/joyful-database-buddy/blob/main/src/lib/reports.ts): `src/lib/reports.ts`
- [Manager area](https://github.com/tusharqlab/joyful-database-buddy/blob/main/src/routes/_authenticated/manager.tsx): `src/routes/_authenticated/manager.tsx`
- [Official report form](https://github.com/tusharqlab/joyful-database-buddy/blob/main/src/components/manager/ManagerReportForm.tsx): `src/components/manager/ManagerReportForm.tsx`
- [Manager operations](https://github.com/tusharqlab/joyful-database-buddy/blob/main/src/lib/manager.functions.ts): `src/lib/manager.functions.ts`

### Data and services

- [Station data and status](https://github.com/tusharqlab/joyful-database-buddy/blob/main/src/lib/stations.ts): `src/lib/stations.ts`
- [Supabase client](https://github.com/tusharqlab/joyful-database-buddy/blob/main/src/integrations/supabase/client.ts): `src/integrations/supabase/client.ts`
- [Preview auth storage](https://github.com/tusharqlab/joyful-database-buddy/blob/main/src/integrations/supabase/previewAuthStorage.ts): `src/integrations/supabase/previewAuthStorage.ts`
- **Supabase**
- **Nominatim**
- **OSRM routing**

### Other components

- **Driver**
- **Station manager**

## Connections

- Driver → Station browser: browses stations (evidence: `src/routes/_authenticated/app.tsx`)
- Driver → Authentication: signs in (evidence: `src/routes/auth.tsx`)
- Station manager → Authentication: signs in (evidence: `src/routes/auth.tsx`)
- Station browser → Auth state: reads session (evidence: `src/routes/_authenticated/app.tsx`)
- Authentication → Auth state: uses auth state (evidence: `src/routes/auth.tsx`)
- Auth state → Supabase client: reads auth session (evidence: `src/hooks/useAuth.tsx`)
- Manager access guard → Manager operations: checks access (evidence: `src/hooks/useManagerGuard.tsx`)
- Station browser → Map and search panel: renders (evidence: `src/routes/_authenticated/app.tsx`)
- Station browser → Station data and status: loads stations (evidence: `src/routes/_authenticated/app.tsx`)
- Map and search panel → Station map: renders (evidence: `src/components/map/MapPanel.tsx`)
- Map and search panel → Station search: renders (evidence: `src/components/map/MapPanel.tsx`)
- Map and search panel → Route search: renders (evidence: `src/components/map/MapPanel.tsx`)
- Map and search panel → Station data and status: fetches station data (evidence: `src/components/map/MapPanel.tsx`)
- Map and search panel → Geocoding and routing: uses route helpers (evidence: `src/components/map/MapPanel.tsx`)
- Route search → Geocoding and routing: geocodes and routes (evidence: `src/components/map/RouteSearchPanel.tsx`)
- Geocoding and routing → Nominatim: geocodes with (evidence: `src/lib/route.ts`)
- Geocoding and routing → OSRM routing: requests routes (evidence: `src/lib/route.ts`)
- Route view → Supabase client: uses client (evidence: `src/routes/_authenticated/route.tsx`)
- Station details page → Station details card: renders (evidence: `src/routes/_authenticated/station.$stationId.tsx`)
- Station details page → Driver status report: renders (evidence: `src/routes/_authenticated/station.$stationId.tsx`)
- Station details page → Favorite control: renders (evidence: `src/routes/_authenticated/station.$stationId.tsx`)
- Station details page → Station data and status: loads station (evidence: `src/routes/_authenticated/station.$stationId.tsx`)
- Station details page → Manager access guard: checks access (evidence: `src/routes/_authenticated/station.$stationId.tsx`)
- Favorites page → Favorite control: renders (evidence: `src/routes/_authenticated/favorites.tsx`)
- Favorites page → Favorite actions: uses favorites (evidence: `src/routes/_authenticated/favorites.tsx`)
- Favorites page → Station data and status: loads stations (evidence: `src/routes/_authenticated/favorites.tsx`)
- Favorites page → Manager access guard: checks access (evidence: `src/routes/_authenticated/favorites.tsx`)
- Driver status report → Auth state: uses user session (evidence: `src/components/station/ReportStatusForm.tsx`)
- Driver status report → Report data: submits reports (evidence: `src/components/station/ReportStatusForm.tsx`)
- Report data → Supabase client: reads and writes (evidence: `src/lib/reports.ts`)
- Manager area → Manager operations: loads manager data (evidence: `src/routes/_authenticated/manager.tsx`)
- Manager area → Official report form: renders (evidence: `src/routes/_authenticated/manager.tsx`)
- Manager area → Station data and status: formats station data (evidence: `src/routes/_authenticated/manager.tsx`)
- Manager area → Auth state: uses session (evidence: `src/routes/_authenticated/manager.tsx`)
- Official report form → Manager operations: loads and submits reports (evidence: `src/components/manager/ManagerReportForm.tsx`)
- Manager operations → Supabase client: queries via auth context
- Station data and status → Supabase client: queries station data (evidence: `src/lib/stations.ts`)
- Supabase client → Preview auth storage: configures auth storage (evidence: `src/integrations/supabase/client.ts`)
- Supabase client → Supabase: connects to (evidence: `src/integrations/supabase/client.ts`)
