This project is a multi-tenant food delivery backend built with Laravel 12, PostgreSQL, Filament, Stancl Tenancy, and Spatie Permission. It is designed for rapid development of food delivery platforms supporting restaurant chains, customers, drivers, and advanced business logic.
- Multi-tenancy (Stancl Tenancy)
- Role & permission management (Spatie Laravel Permission)
- Modern admin panel (Filament)
- Modular and scalable database structure for:
- User & tenant management
- Restaurants, branches, menus, orders
- Delivery, reviews, promotions, payments, notifications, and logging
You can view the initial ERD for this project here: Project ERD on dbdiagram.io
See /database/migrations/ for the full schema. Main modules and tables:
- tenants
- users
- password_reset_tokens
- sessions
- permissions
- roles
- model_has_permissions
- model_has_roles
- role_has_permissions
- food_chains
- restaurants
- restaurant_branches
- menu_categories
- menu_items
- menu_item_variants
- branch_menu_item_overrides
- branch_menu_item_variant_overrides
- menu_add_ons
- menu_add_on_menu_item
- categories
- customer_profiles
- customer_addresses
- customers
- orders
- order_items
- order_item_variants
- deliveries
- drivers
- coupons
- coupon_usages
- payment_transactions
- notifications
- activity_log
- reviews
Below is a visualization of the allowed order state transitions as implemented in app/Domain/Order/OrderState.php:
Open Mermaid Diagram in New Tab
stateDiagram-v2
[*] --> initiated
initiated --> received_by_restaurant
received_by_restaurant --> preparing
preparing --> finding_driver
finding_driver --> prepared
prepared --> handed_to_driver
handed_to_driver --> in_transit
in_transit --> waiting_for_customer
waiting_for_customer --> received_by_customer
received_by_customer --> confirmed_and_feedback
received_by_customer --> refund_requested
received_by_customer --> complaint_received
refund_requested --> refund_approved
refund_requested --> refund_declined
complaint_received --> refund_approved
complaint_received --> refund_declined
refund_approved --> driver_returning
driver_returning --> restaurant_repreparing
restaurant_repreparing --> restaurant_driver_exchange
restaurant_driver_exchange --> driver_intransit_nth
driver_intransit_nth --> customer_fulfilled
confirmed_and_feedback --> customer_fulfilled
refund_declined --> customer_fulfilled
This job is responsible for finding available drivers within a given radius from a location. It supports both a direct search and a progressive search that expands the search radius until a driver is found or a maximum radius is reached.
- Direct Search:
- Find all available drivers within the specified radius using the Haversine formula.
- For SQLite (test) environments, the calculation is performed in PHP; for production, it's done in SQL.
- Progressive Search:
- Start with a default radius (e.g., 5km).
- If no drivers are found, increase the radius by a step (e.g., +5km) every X minutes, up to a maximum (e.g., 20km).
- Stop searching as soon as one or more drivers are found or the maximum radius is reached.
flowchart TD
Start([Start])
Params{Input: lat, lng, radius, max_radius, step, interval}
DirectSearch[Direct Search for Drivers within radius]
FoundDrivers{Drivers Found?}
ReturnDrivers[Return Drivers]
ExpandRadius[Increase radius by step; Wait interval]
MaxRadius{Radius > Max?}
ReturnEmpty[Return empty; no drivers found]
Start --> Params --> DirectSearch --> FoundDrivers
FoundDrivers -- Yes --> ReturnDrivers
FoundDrivers -- No --> MaxRadius
MaxRadius -- No --> ExpandRadius --> DirectSearch
MaxRadius -- Yes --> ReturnEmpty
- Clone & Install
git clone <repo-url> cd foodtech-backend composer install cp .env.example .env # Configure your DB connection in .env php artisan key:generate
- Install JS dependencies (if needed)
npm install && npm run build - Run Migrations
php artisan migrate
- Install Packages
- Stancl Tenancy: See
config/tenancy.phpfor tenant setup. Models usetenant_idfor scoping. - Spatie Permission: See
config/permission.phpfor guard and model settings. Roles/permissions are ready for seeding. - Filament: Admin panel is ready for resource generation for all major models.
- Generate Filament Resources for admin CRUD UI
- Create Model Factories & Seeders for demo/test data
- Configure tenant-aware routes and middleware
- Set up authentication scaffolding (Breeze, Jetstream, or Fortify)
For more, see the /app/Models/ directory and the migrations for details on relationships and architecture.
FoodTech Backend is developed and maintained by John Gerwin De las Alas.
This project is built for the community as a foundation for modern, scalable, multi-tenant food delivery platforms. Contributions, suggestions, and forks are welcome!
This software is released as CopyFree software by John Gerwin De las Alas.
You are free to use, modify, distribute, and build upon this project for any purpose, commercial or non-commercial, without restriction.
Attribution is appreciated but not required.
For questions, improvements, or to get in touch, please contact John Gerwin De las Alas.