Skip to content

AkshayKappala/regal_elephant_web

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

65 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🐘 The Regal Elephant

PHP Bootstrap MySQL License

A full-stack restaurant web ordering platform with real-time order tracking, staff management portal, and seamless customer experience. Built with PHP, MySQL, and vanilla JavaScript for optimal performance.


🎯 What Is This?

The Regal Elephant is a complete restaurant ordering system designed for dine-in and takeout operations. Customers can browse the menu, place orders, and track their status in real-time using Server-Sent Events (SSE). The integrated staff portal allows restaurant employees to manage incoming orders, update statuses, and configure settingsβ€”all from a secure dashboard.

Why This Exists:

  • Streamline restaurant operations without expensive third-party platforms
  • Provide customers with instant order feedback and status updates
  • Enable staff to efficiently manage orders from a centralized interface
  • Maintain full control over customer data and ordering flow

✨ Features

Customer Portal

  • πŸ“‹ Dynamic Menu Display - Browse organized categories (Starters, Main Course, Breads, Desserts & Beverages)
  • πŸ›’ Shopping Cart - Add/remove items with quantity management
  • πŸ“± Responsive Design - Works seamlessly on desktop, tablet, and mobile
  • πŸ”„ Real-Time Order Tracking - Live status updates via SSE
  • πŸ“œ Order History - View active orders and past purchases
  • πŸ’° Tip Support - Optional tipping functionality

Staff Portal

  • πŸ” Secure Authentication - Password-protected admin access
  • πŸ“Š Order Management - View and update order statuses
  • πŸ”” Real-Time Notifications - Instant alerts for new orders
  • βš™οΈ Settings Panel - Configure restaurant operations
  • πŸ“ˆ Order Details - Full order information with customer details

Technical Highlights

  • Server-Sent Events for real-time updates without WebSocket complexity
  • RESTful API architecture for order processing
  • Database caching for optimized performance
  • Modular PHP structure with clean separation of concerns

πŸ› οΈ Tech Stack

Category Technology
Backend PHP 7.4+
Database MySQL 8.0+
Frontend Vanilla JavaScript (ES6 Modules)
CSS Framework Bootstrap 5.3.5
Icons Bootstrap Icons
Fonts Google Fonts (Fredoka, League Gothic, Marko One)
Real-Time Server-Sent Events (SSE)

πŸš€ Quick Start

Prerequisites

# Required
PHP >= 7.4
MySQL >= 8.0
Apache/Nginx web server

Installation

  1. Clone the repository
git clone https://github.com/AkshayKappala/regal_elephant_web.git
cd regal_elephant_web
  1. Configure the database

Create a MySQL database and import your schema:

mysql -u root -p
CREATE DATABASE regal_elephant;
  1. Update database configuration

Edit config/database.php with your credentials:

<?php
class Database {
    private static $connection = null;
    
    public static function getConnection() {
        if (self::$connection === null) {
            $host = 'localhost';
            $username = 'your_username';
            $password = 'your_password';
            $database = 'regal_elephant';
            
            self:: $connection = new mysqli($host, $username, $password, $database);
            
            if (self::$connection->connect_error) {
                die("Connection failed: " . self::$connection->connect_error);
            }
        }
        return self::$connection;
    }
}
  1. Configure API settings

Update config/api_config.php with your staff API URL and key:

<?php
define('STAFF_API_URL', 'https://your-staff-api.com/');
define('API_KEY', 'your-secure-api-key-here');
  1. Set up web server

For Apache:

# Point your document root to the project directory
# Ensure mod_rewrite is enabled
sudo a2enmod rewrite
sudo systemctl restart apache2

For PHP Built-in Server (Development Only):

php -S localhost:8000
  1. Access the application
  • Customer Portal: http://localhost:8000/
  • Staff Portal: http://localhost:8000/staff/
    • Default credentials: admin / elephant2025

πŸ“ Project Structure

regal_elephant_web/
β”œβ”€β”€ api/                          # API endpoints
β”‚   β”œβ”€β”€ place_order.php          # Order placement (legacy proxy)
β”‚   β”œβ”€β”€ get_order_details.php   # Fetch order information
β”‚   β”œβ”€β”€ get_item_ids.php         # Retrieve item IDs by name/price
β”‚   β”œβ”€β”€ order_events.php         # SSE endpoint for real-time updates
β”‚   └── order_status_events.php  # Order status change events
β”œβ”€β”€ assets/
β”‚   β”œβ”€β”€ css/                     # Stylesheets
β”‚   β”œβ”€β”€ src/                     # JavaScript modules
β”‚   β”‚   β”œβ”€β”€ main.js             # Main application entry point
β”‚   β”‚   β”œβ”€β”€ cart.js             # Shopping cart logic
β”‚   β”‚   └── events.js           # Event handling
β”‚   └── js/
β”‚       └── staff. js            # Staff portal JavaScript
β”œβ”€β”€ config/
β”‚   β”œβ”€β”€ database.php            # Database connection
β”‚   β”œβ”€β”€ api_config.php          # API configuration
β”‚   └── get_api_config.php      # API config getter
β”œβ”€β”€ partials/                    # Reusable HTML components
β”œβ”€β”€ staff/                       # Staff portal
β”‚   β”œβ”€β”€ index.php               # Staff dashboard
β”‚   β”œβ”€β”€ login.php               # Staff authentication
β”‚   β”œβ”€β”€ pages/                  # Staff portal pages
β”‚   └── assets/                 # Staff-specific assets
β”œβ”€β”€ views/                       # Customer-facing pages
β”‚   β”œβ”€β”€ home. php                # Landing page
β”‚   β”œβ”€β”€ explore.php             # Category exploration
β”‚   β”œβ”€β”€ menu. php                # Full menu display
β”‚   β”œβ”€β”€ cart.php                # Shopping cart
β”‚   └── orders.php              # Order tracking
β”œβ”€β”€ temp/events/                 # SSE event cache (auto-created)
β”œβ”€β”€ index.php                    # Application entry point
└── 404.html                     # Error page

🎨 Customization Guide

Change Restaurant Name

Update the title in index.php:

<title>Your Restaurant Name</title>

And in views/home.php:

<h1 class="display-3 text-center title-home">YOUR RESTAURANT NAME</h1>

Modify Menu Categories

Edit the category groups in views/menu.php and views/explore.php:

$categoryGroups = [
    "Starters" => ["Veg Starter", "Non-Veg Starter"],
    "Main Course" => ["Veg Entree", "Non-Veg Entree"],
    // Add or remove categories as needed
];

Update Staff Credentials

Change the default login in staff/index.php:

$validUsername = 'your_username';
$validPassword = 'your_secure_password';

⚠️ Security Note: For production, implement proper password hashing and database-based authentication.

Customize Styling

Main stylesheet: assets/css/style.css

Example - Change primary color:

:root {
    --primary-color: #a04b25; /* Update to your brand color */
    --accent-color: #eadab0;
}

🌐 Deployment Instructions

Production Checklist

  • Update database credentials in config/database.php
  • Set strong staff portal password
  • Configure SSL/TLS certificate (HTTPS)
  • Set proper file permissions: chmod 644 *.php
  • Create temp/events/ directory: mkdir -p temp/events/orders
  • Set write permissions: chmod 755 temp/events/
  • Disable error display: ini_set('display_errors', 0);
  • Enable error logging: ini_set('log_errors', 1);
  • Configure API keys in config/api_config.php
  • Test SSE functionality across your network

Apache Configuration

Add to your .htaccess or VirtualHost:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    
    # Prevent directory browsing
    Options -Indexes
    
    # Protect config files
    <Files "database.php">
        Require all denied
    </Files>
    <Files "api_config.php">
        Require all denied
    </Files>
</IfModule>

# Enable SSE
<IfModule mod_headers.c>
    Header set X-Accel-Buffering "no"
    Header set Cache-Control "no-cache"
</IfModule>

Environment Variables (Optional)

For enhanced security, use environment variables for sensitive data:

// In config/database.php
$host = getenv('DB_HOST') ?: 'localhost';
$username = getenv('DB_USER');
$password = getenv('DB_PASS');
$database = getenv('DB_NAME');

πŸ”§ Troubleshooting

Orders Not Updating in Real-Time

Problem: Order status changes don't reflect immediately.

Solution:

# Check temp/events directory exists and is writable
mkdir -p temp/events/orders
chmod 755 temp/events
chmod 755 temp/events/orders

# Verify SSE endpoint is accessible
curl http://localhost:8000/api/order_events.php

Database Connection Errors

Problem: Connection failed: Access denied

Solution:

  • Verify credentials in config/database.php
  • Ensure MySQL is running: sudo systemctl status mysql
  • Grant privileges: GRANT ALL PRIVILEGES ON regal_elephant.* TO 'user'@'localhost';

Staff Portal Not Loading

Problem: Blank page or 500 error.

Solution:

# Check PHP error logs
tail -f /var/log/apache2/error.log

# Verify session directory is writable
ls -la /var/lib/php/sessions/

Cart Items Not Persisting

Problem: Cart empties on page refresh.

Solution:

  • Check browser localStorage: Open DevTools β†’ Application β†’ Local Storage
  • Ensure JavaScript is enabled
  • Clear cache and reload

SSE Connection Drops

Problem: Real-time updates stop after a few minutes.

Solution:

// Add to api/order_events.php (already implemented)
set_time_limit(0);
ini_set('max_execution_time', 0);

// For Apache, add to .htaccess
<IfModule mod_proxy.c>
    ProxyTimeout 600
</IfModule>

πŸ“§ Contact & Support

Developer: Akshay Kappala
GitHub: @AkshayKappala
Repository: regal_elephant_web

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch: git checkout -b feature/amazing-feature
  3. Commit your changes: git commit -m 'Add amazing feature'
  4. Push to the branch: git push origin feature/amazing-feature
  5. Open a Pull Request

πŸ“„ License

This project is open source and available under the MIT License.


Built with ❀️ for restaurant owners who value independence

⭐ Star this repo | πŸ› Report Bug | πŸ’‘ Request Feature

About

A full-stack PHP restaurant ordering platform with real-time order tracking, customer cart management, and secure staff portal for seamless dine-in and takeout operations.

Topics

Resources

Stars

Watchers

Forks

Contributors