# romstab/multi-tenant-ai-booking-pwa architecture

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

- Interactive diagram: https://gitdiagram.com/romstab/multi-tenant-ai-booking-pwa
- Repository: https://github.com/romstab/multi-tenant-ai-booking-pwa

## Overview

BookAI is a multi-tenant appointment-booking SaaS delivered as a browser PWA with Vercel API handlers and Firebase-backed tenant data. Customers choose a business, service, date and slot, then submit a booking; staff and owners manage schedules and bookings through authenticated tools. The README also describes AI, waitlists/CRM, reminders, no-show processing, SMS, themes, trials and super-admin functions. Some of these implementations were not sampled, so their internal links are omitted; documented capability links are identified as such.

Main entry points: [`api/create-booking.js`](https://github.com/romstab/multi-tenant-ai-booking-pwa/blob/main/api/create-booking.js) (Booking API), [`api/business.js`](https://github.com/romstab/multi-tenant-ai-booking-pwa/blob/main/api/business.js) (Business API), [`booking.html`](https://github.com/romstab/multi-tenant-ai-booking-pwa/blob/main/booking.html) (Public booking), [`services/emailService.js`](https://github.com/romstab/multi-tenant-ai-booking-pwa/blob/main/services/emailService.js) (Email transport)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_booking["Booking"]
  node_public_booking["Public booking<br/>[booking.html]"]
  node_booking_api["Booking API<br/>[create-booking.js]"]
  node_slot_engine["Slot helpers<br/>[app.js]"]
  node_appointment_store[("Appointments")]
  node_manage_booking["Manage booking"]
end

subgraph group_operations["Business operations"]
  node_dashboard["Owner dashboard<br/>[dashboard.html]"]
  node_staff_home["Staff workspace<br/>[staff-home.html]"]
  node_business_api["Business API<br/>[business.js]"]
  node_business_logic["Business helpers<br/>[business.js]"]
  node_gemini_api["AI integration<br/>[gemini.js]"]
  node_waitlist_crm["Waitlist and CRM<br/>[business.js]"]
end

subgraph group_identity["Identity and platform"]
  node_auth["Membership and permissions<br/>[authz.js]"]
  node_client_auth["Client auth helpers<br/>[authz.js]"]
  node_super_admin["Super-admin API<br/>[admin.js]"]
  node_admin_login["Super-admin auth<br/>[admin-auth.js]"]
  node_tenant_store[("Tenant data")]
end

subgraph group_messaging["Notifications"]
  node_confirmation["Confirmation email"]
  node_reminder_job["Reminder processor<br/>[cron-reminders.js]"]
  node_noshow_job["No-show processor<br/>[cron-noshow.js]"]
  node_email_service["Email transport<br/>[emailService.js]"]
  node_sms_api["SMS API<br/>[sms.js]"]
end

subgraph group_client["Web experience"]
  node_firebase["Firebase services<br/>[firebase-config.js]"]
  node_pwa["PWA runtime<br/>[service-worker.js]"]
end

node_customer(("Customer"))
node_super_admin_user(("Super admin"))
node_email_provider{{"Email provider"}}
node_sms_provider{{"SMS provider"}}

node_customer -->|"selects service"| node_public_booking
node_public_booking -.->|"submits booking"| node_booking_api
node_booking_api -->|"checks access"| node_auth
node_booking_api -.->|"reads and writes"| node_tenant_store
node_booking_api -.->|"uses time helpers"| node_slot_engine
node_booking_api -.->|"records appointments"| node_appointment_store
node_manage_booking -.->|"requests changes"| node_booking_api
node_dashboard -.->|"manages business"| node_business_api
node_staff_home -.->|"manages work"| node_business_api
node_business_api -->|"resolves membership"| node_auth
node_business_api -.->|"reads and writes"| node_tenant_store
node_business_api -->|"handles CRM actions"| node_waitlist_crm
node_dashboard -.->|"requests AI"| node_gemini_api
node_client_auth -.->|"uses Firebase auth"| node_firebase
node_super_admin_user -->|"authenticates"| node_admin_login
node_admin_login -.->|"issues admin token"| node_super_admin
node_super_admin -.->|"manages tenants"| node_tenant_store
node_booking_api -->|"builds email"| node_confirmation
node_booking_api -->|"sends email"| node_email_service
node_reminder_job -->|"sends reminders"| node_email_service
node_reminder_job -->|"reads and updates"| node_tenant_store
node_noshow_job -.->|"processes bookings"| node_tenant_store
node_email_service -->|"delivers mail"| node_email_provider
node_sms_api -.->|"sends SMS"| node_sms_provider
node_pwa -->|"caches shell"| node_public_booking

click node_public_booking "https://github.com/romstab/multi-tenant-ai-booking-pwa/blob/main/booking.html"
click node_booking_api "https://github.com/romstab/multi-tenant-ai-booking-pwa/blob/main/api/create-booking.js"
click node_slot_engine "https://github.com/romstab/multi-tenant-ai-booking-pwa/blob/main/app.js"
click node_manage_booking "https://github.com/romstab/multi-tenant-ai-booking-pwa/blob/main/manage-booking.html"
click node_dashboard "https://github.com/romstab/multi-tenant-ai-booking-pwa/blob/main/dashboard.html"
click node_staff_home "https://github.com/romstab/multi-tenant-ai-booking-pwa/blob/main/staff-home.html"
click node_business_api "https://github.com/romstab/multi-tenant-ai-booking-pwa/blob/main/api/business.js"
click node_business_logic "https://github.com/romstab/multi-tenant-ai-booking-pwa/blob/main/business.js"
click node_gemini_api "https://github.com/romstab/multi-tenant-ai-booking-pwa/blob/main/api/gemini.js"
click node_waitlist_crm "https://github.com/romstab/multi-tenant-ai-booking-pwa/blob/main/api/business.js"
click node_auth "https://github.com/romstab/multi-tenant-ai-booking-pwa/blob/main/api/authz.js"
click node_client_auth "https://github.com/romstab/multi-tenant-ai-booking-pwa/blob/main/authz.js"
click node_super_admin "https://github.com/romstab/multi-tenant-ai-booking-pwa/blob/main/api/admin.js"
click node_admin_login "https://github.com/romstab/multi-tenant-ai-booking-pwa/blob/main/api/admin-auth.js"
click node_confirmation "https://github.com/romstab/multi-tenant-ai-booking-pwa/blob/main/template/bookingConfirmationTemplate.js"
click node_reminder_job "https://github.com/romstab/multi-tenant-ai-booking-pwa/blob/main/api/cron-reminders.js"
click node_noshow_job "https://github.com/romstab/multi-tenant-ai-booking-pwa/blob/main/api/cron-noshow.js"
click node_email_service "https://github.com/romstab/multi-tenant-ai-booking-pwa/blob/main/services/emailService.js"
click node_sms_api "https://github.com/romstab/multi-tenant-ai-booking-pwa/blob/main/api/sms.js"
click node_firebase "https://github.com/romstab/multi-tenant-ai-booking-pwa/blob/main/firebase-config.js"
click node_pwa "https://github.com/romstab/multi-tenant-ai-booking-pwa/blob/main/service-worker.js"

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_public_booking,node_booking_api,node_slot_engine,node_appointment_store,node_manage_booking toneBlue
class node_dashboard,node_staff_home,node_business_api,node_business_logic,node_gemini_api,node_waitlist_crm toneAmber
class node_auth,node_client_auth,node_super_admin,node_admin_login,node_tenant_store toneMint
class node_confirmation,node_reminder_job,node_noshow_job,node_email_service,node_sms_api toneRose
class node_firebase,node_pwa,node_customer,node_super_admin_user,node_email_provider,node_sms_provider toneIndigo
```

## Components

### Booking

- [Public booking](https://github.com/romstab/multi-tenant-ai-booking-pwa/blob/main/booking.html): `booking.html`
- [Booking API](https://github.com/romstab/multi-tenant-ai-booking-pwa/blob/main/api/create-booking.js): `api/create-booking.js`
- [Slot helpers](https://github.com/romstab/multi-tenant-ai-booking-pwa/blob/main/app.js): `app.js`
- **Appointments**
- [Manage booking](https://github.com/romstab/multi-tenant-ai-booking-pwa/blob/main/manage-booking.html): `manage-booking.html`

### Business operations

- [Owner dashboard](https://github.com/romstab/multi-tenant-ai-booking-pwa/blob/main/dashboard.html): `dashboard.html`
- [Staff workspace](https://github.com/romstab/multi-tenant-ai-booking-pwa/blob/main/staff-home.html): `staff-home.html`
- [Business API](https://github.com/romstab/multi-tenant-ai-booking-pwa/blob/main/api/business.js): `api/business.js`
- [Business helpers](https://github.com/romstab/multi-tenant-ai-booking-pwa/blob/main/business.js): `business.js`
- [AI integration](https://github.com/romstab/multi-tenant-ai-booking-pwa/blob/main/api/gemini.js): `api/gemini.js`
- [Waitlist and CRM](https://github.com/romstab/multi-tenant-ai-booking-pwa/blob/main/api/business.js): `api/business.js`

### Identity and platform

- [Membership and permissions](https://github.com/romstab/multi-tenant-ai-booking-pwa/blob/main/api/authz.js): `api/authz.js`
- [Client auth helpers](https://github.com/romstab/multi-tenant-ai-booking-pwa/blob/main/authz.js): `authz.js`
- [Super-admin API](https://github.com/romstab/multi-tenant-ai-booking-pwa/blob/main/api/admin.js): `api/admin.js`
- [Super-admin auth](https://github.com/romstab/multi-tenant-ai-booking-pwa/blob/main/api/admin-auth.js): `api/admin-auth.js`
- **Tenant data**

### Notifications

- [Confirmation email](https://github.com/romstab/multi-tenant-ai-booking-pwa/blob/main/template/bookingConfirmationTemplate.js): `template/bookingConfirmationTemplate.js`
- [Reminder processor](https://github.com/romstab/multi-tenant-ai-booking-pwa/blob/main/api/cron-reminders.js): `api/cron-reminders.js`
- [No-show processor](https://github.com/romstab/multi-tenant-ai-booking-pwa/blob/main/api/cron-noshow.js): `api/cron-noshow.js`
- [Email transport](https://github.com/romstab/multi-tenant-ai-booking-pwa/blob/main/services/emailService.js): `services/emailService.js`
- [SMS API](https://github.com/romstab/multi-tenant-ai-booking-pwa/blob/main/api/sms.js): `api/sms.js`

### Web experience

- [Firebase services](https://github.com/romstab/multi-tenant-ai-booking-pwa/blob/main/firebase-config.js): `firebase-config.js`
- [PWA runtime](https://github.com/romstab/multi-tenant-ai-booking-pwa/blob/main/service-worker.js): `service-worker.js`

### Other components

- **Customer**
- **Super admin**
- **Email provider**
- **SMS provider**

## Connections

- Customer → Public booking: selects service (evidence: `README.md`)
- Public booking → Booking API: submits booking
- Booking API → Membership and permissions: checks access (evidence: `api/create-booking.js`)
- Booking API → Tenant data: reads and writes
- Booking API → Slot helpers: uses time helpers
- Booking API → Appointments: records appointments
- Manage booking → Booking API: requests changes
- Owner dashboard → Business API: manages business
- Staff workspace → Business API: manages work
- Business API → Membership and permissions: resolves membership (evidence: `api/business.js`)
- Business API → Tenant data: reads and writes
- Business API → Waitlist and CRM: handles CRM actions (evidence: `api/business.js`)
- Owner dashboard → AI integration: requests AI
- Client auth helpers → Firebase services: uses Firebase auth
- Super admin → Super-admin auth: authenticates (evidence: `README.md`)
- Super-admin auth → Super-admin API: issues admin token
- Super-admin API → Tenant data: manages tenants
- Booking API → Confirmation email: builds email (evidence: `api/create-booking.js`)
- Booking API → Email transport: sends email (evidence: `api/create-booking.js`)
- Reminder processor → Email transport: sends reminders (evidence: `api/cron-reminders.js`)
- Reminder processor → Tenant data: reads and updates (evidence: `api/cron-reminders.js`)
- No-show processor → Tenant data: processes bookings
- Email transport → Email provider: delivers mail (evidence: `services/emailService.js`)
- SMS API → SMS provider: sends SMS (evidence: `README.md`)
- PWA runtime → Public booking: caches shell (evidence: `service-worker.js`)
