Skip to content

ahmedsaadawi13/online-order-php

Repository files navigation

πŸ” Restaurant Online Ordering SaaS Platform

A complete multi-tenant SaaS platform for restaurants to manage online ordering, menu, branches, deliveries, and customer interactions.

πŸ“‹ Table of Contents


✨ Features

For Restaurants

  • βœ… Multi-branch management
  • βœ… Dynamic menu builder with modifiers & variants
  • βœ… Real-time order tracking
  • βœ… Multiple payment gateways (Stripe, PayPal, Cash)
  • βœ… Delivery radius & zone management
  • βœ… Coupons & promotional offers
  • βœ… QR code menu generation
  • βœ… Staff & role management (RBAC)
  • βœ… Sales reports & analytics
  • βœ… Multi-language (English + Arabic)
  • βœ… Multi-currency support

For Customers

  • βœ… Browse menu with filters
  • βœ… Customizable orders (modifiers, variants)
  • βœ… Multiple delivery addresses
  • βœ… Order tracking (real-time status)
  • βœ… Order history & reordering
  • βœ… Favorites list
  • βœ… Profile management

For Super Admin

  • βœ… Tenant (restaurant) management
  • βœ… Subscription & billing management
  • βœ… Platform-wide analytics
  • βœ… Support ticket system
  • βœ… Usage monitoring

πŸ› οΈ Tech Stack

Backend

  • Language: PHP 8.2+
  • Database: MySQL 8.0+
  • Cache: Redis 7.0+
  • Queue: Redis-based job queue

Frontend

  • Customer App: HTML5, Bootstrap 5, Vanilla JavaScript
  • Admin Panel: HTML5, Bootstrap 5, jQuery/Alpine.js
  • UI Framework: Bootstrap 5
  • Charts: Chart.js

DevOps

  • Containerization: Docker + Docker Compose
  • Web Server: Nginx
  • CI/CD: GitHub Actions
  • SSL: Let's Encrypt

Third-Party Services

  • Payments: Stripe, PayPal
  • Email: SendGrid
  • SMS: Twilio
  • Maps: Google Maps API

πŸ“š Documentation

Comprehensive documentation available in /docs:

  1. System Architecture - Complete architecture overview, technology decisions, scalability strategy
  2. System Diagrams - Visual architecture, data flows, authentication, deployment
  3. Database Schema - Complete ERD with 37 tables, SQL migrations, relationships
  4. Backend Structure - Folder organization, module breakdown, coding standards
  5. API Documentation - Complete REST API reference with 50+ endpoints

πŸš€ Quick Start

Prerequisites

  • PHP 8.2 or higher
  • MySQL 8.0 or higher
  • Redis 7.0 or higher
  • Composer
  • Node.js & npm (for frontend assets)

Installation

  1. Clone the repository
git clone https://github.com/ahmedsaadawi13/OnlineOrder-PHP.git
cd OnlineOrder-PHP
  1. Install PHP dependencies
composer install
  1. Configure environment
cp .env.example .env
# Edit .env with your database credentials and API keys
  1. Create database
mysql -u root -p
CREATE DATABASE restaurant_saas CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
  1. Run migrations
php cli.php migrate:run
  1. Seed database (optional)
php cli.php db:seed
  1. Start development server
php -S localhost:8000 -t public
  1. Access the application

🐳 Docker Setup (Recommended)

  1. Start containers
docker-compose up -d
  1. Install dependencies
docker-compose exec php composer install
  1. Run migrations
docker-compose exec php php cli.php migrate:run
  1. Access application

πŸ“¦ Project Structure

OnlineOrder-PHP/
β”œβ”€β”€ config/              # Configuration files
β”œβ”€β”€ database/            # Migrations & seeds
β”œβ”€β”€ docs/                # Documentation
β”œβ”€β”€ public/              # Public web root
β”œβ”€β”€ src/                 # Application source code
β”‚   β”œβ”€β”€ Controllers/     # HTTP controllers
β”‚   β”œβ”€β”€ Models/          # Database models
β”‚   β”œβ”€β”€ Services/        # Business logic
β”‚   β”œβ”€β”€ Middleware/      # HTTP middleware
β”‚   β”œβ”€β”€ Validators/      # Input validation
β”‚   β”œβ”€β”€ Helpers/         # Helper functions
β”‚   β”œβ”€β”€ Jobs/            # Background jobs
β”‚   └── Core/            # Core framework
β”œβ”€β”€ storage/             # Logs, cache, uploads
β”œβ”€β”€ tests/               # Automated tests
└── vendor/              # Composer dependencies

πŸ”§ Configuration

Environment Variables

Key environment variables (see .env.example for full list):

# Application
APP_NAME="Restaurant SaaS"
APP_URL=https://yourapp.com

# Database
DB_HOST=localhost
DB_DATABASE=restaurant_saas
DB_USERNAME=root
DB_PASSWORD=

# JWT
JWT_SECRET=your-secret-key
JWT_EXPIRATION=900

# Stripe
STRIPE_PUBLIC_KEY=pk_test_xxx
STRIPE_SECRET_KEY=sk_test_xxx

# SendGrid
SENDGRID_API_KEY=your-api-key

# Twilio
TWILIO_ACCOUNT_SID=xxx
TWILIO_AUTH_TOKEN=xxx

πŸ§ͺ Testing

Run tests using PHPUnit:

# Run all tests
composer test

# Run with coverage
composer test:coverage

# Run specific test
./vendor/bin/phpunit tests/Feature/OrderTest.php

πŸ” Security

  • βœ… JWT authentication with refresh tokens
  • βœ… Role-based access control (RBAC)
  • βœ… Multi-tenant data isolation
  • βœ… SQL injection prevention (PDO prepared statements)
  • βœ… XSS protection (output escaping)
  • βœ… CSRF protection
  • βœ… Rate limiting
  • βœ… Password hashing (bcrypt)
  • βœ… Audit logging

πŸ“Š API Endpoints

Base URL: https://api.yourapp.com/api/v1

Authentication

  • POST /auth/register - Register restaurant
  • POST /auth/login - Login
  • POST /auth/refresh - Refresh token
  • POST /auth/logout - Logout

Restaurant Management

  • GET /restaurants/{id} - Get restaurant
  • PUT /restaurants/{id} - Update restaurant
  • GET /branches - List branches
  • POST /branches - Create branch

Menu Management

  • GET /categories - List categories
  • POST /categories - Create category
  • GET /menu-items - List menu items
  • POST /menu-items - Create menu item

Orders

  • GET /orders - List orders
  • POST /orders - Create order
  • GET /orders/{id} - Get order details
  • PUT /orders/{id}/status - Update status

See full API documentation - 50+ endpoints documented


πŸ—ΊοΈ Roadmap

Phase 1: MVP (Current) βœ…

  • Core architecture
  • Database schema
  • API documentation
  • Backend structure
  • Core API implementation
  • Authentication system
  • Basic frontend

Phase 2: Enhancement

  • Admin panel UI
  • Customer web app UI
  • Payment integration
  • Email & SMS notifications
  • QR code generation

Phase 3: Advanced Features

  • Mobile app (React Native)
  • Kitchen display system
  • Driver management
  • Advanced analytics
  • Multi-currency support

Phase 4: Scale

  • Load balancing
  • Database sharding
  • CDN integration
  • Advanced caching
  • Microservices migration

πŸ“ˆ Performance

Current Capacity

  • Single server: ~10k orders/day
  • Response time: <200ms average
  • Database queries: Optimized with indexes
  • Caching: Redis-based multi-layer

Scalability

  • Horizontal scaling ready
  • Stateless application design
  • Session stored in Redis
  • Database replication supported

🀝 Contributing

We welcome contributions! Please follow these steps:

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

Coding Standards

  • Follow PSR-12 coding style
  • Write PHPUnit tests for new features
  • Update documentation
  • Add comments for complex logic

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


πŸ’¬ Support


πŸ™ Acknowledgments

  • Built with PHP 8.2+ and modern best practices
  • Inspired by leading food delivery platforms
  • Community-driven development

πŸ“Έ Screenshots

Customer Menu View

Coming soon

Restaurant Admin Dashboard

Coming soon

Order Tracking

Coming soon


Built with ❀️ for the restaurant industry

About

A complete multi-tenant SaaS platform for restaurants to manage online ordering, menu, branches, deliveries, and customer interactions.

Topics

Resources

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors