How adebayo-jzs/restaurant-booking works
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: app.ts HTTP app · prisma.ts Prisma access · user.service.ts Identity service · booking.route.ts Booking routes
Components 22
Frontend
- Next.js shell · Minimal application entry and layout.
frontend/app/page.tsx
Backend API
- HTTP app
backend/src/app.ts - Server entry · Conventional backend server bootstrap.
backend/src/server.ts - Auth routes
backend/src/routes/authRoutes.ts - Booking routes
backend/src/routes/booking.route.ts - Restaurant routes
backend/src/routes/restaurant.route.ts - Authorization
backend/src/middleware/auth.ts - Auth controller
backend/src/controllers/authController.ts - Booking controller
backend/src/controllers/booking.controller.ts - Restaurant controller
backend/src/controllers/restaurant.controller.ts
Domain services
- Identity service · Coordinates user, verification, and provider identity flows.
backend/src/services/user.service.ts - Credential services · Password hashing, JWT, and refresh-token lifecycle.
backend/src/services/jwtService.ts - Google OAuth
backend/src/services/googleOAuth.service.ts - Booking service · Creates and manages bookings against availability.
backend/src/services/booking.service.ts - Restaurant service · Manages restaurants and per-slot availability.
backend/src/services/restaurant.service.ts
Persistence
- Prisma access
backend/src/config/prisma.ts - Booking data model · Users, restaurants, bookings, availability, tokens, and reminders.
backend/prisma/schema.prisma
Worker & delivery
- Worker runtime · Worker-oriented deployment entry.
backend/src/worker.ts - Reminder scheduler
backend/src/services/cron.service.ts - Email delivery
backend/src/services/email.service.ts - API documentation
backend/src/swagger.ts - Backend deployment · Deploys the Worker backend.
.github/workflows/deploy-backend.yml
Connections 25
- 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