# adebayo-jzs/restaurant-booking architecture

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

- Interactive diagram: https://gitdiagram.com/adebayo-jzs/restaurant-booking
- Repository: https://github.com/adebayo-jzs/restaurant-booking

## Overview

#### Purpose and Entry Points
This is a restaurant booking system with a TypeScript backend, database-backed authentication, restaurant/availability management, and booking reminders. The frontend is a minimal Next.js application shell.
- HTTP application/bootstrap: `backend/src/app.ts`, `backend/src/server.ts`
- Worker-oriented runtime entry: `backend/src/worker.ts`
- Frontend entry/layout: `frontend/app/page.tsx`, `frontend/app/layout.tsx`

#### API Boundary and Request Routing
Backend requests are organized by domain routes, then handled by controllers. Authentication middleware protects applicable operations before service-layer execution.
- Auth API: `backend/src/routes/authRoutes.ts`, `backend/src/controllers/authController.ts`
- Booking API: `backend/src/routes/booking.route.ts`, `backend/src/controllers/booking.controller.ts`
- Restaurant API: `backend/src/routes/restaurant.route.ts`, `backend/src/controllers/restaurant.controller.ts`
- Authorization boundary: `backend/src/middleware/auth.ts`

#### Domain Services and Booking Flow
Controllers delegate business operations to services. Restaurant configuration and slot availability feed booking creation/management; the schema history explicitly includes per-slot availability and booking/restaurant models.
- Booking orchestration: `backend/src/services/booking.service.ts`
- Restaurant and availability operations: `backend/src/services/restaurant.service.ts`
- Persistence model: `backend/prisma/schema.prisma`
- Relevant schema evolution: `backend/prisma/migrations/20260816225649_add_perslot_availability/migration.sql`

#### Identity and Session Lifecycle
Authentication supports password hashing, JWTs, refresh tokens, email verification, and Google OAuth. Auth endpoints/controllers form the external identity boundary; specialized services isolate credential and provider concerns.
- Auth coordination: `backend/src/controllers/authController.ts`, `backend/src/services/user.service.ts`
- Password/JWT/refresh-token mechanics: `backend/src/services/hashService.ts`, `backend/src/services/jwtService.ts`, `backend/src/services/refreshTokenService.ts`
- Google provider integration: `backend/src/services/googleOAuth.service.ts`
- Supporting database migrations: `backend/prisma/migrations/20260730121435_add_refresh_tokens/migration.sql`, `backend/prisma/migrations/20260803141959_add_google_oauth_fields/migration.sql`

#### Persistence, Notifications, and Scheduled Work
Prisma is the database access boundary. Booking reminder state is persisted, while email delivery and scheduled processing are separated into services.
- Prisma client configuration and schema: `backend/src/config/prisma.ts`, `backend/prisma/schema.prisma`
- Reminder scheduler and mail delivery: `backend/src/services/cron.service.ts`, `backend/src/services/email.service.ts`
- Reminder persistence migration: `backend/prisma/migrations/20260818213435_add_reminder_sent/migration.sql`

#### Runtime and Delivery Infrastructure
The backend is configured for a Worker deployment model, with a dedicated worker entry and Wrangler configuration. Backend deployment is automated through GitHub Actions. API documentation is exposed/configured separately from route implementation.
- Worker deployment configuration: `backend/wrangler.jsonc`, `backend/src/worker.ts`
- Backend CI/CD workflow: `.github/workflows/deploy-backend.yml`
- API documentation setup: `backend/src/swagger.ts`

Main entry points: [`backend/src/app.ts`](https://github.com/adebayo-jzs/restaurant-booking/blob/main/backend/src/app.ts) (HTTP app), [`backend/src/config/prisma.ts`](https://github.com/adebayo-jzs/restaurant-booking/blob/main/backend/src/config/prisma.ts) (Prisma access), [`backend/src/services/user.service.ts`](https://github.com/adebayo-jzs/restaurant-booking/blob/main/backend/src/services/user.service.ts) (Identity service), [`backend/src/routes/booking.route.ts`](https://github.com/adebayo-jzs/restaurant-booking/blob/main/backend/src/routes/booking.route.ts) (Booking routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend"]
  node_frontend_shell["Next.js shell<br/>frontend<br/>[page.tsx]"]
end

subgraph group_api["Backend API"]
  node_backend_app["HTTP app<br/>[app.ts]"]
  node_http_server["Server entry<br/>runtime entry<br/>[server.ts]"]
  node_auth_routes["Auth routes<br/>route module<br/>[authRoutes.ts]"]
  node_booking_routes["Booking routes<br/>route module<br/>[booking.route.ts]"]
  node_restaurant_routes["Restaurant routes<br/>route module"]
  node_auth_middleware["Authorization<br/>middleware<br/>[auth.ts]"]
  node_auth_controller["Auth controller<br/>[authController.ts]"]
  node_booking_controller["Booking controller"]
  node_restaurant_controller["Restaurant controller"]
end

subgraph group_domain["Domain services"]
  node_user_service["Identity service<br/>[user.service.ts]"]
  node_token_services["Credential services<br/>security services<br/>[jwtService.ts]"]
  node_google_oauth["Google OAuth<br/>provider integration"]
  node_booking_service["Booking service<br/>[booking.service.ts]"]
  node_restaurant_service["Restaurant service"]
end

subgraph group_data["Persistence"]
  node_prisma[("Prisma access<br/>data access<br/>[prisma.ts]")]
  node_schema["Booking data model<br/>Prisma schema<br/>[schema.prisma]"]
end

subgraph group_operations["Worker &amp; delivery"]
  node_worker{{"Worker runtime<br/>runtime entry<br/>[worker.ts]"}}
  node_reminder_scheduler["Reminder scheduler<br/>scheduled service<br/>[cron.service.ts]"]
  node_email_service["Email delivery<br/>notification service<br/>[email.service.ts]"]
  node_api_docs["API documentation<br/>Swagger setup<br/>[swagger.ts]"]
  node_deployment["Backend deployment<br/>CI/CD workflow<br/>[deploy-backend.yml]"]
end

node_frontend_shell -->|"HTTP API"| node_backend_app
node_http_server -->|"boots"| node_backend_app
node_worker -->|"hosts"| node_backend_app
node_backend_app -->|"routes"| node_auth_routes
node_backend_app -->|"routes"| node_booking_routes
node_backend_app -->|"routes"| node_restaurant_routes
node_backend_app -.->|"publishes"| node_api_docs
node_auth_routes -->|"handles"| node_auth_controller
node_booking_routes -->|"protects"| node_auth_middleware
node_booking_routes -->|"handles"| node_booking_controller
node_restaurant_routes -->|"protects"| node_auth_middleware
node_restaurant_routes -->|"handles"| node_restaurant_controller
node_auth_controller -->|"coordinates"| node_user_service
node_user_service -->|"uses"| node_token_services
node_user_service -->|"uses"| node_google_oauth
node_booking_controller -->|"delegates"| node_booking_service
node_restaurant_controller -->|"delegates"| node_restaurant_service
node_booking_service -->|"checks availability"| node_restaurant_service
node_user_service -->|"persists"| node_prisma
node_booking_service -->|"persists"| node_prisma
node_restaurant_service -->|"persists"| node_prisma
node_prisma -->|"models"| node_schema
node_reminder_scheduler -->|"finds pending reminders"| node_prisma
node_reminder_scheduler -->|"sends reminders"| node_email_service
node_deployment -->|"deploys"| node_worker

click node_frontend_shell "https://github.com/adebayo-jzs/restaurant-booking/blob/main/frontend/app/page.tsx"
click node_backend_app "https://github.com/adebayo-jzs/restaurant-booking/blob/main/backend/src/app.ts"
click node_http_server "https://github.com/adebayo-jzs/restaurant-booking/blob/main/backend/src/server.ts"
click node_auth_routes "https://github.com/adebayo-jzs/restaurant-booking/blob/main/backend/src/routes/authRoutes.ts"
click node_booking_routes "https://github.com/adebayo-jzs/restaurant-booking/blob/main/backend/src/routes/booking.route.ts"
click node_restaurant_routes "https://github.com/adebayo-jzs/restaurant-booking/blob/main/backend/src/routes/restaurant.route.ts"
click node_auth_middleware "https://github.com/adebayo-jzs/restaurant-booking/blob/main/backend/src/middleware/auth.ts"
click node_auth_controller "https://github.com/adebayo-jzs/restaurant-booking/blob/main/backend/src/controllers/authController.ts"
click node_booking_controller "https://github.com/adebayo-jzs/restaurant-booking/blob/main/backend/src/controllers/booking.controller.ts"
click node_restaurant_controller "https://github.com/adebayo-jzs/restaurant-booking/blob/main/backend/src/controllers/restaurant.controller.ts"
click node_user_service "https://github.com/adebayo-jzs/restaurant-booking/blob/main/backend/src/services/user.service.ts"
click node_token_services "https://github.com/adebayo-jzs/restaurant-booking/blob/main/backend/src/services/jwtService.ts"
click node_google_oauth "https://github.com/adebayo-jzs/restaurant-booking/blob/main/backend/src/services/googleOAuth.service.ts"
click node_booking_service "https://github.com/adebayo-jzs/restaurant-booking/blob/main/backend/src/services/booking.service.ts"
click node_restaurant_service "https://github.com/adebayo-jzs/restaurant-booking/blob/main/backend/src/services/restaurant.service.ts"
click node_prisma "https://github.com/adebayo-jzs/restaurant-booking/blob/main/backend/src/config/prisma.ts"
click node_schema "https://github.com/adebayo-jzs/restaurant-booking/blob/main/backend/prisma/schema.prisma"
click node_worker "https://github.com/adebayo-jzs/restaurant-booking/blob/main/backend/src/worker.ts"
click node_reminder_scheduler "https://github.com/adebayo-jzs/restaurant-booking/blob/main/backend/src/services/cron.service.ts"
click node_email_service "https://github.com/adebayo-jzs/restaurant-booking/blob/main/backend/src/services/email.service.ts"
click node_api_docs "https://github.com/adebayo-jzs/restaurant-booking/blob/main/backend/src/swagger.ts"
click node_deployment "https://github.com/adebayo-jzs/restaurant-booking/blob/main/.github/workflows/deploy-backend.yml"

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_shell toneBlue
class node_backend_app,node_http_server,node_auth_routes,node_booking_routes,node_restaurant_routes,node_auth_middleware,node_auth_controller,node_booking_controller,node_restaurant_controller toneAmber
class node_user_service,node_token_services,node_google_oauth,node_booking_service,node_restaurant_service toneMint
class node_prisma,node_schema toneRose
class node_worker,node_reminder_scheduler,node_email_service,node_api_docs,node_deployment toneIndigo
```

## Components

### Frontend

- [Next.js shell](https://github.com/adebayo-jzs/restaurant-booking/blob/main/frontend/app/page.tsx): frontend · Minimal application entry and layout. · `frontend/app/page.tsx`

### Backend API

- [HTTP app](https://github.com/adebayo-jzs/restaurant-booking/blob/main/backend/src/app.ts): application · `backend/src/app.ts`
- [Server entry](https://github.com/adebayo-jzs/restaurant-booking/blob/main/backend/src/server.ts): runtime entry · Conventional backend server bootstrap. · `backend/src/server.ts`
- [Auth routes](https://github.com/adebayo-jzs/restaurant-booking/blob/main/backend/src/routes/authRoutes.ts): route module · `backend/src/routes/authRoutes.ts`
- [Booking routes](https://github.com/adebayo-jzs/restaurant-booking/blob/main/backend/src/routes/booking.route.ts): route module · `backend/src/routes/booking.route.ts`
- [Restaurant routes](https://github.com/adebayo-jzs/restaurant-booking/blob/main/backend/src/routes/restaurant.route.ts): route module · `backend/src/routes/restaurant.route.ts`
- [Authorization](https://github.com/adebayo-jzs/restaurant-booking/blob/main/backend/src/middleware/auth.ts): middleware · `backend/src/middleware/auth.ts`
- [Auth controller](https://github.com/adebayo-jzs/restaurant-booking/blob/main/backend/src/controllers/authController.ts): controller · `backend/src/controllers/authController.ts`
- [Booking controller](https://github.com/adebayo-jzs/restaurant-booking/blob/main/backend/src/controllers/booking.controller.ts): controller · `backend/src/controllers/booking.controller.ts`
- [Restaurant controller](https://github.com/adebayo-jzs/restaurant-booking/blob/main/backend/src/controllers/restaurant.controller.ts): controller · `backend/src/controllers/restaurant.controller.ts`

### Domain services

- [Identity service](https://github.com/adebayo-jzs/restaurant-booking/blob/main/backend/src/services/user.service.ts): service · Coordinates user, verification, and provider identity flows. · `backend/src/services/user.service.ts`
- [Credential services](https://github.com/adebayo-jzs/restaurant-booking/blob/main/backend/src/services/jwtService.ts): security services · Password hashing, JWT, and refresh-token lifecycle. · `backend/src/services/jwtService.ts`
- [Google OAuth](https://github.com/adebayo-jzs/restaurant-booking/blob/main/backend/src/services/googleOAuth.service.ts): provider integration · `backend/src/services/googleOAuth.service.ts`
- [Booking service](https://github.com/adebayo-jzs/restaurant-booking/blob/main/backend/src/services/booking.service.ts): service · Creates and manages bookings against availability. · `backend/src/services/booking.service.ts`
- [Restaurant service](https://github.com/adebayo-jzs/restaurant-booking/blob/main/backend/src/services/restaurant.service.ts): service · Manages restaurants and per-slot availability. · `backend/src/services/restaurant.service.ts`

### Persistence

- [Prisma access](https://github.com/adebayo-jzs/restaurant-booking/blob/main/backend/src/config/prisma.ts): data access · `backend/src/config/prisma.ts`
- [Booking data model](https://github.com/adebayo-jzs/restaurant-booking/blob/main/backend/prisma/schema.prisma): Prisma schema · Users, restaurants, bookings, availability, tokens, and reminders. · `backend/prisma/schema.prisma`

### Worker & delivery

- [Worker runtime](https://github.com/adebayo-jzs/restaurant-booking/blob/main/backend/src/worker.ts): runtime entry · Worker-oriented deployment entry. · `backend/src/worker.ts`
- [Reminder scheduler](https://github.com/adebayo-jzs/restaurant-booking/blob/main/backend/src/services/cron.service.ts): scheduled service · `backend/src/services/cron.service.ts`
- [Email delivery](https://github.com/adebayo-jzs/restaurant-booking/blob/main/backend/src/services/email.service.ts): notification service · `backend/src/services/email.service.ts`
- [API documentation](https://github.com/adebayo-jzs/restaurant-booking/blob/main/backend/src/swagger.ts): Swagger setup · `backend/src/swagger.ts`
- [Backend deployment](https://github.com/adebayo-jzs/restaurant-booking/blob/main/.github/workflows/deploy-backend.yml): CI/CD workflow · Deploys the Worker backend. · `.github/workflows/deploy-backend.yml`

## Connections

- Next.js shell → HTTP app: HTTP API
- Server entry → HTTP app: boots
- Worker runtime → HTTP app: hosts
- HTTP app → Auth routes: routes
- HTTP app → Booking routes: routes
- HTTP app → Restaurant routes: routes
- HTTP app → API documentation: publishes
- Auth routes → Auth controller: handles
- Booking routes → Authorization: protects
- Booking routes → Booking controller: handles
- Restaurant routes → Authorization: protects
- Restaurant routes → Restaurant controller: handles
- Auth controller → Identity service: coordinates
- Identity service → Credential services: uses
- Identity service → Google OAuth: uses
- Booking controller → Booking service: delegates
- Restaurant controller → Restaurant service: delegates
- Booking service → Restaurant service: checks availability
- Identity service → Prisma access: persists
- Booking service → Prisma access: persists
- Restaurant service → Prisma access: persists
- Prisma access → Booking data model: models
- Reminder scheduler → Prisma access: finds pending reminders
- Reminder scheduler → Email delivery: sends reminders
- Backend deployment → Worker runtime: deploys
