# usghejr/fuel_tracker architecture

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

- Interactive diagram: https://gitdiagram.com/usghejr/fuel_tracker
- Repository: https://github.com/usghejr/fuel_tracker

## Overview

This is a web app for recording vehicle trips and fuel purchases, estimating trip costs, filtering trip history, and tracking reimbursements. The main workflow runs from the authenticated user through the app controller, which coordinates local trip/refuel data, cloud reads, matching and cost calculations, and reimbursement actions; the UI presents those results and supports trip entry/import. Authentication and offline-capable synchronization are supporting subsystems. Some component and sync implementations were not sampled, so their internal relationships are omitted unless the excerpts or README establish them.

Main entry points: [`src/App.tsx`](https://github.com/usghejr/fuel_tracker/blob/main/src/App.tsx) (App shell), [`src/features/app/hooks/useAppController.ts`](https://github.com/usghejr/fuel_tracker/blob/main/src/features/app/hooks/useAppController.ts) (App controller), [`src/features/sync/hooks/useDataSync.ts`](https://github.com/usghejr/fuel_tracker/blob/main/src/features/sync/hooks/useDataSync.ts) (Data sync), [`src/features/auth/services/authService.ts`](https://github.com/usghejr/fuel_tracker/blob/main/src/features/auth/services/authService.ts) (Auth service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_trip_management["Trip management"]
  node_app["App shell<br/>[App.tsx]"]
  node_controller["App controller"]
  node_trip_entry["Trip entry and import"]
  node_trip_browse["Trip filters and table"]
end

subgraph group_fuel_costs["Fuel and costs"]
  node_trip_match["Trip matching and costs"]
  node_fuel_convert["Fuel conversion<br/>[fuelConverter.ts]"]
  node_refuel_ui["Refuel management<br/>[RefuelBoxList.tsx]"]
  node_refuel_service["Refuel service<br/>[refuelService.ts]"]
  node_reimbursement_hook["Reimbursement actions"]
  node_reimbursement_calc["Reimbursement calculation"]
  node_reimbursement_ui["Reimbursement summary"]
end

subgraph group_identity_sync["Identity and sync"]
  node_auth_ui["Login<br/>[Login.tsx]"]
  node_auth_context["Auth context<br/>[AuthContext.tsx]"]
  node_auth_service["Auth service<br/>[authService.ts]"]
  node_master_sync["Master sync<br/>[useMasterSync.ts]"]
  node_data_sync["Data sync<br/>[useDataSync.ts]"]
  node_lifecycle_sync["Browser lifecycle sync"]
  node_sync_service["Sync service<br/>[syncService.ts]"]
  node_sync_status["Sync status"]
end

subgraph group_platform["Data and platform"]
  node_trip_repo["Trip repository<br/>[tripRepository.ts]"]
  node_refuel_repo["Refuel repository"]
  node_supabase_client["Supabase client<br/>[supabaseClient.ts]"]
  node_local_storage_service["Local storage service"]
  node_pwa_install["PWA install"]
end

node_user(("Driver"))
node_supabase[("Supabase")]
node_local_storage[("Local storage")]

node_user -->|"uses"| node_app
node_app -->|"coordinates"| node_controller
node_app -->|"renders"| node_trip_entry
node_app -->|"renders"| node_trip_browse
node_app -->|"renders"| node_refuel_ui
node_app -->|"renders"| node_reimbursement_ui
node_app -->|"renders"| node_auth_ui
node_app -->|"renders"| node_sync_status
node_app -->|"renders"| node_pwa_install
node_controller -->|"loads trips"| node_trip_repo
node_controller -->|"loads refuels"| node_refuel_repo
node_controller -->|"enriches trips"| node_trip_match
node_controller -->|"coordinates"| node_reimbursement_hook
node_controller -->|"gets auth"| node_auth_context
node_controller -->|"starts sync"| node_master_sync
node_trip_match -->|"converts fuel"| node_fuel_convert
node_reimbursement_hook -->|"calculates"| node_reimbursement_calc
node_reimbursement_hook -->|"uses matches"| node_trip_match
node_reimbursement_ui -->|"reads summary"| node_reimbursement_calc
node_auth_ui -.->|"authenticates"| node_auth_service
node_auth_context -->|"uses"| node_auth_service
node_auth_service -->|"auth requests"| node_supabase_client
node_auth_service -->|"clears metadata"| node_local_storage_service
node_master_sync -->|"coordinates"| node_data_sync
node_data_sync -->|"syncs queue"| node_sync_service
node_data_sync -->|"registers flush"| node_lifecycle_sync
node_data_sync -->|"persists queue"| node_local_storage_service
node_trip_repo -->|"queries"| node_supabase_client
node_refuel_repo -->|"queries"| node_supabase_client
node_supabase_client -->|"connects"| node_supabase
node_local_storage_service -->|"reads and writes"| node_local_storage
node_sync_service -.->|"dispatches data"| node_trip_repo
node_sync_service -.->|"dispatches data"| node_refuel_repo

click node_app "https://github.com/usghejr/fuel_tracker/blob/main/src/App.tsx"
click node_controller "https://github.com/usghejr/fuel_tracker/blob/main/src/features/app/hooks/useAppController.ts"
click node_trip_entry "https://github.com/usghejr/fuel_tracker/tree/main/src/features/trips/components"
click node_trip_browse "https://github.com/usghejr/fuel_tracker/tree/main/src/features/trips/components"
click node_trip_match "https://github.com/usghejr/fuel_tracker/blob/main/src/features/trips/services/tripMatchingService.ts"
click node_fuel_convert "https://github.com/usghejr/fuel_tracker/blob/main/src/shared/utils/fuelConverter.ts"
click node_refuel_ui "https://github.com/usghejr/fuel_tracker/blob/main/src/features/refuels/components/RefuelBoxList.tsx"
click node_refuel_service "https://github.com/usghejr/fuel_tracker/blob/main/src/features/refuels/services/refuelService.ts"
click node_reimbursement_hook "https://github.com/usghejr/fuel_tracker/blob/main/src/features/reimbursements/hooks/useReimbursements.ts"
click node_reimbursement_calc "https://github.com/usghejr/fuel_tracker/blob/main/src/features/reimbursements/services/reimbursementCalculator.ts"
click node_reimbursement_ui "https://github.com/usghejr/fuel_tracker/blob/main/src/features/reimbursements/components/ReimbursementSummaryCard.tsx"
click node_auth_ui "https://github.com/usghejr/fuel_tracker/blob/main/src/features/auth/components/Login.tsx"
click node_auth_context "https://github.com/usghejr/fuel_tracker/blob/main/src/features/auth/context/AuthContext.tsx"
click node_auth_service "https://github.com/usghejr/fuel_tracker/blob/main/src/features/auth/services/authService.ts"
click node_master_sync "https://github.com/usghejr/fuel_tracker/blob/main/src/features/sync/hooks/useMasterSync.ts"
click node_data_sync "https://github.com/usghejr/fuel_tracker/blob/main/src/features/sync/hooks/useDataSync.ts"
click node_lifecycle_sync "https://github.com/usghejr/fuel_tracker/blob/main/src/features/sync/hooks/useBrowserLifecycleSync.ts"
click node_sync_service "https://github.com/usghejr/fuel_tracker/blob/main/src/features/sync/services/syncService.ts"
click node_sync_status "https://github.com/usghejr/fuel_tracker/blob/main/src/features/sync/components/SyncStatusIndicator.tsx"
click node_trip_repo "https://github.com/usghejr/fuel_tracker/blob/main/src/database/repositories/tripRepository.ts"
click node_refuel_repo "https://github.com/usghejr/fuel_tracker/blob/main/src/database/repositories/refuelRepository.ts"
click node_supabase_client "https://github.com/usghejr/fuel_tracker/blob/main/src/database/supabaseClient.ts"
click node_local_storage_service "https://github.com/usghejr/fuel_tracker/blob/main/src/shared/services/storage/localStorageService.ts"
click node_pwa_install "https://github.com/usghejr/fuel_tracker/blob/main/src/features/pwa/components/InstallAppButton.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_app,node_controller,node_trip_entry,node_trip_browse toneBlue
class node_trip_match,node_fuel_convert,node_refuel_ui,node_refuel_service,node_reimbursement_hook,node_reimbursement_calc,node_reimbursement_ui,node_supabase,node_local_storage toneAmber
class node_auth_ui,node_auth_context,node_auth_service,node_master_sync,node_data_sync,node_lifecycle_sync,node_sync_service,node_sync_status toneMint
class node_trip_repo,node_refuel_repo,node_supabase_client,node_local_storage_service,node_pwa_install toneRose
class node_user toneIndigo
```

## Components

### Trip management

- [App shell](https://github.com/usghejr/fuel_tracker/blob/main/src/App.tsx): `src/App.tsx`
- [App controller](https://github.com/usghejr/fuel_tracker/blob/main/src/features/app/hooks/useAppController.ts): `src/features/app/hooks/useAppController.ts`
- [Trip entry and import](https://github.com/usghejr/fuel_tracker/tree/main/src/features/trips/components): `src/features/trips/components`
- [Trip filters and table](https://github.com/usghejr/fuel_tracker/tree/main/src/features/trips/components): `src/features/trips/components`

### Fuel and costs

- [Trip matching and costs](https://github.com/usghejr/fuel_tracker/blob/main/src/features/trips/services/tripMatchingService.ts): `src/features/trips/services/tripMatchingService.ts`
- [Fuel conversion](https://github.com/usghejr/fuel_tracker/blob/main/src/shared/utils/fuelConverter.ts): `src/shared/utils/fuelConverter.ts`
- [Refuel management](https://github.com/usghejr/fuel_tracker/blob/main/src/features/refuels/components/RefuelBoxList.tsx): `src/features/refuels/components/RefuelBoxList.tsx`
- [Refuel service](https://github.com/usghejr/fuel_tracker/blob/main/src/features/refuels/services/refuelService.ts): `src/features/refuels/services/refuelService.ts`
- [Reimbursement actions](https://github.com/usghejr/fuel_tracker/blob/main/src/features/reimbursements/hooks/useReimbursements.ts): `src/features/reimbursements/hooks/useReimbursements.ts`
- [Reimbursement calculation](https://github.com/usghejr/fuel_tracker/blob/main/src/features/reimbursements/services/reimbursementCalculator.ts): `src/features/reimbursements/services/reimbursementCalculator.ts`
- [Reimbursement summary](https://github.com/usghejr/fuel_tracker/blob/main/src/features/reimbursements/components/ReimbursementSummaryCard.tsx): `src/features/reimbursements/components/ReimbursementSummaryCard.tsx`

### Identity and sync

- [Login](https://github.com/usghejr/fuel_tracker/blob/main/src/features/auth/components/Login.tsx): `src/features/auth/components/Login.tsx`
- [Auth context](https://github.com/usghejr/fuel_tracker/blob/main/src/features/auth/context/AuthContext.tsx): `src/features/auth/context/AuthContext.tsx`
- [Auth service](https://github.com/usghejr/fuel_tracker/blob/main/src/features/auth/services/authService.ts): `src/features/auth/services/authService.ts`
- [Master sync](https://github.com/usghejr/fuel_tracker/blob/main/src/features/sync/hooks/useMasterSync.ts): `src/features/sync/hooks/useMasterSync.ts`
- [Data sync](https://github.com/usghejr/fuel_tracker/blob/main/src/features/sync/hooks/useDataSync.ts): `src/features/sync/hooks/useDataSync.ts`
- [Browser lifecycle sync](https://github.com/usghejr/fuel_tracker/blob/main/src/features/sync/hooks/useBrowserLifecycleSync.ts): `src/features/sync/hooks/useBrowserLifecycleSync.ts`
- [Sync service](https://github.com/usghejr/fuel_tracker/blob/main/src/features/sync/services/syncService.ts): `src/features/sync/services/syncService.ts`
- [Sync status](https://github.com/usghejr/fuel_tracker/blob/main/src/features/sync/components/SyncStatusIndicator.tsx): `src/features/sync/components/SyncStatusIndicator.tsx`

### Data and platform

- [Trip repository](https://github.com/usghejr/fuel_tracker/blob/main/src/database/repositories/tripRepository.ts): `src/database/repositories/tripRepository.ts`
- [Refuel repository](https://github.com/usghejr/fuel_tracker/blob/main/src/database/repositories/refuelRepository.ts): `src/database/repositories/refuelRepository.ts`
- [Supabase client](https://github.com/usghejr/fuel_tracker/blob/main/src/database/supabaseClient.ts): `src/database/supabaseClient.ts`
- [Local storage service](https://github.com/usghejr/fuel_tracker/blob/main/src/shared/services/storage/localStorageService.ts): `src/shared/services/storage/localStorageService.ts`
- [PWA install](https://github.com/usghejr/fuel_tracker/blob/main/src/features/pwa/components/InstallAppButton.tsx): `src/features/pwa/components/InstallAppButton.tsx`

### Other components

- **Driver**
- **Supabase**
- **Local storage**

## Connections

- Driver → App shell: uses (evidence: `src/App.tsx`)
- App shell → App controller: coordinates (evidence: `src/App.tsx`)
- App shell → Trip entry and import: renders (evidence: `src/App.tsx`)
- App shell → Trip filters and table: renders (evidence: `src/App.tsx`)
- App shell → Refuel management: renders (evidence: `src/App.tsx`)
- App shell → Reimbursement summary: renders (evidence: `src/App.tsx`)
- App shell → Login: renders (evidence: `src/App.tsx`)
- App shell → Sync status: renders (evidence: `src/App.tsx`)
- App shell → PWA install: renders (evidence: `src/App.tsx`)
- App controller → Trip repository: loads trips (evidence: `src/features/app/hooks/useAppController.ts`)
- App controller → Refuel repository: loads refuels (evidence: `src/features/app/hooks/useAppController.ts`)
- App controller → Trip matching and costs: enriches trips (evidence: `src/features/app/hooks/useAppController.ts`)
- App controller → Reimbursement actions: coordinates (evidence: `src/features/app/hooks/useAppController.ts`)
- App controller → Auth context: gets auth (evidence: `src/features/app/hooks/useAppController.ts`)
- App controller → Master sync: starts sync (evidence: `src/features/app/hooks/useAppController.ts`)
- Trip matching and costs → Fuel conversion: converts fuel (evidence: `src/features/trips/services/tripMatchingService.ts`)
- Reimbursement actions → Reimbursement calculation: calculates (evidence: `src/features/reimbursements/hooks/useReimbursements.ts`)
- Reimbursement actions → Trip matching and costs: uses matches (evidence: `src/features/reimbursements/hooks/useReimbursements.ts`)
- Reimbursement summary → Reimbursement calculation: reads summary (evidence: `src/features/reimbursements/components/ReimbursementSummaryCard.tsx`)
- Login → Auth service: authenticates
- Auth context → Auth service: uses (evidence: `src/features/auth/context/AuthContext.tsx`)
- Auth service → Supabase client: auth requests (evidence: `src/features/auth/services/authService.ts`)
- Auth service → Local storage service: clears metadata (evidence: `src/features/auth/services/authService.ts`)
- Master sync → Data sync: coordinates (evidence: `src/features/sync/hooks/useMasterSync.ts`)
- Data sync → Sync service: syncs queue (evidence: `src/features/sync/hooks/useDataSync.ts`)
- Data sync → Browser lifecycle sync: registers flush (evidence: `src/features/sync/hooks/useDataSync.ts`)
- Data sync → Local storage service: persists queue (evidence: `src/features/sync/hooks/useDataSync.ts`)
- Trip repository → Supabase client: queries (evidence: `src/database/repositories/tripRepository.ts`)
- Refuel repository → Supabase client: queries (evidence: `src/database/repositories/refuelRepository.ts`)
- Supabase client → Supabase: connects (evidence: `src/database/supabaseClient.ts`)
- Local storage service → Local storage: reads and writes (evidence: `src/shared/services/storage/localStorageService.ts`)
- Sync service → Trip repository: dispatches data (evidence: `src/features/sync/services/syncService.ts`)
- Sync service → Refuel repository: dispatches data (evidence: `src/features/sync/services/syncService.ts`)
