# StayWise Hotel Booking Platform ## Complete Installation & Configuration Guide --- ## 🚀 Quick Start ### Requirements - PHP 7.4+ (8.0+ recommended) - MySQL 5.7+ or MariaDB 10.3+ - Apache with mod_rewrite enabled - SSL Certificate (required for Paystack) --- ## 📁 File Structure ``` staywise/ ├── index.php # Homepage ├── search.php # Search results + map ├── hotel-detail.php # Hotel detail + booking ├── booking-confirmation.php # Payment confirmation ├── manifest.json # PWA manifest ├── sw.js # Service Worker (PWA) ├── robots.txt # SEO robots ├── .htaccess # Apache config ├── database.sql # Database schema │ ├── assets/ │ ├── css/style.css # Main stylesheet │ └── js/main.js # Main JavaScript │ ├── auth/ │ ├── login.php # Login page │ ├── register.php # Register page │ └── my-bookings.php # User bookings │ ├── hotel-dashboard/ │ └── index.php # Hotel owner dashboard │ ├── admin/ │ └── index.php # Admin panel │ ├── api/ │ ├── config/ │ │ ├── database.php # PDO DB connection │ │ └── config.php # App config & helpers │ ├── auth/ │ │ ├── login.php # POST /api/auth/login │ │ └── register.php # POST /api/auth/register │ ├── hotels/ │ │ ├── index.php # GET /api/hotels/list │ │ ├── detail.php # GET /api/hotels/detail │ │ ├── manage.php # CRUD /api/hotels/manage │ │ ├── upload.php # POST /api/hotels/upload │ │ └── wishlist.php # POST /api/hotels/wishlist │ ├── rooms/ │ │ └── index.php # CRUD /api/rooms │ ├── bookings/ │ │ └── index.php # CRUD /api/bookings │ ├── payments/ │ │ └── paystack.php # Paystack integration │ ├── search/ │ │ └── external.php # External hotel API │ └── admin/ │ └── index.php # Admin API │ └── uploads/ ├── hotels/ # Hotel photos └── rooms/ # Room photos ``` --- ## ⚙️ Installation Steps ### Step 1: Upload Files Upload all files to your web server's public directory (e.g., `/public_html/`). ### Step 2: Create Database 1. Log in to your hosting control panel (cPanel/Plesk) 2. Create a new MySQL database 3. Import `database.sql` via phpMyAdmin ### Step 3: Configure Database Edit `/api/config/database.php`: ```php define('DB_HOST', 'localhost'); // Usually localhost define('DB_NAME', 'your_db_name'); // Your database name define('DB_USER', 'your_db_user'); // Your database user define('DB_PASS', 'your_db_pass'); // Your database password ``` ### Step 4: Configure Application Edit `/api/config/config.php`: ```php define('APP_URL', 'https://yourdomain.com'); // Your domain define('JWT_SECRET', 'your-very-long-random-secret-key'); // Change this! ``` ### Step 5: Set Up Paystack 1. Sign up at https://paystack.com 2. Get your API keys from the dashboard 3. Login to admin panel → Settings → Update Paystack keys 4. Update in `/assets/js/main.js`: ```javascript const PAYSTACK_PUBLIC_KEY = 'pk_live_YOUR_KEY'; ``` ### Step 6: Configure Upload Directory ```bash chmod 755 uploads/ chmod 755 uploads/hotels/ chmod 755 uploads/rooms/ ``` ### Step 7: Admin Login Default admin credentials: - **Email:** admin@staywise.com - **Password:** Admin@123 ⚠️ **CHANGE PASSWORD IMMEDIATELY after first login!** --- ## 🔑 API Keys Required ### Paystack (Payments) - Register at: https://paystack.com - Required keys: Public Key + Secret Key - Configure in Admin → Settings ### Google Maps (Map View - Optional) - Get key at: https://console.cloud.google.com - Enable: Maps JavaScript API - Configure in Admin → Settings ### External Hotel API (Global Listings - Optional) Several options: - **RapidAPI Hotels.com API:** https://rapidapi.com/apidojo/api/hotels4 - **Amadeus API:** https://developers.amadeus.com - **HotelBeds API:** https://developer.hotelbeds.com - Configure endpoint in `/api/search/external.php` --- ## 💰 Revenue Configuration All fees are configurable in Admin → Settings: | Fee | Default | Description | |-----|---------|-------------| | Hotel Commission | 10% | Deducted from hotel payout per booking | | Guest Service Fee | 2% | Added to guest total (invisible to user) | | Premium Listing | Custom | Monthly subscription for hotel visibility | --- ## 📧 Email Configuration (SMTP) Configure in Admin → Settings: - SMTP Host (e.g., smtp.gmail.com) - SMTP Port (587 for TLS) - SMTP Username & Password For Gmail: Use App Password (not your regular password) --- ## 🔒 Security Checklist Before going live: - [ ] Change JWT_SECRET in config.php - [ ] Change admin password - [ ] Enable HTTPS (uncomment in .htaccess) - [ ] Set Paystack to Live Mode - [ ] Remove `database.sql` from web root - [ ] Set strong database password - [ ] Enable PHP error logging (not display) --- ## 🏨 Cancellation Policy Default policy (configurable in Admin): | Timing | Policy | |--------|--------| | 48+ hours before | Full refund | | 24–48 hours before | 50% refund | | <24 hours / No-show | No refund | --- ## 📱 PWA Setup The app is PWA-ready. To complete setup: 1. Add icons to `/assets/images/`: icon-72.png through icon-512.png 2. Update `manifest.json` with your domain 3. Ensure HTTPS is active 4. Test with Chrome DevTools → Application → Service Workers --- ## 🌐 SEO Configuration Update these for each page: - `