# nilan92/mazdabuddy architecture

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

- Interactive diagram: https://gitdiagram.com/nilan92/mazdabuddy
- Repository: https://github.com/nilan92/mazdabuddy
- Video tour (about a minute): https://gitdiagram.com/nilan92/mazdabuddy/video

## Overview

AutoPulse is a mobile-first workshop management app. Workshop staff authenticate and enter a tenant-scoped workspace to manage vehicles, jobs, parts, invoices, and finances; technicians track assigned work and customers receive status updates and invoices. The README documents offline caching, plate scanning, automatic completion invoicing, stock deduction, SMS, and push notifications. Source excerpts confirm app routing, authentication, persisted query state, technician-progress queries, job-detail integrations, and photo-upload authorization; wiring among unsampled feature screens is shown only where documented.

Main entry points: [`src/lib/supabase.ts`](https://github.com/nilan92/mazdabuddy/blob/main/src/lib/supabase.ts) (Workshop data), [`src/App.tsx`](https://github.com/nilan92/mazdabuddy/blob/main/src/App.tsx) (App router), [`src/components/Layout.tsx`](https://github.com/nilan92/mazdabuddy/blob/main/src/components/Layout.tsx) (Workspace layout), [`src/components/JobDetails.tsx`](https://github.com/nilan92/mazdabuddy/blob/main/src/components/JobDetails.tsx) (Job details)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Access and workspace"]
  node_app["App router<br/>[App.tsx]"]
  node_auth["Authentication<br/>[AuthContext.tsx]"]
  node_onboarding["Workshop onboarding<br/>[Onboarding.tsx]"]
  node_layout["Workspace layout<br/>[Layout.tsx]"]
end

subgraph group_operations["Workshop operations"]
  node_jobs["Job board<br/>[Jobs.tsx]"]
  node_jobdetails["Job details<br/>[JobDetails.tsx]"]
  node_scan["Plate scan<br/>[SmartScan.tsx]"]
  node_inventory["Parts inventory<br/>[Inventory.tsx]"]
  node_technician["Technician progress"]
end

subgraph group_business["Business records"]
  node_customers["Customer records<br/>[Customers.tsx]"]
  node_invoices["Invoices and PDFs<br/>[Invoices.tsx]"]
  node_finance["Financial reporting<br/>[Finances.tsx]"]
end

subgraph group_shared["Shared services"]
  node_supabase[("Workshop data<br/>[supabase.ts]")]
  node_querycache[("Persisted query cache<br/>[main.tsx]")]
  node_financecalc["Finance calculations<br/>[finance.ts]"]
  node_photos["Job photo client<br/>[photos.ts]"]
  node_photoauth["Photo upload authorizer<br/>[index.ts]"]
end

subgraph group_integrations["External integrations"]
  node_objectstore[("Photo object storage")]
  node_sms["SMS service<br/>[sms.ts]"]
  node_push["Push notifications<br/>[push.ts]"]
  node_serviceworker["Service worker<br/>[sw.js]"]
  node_ai["AI diagnosis<br/>[ai.ts]"]
  node_textlk["text.lk"]
end

node_staff(("Workshop staff"))
node_browser(("Camera and browser"))

node_staff -->|"opens"| node_app
node_app -->|"checks session"| node_auth
node_app -->|"routes new users"| node_onboarding
node_app -->|"renders workspace"| node_layout
node_auth -->|"authenticates"| node_supabase
node_auth -->|"loads profile"| node_supabase
node_onboarding -->|"creates workshop"| node_supabase
node_layout -->|"navigates"| node_jobs
node_layout -->|"navigates"| node_customers
node_layout -->|"navigates"| node_inventory
node_layout -->|"navigates"| node_invoices
node_layout -->|"navigates"| node_finance
node_staff -->|"scans plate"| node_scan
node_browser -->|"provides camera"| node_scan
node_jobs -->|"reads and writes"| node_supabase
node_jobdetails -->|"reads and writes"| node_supabase
node_customers -->|"reads and writes"| node_supabase
node_inventory -->|"reads and writes"| node_supabase
node_invoices -->|"reads and writes"| node_supabase
node_finance -->|"reads records"| node_supabase
node_finance -->|"calculates reports"| node_financecalc
node_technician -->|"queries staff and jobs"| node_supabase
node_jobdetails -->|"sends customer SMS"| node_sms
node_sms -.->|"delivers messages"| node_textlk
node_jobdetails -.->|"requests diagnosis"| node_ai
node_jobdetails -->|"uploads photos"| node_photos
node_photos -->|"requests authorization"| node_photoauth
node_photoauth -->|"checks tenant and job"| node_supabase
node_photoauth -->|"stores photos"| node_objectstore
node_app -->|"registers worker"| node_push
node_push -->|"registers"| node_serviceworker
node_serviceworker -->|"shows push alerts"| node_staff
node_app -->|"persists query data"| node_querycache

click node_app "https://github.com/nilan92/mazdabuddy/blob/main/src/App.tsx"
click node_auth "https://github.com/nilan92/mazdabuddy/blob/main/src/context/AuthContext.tsx"
click node_onboarding "https://github.com/nilan92/mazdabuddy/blob/main/src/components/Onboarding.tsx"
click node_layout "https://github.com/nilan92/mazdabuddy/blob/main/src/components/Layout.tsx"
click node_jobs "https://github.com/nilan92/mazdabuddy/blob/main/src/components/Jobs.tsx"
click node_jobdetails "https://github.com/nilan92/mazdabuddy/blob/main/src/components/JobDetails.tsx"
click node_scan "https://github.com/nilan92/mazdabuddy/blob/main/src/components/SmartScan.tsx"
click node_inventory "https://github.com/nilan92/mazdabuddy/blob/main/src/components/Inventory.tsx"
click node_technician "https://github.com/nilan92/mazdabuddy/blob/main/src/hooks/useTechnicianProgress.ts"
click node_customers "https://github.com/nilan92/mazdabuddy/blob/main/src/components/Customers.tsx"
click node_invoices "https://github.com/nilan92/mazdabuddy/blob/main/src/components/Invoices.tsx"
click node_finance "https://github.com/nilan92/mazdabuddy/blob/main/src/components/Finances.tsx"
click node_supabase "https://github.com/nilan92/mazdabuddy/blob/main/src/lib/supabase.ts"
click node_querycache "https://github.com/nilan92/mazdabuddy/blob/main/src/main.tsx"
click node_financecalc "https://github.com/nilan92/mazdabuddy/blob/main/src/lib/finance.ts"
click node_photos "https://github.com/nilan92/mazdabuddy/blob/main/src/lib/photos.ts"
click node_photoauth "https://github.com/nilan92/mazdabuddy/blob/main/worker/src/index.ts"
click node_sms "https://github.com/nilan92/mazdabuddy/blob/main/src/lib/sms.ts"
click node_push "https://github.com/nilan92/mazdabuddy/blob/main/src/lib/push.ts"
click node_serviceworker "https://github.com/nilan92/mazdabuddy/blob/main/public/sw.js"
click node_ai "https://github.com/nilan92/mazdabuddy/blob/main/src/lib/ai.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_onboarding,node_layout,node_browser toneBlue
class node_jobs,node_jobdetails,node_scan,node_inventory,node_technician toneAmber
class node_customers,node_invoices,node_finance toneMint
class node_supabase,node_querycache,node_financecalc,node_photos,node_photoauth toneRose
class node_objectstore,node_sms,node_push,node_serviceworker,node_ai,node_textlk,node_staff toneIndigo
```

## Components

### Access and workspace

- [App router](https://github.com/nilan92/mazdabuddy/blob/main/src/App.tsx): `src/App.tsx`
- [Authentication](https://github.com/nilan92/mazdabuddy/blob/main/src/context/AuthContext.tsx): `src/context/AuthContext.tsx`
- [Workshop onboarding](https://github.com/nilan92/mazdabuddy/blob/main/src/components/Onboarding.tsx): `src/components/Onboarding.tsx`
- [Workspace layout](https://github.com/nilan92/mazdabuddy/blob/main/src/components/Layout.tsx): `src/components/Layout.tsx`

### Workshop operations

- [Job board](https://github.com/nilan92/mazdabuddy/blob/main/src/components/Jobs.tsx): `src/components/Jobs.tsx`
- [Job details](https://github.com/nilan92/mazdabuddy/blob/main/src/components/JobDetails.tsx): `src/components/JobDetails.tsx`
- [Plate scan](https://github.com/nilan92/mazdabuddy/blob/main/src/components/SmartScan.tsx): `src/components/SmartScan.tsx`
- [Parts inventory](https://github.com/nilan92/mazdabuddy/blob/main/src/components/Inventory.tsx): `src/components/Inventory.tsx`
- [Technician progress](https://github.com/nilan92/mazdabuddy/blob/main/src/hooks/useTechnicianProgress.ts): `src/hooks/useTechnicianProgress.ts`

### Business records

- [Customer records](https://github.com/nilan92/mazdabuddy/blob/main/src/components/Customers.tsx): `src/components/Customers.tsx`
- [Invoices and PDFs](https://github.com/nilan92/mazdabuddy/blob/main/src/components/Invoices.tsx): `src/components/Invoices.tsx`
- [Financial reporting](https://github.com/nilan92/mazdabuddy/blob/main/src/components/Finances.tsx): `src/components/Finances.tsx`

### Shared services

- [Workshop data](https://github.com/nilan92/mazdabuddy/blob/main/src/lib/supabase.ts): `src/lib/supabase.ts`
- [Persisted query cache](https://github.com/nilan92/mazdabuddy/blob/main/src/main.tsx): `src/main.tsx`
- [Finance calculations](https://github.com/nilan92/mazdabuddy/blob/main/src/lib/finance.ts): `src/lib/finance.ts`
- [Job photo client](https://github.com/nilan92/mazdabuddy/blob/main/src/lib/photos.ts): `src/lib/photos.ts`
- [Photo upload authorizer](https://github.com/nilan92/mazdabuddy/blob/main/worker/src/index.ts): `worker/src/index.ts`

### External integrations

- **Photo object storage**
- [SMS service](https://github.com/nilan92/mazdabuddy/blob/main/src/lib/sms.ts): `src/lib/sms.ts`
- [Push notifications](https://github.com/nilan92/mazdabuddy/blob/main/src/lib/push.ts): `src/lib/push.ts`
- [Service worker](https://github.com/nilan92/mazdabuddy/blob/main/public/sw.js): `public/sw.js`
- [AI diagnosis](https://github.com/nilan92/mazdabuddy/blob/main/src/lib/ai.ts): `src/lib/ai.ts`
- **text.lk**

### Other components

- **Workshop staff**
- **Camera and browser**

## Connections

- Workshop staff → App router: opens
- App router → Authentication: checks session
- App router → Workshop onboarding: routes new users
- App router → Workspace layout: renders workspace
- Authentication → Workshop data: authenticates
- Authentication → Workshop data: loads profile
- Workshop onboarding → Workshop data: creates workshop
- Workspace layout → Job board: navigates
- Workspace layout → Customer records: navigates
- Workspace layout → Parts inventory: navigates
- Workspace layout → Invoices and PDFs: navigates
- Workspace layout → Financial reporting: navigates
- Workshop staff → Plate scan: scans plate
- Camera and browser → Plate scan: provides camera
- Job board → Workshop data: reads and writes
- Job details → Workshop data: reads and writes
- Customer records → Workshop data: reads and writes
- Parts inventory → Workshop data: reads and writes
- Invoices and PDFs → Workshop data: reads and writes
- Financial reporting → Workshop data: reads records
- Financial reporting → Finance calculations: calculates reports
- Technician progress → Workshop data: queries staff and jobs
- Job details → SMS service: sends customer SMS
- SMS service → text.lk: delivers messages
- Job details → AI diagnosis: requests diagnosis
- Job details → Job photo client: uploads photos
- Job photo client → Photo upload authorizer: requests authorization
- Photo upload authorizer → Workshop data: checks tenant and job
- Photo upload authorizer → Photo object storage: stores photos
- App router → Push notifications: registers worker
- Push notifications → Service worker: registers
- Service worker → Workshop staff: shows push alerts
- App router → Persisted query cache: persists query data
