Overview

StayForge is a full-featured hotel booking and management platform built on Laravel 12. It ships with a guest-facing booking site and a completely separate admin panel, dual AI providers (OpenAI and Anthropic Claude) that can be toggled feature-by-feature, and four payment gateways that admins can enable independently.

This page documents how the system is put together. For step-by-step installation, see the Setup Guide.

Architecture

The codebase follows standard Laravel conventions with a few dedicated service layers so that AI providers and payment gateways can be swapped or extended without touching controllers:

Data Model

TablePurpose
hotelsOne row per property; supports draft/published/suspended status and an optional owner (hotel manager).
roomsBelongs to a hotel; tracks base price, AI-suggested price, and total inventory units.
room_rate_calendarPer-date price overrides and blackout dates for a room.
bookingsGuest reservation with full price breakdown (subtotal, tax, discount, total) and a status pipeline.
paymentsOne row per payment attempt, tagged with the gateway used and its raw response payload.
reviewsGuest reviews with admin moderation status, owner replies, and an AI-generated sentiment tag.
couponsPercent or fixed discounts, optionally scoped to one hotel, with usage limits.
settingsGrouped key/value store for every admin-configurable option (AI, payments, email, site).
ai_conversations / ai_messagesChat history for the guest-facing AI assistant, keyed by session.

Guests search by city, dates, price range and star rating. Availability is computed by checking each room's total inventory against overlapping bookings in pending, confirmed, or checked_in status โ€” no separate availability cron job required.

Booking a room calculates nights, subtotal, tax, and any coupon discount server-side before creating the booking record, then hands off to the selected payment gateway.

Payments

The checkout page only ever shows gateways the admin has switched on. Each gateway implements the same three-method interface:

MethodPurpose
initiate()Creates the payment record and returns either a redirect URL (Stripe, PayPal, Manual) or the data a JS widget needs (Razorpay).
handleCallback()Confirms a payment after redirect, marking the booking confirmed and paid.
key() / label()Identifies the gateway to the settings screen and checkout form.

Account Features

Hotels & Rooms

Admins (or scoped hotel managers) create hotels and rooms, assign amenities, upload galleries, and optionally generate descriptions or price suggestions with one click using AI. Every image uploaded here lands in public/uploads/hotels/ or public/uploads/rooms/.

Bookings & Reviews

The bookings table supports filtering by status and hotel, with an inline status-change dropdown for the full pipeline: pending โ†’ confirmed โ†’ checked_in โ†’ checked_out (plus cancelled / no_show). The reviews screen shows the AI sentiment tag next to each review and lets admins approve, reject, or reply.

Reports

Revenue-by-hotel and occupancy (bookings / room-nights) reports are available for any date range, computed directly from completed payments and confirmed bookings.

How AI Is Wired

Every AI-powered feature calls AIManager::chat($feature, $messages). Internally this:

Feature Reference

Feature keyWhere it runsFallback when disabled
chatbotFloating widget, all guest pagesWidget reports itself unavailable
description_generatorAdmin hotel/room forms"Generate with AI" button shows an error
dynamic_pricingAdmin room listOnly the deterministic demand calculation runs, no AI rationale
recommendationsGuest homepageFalls back to top-rated/most-popular hotels
review_sentimentOn review submissionSentiment estimated from star rating only
trip_summaryBooking confirmation page & emailSummary block simply doesn't appear

AI Settings

Located at Admin โ†’ Settings โ†’ AI. Configure the global switch, default provider, both providers' API keys and models, and per-feature enable + provider-override toggles. Keys are stored encrypted in the settings table.

Payment Settings

Located at Admin โ†’ Settings โ†’ Payments. Enable/disable Manual, Stripe, PayPal and Razorpay independently, each with its own credential fields. Multiple gateways can be active simultaneously.

Email Settings

Located at Admin โ†’ Settings โ†’ Email. Set mailer type (SMTP/Sendmail/Log), host, port, credentials and encryption, plus a from-address and from-name. A DynamicSettingsServiceProvider applies these over config/mail.php at runtime โ€” no .env edit or redeploy needed. A "Send Test Email" button confirms the configuration instantly.

Uploads

All uploads โ€” hotel/room images, avatars โ€” pass through App\Services\UploadService, which writes to the uploads filesystem disk (mapped to public/uploads). No storage:link symlink is required, which makes this compatible with shared hosting environments that don't allow symlinks.

Route Reference

RouteDescription
GET /Homepage with featured & AI-recommended hotels
GET /searchFiltered hotel search
GET /hotels/{slug}Hotel detail with rooms and reviews
POST /rooms/{room}/bookCreate a booking and initiate payment
GET /payments/{gateway}/callback/{booking}Payment gateway redirect handler
POST /ai/chatChatbot message endpoint
/admin/*Full admin panel, gated by the access-admin gate

Extending the Platform

Add a new payment gateway by implementing PaymentGatewayInterface and registering it in PaymentManager::__construct() โ€” it appears in checkout and the settings screen automatically. Add a new AI provider the same way via AIProviderInterface. New languages/currencies are just rows in the languages / currencies tables.