# enochblake/autocare architecture

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

- Interactive diagram: https://gitdiagram.com/enochblake/autocare
- Repository: https://github.com/enochblake/autocare

## Overview

AutoCare is a multi-tenant service-management product connecting vehicle owners with garages. Customers register, maintain vehicles, request visits, and follow approved repairs through quotes, work, and invoices; garage staff manage bookings, scheduling, jobs, inventory, and billing according to role. History, photos, reminders, and payment integrations extend that core workflow. The map uses README capabilities plus indexed source references; unsampled route internals are represented at their exact route paths, and uncertain runtime links are omitted.

Main entry points: [`src/app/api/dashboard/route.ts`](https://github.com/enochblake/autocare/blob/main/src/app/api/dashboard/route.ts) (Workspace dashboard), [`src/server/auth/context.ts`](https://github.com/enochblake/autocare/blob/main/src/server/auth/context.ts) (Identity and roles), [`src/app/api/staff/route.ts`](https://github.com/enochblake/autocare/blob/main/src/app/api/staff/route.ts) (Staff and invitations), [`src/server/garage/scope.ts`](https://github.com/enochblake/autocare/blob/main/src/server/garage/scope.ts) (Garage access scope)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Access and tenancy"]
  node_dashboard["Workspace dashboard<br/>[route.ts]"]
  node_auth["Identity and roles<br/>[context.ts]"]
  node_garage_scope["Garage access scope<br/>[scope.ts]"]
  node_supabase_auth["Supabase Auth"]
end

subgraph group_service["Service operations"]
  node_booking_api["Visit requests<br/>[route.ts]"]
  node_booking_service["Booking creation<br/>[service.ts]"]
  node_schedule_api["Workshop calendar<br/>[route.ts]"]
  node_jobs_api["Repair jobs<br/>[route.ts]"]
  node_workshop["Workshop workflows<br/>[workshop.ts]"]
  node_inventory["Parts inventory<br/>[route.ts]"]
  node_staff_admin["Staff and invitations<br/>[route.ts]"]
end

subgraph group_records["Customer records"]
  node_vehicle_api["Vehicles<br/>[route.ts]"]
  node_history_api["Service history<br/>[route.ts]"]
  node_history_service["History access<br/>[history.ts]"]
  node_photos["Repair photos<br/>[route.ts]"]
  node_garage_settings["Garage settings<br/>[route.ts]"]
end

subgraph group_money["Billing and payments"]
  node_invoices["Invoices<br/>[route.ts]"]
  node_payment_api["Invoice payments<br/>[route.ts]"]
  node_paystack["Paystack integration<br/>[paystack.ts]"]
  node_mpesa["M-Pesa payments<br/>[mpesa.ts]"]
  node_billing["Garage subscriptions<br/>[route.ts]"]
end

node_customer(("Customer"))
node_staff(("Garage staff"))
node_database[("Supabase database")]
node_payment_provider["Paystack service"]
node_mpesa_provider["M-Pesa Daraja"]

node_customer -.->|"opens workspace"| node_dashboard
node_staff -.->|"opens workspace"| node_dashboard
node_dashboard -->|"loads workspace"| node_auth
node_dashboard -->|"reads metrics"| node_database
node_auth -->|"checks user"| node_supabase_auth
node_auth -->|"reads profile"| node_database
node_garage_scope -->|"authenticates user"| node_auth
node_garage_scope -->|"reads memberships"| node_database
node_customer -.->|"requests visit"| node_booking_api
node_booking_api -->|"creates booking"| node_booking_service
node_booking_service -->|"creates booking"| node_database
node_staff -.->|"schedules visit"| node_schedule_api
node_schedule_api -->|"saves slot"| node_workshop
node_workshop -->|"calls workflow RPC"| node_database
node_staff -.->|"manages repairs"| node_jobs_api
node_jobs_api -.->|"reads and updates jobs"| node_database
node_staff -.->|"manages stock"| node_inventory
node_inventory -->|"reads and writes stock"| node_database
node_staff -->|"manages access"| node_staff_admin
node_staff_admin -->|"checks staff scope"| node_garage_scope
node_staff_admin -->|"manages memberships"| node_database
node_customer -.->|"manages vehicles"| node_vehicle_api
node_vehicle_api -.->|"reads and writes vehicles"| node_database
node_customer -->|"views service history"| node_history_api
node_history_api -->|"loads vehicle history"| node_history_service
node_history_service -->|"reads history"| node_database
node_customer -->|"updates mileage and reminders"| node_history_api
node_staff -.->|"shares repair photos"| node_photos
node_customer -.->|"shares repair photos"| node_photos
node_photos -->|"checks booking access"| node_database
node_staff -.->|"customizes garage"| node_garage_settings
node_garage_settings -->|"reads and writes settings"| node_database
node_customer -.->|"views invoices"| node_invoices
node_staff -.->|"issues invoices"| node_invoices
node_invoices -->|"reads invoices"| node_database
node_customer -.->|"pays invoice"| node_payment_api
node_payment_api -->|"starts checkout"| node_paystack
node_paystack -.->|"creates transaction"| node_payment_provider
node_customer -.->|"pays by M-Pesa"| node_mpesa
node_mpesa -.->|"initiates payment"| node_mpesa_provider
node_staff -->|"starts subscription"| node_billing
node_billing -->|"starts subscription checkout"| node_paystack

click node_dashboard "https://github.com/enochblake/autocare/blob/main/src/app/api/dashboard/route.ts"
click node_auth "https://github.com/enochblake/autocare/blob/main/src/server/auth/context.ts"
click node_garage_scope "https://github.com/enochblake/autocare/blob/main/src/server/garage/scope.ts"
click node_booking_api "https://github.com/enochblake/autocare/blob/main/src/app/api/bookings/route.ts"
click node_booking_service "https://github.com/enochblake/autocare/blob/main/src/server/bookings/service.ts"
click node_schedule_api "https://github.com/enochblake/autocare/blob/main/src/app/api/schedule/route.ts"
click node_jobs_api "https://github.com/enochblake/autocare/blob/main/src/app/api/jobs/route.ts"
click node_workshop "https://github.com/enochblake/autocare/blob/main/src/server/workshop.ts"
click node_inventory "https://github.com/enochblake/autocare/blob/main/src/app/api/inventory/route.ts"
click node_staff_admin "https://github.com/enochblake/autocare/blob/main/src/app/api/staff/route.ts"
click node_vehicle_api "https://github.com/enochblake/autocare/blob/main/src/app/api/vehicles/route.ts"
click node_history_api "https://github.com/enochblake/autocare/blob/main/src/app/api/history/route.ts"
click node_history_service "https://github.com/enochblake/autocare/blob/main/src/server/history.ts"
click node_photos "https://github.com/enochblake/autocare/blob/main/src/app/api/repair-photos/route.ts"
click node_garage_settings "https://github.com/enochblake/autocare/blob/main/src/app/api/garage-settings/route.ts"
click node_invoices "https://github.com/enochblake/autocare/blob/main/src/app/api/invoices/route.ts"
click node_payment_api "https://github.com/enochblake/autocare/blob/main/src/app/api/payments/paystack/route.ts"
click node_paystack "https://github.com/enochblake/autocare/blob/main/src/server/payments/paystack.ts"
click node_mpesa "https://github.com/enochblake/autocare/blob/main/src/server/payments/mpesa.ts"
click node_billing "https://github.com/enochblake/autocare/blob/main/src/app/api/billing/subscribe/route.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_dashboard,node_auth,node_garage_scope,node_supabase_auth toneBlue
class node_booking_api,node_booking_service,node_schedule_api,node_jobs_api,node_workshop,node_inventory,node_staff_admin,node_database toneAmber
class node_vehicle_api,node_history_api,node_history_service,node_photos,node_garage_settings toneMint
class node_invoices,node_payment_api,node_paystack,node_mpesa,node_billing toneRose
class node_customer,node_staff,node_payment_provider,node_mpesa_provider toneIndigo
```

## Components

### Access and tenancy

- [Workspace dashboard](https://github.com/enochblake/autocare/blob/main/src/app/api/dashboard/route.ts): `src/app/api/dashboard/route.ts`
- [Identity and roles](https://github.com/enochblake/autocare/blob/main/src/server/auth/context.ts): `src/server/auth/context.ts`
- [Garage access scope](https://github.com/enochblake/autocare/blob/main/src/server/garage/scope.ts): `src/server/garage/scope.ts`
- **Supabase Auth**

### Service operations

- [Visit requests](https://github.com/enochblake/autocare/blob/main/src/app/api/bookings/route.ts): `src/app/api/bookings/route.ts`
- [Booking creation](https://github.com/enochblake/autocare/blob/main/src/server/bookings/service.ts): `src/server/bookings/service.ts`
- [Workshop calendar](https://github.com/enochblake/autocare/blob/main/src/app/api/schedule/route.ts): `src/app/api/schedule/route.ts`
- [Repair jobs](https://github.com/enochblake/autocare/blob/main/src/app/api/jobs/route.ts): `src/app/api/jobs/route.ts`
- [Workshop workflows](https://github.com/enochblake/autocare/blob/main/src/server/workshop.ts): `src/server/workshop.ts`
- [Parts inventory](https://github.com/enochblake/autocare/blob/main/src/app/api/inventory/route.ts): `src/app/api/inventory/route.ts`
- [Staff and invitations](https://github.com/enochblake/autocare/blob/main/src/app/api/staff/route.ts): `src/app/api/staff/route.ts`

### Customer records

- [Vehicles](https://github.com/enochblake/autocare/blob/main/src/app/api/vehicles/route.ts): `src/app/api/vehicles/route.ts`
- [Service history](https://github.com/enochblake/autocare/blob/main/src/app/api/history/route.ts): `src/app/api/history/route.ts`
- [History access](https://github.com/enochblake/autocare/blob/main/src/server/history.ts): `src/server/history.ts`
- [Repair photos](https://github.com/enochblake/autocare/blob/main/src/app/api/repair-photos/route.ts): `src/app/api/repair-photos/route.ts`
- [Garage settings](https://github.com/enochblake/autocare/blob/main/src/app/api/garage-settings/route.ts): `src/app/api/garage-settings/route.ts`

### Billing and payments

- [Invoices](https://github.com/enochblake/autocare/blob/main/src/app/api/invoices/route.ts): `src/app/api/invoices/route.ts`
- [Invoice payments](https://github.com/enochblake/autocare/blob/main/src/app/api/payments/paystack/route.ts): `src/app/api/payments/paystack/route.ts`
- [Paystack integration](https://github.com/enochblake/autocare/blob/main/src/server/payments/paystack.ts): `src/server/payments/paystack.ts`
- [M-Pesa payments](https://github.com/enochblake/autocare/blob/main/src/server/payments/mpesa.ts): `src/server/payments/mpesa.ts`
- [Garage subscriptions](https://github.com/enochblake/autocare/blob/main/src/app/api/billing/subscribe/route.ts): `src/app/api/billing/subscribe/route.ts`

### Other components

- **Customer**
- **Garage staff**
- **Supabase database**
- **Paystack service**
- **M-Pesa Daraja**

## Connections

- Customer → Workspace dashboard: opens workspace
- Garage staff → Workspace dashboard: opens workspace
- Workspace dashboard → Identity and roles: loads workspace (evidence: `src/app/api/dashboard/route.ts`)
- Workspace dashboard → Supabase database: reads metrics (evidence: `src/app/api/dashboard/route.ts`)
- Identity and roles → Supabase Auth: checks user (evidence: `src/server/auth/context.ts`)
- Identity and roles → Supabase database: reads profile (evidence: `src/server/auth/context.ts`)
- Garage access scope → Identity and roles: authenticates user (evidence: `src/server/garage/scope.ts`)
- Garage access scope → Supabase database: reads memberships (evidence: `src/server/garage/scope.ts`)
- Customer → Visit requests: requests visit
- Visit requests → Booking creation: creates booking (evidence: `src/app/api/bookings/route.ts`)
- Booking creation → Supabase database: creates booking (evidence: `src/server/bookings/service.ts`)
- Garage staff → Workshop calendar: schedules visit
- Workshop calendar → Workshop workflows: saves slot (evidence: `src/app/api/schedule/route.ts`)
- Workshop workflows → Supabase database: calls workflow RPC
- Garage staff → Repair jobs: manages repairs
- Repair jobs → Supabase database: reads and updates jobs
- Garage staff → Parts inventory: manages stock
- Parts inventory → Supabase database: reads and writes stock (evidence: `src/app/api/inventory/route.ts`)
- Garage staff → Staff and invitations: manages access (evidence: `src/app/api/staff/route.ts`)
- Staff and invitations → Garage access scope: checks staff scope (evidence: `src/app/api/staff/route.ts`)
- Staff and invitations → Supabase database: manages memberships (evidence: `src/app/api/staff/route.ts`)
- Customer → Vehicles: manages vehicles
- Vehicles → Supabase database: reads and writes vehicles
- Customer → Service history: views service history
- Service history → History access: loads vehicle history (evidence: `src/app/api/history/route.ts`)
- History access → Supabase database: reads history (evidence: `src/server/history.ts`)
- Customer → Service history: updates mileage and reminders (evidence: `src/app/api/history/route.ts`)
- Garage staff → Repair photos: shares repair photos
- Customer → Repair photos: shares repair photos
- Repair photos → Supabase database: checks booking access (evidence: `src/app/api/repair-photos/route.ts`)
- Garage staff → Garage settings: customizes garage
- Garage settings → Supabase database: reads and writes settings (evidence: `src/app/api/garage-settings/route.ts`)
- Customer → Invoices: views invoices
- Garage staff → Invoices: issues invoices
- Invoices → Supabase database: reads invoices (evidence: `src/app/api/invoices/route.ts`)
- Customer → Invoice payments: pays invoice
- Invoice payments → Paystack integration: starts checkout (evidence: `src/app/api/payments/paystack/route.ts`)
- Paystack integration → Paystack service: creates transaction
- Customer → M-Pesa payments: pays by M-Pesa
- M-Pesa payments → M-Pesa Daraja: initiates payment
- Garage staff → Garage subscriptions: starts subscription
- Garage subscriptions → Paystack integration: starts subscription checkout (evidence: `src/app/api/billing/subscribe/route.ts`)
