Backend

Server Setup

Node.js booking server using Express, Prisma ORM, and PostgreSQL.

Features

Authentication
JWT-based auth with bcrypt hashing.
Database
PostgreSQL with deep Prisma ORM integration.
Payments
Native Stripe integration for secure transactions.
Image Upload
Cloudinary integration for room assets.
Email Engine
Nodemailer support for confirmations.
iCal Sync
Bidirectional sync with external platforms.

Installation & Configuration

1

Prerequisites

Ensure your development environment meets these requirements before proceeding:

Node.jsv22+
npmv12+
PostgreSQLv14+
StripeActive Account
CloudinaryActive Account
2

Install PostgreSQL

A running PostgreSQL instance is required. If not installed, use the following methods:

macOS (Homebrew)
brew install postgresql
brew services start postgresql
Windows / Linux

Download the installer from the official website.

3

Database Setup

Create a fresh database for the project. You can use terminal commands or a GUI client like TablePlus or pgAdmin.

createdb booking_db
4

Project Setup

Download the project source code and extract it to your desired folder.

After extracting, navigate to the server folder and install dependencies. This will automatically generate the Prisma client and seed initial data.

cd server
npm install
Database URL Format
Your .env file must contain a valid DATABASE_URL:
postgresql://user:pass@localhost:5432/booking_db?schema=public
Default Admin Credentials
Initial data includes a default administrator:
Email: admin@admin.com | Password: admin
5

Authentication Configuration

Generate a secure JWT_SECRET to sign authentication tokens. Use a long random string.

JWT_SECRET="your_custom_secure_string_here"
6

Service Integration (Stripe & Cloudinary)

Configure payments and asset management by modifying the local .env file adding the following keywords with their respective values from your third-party service provider accounts.

Stripe Configuration

For secure payment processing and guest transactions.

1. Create an account at dashboard.stripe.com.
2. Navigate to Developers > API keys to find your Secret key (sk_test_...).
STRIPE_SECRET_KEY="sk_test_..."
Going Live (Production)
  • Activate your account by completing the business profile.
  • Switch the Test mode toggle to Live.
  • Use the Live Secret Key (sk_live_...) in your production environment variables.

Cloudinary Setup

Cloud-based management for room images and assets.

1. Sign up at cloudinary.com.
2. Copy Cloud Name, API Key, and API Secret from your Dashboard.
CLOUDINARY_CLOUD_NAME="..."
CLOUDINARY_API_KEY="..."
CLOUDINARY_API_SECRET="..."
7

Email Engine

Configure your SMTP settings for automated guest notifications and booking confirmations.

SMTP Configuration

You can use services like Gmail, SendGrid, Mailgun, or any custom SMTP server.

Environment Variables
EMAIL_HOST="smtp.example.com"
EMAIL_PORT="587"
EMAIL_USER="your_email_user"
EMAIL_PASS="your_email_password"
EMAIL_FROM_ADDRESS="noreply@example.com"
Example: Gmail Setup
Host: smtp.gmail.comPort: 587

Important: Use an App Password for the EMAIL_PASS field if using two-factor authentication.

8

iCal Synchronization

The system supports bidirectional synchronization via iCalendar feeds, ensuring your availability is always up to date across all platforms.

Export (Feed Generation)

Each room has a unique URL that exposes its current bookings to external platforms.

URL Format
https://your-api.com/api/ical/export/:roomId
Example: Booking.com
  1. Extranet > Rates & Availability > Calendar
  2. Sync calendars > Add connection
  3. Paste your unique export URL
Import (Parsing)

Import feeds from external platforms to block dates in your system automatically.

Configuration

Modify src/config/icalFeeds.ts:

export const EXTERNAL_ICAL_FEEDS = [
  {
    channelName: 'Booking.com',
    roomId: 1,
    icalUrl: 'https://ical.booking.com/...'
  }
];
Example: From Booking.com
  1. Extranet > Rates & Availability > Calendar
  2. Click Export calendar to get iCal link
  3. Copy and paste into your config array
Automatic Sync
The system periodically (managed by client requests or background tasks) fetches these feeds to refresh local availability and block dates.
9

Deployment & Vercel

Go live with a single command. The system is fully optimized for Vercel's edge infrastructure.

Vercel Edge CLI

Production-ready deployment

vercel --prod
Automatic SSL termination
Global Edge Network performance
Vercel Environment Setup
Ensure you map POSTGRES_PRISMA_URL to DATABASE_URL in your Vercel project settings to enable the database connection.

📂 Directory Structure

  • prisma/
    • schema.prisma
    • seed.ts
  • src/
    • controllers/
      • bookingController.ts
    • routes/
      • bookingRoutes.ts
    • services/
      • stripeService.ts
    • config/
      • icalFeeds.ts
    • middleware/
  • .env
  • package.json