# pwg09/detailflow architecture

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

- Interactive diagram: https://gitdiagram.com/pwg09/detailflow
- Repository: https://github.com/pwg09/detailflow

## Overview

DetailFlow is a multi-tenant SaaS for automotive detail businesses. Owners configure a business and services, share a business-specific lead form, review submitted leads, create and share quotes, and collect customer payments; customers submit vehicle details and photos and can access quotes. The graph preserves the documented dashboard, team, analytics, billing, and AI-assessment capabilities. Source excerpts are partial, so uncertain wiring—particularly email and several dashboard endpoints—is omitted.

Main entry points: [`app/dashboard/page.tsx`](https://github.com/pwg09/detailflow/blob/master/app/dashboard/page.tsx) (Business dashboard), [`lib/supabase/server.ts`](https://github.com/pwg09/detailflow/blob/master/lib/supabase/server.ts) (Authenticated data access), [`app/api/dashboard/ai/route.ts`](https://github.com/pwg09/detailflow/blob/master/app/api/dashboard/ai/route.ts) (AI assessment endpoint), [`app/api/public/quote/route.ts`](https://github.com/pwg09/detailflow/blob/master/app/api/public/quote/route.ts) (Lead submission)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_customer_flow["Customer flow"]
  node_lead_form["Business lead form<br/>[page.tsx]"]
  node_public_quote_api["Lead submission<br/>[route.ts]"]
  node_quote_page["Customer quote page<br/>[page.tsx]"]
end

subgraph group_workspace["Business workspace"]
  node_dashboard["Business dashboard<br/>[page.tsx]"]
  node_onboarding["Business onboarding<br/>[route.ts]"]
  node_business_api["Business settings<br/>[route.ts]"]
  node_services_api["Service management<br/>[route.ts]"]
  node_leads_api["Lead management<br/>[route.ts]"]
  node_team_api["Team management<br/>[route.ts]"]
  node_analytics_api["Analytics<br/>[route.ts]"]
  node_ai_api["AI assessment endpoint<br/>[route.ts]"]
end

subgraph group_quotes_payments["Quotes and payments"]
  node_quote_access["Quote access and checkout<br/>[route.ts]"]
  node_quotes_api["Quote management<br/>[route.ts]"]
  node_billing_api["Subscription billing<br/>[route.ts]"]
  node_connect_api["Stripe Connect<br/>[route.ts]"]
  node_webhook["Stripe webhook<br/>[route.ts]"]
  node_stripe["Stripe"]
end

subgraph group_services["Application services"]
  node_supabase_server["Authenticated data access<br/>[server.ts]"]
  node_supabase_admin["Admin data access<br/>[admin.ts]"]
  node_ai_service["Vehicle assessment<br/>[ai.ts]"]
  node_security_service["Rate limiting and security<br/>[security.ts]"]
  node_database[("Supabase database")]
  node_photo_storage[("Vehicle photo storage")]
end

node_customer(("Customer"))
node_owner(("Business owner"))
node_nvidia["NVIDIA AI API"]

node_customer -->|"opens link"| node_lead_form
node_lead_form -->|"submits request"| node_public_quote_api
node_public_quote_api -->|"rate limits"| node_security_service
node_public_quote_api -->|"uses"| node_supabase_server
node_public_quote_api -->|"reads services; saves lead"| node_database
node_public_quote_api -->|"uploads photos"| node_photo_storage
node_public_quote_api -->|"assesses photos"| node_ai_service
node_ai_service -.->|"requests assessment"| node_nvidia
node_owner -->|"manages business"| node_dashboard
node_dashboard -->|"starts setup"| node_onboarding
node_dashboard -->|"configures profile"| node_business_api
node_dashboard -->|"manages services"| node_services_api
node_dashboard -->|"reviews leads"| node_leads_api
node_dashboard -->|"manages team"| node_team_api
node_dashboard -->|"views analytics"| node_analytics_api
node_dashboard -->|"manages quotes"| node_quotes_api
node_dashboard -->|"manages subscription"| node_billing_api
node_dashboard -->|"sets up payouts"| node_connect_api
node_dashboard -->|"requests assessment"| node_ai_api
node_onboarding -->|"uses"| node_supabase_server
node_onboarding -->|"creates business and service"| node_database
node_business_api -->|"uses"| node_supabase_server
node_services_api -->|"uses"| node_supabase_server
node_leads_api -->|"uses"| node_supabase_server
node_team_api -->|"uses"| node_supabase_server
node_analytics_api -->|"uses"| node_supabase_server
node_quotes_api -->|"uses"| node_supabase_server
node_quotes_api -->|"reads lead; saves quote"| node_database
node_billing_api -->|"uses"| node_supabase_server
node_billing_api -->|"manages billing"| node_stripe
node_connect_api -->|"uses"| node_supabase_server
node_connect_api -->|"manages connected account"| node_stripe
node_ai_api -->|"authenticates user"| node_supabase_server
node_ai_api -->|"loads lead photos"| node_supabase_admin
node_ai_api -->|"rate limits"| node_security_service
node_ai_api -->|"assesses photos"| node_ai_service
node_ai_api -->|"downloads photos"| node_photo_storage
node_ai_api -->|"reads and updates lead"| node_database
node_ai_service -.->|"assessment data"| node_database
node_customer -->|"opens quote"| node_quote_page
node_quote_page -->|"accesses quote"| node_quote_access
node_quote_access -->|"uses"| node_supabase_admin
node_quote_access -->|"creates payment checkout"| node_stripe
node_stripe -->|"sends events"| node_webhook
node_webhook -->|"records payment and subscription"| node_database
node_webhook -->|"verifies event"| node_stripe

click node_lead_form "https://github.com/pwg09/detailflow/blob/master/app/%5BbusinessSlug%5D/lead/page.tsx"
click node_public_quote_api "https://github.com/pwg09/detailflow/blob/master/app/api/public/quote/route.ts"
click node_quote_page "https://github.com/pwg09/detailflow/blob/master/app/q/%5Btoken%5D/page.tsx"
click node_quote_access "https://github.com/pwg09/detailflow/blob/master/app/api/public/quote-access/%5Btoken%5D/route.ts"
click node_dashboard "https://github.com/pwg09/detailflow/blob/master/app/dashboard/page.tsx"
click node_onboarding "https://github.com/pwg09/detailflow/blob/master/app/api/onboarding/business/route.ts"
click node_business_api "https://github.com/pwg09/detailflow/blob/master/app/api/dashboard/business/route.ts"
click node_services_api "https://github.com/pwg09/detailflow/blob/master/app/api/dashboard/services/route.ts"
click node_leads_api "https://github.com/pwg09/detailflow/blob/master/app/api/dashboard/leads/route.ts"
click node_team_api "https://github.com/pwg09/detailflow/blob/master/app/api/dashboard/team/route.ts"
click node_analytics_api "https://github.com/pwg09/detailflow/blob/master/app/api/dashboard/analytics/route.ts"
click node_quotes_api "https://github.com/pwg09/detailflow/blob/master/app/api/dashboard/quotes/route.ts"
click node_billing_api "https://github.com/pwg09/detailflow/blob/master/app/api/dashboard/billing/route.ts"
click node_connect_api "https://github.com/pwg09/detailflow/blob/master/app/api/dashboard/billing/connect/route.ts"
click node_webhook "https://github.com/pwg09/detailflow/blob/master/app/api/stripe/webhook/route.ts"
click node_ai_api "https://github.com/pwg09/detailflow/blob/master/app/api/dashboard/ai/route.ts"
click node_supabase_server "https://github.com/pwg09/detailflow/blob/master/lib/supabase/server.ts"
click node_supabase_admin "https://github.com/pwg09/detailflow/blob/master/lib/supabase/admin.ts"
click node_ai_service "https://github.com/pwg09/detailflow/blob/master/lib/ai.ts"
click node_security_service "https://github.com/pwg09/detailflow/blob/master/lib/security.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_lead_form,node_public_quote_api,node_quote_page toneBlue
class node_dashboard,node_onboarding,node_business_api,node_services_api,node_leads_api,node_team_api,node_analytics_api,node_ai_api toneAmber
class node_quote_access,node_quotes_api,node_billing_api,node_connect_api,node_webhook,node_stripe,node_nvidia toneMint
class node_supabase_server,node_supabase_admin,node_ai_service,node_security_service,node_database,node_photo_storage toneRose
class node_customer,node_owner toneIndigo
```

## Components

### Customer flow

- [Business lead form](https://github.com/pwg09/detailflow/blob/master/app/%5BbusinessSlug%5D/lead/page.tsx): `app/[businessSlug]/lead/page.tsx`
- [Lead submission](https://github.com/pwg09/detailflow/blob/master/app/api/public/quote/route.ts): `app/api/public/quote/route.ts`
- [Customer quote page](https://github.com/pwg09/detailflow/blob/master/app/q/%5Btoken%5D/page.tsx): `app/q/[token]/page.tsx`

### Business workspace

- [Business dashboard](https://github.com/pwg09/detailflow/blob/master/app/dashboard/page.tsx): `app/dashboard/page.tsx`
- [Business onboarding](https://github.com/pwg09/detailflow/blob/master/app/api/onboarding/business/route.ts): `app/api/onboarding/business/route.ts`
- [Business settings](https://github.com/pwg09/detailflow/blob/master/app/api/dashboard/business/route.ts): `app/api/dashboard/business/route.ts`
- [Service management](https://github.com/pwg09/detailflow/blob/master/app/api/dashboard/services/route.ts): `app/api/dashboard/services/route.ts`
- [Lead management](https://github.com/pwg09/detailflow/blob/master/app/api/dashboard/leads/route.ts): `app/api/dashboard/leads/route.ts`
- [Team management](https://github.com/pwg09/detailflow/blob/master/app/api/dashboard/team/route.ts): `app/api/dashboard/team/route.ts`
- [Analytics](https://github.com/pwg09/detailflow/blob/master/app/api/dashboard/analytics/route.ts): `app/api/dashboard/analytics/route.ts`
- [AI assessment endpoint](https://github.com/pwg09/detailflow/blob/master/app/api/dashboard/ai/route.ts): `app/api/dashboard/ai/route.ts`

### Quotes and payments

- [Quote access and checkout](https://github.com/pwg09/detailflow/blob/master/app/api/public/quote-access/%5Btoken%5D/route.ts): `app/api/public/quote-access/[token]/route.ts`
- [Quote management](https://github.com/pwg09/detailflow/blob/master/app/api/dashboard/quotes/route.ts): `app/api/dashboard/quotes/route.ts`
- [Subscription billing](https://github.com/pwg09/detailflow/blob/master/app/api/dashboard/billing/route.ts): `app/api/dashboard/billing/route.ts`
- [Stripe Connect](https://github.com/pwg09/detailflow/blob/master/app/api/dashboard/billing/connect/route.ts): `app/api/dashboard/billing/connect/route.ts`
- [Stripe webhook](https://github.com/pwg09/detailflow/blob/master/app/api/stripe/webhook/route.ts): `app/api/stripe/webhook/route.ts`
- **Stripe**

### Application services

- [Authenticated data access](https://github.com/pwg09/detailflow/blob/master/lib/supabase/server.ts): `lib/supabase/server.ts`
- [Admin data access](https://github.com/pwg09/detailflow/blob/master/lib/supabase/admin.ts): `lib/supabase/admin.ts`
- [Vehicle assessment](https://github.com/pwg09/detailflow/blob/master/lib/ai.ts): `lib/ai.ts`
- [Rate limiting and security](https://github.com/pwg09/detailflow/blob/master/lib/security.ts): `lib/security.ts`
- **Supabase database**
- **Vehicle photo storage**

### Other components

- **Customer**
- **Business owner**
- **NVIDIA AI API**

## Connections

- Customer → Business lead form: opens link
- Business lead form → Lead submission: submits request
- Lead submission → Rate limiting and security: rate limits
- Lead submission → Authenticated data access: uses
- Lead submission → Supabase database: reads services; saves lead
- Lead submission → Vehicle photo storage: uploads photos
- Lead submission → Vehicle assessment: assesses photos
- Vehicle assessment → NVIDIA AI API: requests assessment
- Business owner → Business dashboard: manages business
- Business dashboard → Business onboarding: starts setup
- Business dashboard → Business settings: configures profile
- Business dashboard → Service management: manages services
- Business dashboard → Lead management: reviews leads
- Business dashboard → Team management: manages team
- Business dashboard → Analytics: views analytics
- Business dashboard → Quote management: manages quotes
- Business dashboard → Subscription billing: manages subscription
- Business dashboard → Stripe Connect: sets up payouts
- Business dashboard → AI assessment endpoint: requests assessment
- Business onboarding → Authenticated data access: uses
- Business onboarding → Supabase database: creates business and service
- Business settings → Authenticated data access: uses
- Service management → Authenticated data access: uses
- Lead management → Authenticated data access: uses
- Team management → Authenticated data access: uses
- Analytics → Authenticated data access: uses
- Quote management → Authenticated data access: uses
- Quote management → Supabase database: reads lead; saves quote
- Subscription billing → Authenticated data access: uses
- Subscription billing → Stripe: manages billing
- Stripe Connect → Authenticated data access: uses
- Stripe Connect → Stripe: manages connected account
- AI assessment endpoint → Authenticated data access: authenticates user
- AI assessment endpoint → Admin data access: loads lead photos
- AI assessment endpoint → Rate limiting and security: rate limits
- AI assessment endpoint → Vehicle assessment: assesses photos
- AI assessment endpoint → Vehicle photo storage: downloads photos
- AI assessment endpoint → Supabase database: reads and updates lead
- Vehicle assessment → Supabase database: assessment data
- Customer → Customer quote page: opens quote
- Customer quote page → Quote access and checkout: accesses quote
- Quote access and checkout → Admin data access: uses
- Quote access and checkout → Stripe: creates payment checkout
- Stripe → Stripe webhook: sends events
- Stripe webhook → Supabase database: records payment and subscription
- Stripe webhook → Stripe: verifies event
