# chana758/food_shop_backend architecture

> Architecture diagram of the GitHub repository chana758/food_shop_backend, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/chana758/food_shop_backend
- Repository: https://github.com/chana758/food_shop_backend

## Overview

Khmer-Fresh is a Laravel restaurant-ordering backend powering a customer storefront and admin/POS dashboard. The principal workflow is API requests routed to domain controllers, which manage catalog discovery, order creation and payment, then support fulfillment and reservations; models persist the system’s records. Separate capabilities cover customer engagement, operations reporting, and real-time updates. The map follows documented features and visible route/controller references; several unsampled features have only directory-level nodes, so uncertain implementation links are omitted.

Main entry points: [`routes/api.php`](https://github.com/chana758/food_shop_backend/blob/main/routes/api.php) (API routes), [`app/Http/Controllers/OrderController.php`](https://github.com/chana758/food_shop_backend/blob/main/app/Http/Controllers/OrderController.php) (Order management), [`app/Http/Controllers/Admin/DashboardController.php`](https://github.com/chana758/food_shop_backend/blob/main/app/Http/Controllers/Admin/DashboardController.php) (POS dashboard), [`app/Models/Product.php`](https://github.com/chana758/food_shop_backend/blob/main/app/Models/Product.php) (Product catalog)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API entry"]
  node_api_routes["API routes<br/>[api.php]"]
  node_auth["Authentication<br/>[AuthController.php]"]
  node_users["Staff and customers<br/>[UserController.php]"]
end

subgraph group_commerce["Commerce workflow"]
  node_catalog["Catalog and search"]
  node_categories["Categories"]
  node_products[("Product catalog<br/>[Product.php]")]
  node_category_model[("Category records<br/>[Category.php]")]
  node_orders["Order management"]
  node_order_data[("Orders and items<br/>[Order.php]")]
  node_payments["Payment processing"]
  node_payment_data[("Payment records<br/>[Payment.php]")]
  node_inventory["Stock adjustment"]
end

subgraph group_operations["Restaurant operations"]
  node_reservations["Reservations"]
  node_tables["Tables"]
  node_delivery["Rider delivery"]
  node_dashboard["POS dashboard"]
  node_reports["Reports"]
  node_backup["Backups"]
end

subgraph group_engagement["Customer engagement"]
  node_favorites["Favorites"]
  node_reviews["Reviews"]
  node_contacts["Contact messages"]
  node_notifications["Notifications"]
end

subgraph group_platform["Persistence and events"]
  node_order_events["Order events"]
  node_reservation_events["Reservation events"]
  node_database[("PostgreSQL database")]
  node_reverb["Laravel Reverb"]
end

node_storefront(("Storefront clients"))
node_bakong["Bakong KHQR"]

node_storefront -->|"sends requests"| node_api_routes
node_api_routes -->|"routes to"| node_catalog
node_api_routes -->|"routes to"| node_categories
node_api_routes -->|"routes to"| node_orders
node_api_routes -->|"routes to"| node_payments
node_api_routes -->|"routes to"| node_reservations
node_api_routes -->|"routes to"| node_auth
node_api_routes -->|"routes to"| node_favorites
node_api_routes -->|"routes to"| node_reviews
node_api_routes -->|"routes to"| node_contacts
node_api_routes -->|"routes to"| node_notifications
node_api_routes -->|"routes to"| node_dashboard
node_api_routes -->|"routes to"| node_users
node_orders -->|"reads and writes"| node_order_data
node_orders -->|"adjusts stock"| node_inventory
node_orders -->|"dispatches"| node_order_events
node_payments -->|"reads and writes"| node_payment_data
node_payments -->|"updates orders"| node_order_data
node_orders -->|"verifies KHQR"| node_bakong
node_catalog -->|"manages"| node_products
node_categories -->|"manages"| node_category_model
node_products -->|"belongs to"| node_category_model
node_dashboard -->|"queries"| node_order_data
node_dashboard -->|"queries"| node_payment_data
node_dashboard -->|"queries"| node_products
node_dashboard -.->|"offers reporting"| node_reports
node_reports -->|"aggregates"| node_order_data
node_reports -->|"analyzes sales"| node_products
node_reservations -->|"dispatches"| node_reservation_events
node_orders -.->|"assigns fulfillment"| node_delivery
node_favorites -.->|"persists favorites"| node_database
node_reviews -->|"persists reviews"| node_database
node_contacts -->|"creates notices"| node_notifications
node_order_events -.->|"broadcasts"| node_reverb
node_reservations -.->|"persists bookings"| node_database
node_backup -.->|"backs up"| node_database
node_auth -.->|"authenticates users"| node_database

click node_api_routes "https://github.com/chana758/food_shop_backend/blob/main/routes/api.php"
click node_catalog "https://github.com/chana758/food_shop_backend/blob/main/app/Http/Controllers/ProductController.php"
click node_categories "https://github.com/chana758/food_shop_backend/blob/main/app/Http/Controllers/CategoryController.php"
click node_products "https://github.com/chana758/food_shop_backend/blob/main/app/Models/Product.php"
click node_category_model "https://github.com/chana758/food_shop_backend/blob/main/app/Models/Category.php"
click node_orders "https://github.com/chana758/food_shop_backend/blob/main/app/Http/Controllers/OrderController.php"
click node_order_data "https://github.com/chana758/food_shop_backend/blob/main/app/Models/Order.php"
click node_payments "https://github.com/chana758/food_shop_backend/blob/main/app/Http/Controllers/PaymentController.php"
click node_payment_data "https://github.com/chana758/food_shop_backend/blob/main/app/Models/Payment.php"
click node_inventory "https://github.com/chana758/food_shop_backend/blob/main/app/Services/InventoryService.php"
click node_reservations "https://github.com/chana758/food_shop_backend/blob/main/app/Http/Controllers/ReservationController.php"
click node_tables "https://github.com/chana758/food_shop_backend/blob/main/app/Http/Controllers/TableController.php"
click node_delivery "https://github.com/chana758/food_shop_backend/blob/main/app/Http/Controllers/RiderController.php"
click node_dashboard "https://github.com/chana758/food_shop_backend/blob/main/app/Http/Controllers/Admin/DashboardController.php"
click node_reports "https://github.com/chana758/food_shop_backend/blob/main/app/Http/Controllers/Api/Admin/ReportController.php"
click node_backup "https://github.com/chana758/food_shop_backend/blob/main/app/Http/Controllers/Api/BackupController.php"
click node_auth "https://github.com/chana758/food_shop_backend/blob/main/app/Http/Controllers/AuthController.php"
click node_users "https://github.com/chana758/food_shop_backend/blob/main/app/Http/Controllers/UserController.php"
click node_favorites "https://github.com/chana758/food_shop_backend/blob/main/app/Http/Controllers/FavoriteController.php"
click node_reviews "https://github.com/chana758/food_shop_backend/blob/main/app/Http/Controllers/ReviewController.php"
click node_contacts "https://github.com/chana758/food_shop_backend/blob/main/app/Http/Controllers/ContactController.php"
click node_notifications "https://github.com/chana758/food_shop_backend/blob/main/app/Http/Controllers/NotificationController.php"
click node_order_events "https://github.com/chana758/food_shop_backend/blob/main/app/Events/OrderStatusChanged.php"
click node_reservation_events "https://github.com/chana758/food_shop_backend/blob/main/app/Events/ReservationStatusChanged.php"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_api_routes,node_auth,node_users,node_storefront toneBlue
class node_catalog,node_categories,node_products,node_category_model,node_orders,node_order_data,node_payments,node_payment_data,node_inventory toneAmber
class node_reservations,node_tables,node_delivery,node_dashboard,node_reports,node_backup toneMint
class node_favorites,node_reviews,node_contacts,node_notifications toneRose
class node_order_events,node_reservation_events,node_database,node_reverb,node_bakong toneIndigo
```

## Components

### API entry

- [API routes](https://github.com/chana758/food_shop_backend/blob/main/routes/api.php): `routes/api.php`
- [Authentication](https://github.com/chana758/food_shop_backend/blob/main/app/Http/Controllers/AuthController.php): `app/Http/Controllers/AuthController.php`
- [Staff and customers](https://github.com/chana758/food_shop_backend/blob/main/app/Http/Controllers/UserController.php): `app/Http/Controllers/UserController.php`

### Commerce workflow

- [Catalog and search](https://github.com/chana758/food_shop_backend/blob/main/app/Http/Controllers/ProductController.php): `app/Http/Controllers/ProductController.php`
- [Categories](https://github.com/chana758/food_shop_backend/blob/main/app/Http/Controllers/CategoryController.php): `app/Http/Controllers/CategoryController.php`
- [Product catalog](https://github.com/chana758/food_shop_backend/blob/main/app/Models/Product.php): `app/Models/Product.php`
- [Category records](https://github.com/chana758/food_shop_backend/blob/main/app/Models/Category.php): `app/Models/Category.php`
- [Order management](https://github.com/chana758/food_shop_backend/blob/main/app/Http/Controllers/OrderController.php): `app/Http/Controllers/OrderController.php`
- [Orders and items](https://github.com/chana758/food_shop_backend/blob/main/app/Models/Order.php): `app/Models/Order.php`
- [Payment processing](https://github.com/chana758/food_shop_backend/blob/main/app/Http/Controllers/PaymentController.php): `app/Http/Controllers/PaymentController.php`
- [Payment records](https://github.com/chana758/food_shop_backend/blob/main/app/Models/Payment.php): `app/Models/Payment.php`
- [Stock adjustment](https://github.com/chana758/food_shop_backend/blob/main/app/Services/InventoryService.php): `app/Services/InventoryService.php`

### Restaurant operations

- [Reservations](https://github.com/chana758/food_shop_backend/blob/main/app/Http/Controllers/ReservationController.php): `app/Http/Controllers/ReservationController.php`
- [Tables](https://github.com/chana758/food_shop_backend/blob/main/app/Http/Controllers/TableController.php): `app/Http/Controllers/TableController.php`
- [Rider delivery](https://github.com/chana758/food_shop_backend/blob/main/app/Http/Controllers/RiderController.php): `app/Http/Controllers/RiderController.php`
- [POS dashboard](https://github.com/chana758/food_shop_backend/blob/main/app/Http/Controllers/Admin/DashboardController.php): `app/Http/Controllers/Admin/DashboardController.php`
- [Reports](https://github.com/chana758/food_shop_backend/blob/main/app/Http/Controllers/Api/Admin/ReportController.php): `app/Http/Controllers/Api/Admin/ReportController.php`
- [Backups](https://github.com/chana758/food_shop_backend/blob/main/app/Http/Controllers/Api/BackupController.php): `app/Http/Controllers/Api/BackupController.php`

### Customer engagement

- [Favorites](https://github.com/chana758/food_shop_backend/blob/main/app/Http/Controllers/FavoriteController.php): `app/Http/Controllers/FavoriteController.php`
- [Reviews](https://github.com/chana758/food_shop_backend/blob/main/app/Http/Controllers/ReviewController.php): `app/Http/Controllers/ReviewController.php`
- [Contact messages](https://github.com/chana758/food_shop_backend/blob/main/app/Http/Controllers/ContactController.php): `app/Http/Controllers/ContactController.php`
- [Notifications](https://github.com/chana758/food_shop_backend/blob/main/app/Http/Controllers/NotificationController.php): `app/Http/Controllers/NotificationController.php`

### Persistence and events

- [Order events](https://github.com/chana758/food_shop_backend/blob/main/app/Events/OrderStatusChanged.php): `app/Events/OrderStatusChanged.php`
- [Reservation events](https://github.com/chana758/food_shop_backend/blob/main/app/Events/ReservationStatusChanged.php): `app/Events/ReservationStatusChanged.php`
- **PostgreSQL database**
- **Laravel Reverb**

### Other components

- **Storefront clients**
- **Bakong KHQR**

## Connections

- Storefront clients → API routes: sends requests (evidence: `README.md`)
- API routes → Catalog and search: routes to (evidence: `routes/api.php`)
- API routes → Categories: routes to (evidence: `routes/api.php`)
- API routes → Order management: routes to (evidence: `routes/api.php`)
- API routes → Payment processing: routes to (evidence: `routes/api.php`)
- API routes → Reservations: routes to (evidence: `routes/api.php`)
- API routes → Authentication: routes to (evidence: `routes/api.php`)
- API routes → Favorites: routes to (evidence: `routes/api.php`)
- API routes → Reviews: routes to (evidence: `routes/api.php`)
- API routes → Contact messages: routes to (evidence: `routes/api.php`)
- API routes → Notifications: routes to (evidence: `routes/api.php`)
- API routes → POS dashboard: routes to (evidence: `routes/api.php`)
- API routes → Staff and customers: routes to (evidence: `routes/api.php`)
- Order management → Orders and items: reads and writes (evidence: `app/Http/Controllers/OrderController.php`)
- Order management → Stock adjustment: adjusts stock (evidence: `app/Http/Controllers/OrderController.php`)
- Order management → Order events: dispatches (evidence: `app/Http/Controllers/OrderController.php`)
- Payment processing → Payment records: reads and writes (evidence: `app/Http/Controllers/PaymentController.php`)
- Payment processing → Orders and items: updates orders (evidence: `app/Http/Controllers/PaymentController.php`)
- Order management → Bakong KHQR: verifies KHQR (evidence: `app/Http/Controllers/OrderController.php`)
- Catalog and search → Product catalog: manages
- Categories → Category records: manages (evidence: `app/Http/Controllers/CategoryController.php`)
- Product catalog → Category records: belongs to (evidence: `app/Models/Product.php`)
- POS dashboard → Orders and items: queries (evidence: `app/Http/Controllers/Admin/DashboardController.php`)
- POS dashboard → Payment records: queries (evidence: `app/Http/Controllers/Admin/DashboardController.php`)
- POS dashboard → Product catalog: queries (evidence: `app/Http/Controllers/Admin/DashboardController.php`)
- POS dashboard → Reports: offers reporting
- Reports → Orders and items: aggregates (evidence: `app/Http/Controllers/Api/Admin/ReportController.php`)
- Reports → Product catalog: analyzes sales (evidence: `app/Http/Controllers/Api/Admin/ReportController.php`)
- Reservations → Reservation events: dispatches (evidence: `app/Http/Controllers/ReservationController.php`)
- Order management → Rider delivery: assigns fulfillment
- Favorites → PostgreSQL database: persists favorites
- Reviews → PostgreSQL database: persists reviews (evidence: `app/Http/Controllers/ReviewController.php`)
- Contact messages → Notifications: creates notices (evidence: `app/Http/Controllers/ContactController.php`)
- Order events → Laravel Reverb: broadcasts
- Reservations → PostgreSQL database: persists bookings
- Backups → PostgreSQL database: backs up
- Authentication → PostgreSQL database: authenticates users
