# tsttyy/hanabi-booking architecture

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

- Interactive diagram: https://gitdiagram.com/tsttyy/hanabi-booking
- Repository: https://github.com/tsttyy/hanabi-booking

## Overview

Hanabi Booking is a B2B appointment-booking platform: customers browse active businesses, services and staff, check available slots, book and manage appointments; business admins manage booking resources and appointments, while system owners provision and enable businesses. The React frontend communicates with an Express API, whose routes dispatch to controllers and domain services backed by PostgreSQL through Prisma. The README documents the frontend/API boundary and booking flow; some domain services and frontend internals were not sampled, so their detailed connections are omitted.

Main entry points: [`src/routes`](https://github.com/tsttyy/hanabi-booking/tree/main/src/routes) (Admin routes), [`src/lib/prisma.ts`](https://github.com/tsttyy/hanabi-booking/blob/main/src/lib/prisma.ts) (PostgreSQL), [`src/controllers/customer.controller.ts`](https://github.com/tsttyy/hanabi-booking/blob/main/src/controllers/customer.controller.ts) (Customer handlers), [`src/middleware/auth.ts`](https://github.com/tsttyy/hanabi-booking/blob/main/src/middleware/auth.ts) (Auth checks)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Booking client"]
  node_frontend["Booking interface<br/>[main.tsx]"]
end

subgraph group_api["API entry"]
  node_api_server["Express API<br/>[app.ts]"]
  node_customer_routes["Customer routes<br/>[customer.routes.ts]"]
  node_public_routes["Public routes<br/>[public.routes.ts]"]
  node_admin_routes["Admin routes"]
  node_customer_controller["Customer handlers"]
  node_public_controller["Public handlers"]
  node_appointment_controller["Appointment handlers"]
end

subgraph group_identity["Identity"]
  node_auth_middleware["Auth checks<br/>[auth.ts]"]
  node_auth_service["User authentication<br/>[auth.service.ts]"]
  node_customer_service["Customer accounts"]
end

subgraph group_catalog["Business catalog"]
  node_business_service["Business management"]
  node_service_service["Service management<br/>[service.service.ts]"]
  node_staff_service["Staff management<br/>[staff.service.ts]"]
  node_availability_service["Availability rules"]
  node_public_service["Public directory<br/>[public.service.ts]"]
end

subgraph group_booking["Appointments"]
  node_booking_service["Slot and booking logic<br/>[booking.service.ts]"]
  node_appointment_service["Appointment management"]
  node_customer_appointments["Customer appointments"]
end

node_customer(("Customer"))
node_database[("PostgreSQL<br/>[prisma.ts]")]

node_customer -->|"uses"| node_frontend
node_frontend -->|"requests"| node_api_server
node_api_server -->|"mounts"| node_customer_routes
node_api_server -->|"mounts"| node_public_routes
node_customer_routes -->|"dispatches"| node_customer_controller
node_customer_routes -->|"guards"| node_auth_middleware
node_public_routes -->|"dispatches"| node_public_controller
node_customer_controller -->|"manages accounts"| node_customer_service
node_customer_controller -->|"manages bookings"| node_customer_appointments
node_customer_controller -.->|"sets customer identity"| node_auth_middleware
node_public_controller -->|"loads directory"| node_public_service
node_public_controller -->|"checks slots"| node_booking_service
node_appointment_controller -->|"creates booking"| node_booking_service
node_appointment_controller -->|"manages appointments"| node_appointment_service
node_auth_service -->|"signs tokens"| node_auth_middleware
node_customer_service -.->|"issues customer token"| node_auth_middleware
node_business_service -->|"reads and writes"| node_database
node_service_service -->|"reads and writes"| node_database
node_appointment_service -->|"reads and writes"| node_database
node_customer_appointments -->|"reads and writes"| node_database
node_public_service -->|"reads"| node_database
node_booking_service -->|"checks and writes"| node_database
node_admin_routes -.->|"dispatches"| node_appointment_controller
node_admin_routes -.->|"dispatches"| node_business_service
node_admin_routes -.->|"dispatches"| node_service_service
node_admin_routes -.->|"dispatches"| node_staff_service
node_admin_routes -.->|"dispatches"| node_availability_service

click node_frontend "https://github.com/tsttyy/hanabi-booking/blob/main/frontend/src/main.tsx"
click node_api_server "https://github.com/tsttyy/hanabi-booking/blob/main/src/app.ts"
click node_customer_routes "https://github.com/tsttyy/hanabi-booking/blob/main/src/routes/customer.routes.ts"
click node_public_routes "https://github.com/tsttyy/hanabi-booking/blob/main/src/routes/public.routes.ts"
click node_admin_routes "https://github.com/tsttyy/hanabi-booking/tree/main/src/routes"
click node_customer_controller "https://github.com/tsttyy/hanabi-booking/blob/main/src/controllers/customer.controller.ts"
click node_public_controller "https://github.com/tsttyy/hanabi-booking/blob/main/src/controllers/public.controller.ts"
click node_appointment_controller "https://github.com/tsttyy/hanabi-booking/blob/main/src/controllers/appointment.controller.ts"
click node_auth_middleware "https://github.com/tsttyy/hanabi-booking/blob/main/src/middleware/auth.ts"
click node_auth_service "https://github.com/tsttyy/hanabi-booking/blob/main/src/services/auth.service.ts"
click node_customer_service "https://github.com/tsttyy/hanabi-booking/blob/main/src/services/customer.service.ts"
click node_business_service "https://github.com/tsttyy/hanabi-booking/blob/main/src/services/business.service.ts"
click node_service_service "https://github.com/tsttyy/hanabi-booking/blob/main/src/services/service.service.ts"
click node_staff_service "https://github.com/tsttyy/hanabi-booking/blob/main/src/services/staff.service.ts"
click node_availability_service "https://github.com/tsttyy/hanabi-booking/blob/main/src/services/availability.service.ts"
click node_booking_service "https://github.com/tsttyy/hanabi-booking/blob/main/src/services/booking.service.ts"
click node_appointment_service "https://github.com/tsttyy/hanabi-booking/blob/main/src/services/appointment.service.ts"
click node_customer_appointments "https://github.com/tsttyy/hanabi-booking/blob/main/src/services/customer-appointment.service.ts"
click node_public_service "https://github.com/tsttyy/hanabi-booking/blob/main/src/services/public.service.ts"
click node_database "https://github.com/tsttyy/hanabi-booking/blob/main/src/lib/prisma.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_frontend toneBlue
class node_api_server,node_customer_routes,node_public_routes,node_admin_routes,node_customer_controller,node_public_controller,node_appointment_controller,node_database toneAmber
class node_auth_middleware,node_auth_service,node_customer_service toneMint
class node_business_service,node_service_service,node_staff_service,node_availability_service,node_public_service toneRose
class node_booking_service,node_appointment_service,node_customer_appointments,node_customer toneIndigo
```

## Components

### Booking client

- [Booking interface](https://github.com/tsttyy/hanabi-booking/blob/main/frontend/src/main.tsx): `frontend/src/main.tsx`

### API entry

- [Express API](https://github.com/tsttyy/hanabi-booking/blob/main/src/app.ts): `src/app.ts`
- [Customer routes](https://github.com/tsttyy/hanabi-booking/blob/main/src/routes/customer.routes.ts): `src/routes/customer.routes.ts`
- [Public routes](https://github.com/tsttyy/hanabi-booking/blob/main/src/routes/public.routes.ts): `src/routes/public.routes.ts`
- [Admin routes](https://github.com/tsttyy/hanabi-booking/tree/main/src/routes): `src/routes`
- [Customer handlers](https://github.com/tsttyy/hanabi-booking/blob/main/src/controllers/customer.controller.ts): `src/controllers/customer.controller.ts`
- [Public handlers](https://github.com/tsttyy/hanabi-booking/blob/main/src/controllers/public.controller.ts): `src/controllers/public.controller.ts`
- [Appointment handlers](https://github.com/tsttyy/hanabi-booking/blob/main/src/controllers/appointment.controller.ts): `src/controllers/appointment.controller.ts`

### Identity

- [Auth checks](https://github.com/tsttyy/hanabi-booking/blob/main/src/middleware/auth.ts): `src/middleware/auth.ts`
- [User authentication](https://github.com/tsttyy/hanabi-booking/blob/main/src/services/auth.service.ts): `src/services/auth.service.ts`
- [Customer accounts](https://github.com/tsttyy/hanabi-booking/blob/main/src/services/customer.service.ts): `src/services/customer.service.ts`

### Business catalog

- [Business management](https://github.com/tsttyy/hanabi-booking/blob/main/src/services/business.service.ts): `src/services/business.service.ts`
- [Service management](https://github.com/tsttyy/hanabi-booking/blob/main/src/services/service.service.ts): `src/services/service.service.ts`
- [Staff management](https://github.com/tsttyy/hanabi-booking/blob/main/src/services/staff.service.ts): `src/services/staff.service.ts`
- [Availability rules](https://github.com/tsttyy/hanabi-booking/blob/main/src/services/availability.service.ts): `src/services/availability.service.ts`
- [Public directory](https://github.com/tsttyy/hanabi-booking/blob/main/src/services/public.service.ts): `src/services/public.service.ts`

### Appointments

- [Slot and booking logic](https://github.com/tsttyy/hanabi-booking/blob/main/src/services/booking.service.ts): `src/services/booking.service.ts`
- [Appointment management](https://github.com/tsttyy/hanabi-booking/blob/main/src/services/appointment.service.ts): `src/services/appointment.service.ts`
- [Customer appointments](https://github.com/tsttyy/hanabi-booking/blob/main/src/services/customer-appointment.service.ts): `src/services/customer-appointment.service.ts`

### Other components

- **Customer**
- [PostgreSQL](https://github.com/tsttyy/hanabi-booking/blob/main/src/lib/prisma.ts): `src/lib/prisma.ts`

## Connections

- Customer → Booking interface: uses (evidence: `README.md`)
- Booking interface → Express API: requests (evidence: `README.md`)
- Express API → Customer routes: mounts (evidence: `src/app.ts`)
- Express API → Public routes: mounts (evidence: `src/app.ts`)
- Customer routes → Customer handlers: dispatches (evidence: `src/routes/customer.routes.ts`)
- Customer routes → Auth checks: guards (evidence: `src/routes/customer.routes.ts`)
- Public routes → Public handlers: dispatches (evidence: `src/routes/public.routes.ts`)
- Customer handlers → Customer accounts: manages accounts (evidence: `src/controllers/customer.controller.ts`)
- Customer handlers → Customer appointments: manages bookings (evidence: `src/controllers/customer.controller.ts`)
- Customer handlers → Auth checks: sets customer identity
- Public handlers → Public directory: loads directory (evidence: `src/controllers/public.controller.ts`)
- Public handlers → Slot and booking logic: checks slots (evidence: `src/controllers/public.controller.ts`)
- Appointment handlers → Slot and booking logic: creates booking (evidence: `src/controllers/appointment.controller.ts`)
- Appointment handlers → Appointment management: manages appointments (evidence: `src/controllers/appointment.controller.ts`)
- User authentication → Auth checks: signs tokens (evidence: `src/services/auth.service.ts`)
- Customer accounts → Auth checks: issues customer token (evidence: `src/services/customer.service.ts`)
- Business management → PostgreSQL: reads and writes (evidence: `src/services/business.service.ts`)
- Service management → PostgreSQL: reads and writes (evidence: `src/services/service.service.ts`)
- Appointment management → PostgreSQL: reads and writes (evidence: `src/services/appointment.service.ts`)
- Customer appointments → PostgreSQL: reads and writes (evidence: `src/services/customer-appointment.service.ts`)
- Public directory → PostgreSQL: reads (evidence: `src/services/public.service.ts`)
- Slot and booking logic → PostgreSQL: checks and writes (evidence: `src/services/booking.service.ts`)
- Admin routes → Appointment handlers: dispatches (evidence: `src/routes/appointment.routes.ts`)
- Admin routes → Business management: dispatches
- Admin routes → Service management: dispatches
- Admin routes → Staff management: dispatches
- Admin routes → Availability rules: dispatches
