# holy-auto/ledra architecture

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

- Interactive diagram: https://gitdiagram.com/holy-auto/ledra
- Repository: https://github.com/holy-auto/ledra

## Overview

Ledra is a multitenant SaaS for automotive repair, bodywork, coating, and PPF businesses, with staff mobile/watch clients and insurer, agent, manufacturer, and customer-facing workflows. A central shop workflow progresses from job completion and photo-backed certificate issuance through customer sign-off, payment, and integrity anchoring. The graph also preserves the README’s distinct parts-integrity, AI, enterprise-sync, LINE, and billing capabilities. Evidence is limited to the supplied README and sampled excerpts; several major subsystems are represented by their documented directory paths rather than inspected implementation files.

Main entry points: [`src/lib/supabase/admin.ts`](https://github.com/holy-auto/ledra/blob/main/src/lib/supabase/admin.ts) (Supabase data), [`src/app/admin`](https://github.com/holy-auto/ledra/tree/main/src/app/admin) (Certificates), [`src/lib/parts`](https://github.com/holy-auto/ledra/tree/main/src/lib/parts) (Parts integrity), [`src/lib/api/ingest.ts`](https://github.com/holy-auto/ledra/blob/main/src/lib/api/ingest.ts) (Tenant data ingest)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_shop["Shop operations"]
  node_jobs["Job workflow"]
  node_certificates["Certificates"]
  node_signoff["Customer sign-off<br/>[state.ts]"]
  node_documents["Invoices and forms<br/>[route.ts]"]
end

subgraph group_integrity["Evidence and integrity"]
  node_parts["Parts integrity"]
  node_ai["AI automation"]
  node_anchoring["Blockchain anchoring<br/>[polygon.ts]"]
  node_edgeevents["Device event intake<br/>[eventIngestion.ts]"]
end

subgraph group_platform["Platform services"]
  node_enterprise["Tenant data ingest<br/>[ingest.ts]"]
  node_line["LINE self-service"]
  node_billing["Subscriptions<br/>[route.ts]"]
  node_store[("Supabase data<br/>[admin.ts]")]
end

subgraph group_clients["Staff clients"]
  node_mobile["Mobile app"]
  node_watch["Apple Watch app"]
end

node_staff(("Shop staff"))
node_insurer(("Insurer users"))
node_customer(("Customers"))
node_core(("Shop operators"))

node_staff -->|"manage jobs"| node_jobs
node_jobs -->|"issue certificates"| node_certificates
node_certificates -->|"request sign-off"| node_signoff
node_signoff -->|"determine payment"| node_documents
node_certificates -->|"anchor records"| node_anchoring
node_parts -->|"inspect evidence"| node_ai
node_parts -->|"anchor confirmation"| node_anchoring
node_customer -->|"confirm by LINE"| node_parts
node_edgeevents -->|"anchor hash"| node_anchoring
node_edgeevents -->|"store events"| node_store
node_enterprise -->|"upsert tenant data"| node_store
node_enterprise -->|"emit webhook events"| node_store
node_insurer -.->|"request shop matching"| node_ai
node_line -->|"support reservation changes"| node_customer
node_billing -->|"sync subscription state"| node_store
node_staff -->|"use in field"| node_mobile
node_staff -->|"check work"| node_watch
node_core -->|"push business records"| node_enterprise

click node_jobs "https://github.com/holy-auto/ledra/tree/main/src/app/admin"
click node_certificates "https://github.com/holy-auto/ledra/tree/main/src/app/admin"
click node_signoff "https://github.com/holy-auto/ledra/blob/main/src/lib/signoff/state.ts"
click node_documents "https://github.com/holy-auto/ledra/blob/main/src/app/api/admin/documents/route.ts"
click node_parts "https://github.com/holy-auto/ledra/tree/main/src/lib/parts"
click node_ai "https://github.com/holy-auto/ledra/tree/main/src/lib/ai/automation"
click node_anchoring "https://github.com/holy-auto/ledra/blob/main/src/lib/anchoring/providers/polygon.ts"
click node_edgeevents "https://github.com/holy-auto/ledra/blob/main/src/lib/edge/eventIngestion.ts"
click node_enterprise "https://github.com/holy-auto/ledra/blob/main/src/lib/api/ingest.ts"
click node_line "https://github.com/holy-auto/ledra/tree/main/src/lib/line/flow"
click node_billing "https://github.com/holy-auto/ledra/blob/main/src/app/api/stripe/webhook/route.ts"
click node_store "https://github.com/holy-auto/ledra/blob/main/src/lib/supabase/admin.ts"
click node_mobile "https://github.com/holy-auto/ledra/tree/main/apps/mobile/src/app"
click node_watch "https://github.com/holy-auto/ledra/tree/main/apps/watch/LedraWatchApp"

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_jobs,node_certificates,node_signoff,node_documents,node_insurer toneBlue
class node_parts,node_ai,node_anchoring,node_edgeevents toneAmber
class node_enterprise,node_line,node_billing,node_store toneMint
class node_mobile,node_watch toneRose
class node_staff,node_customer,node_core toneIndigo
```

## Components

### Shop operations

- [Job workflow](https://github.com/holy-auto/ledra/tree/main/src/app/admin): `src/app/admin`
- [Certificates](https://github.com/holy-auto/ledra/tree/main/src/app/admin): `src/app/admin`
- [Customer sign-off](https://github.com/holy-auto/ledra/blob/main/src/lib/signoff/state.ts): `src/lib/signoff/state.ts`
- [Invoices and forms](https://github.com/holy-auto/ledra/blob/main/src/app/api/admin/documents/route.ts): `src/app/api/admin/documents/route.ts`

### Evidence and integrity

- [Parts integrity](https://github.com/holy-auto/ledra/tree/main/src/lib/parts): `src/lib/parts`
- [AI automation](https://github.com/holy-auto/ledra/tree/main/src/lib/ai/automation): `src/lib/ai/automation`
- [Blockchain anchoring](https://github.com/holy-auto/ledra/blob/main/src/lib/anchoring/providers/polygon.ts): `src/lib/anchoring/providers/polygon.ts`
- [Device event intake](https://github.com/holy-auto/ledra/blob/main/src/lib/edge/eventIngestion.ts): `src/lib/edge/eventIngestion.ts`

### Platform services

- [Tenant data ingest](https://github.com/holy-auto/ledra/blob/main/src/lib/api/ingest.ts): `src/lib/api/ingest.ts`
- [LINE self-service](https://github.com/holy-auto/ledra/tree/main/src/lib/line/flow): `src/lib/line/flow`
- [Subscriptions](https://github.com/holy-auto/ledra/blob/main/src/app/api/stripe/webhook/route.ts): `src/app/api/stripe/webhook/route.ts`
- [Supabase data](https://github.com/holy-auto/ledra/blob/main/src/lib/supabase/admin.ts): `src/lib/supabase/admin.ts`

### Staff clients

- [Mobile app](https://github.com/holy-auto/ledra/tree/main/apps/mobile/src/app): `apps/mobile/src/app`
- [Apple Watch app](https://github.com/holy-auto/ledra/tree/main/apps/watch/LedraWatchApp): `apps/watch/LedraWatchApp`

### Other components

- **Shop staff**
- **Insurer users**
- **Customers**
- **Shop operators**

## Connections

- Shop staff → Job workflow: manage jobs
- Job workflow → Certificates: issue certificates
- Certificates → Customer sign-off: request sign-off
- Customer sign-off → Invoices and forms: determine payment
- Certificates → Blockchain anchoring: anchor records
- Parts integrity → AI automation: inspect evidence
- Parts integrity → Blockchain anchoring: anchor confirmation
- Customers → Parts integrity: confirm by LINE
- Device event intake → Blockchain anchoring: anchor hash (evidence: `src/lib/edge/eventIngestion.ts`)
- Device event intake → Supabase data: store events (evidence: `src/lib/edge/eventIngestion.ts`)
- Tenant data ingest → Supabase data: upsert tenant data (evidence: `src/lib/api/ingest.ts`)
- Tenant data ingest → Supabase data: emit webhook events (evidence: `src/lib/api/ingest.ts`)
- Insurer users → AI automation: request shop matching
- LINE self-service → Customers: support reservation changes
- Subscriptions → Supabase data: sync subscription state (evidence: `src/app/api/stripe/webhook/route.ts`)
- Shop staff → Mobile app: use in field
- Shop staff → Apple Watch app: check work
- Shop operators → Tenant data ingest: push business records
