# Architecture

FoodPortal uses a central Laravel application with a multi-tenant model. The marketplace is served from the main domain. Custom restaurant domains are stored in restaurant_domains and resolved by middleware. The same restaurant, menu, cart, checkout and order tables are used for both domain types.

## Tenant concept
A restaurant is the tenant. It owns domains, categories, products, delivery areas, storefront blocks and orders.

## Storefront builder
Storefront blocks are stored in storefront_blocks. Each block has type, title, settings JSON, is_enabled and sort_order. Restaurant admin and portal admin can enable/disable blocks.

## Menu page order
Hero slider first, category buttons after hero, top products, then full categories and product cards.

## Cart calculation
Product price + add-ons. Product inherits tax from product override or category tax. Delivery fee is applied after delivery area match.
