# sam-make/trade-in-pro architecture

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

- Interactive diagram: https://gitdiagram.com/sam-make/trade-in-pro
- Repository: https://github.com/sam-make/trade-in-pro

## Overview

Trade-In Pro is a multi-shop SaaS for phone trade-ins and repair-shop operations. The main workflow is a seller diagnosing a device, applying shop-configured pricing rules, and retaining the resulting estimate; the repository also exposes repair, customer, invoice, administration, and tracking capabilities. The graph combines excerpted calls and SOURCE INDEX references with README-described capabilities. Several routes and subsystems were not sampled, so their internal wiring is intentionally omitted or marked unverified.

Main entry points: [`src/lib/repairs.functions.ts`](https://github.com/sam-make/trade-in-pro/blob/main/src/lib/repairs.functions.ts) (Repair operations), [`src/hooks/useWorkspace.ts`](https://github.com/sam-make/trade-in-pro/blob/main/src/hooks/useWorkspace.ts) (Workspace context), [`src/routes/index.tsx`](https://github.com/sam-make/trade-in-pro/blob/main/src/routes/index.tsx) (Landing page), [`src/components/app/AppShell.tsx`](https://github.com/sam-make/trade-in-pro/blob/main/src/components/app/AppShell.tsx) (App shell)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry and identity"]
  node_landing["Landing page<br/>[index.tsx]"]
  node_auth["Auth state<br/>[useAuth.tsx]"]
  node_authpages["Sign-in and signup<br/>[connexion.tsx]"]
  node_guard["Authenticated routes<br/>[route.tsx]"]
  node_shell["App shell<br/>[AppShell.tsx]"]
end

subgraph group_tradein["Trade-in workflow"]
  node_estimate["Device estimation<br/>[estimation.tsx]"]
  node_pricing["Pricing rules<br/>[pricing.ts]"]
  node_estimatepanel["Market analysis"]
  node_history["Estimate history<br/>[historique.tsx]"]
  node_dashboard["Shop dashboard"]
end

subgraph group_repairs["Repairs and customers"]
  node_repairflow["Repair intake"]
  node_repairdetail["Repair records"]
  node_repairapi["Repair operations"]
  node_repairserver["Repair persistence<br/>[repairs.server.ts]"]
  node_repairdomain["Repair domain<br/>[repairs.ts]"]
  node_clients["Client records<br/>[clients.index.tsx]"]
  node_clientdetail["Client details<br/>[clients.$id.tsx]"]
  node_tracking["Public repair tracking<br/>[suivi.$token.tsx]"]
end

subgraph group_admin["Shop administration"]
  node_administration["Shop settings<br/>[administration.tsx]"]
  node_owneradmin["Platform admin<br/>[admin.tsx]"]
  node_workspace["Workspace context<br/>[useWorkspace.ts]"]
  node_workspacefn["Workspace services"]
  node_analytics["Owner analytics"]
end

subgraph group_platform["Data and services"]
  node_supabase["Supabase client<br/>[client.ts]"]
  node_supabaseadmin["Admin client<br/>[client.server.ts]"]
end

node_visitor(("Shop user"))

node_visitor -->|"opens"| node_landing
node_landing -->|"links to"| node_authpages
node_landing -->|"links to"| node_dashboard
node_auth -->|"reads session"| node_supabase
node_guard -->|"checks user"| node_supabase
node_guard -->|"renders"| node_shell
node_shell -->|"loads context"| node_workspace
node_workspace -->|"invokes"| node_workspacefn
node_workspace -->|"uses identity"| node_auth
node_estimate -.->|"uses pricing"| node_pricing
node_estimate -.->|"archives estimate"| node_history
node_estimatepanel -->|"uses pricing"| node_pricing
node_administration -->|"configures rules"| node_pricing
node_dashboard -->|"loads metrics"| node_analytics
node_repairflow -.->|"submits repair"| node_repairapi
node_repairapi -->|"delegates to"| node_repairserver
node_repairapi -->|"uses domain"| node_repairdomain
node_repairserver -->|"uses domain"| node_repairdomain
node_repairserver -.->|"supports status"| node_tracking
node_clients -->|"links to"| node_clientdetail
node_clientdetail -->|"formats records"| node_repairdomain
node_clientdetail -->|"saves customer"| node_repairapi
node_administration -->|"uses context"| node_workspace
node_owneradmin -->|"uses admin access"| node_supabaseadmin
node_shell -->|"loads admin data"| node_owneradmin
node_supabase -.->|"authenticates"| node_visitor

click node_landing "https://github.com/sam-make/trade-in-pro/blob/main/src/routes/index.tsx"
click node_auth "https://github.com/sam-make/trade-in-pro/blob/main/src/hooks/useAuth.tsx"
click node_authpages "https://github.com/sam-make/trade-in-pro/blob/main/src/routes/connexion.tsx"
click node_guard "https://github.com/sam-make/trade-in-pro/blob/main/src/routes/_authenticated/route.tsx"
click node_shell "https://github.com/sam-make/trade-in-pro/blob/main/src/components/app/AppShell.tsx"
click node_estimate "https://github.com/sam-make/trade-in-pro/blob/main/src/routes/_authenticated/estimation.tsx"
click node_pricing "https://github.com/sam-make/trade-in-pro/blob/main/src/lib/pricing.ts"
click node_estimatepanel "https://github.com/sam-make/trade-in-pro/blob/main/src/components/estimation/MarketAnalysisPanel.tsx"
click node_history "https://github.com/sam-make/trade-in-pro/blob/main/src/routes/_authenticated/historique.tsx"
click node_dashboard "https://github.com/sam-make/trade-in-pro/blob/main/src/routes/_authenticated/tableau-de-bord.tsx"
click node_repairflow "https://github.com/sam-make/trade-in-pro/blob/main/src/routes/_authenticated/reparations.nouvelle.tsx"
click node_repairdetail "https://github.com/sam-make/trade-in-pro/blob/main/src/routes/_authenticated/reparations.%24id.tsx"
click node_repairapi "https://github.com/sam-make/trade-in-pro/blob/main/src/lib/repairs.functions.ts"
click node_repairserver "https://github.com/sam-make/trade-in-pro/blob/main/src/lib/repairs.server.ts"
click node_repairdomain "https://github.com/sam-make/trade-in-pro/blob/main/src/lib/repairs.ts"
click node_clients "https://github.com/sam-make/trade-in-pro/blob/main/src/routes/_authenticated/clients.index.tsx"
click node_clientdetail "https://github.com/sam-make/trade-in-pro/blob/main/src/routes/_authenticated/clients.%24id.tsx"
click node_tracking "https://github.com/sam-make/trade-in-pro/blob/main/src/routes/suivi.%24token.tsx"
click node_administration "https://github.com/sam-make/trade-in-pro/blob/main/src/routes/_authenticated/administration.tsx"
click node_owneradmin "https://github.com/sam-make/trade-in-pro/blob/main/src/routes/_authenticated/admin.tsx"
click node_workspace "https://github.com/sam-make/trade-in-pro/blob/main/src/hooks/useWorkspace.ts"
click node_workspacefn "https://github.com/sam-make/trade-in-pro/blob/main/src/lib/workspace.functions.ts"
click node_supabase "https://github.com/sam-make/trade-in-pro/blob/main/src/integrations/supabase/client.ts"
click node_supabaseadmin "https://github.com/sam-make/trade-in-pro/blob/main/src/integrations/supabase/client.server.ts"
click node_analytics "https://github.com/sam-make/trade-in-pro/blob/main/src/lib/owner-analytics.functions.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_landing,node_auth,node_authpages,node_guard,node_shell,node_visitor toneBlue
class node_estimate,node_pricing,node_estimatepanel,node_history,node_dashboard toneAmber
class node_repairflow,node_repairdetail,node_repairapi,node_repairserver,node_repairdomain,node_clients,node_clientdetail,node_tracking toneMint
class node_administration,node_owneradmin,node_workspace,node_workspacefn,node_analytics toneRose
class node_supabase,node_supabaseadmin toneIndigo
```

## Components

### Entry and identity

- [Landing page](https://github.com/sam-make/trade-in-pro/blob/main/src/routes/index.tsx): `src/routes/index.tsx`
- [Auth state](https://github.com/sam-make/trade-in-pro/blob/main/src/hooks/useAuth.tsx): `src/hooks/useAuth.tsx`
- [Sign-in and signup](https://github.com/sam-make/trade-in-pro/blob/main/src/routes/connexion.tsx): `src/routes/connexion.tsx`
- [Authenticated routes](https://github.com/sam-make/trade-in-pro/blob/main/src/routes/_authenticated/route.tsx): `src/routes/_authenticated/route.tsx`
- [App shell](https://github.com/sam-make/trade-in-pro/blob/main/src/components/app/AppShell.tsx): `src/components/app/AppShell.tsx`

### Trade-in workflow

- [Device estimation](https://github.com/sam-make/trade-in-pro/blob/main/src/routes/_authenticated/estimation.tsx): `src/routes/_authenticated/estimation.tsx`
- [Pricing rules](https://github.com/sam-make/trade-in-pro/blob/main/src/lib/pricing.ts): `src/lib/pricing.ts`
- [Market analysis](https://github.com/sam-make/trade-in-pro/blob/main/src/components/estimation/MarketAnalysisPanel.tsx): `src/components/estimation/MarketAnalysisPanel.tsx`
- [Estimate history](https://github.com/sam-make/trade-in-pro/blob/main/src/routes/_authenticated/historique.tsx): `src/routes/_authenticated/historique.tsx`
- [Shop dashboard](https://github.com/sam-make/trade-in-pro/blob/main/src/routes/_authenticated/tableau-de-bord.tsx): `src/routes/_authenticated/tableau-de-bord.tsx`

### Repairs and customers

- [Repair intake](https://github.com/sam-make/trade-in-pro/blob/main/src/routes/_authenticated/reparations.nouvelle.tsx): `src/routes/_authenticated/reparations.nouvelle.tsx`
- [Repair records](https://github.com/sam-make/trade-in-pro/blob/main/src/routes/_authenticated/reparations.%24id.tsx): `src/routes/_authenticated/reparations.$id.tsx`
- [Repair operations](https://github.com/sam-make/trade-in-pro/blob/main/src/lib/repairs.functions.ts): `src/lib/repairs.functions.ts`
- [Repair persistence](https://github.com/sam-make/trade-in-pro/blob/main/src/lib/repairs.server.ts): `src/lib/repairs.server.ts`
- [Repair domain](https://github.com/sam-make/trade-in-pro/blob/main/src/lib/repairs.ts): `src/lib/repairs.ts`
- [Client records](https://github.com/sam-make/trade-in-pro/blob/main/src/routes/_authenticated/clients.index.tsx): `src/routes/_authenticated/clients.index.tsx`
- [Client details](https://github.com/sam-make/trade-in-pro/blob/main/src/routes/_authenticated/clients.%24id.tsx): `src/routes/_authenticated/clients.$id.tsx`
- [Public repair tracking](https://github.com/sam-make/trade-in-pro/blob/main/src/routes/suivi.%24token.tsx): `src/routes/suivi.$token.tsx`

### Shop administration

- [Shop settings](https://github.com/sam-make/trade-in-pro/blob/main/src/routes/_authenticated/administration.tsx): `src/routes/_authenticated/administration.tsx`
- [Platform admin](https://github.com/sam-make/trade-in-pro/blob/main/src/routes/_authenticated/admin.tsx): `src/routes/_authenticated/admin.tsx`
- [Workspace context](https://github.com/sam-make/trade-in-pro/blob/main/src/hooks/useWorkspace.ts): `src/hooks/useWorkspace.ts`
- [Workspace services](https://github.com/sam-make/trade-in-pro/blob/main/src/lib/workspace.functions.ts): `src/lib/workspace.functions.ts`
- [Owner analytics](https://github.com/sam-make/trade-in-pro/blob/main/src/lib/owner-analytics.functions.ts): `src/lib/owner-analytics.functions.ts`

### Data and services

- [Supabase client](https://github.com/sam-make/trade-in-pro/blob/main/src/integrations/supabase/client.ts): `src/integrations/supabase/client.ts`
- [Admin client](https://github.com/sam-make/trade-in-pro/blob/main/src/integrations/supabase/client.server.ts): `src/integrations/supabase/client.server.ts`

### Other components

- **Shop user**

## Connections

- Shop user → Landing page: opens (evidence: `src/routes/index.tsx`)
- Landing page → Sign-in and signup: links to (evidence: `src/routes/index.tsx`)
- Landing page → Shop dashboard: links to (evidence: `src/routes/index.tsx`)
- Auth state → Supabase client: reads session (evidence: `src/hooks/useAuth.tsx`)
- Authenticated routes → Supabase client: checks user (evidence: `src/routes/_authenticated/route.tsx`)
- Authenticated routes → App shell: renders (evidence: `src/routes/_authenticated/route.tsx`)
- App shell → Workspace context: loads context (evidence: `src/components/app/AppShell.tsx`)
- Workspace context → Workspace services: invokes (evidence: `src/hooks/useWorkspace.ts`)
- Workspace context → Auth state: uses identity (evidence: `src/hooks/useWorkspace.ts`)
- Device estimation → Pricing rules: uses pricing
- Device estimation → Estimate history: archives estimate
- Market analysis → Pricing rules: uses pricing (evidence: `src/components/estimation/MarketAnalysisPanel.tsx`)
- Shop settings → Pricing rules: configures rules (evidence: `src/routes/_authenticated/administration.tsx`)
- Shop dashboard → Owner analytics: loads metrics
- Repair intake → Repair operations: submits repair
- Repair operations → Repair persistence: delegates to (evidence: `src/lib/repairs.functions.ts`)
- Repair operations → Repair domain: uses domain (evidence: `src/lib/repairs.functions.ts`)
- Repair persistence → Repair domain: uses domain (evidence: `src/lib/repairs.server.ts`)
- Repair persistence → Public repair tracking: supports status
- Client records → Client details: links to (evidence: `src/routes/_authenticated/clients.$id.tsx`)
- Client details → Repair domain: formats records (evidence: `src/routes/_authenticated/clients.$id.tsx`)
- Client details → Repair operations: saves customer
- Shop settings → Workspace context: uses context (evidence: `src/routes/_authenticated/administration.tsx`)
- Platform admin → Admin client: uses admin access
- App shell → Platform admin: loads admin data (evidence: `src/components/app/AppShell.tsx`)
- Supabase client → Shop user: authenticates
