# gungooner/marketplace architecture

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

- Interactive diagram: https://gitdiagram.com/gungooner/marketplace
- Repository: https://github.com/gungooner/marketplace

## Overview

This is a Laravel API for a multi-vendor marketplace, with buyer, vendor, and admin roles. The principal buyer workflow is to browse the public catalogue, manage a cart, place an order, and receive a multi-store order; vendors manage stores and products and update their order statuses, while admins manage categories and earnings. The graph preserves those domain branches and the service/model layers. Some controllers and services are unsampled, so their internal calls are omitted rather than inferred.

Main entry points: [`routes/api.php`](https://github.com/gungooner/marketplace/blob/main/routes/api.php) (API routes), [`app/Services/CheckoutService.php`](https://github.com/gungooner/marketplace/blob/main/app/Services/CheckoutService.php) (Checkout service), [`app/Models/Product.php`](https://github.com/gungooner/marketplace/blob/main/app/Models/Product.php) (Products), [`app/Services/CartService.php`](https://github.com/gungooner/marketplace/blob/main/app/Services/CartService.php) (Cart service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and identity"]
  node_routes["API routes<br/>[api.php]"]
  node_auth["Authentication<br/>[AuthController.php]"]
  node_auth_service["Auth service<br/>[AuthService.php]"]
  node_role_access["Role access"]
  node_response["API responses<br/>[ApiResponse.php]"]
end

subgraph group_catalog["Marketplace catalogue"]
  node_public_catalog["Public catalogue"]
  node_public_stores["Public stores"]
  node_categories["Category management"]
  node_vendor_stores["Vendor stores"]
  node_vendor_products["Vendor products"]
end

subgraph group_commerce["Cart and checkout"]
  node_cart_api["Cart endpoints<br/>[CartController.php]"]
  node_cart_service["Cart service<br/>[CartService.php]"]
  node_checkout_api["Checkout endpoint"]
  node_checkout["Checkout service"]
end

subgraph group_fulfillment["Orders and earnings"]
  node_vendor_orders["Vendor order management"]
  node_status_service["Order status service"]
  node_earnings["Earnings reporting"]
  node_admin_earnings["Admin earnings"]
  node_vendor_earnings["Vendor earnings"]
end

subgraph group_domain["Domain and persistence"]
  node_user[("Users and roles<br/>[User.php]")]
  node_store[("Stores<br/>[Store.php]")]
  node_product[("Products<br/>[Product.php]")]
  node_category[("Categories<br/>[Category.php]")]
  node_cart[("Cart and items<br/>[Cart.php]")]
  node_cart_item[("Cart item<br/>[CartItem.php]")]
  node_order[("Orders<br/>[Order.php]")]
  node_vendor_order[("Vendor orders<br/>[VendorOrder.php]")]
  node_commission["Commission calculator"]
  node_order_status["Order status rules<br/>[OrderStatus.php]"]
  node_user_role["User role enum<br/>[UserRole.php]"]
  node_exceptions["Commerce exceptions"]
end

node_visitor(("Buyer or visitor"))
node_vendor(("Vendor"))
node_admin(("Admin"))

node_visitor -->|"requests"| node_routes
node_vendor -->|"requests"| node_routes
node_admin -->|"requests"| node_routes
node_routes -->|"routes to"| node_auth
node_routes -->|"routes to"| node_public_catalog
node_routes -->|"routes to"| node_public_stores
node_routes -->|"routes to"| node_categories
node_routes -->|"routes to"| node_vendor_stores
node_routes -->|"routes to"| node_vendor_products
node_routes -->|"routes to"| node_cart_api
node_routes -->|"routes to"| node_checkout_api
node_routes -->|"routes to"| node_vendor_orders
node_routes -->|"routes to"| node_admin_earnings
node_routes -->|"routes to"| node_vendor_earnings
node_auth -->|"delegates"| node_auth_service
node_cart_api -->|"delegates"| node_cart_service
node_checkout_api -->|"places order"| node_checkout
node_vendor_orders -->|"transitions status"| node_status_service
node_checkout -->|"calculates commission"| node_commission
node_checkout -->|"creates order"| node_order
node_checkout -->|"creates vendor orders"| node_vendor_order
node_checkout -->|"reserves stock"| node_product
node_checkout -->|"reads cart"| node_cart
node_checkout -->|"reads items"| node_cart_item
node_checkout -->|"raises stock error"| node_exceptions
node_cart_service -->|"uses cart"| node_cart
node_cart_service -->|"manages items"| node_cart_item
node_cart_service -->|"checks product"| node_product
node_user -->|"casts role"| node_user_role
node_product -->|"belongs to"| node_store
node_product -->|"belongs to"| node_category
node_store -->|"has products"| node_product
node_store -->|"has vendor orders"| node_vendor_order
node_order -->|"has vendor orders"| node_vendor_order
node_vendor_orders -->|"parses status"| node_order_status

click node_routes "https://github.com/gungooner/marketplace/blob/main/routes/api.php"
click node_auth "https://github.com/gungooner/marketplace/blob/main/app/Http/Controllers/AuthController.php"
click node_auth_service "https://github.com/gungooner/marketplace/blob/main/app/Services/AuthService.php"
click node_role_access "https://github.com/gungooner/marketplace/blob/main/app/Http/Middleware/EnsureUserHasRole.php"
click node_response "https://github.com/gungooner/marketplace/blob/main/app/Traits/ApiResponse.php"
click node_public_catalog "https://github.com/gungooner/marketplace/blob/main/app/Http/Controllers/PublicProductController.php"
click node_public_stores "https://github.com/gungooner/marketplace/blob/main/app/Http/Controllers/PublicStoreController.php"
click node_categories "https://github.com/gungooner/marketplace/blob/main/app/Http/Controllers/CategoryController.php"
click node_vendor_stores "https://github.com/gungooner/marketplace/blob/main/app/Http/Controllers/StoreController.php"
click node_vendor_products "https://github.com/gungooner/marketplace/blob/main/app/Http/Controllers/VendorProductController.php"
click node_cart_api "https://github.com/gungooner/marketplace/blob/main/app/Http/Controllers/CartController.php"
click node_cart_service "https://github.com/gungooner/marketplace/blob/main/app/Services/CartService.php"
click node_checkout_api "https://github.com/gungooner/marketplace/blob/main/app/Http/Controllers/OrderController.php"
click node_checkout "https://github.com/gungooner/marketplace/blob/main/app/Services/CheckoutService.php"
click node_vendor_orders "https://github.com/gungooner/marketplace/blob/main/app/Http/Controllers/VendorOrderController.php"
click node_status_service "https://github.com/gungooner/marketplace/blob/main/app/Services/OrderStatusService.php"
click node_earnings "https://github.com/gungooner/marketplace/blob/main/app/Services/EarningsService.php"
click node_admin_earnings "https://github.com/gungooner/marketplace/blob/main/app/Http/Controllers/AdminEarningsController.php"
click node_vendor_earnings "https://github.com/gungooner/marketplace/blob/main/app/Http/Controllers/VendorEarningsController.php"
click node_user "https://github.com/gungooner/marketplace/blob/main/app/Models/User.php"
click node_store "https://github.com/gungooner/marketplace/blob/main/app/Models/Store.php"
click node_product "https://github.com/gungooner/marketplace/blob/main/app/Models/Product.php"
click node_category "https://github.com/gungooner/marketplace/blob/main/app/Models/Category.php"
click node_cart "https://github.com/gungooner/marketplace/blob/main/app/Models/Cart.php"
click node_cart_item "https://github.com/gungooner/marketplace/blob/main/app/Models/CartItem.php"
click node_order "https://github.com/gungooner/marketplace/blob/main/app/Models/Order.php"
click node_vendor_order "https://github.com/gungooner/marketplace/blob/main/app/Models/VendorOrder.php"
click node_commission "https://github.com/gungooner/marketplace/blob/main/app/Contracts/CommissionCalculator.php"
click node_order_status "https://github.com/gungooner/marketplace/blob/main/app/Enums/OrderStatus.php"
click node_user_role "https://github.com/gungooner/marketplace/blob/main/app/Enums/UserRole.php"
click node_exceptions "https://github.com/gungooner/marketplace/blob/main/app/Exceptions/InsufficientStockException.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_routes,node_auth,node_auth_service,node_role_access,node_response toneBlue
class node_public_catalog,node_public_stores,node_categories,node_vendor_stores,node_vendor_products toneAmber
class node_cart_api,node_cart_service,node_checkout_api,node_checkout toneMint
class node_vendor_orders,node_status_service,node_earnings,node_admin_earnings,node_vendor_earnings toneRose
class node_user,node_store,node_product,node_category,node_cart,node_cart_item,node_order,node_vendor_order,node_commission,node_order_status,node_user_role,node_exceptions,node_visitor,node_vendor,node_admin toneIndigo
```

## Components

### API and identity

- [API routes](https://github.com/gungooner/marketplace/blob/main/routes/api.php): `routes/api.php`
- [Authentication](https://github.com/gungooner/marketplace/blob/main/app/Http/Controllers/AuthController.php): `app/Http/Controllers/AuthController.php`
- [Auth service](https://github.com/gungooner/marketplace/blob/main/app/Services/AuthService.php): `app/Services/AuthService.php`
- [Role access](https://github.com/gungooner/marketplace/blob/main/app/Http/Middleware/EnsureUserHasRole.php): `app/Http/Middleware/EnsureUserHasRole.php`
- [API responses](https://github.com/gungooner/marketplace/blob/main/app/Traits/ApiResponse.php): `app/Traits/ApiResponse.php`

### Marketplace catalogue

- [Public catalogue](https://github.com/gungooner/marketplace/blob/main/app/Http/Controllers/PublicProductController.php): `app/Http/Controllers/PublicProductController.php`
- [Public stores](https://github.com/gungooner/marketplace/blob/main/app/Http/Controllers/PublicStoreController.php): `app/Http/Controllers/PublicStoreController.php`
- [Category management](https://github.com/gungooner/marketplace/blob/main/app/Http/Controllers/CategoryController.php): `app/Http/Controllers/CategoryController.php`
- [Vendor stores](https://github.com/gungooner/marketplace/blob/main/app/Http/Controllers/StoreController.php): `app/Http/Controllers/StoreController.php`
- [Vendor products](https://github.com/gungooner/marketplace/blob/main/app/Http/Controllers/VendorProductController.php): `app/Http/Controllers/VendorProductController.php`

### Cart and checkout

- [Cart endpoints](https://github.com/gungooner/marketplace/blob/main/app/Http/Controllers/CartController.php): `app/Http/Controllers/CartController.php`
- [Cart service](https://github.com/gungooner/marketplace/blob/main/app/Services/CartService.php): `app/Services/CartService.php`
- [Checkout endpoint](https://github.com/gungooner/marketplace/blob/main/app/Http/Controllers/OrderController.php): `app/Http/Controllers/OrderController.php`
- [Checkout service](https://github.com/gungooner/marketplace/blob/main/app/Services/CheckoutService.php): `app/Services/CheckoutService.php`

### Orders and earnings

- [Vendor order management](https://github.com/gungooner/marketplace/blob/main/app/Http/Controllers/VendorOrderController.php): `app/Http/Controllers/VendorOrderController.php`
- [Order status service](https://github.com/gungooner/marketplace/blob/main/app/Services/OrderStatusService.php): `app/Services/OrderStatusService.php`
- [Earnings reporting](https://github.com/gungooner/marketplace/blob/main/app/Services/EarningsService.php): `app/Services/EarningsService.php`
- [Admin earnings](https://github.com/gungooner/marketplace/blob/main/app/Http/Controllers/AdminEarningsController.php): `app/Http/Controllers/AdminEarningsController.php`
- [Vendor earnings](https://github.com/gungooner/marketplace/blob/main/app/Http/Controllers/VendorEarningsController.php): `app/Http/Controllers/VendorEarningsController.php`

### Domain and persistence

- [Users and roles](https://github.com/gungooner/marketplace/blob/main/app/Models/User.php): `app/Models/User.php`
- [Stores](https://github.com/gungooner/marketplace/blob/main/app/Models/Store.php): `app/Models/Store.php`
- [Products](https://github.com/gungooner/marketplace/blob/main/app/Models/Product.php): `app/Models/Product.php`
- [Categories](https://github.com/gungooner/marketplace/blob/main/app/Models/Category.php): `app/Models/Category.php`
- [Cart and items](https://github.com/gungooner/marketplace/blob/main/app/Models/Cart.php): `app/Models/Cart.php`
- [Cart item](https://github.com/gungooner/marketplace/blob/main/app/Models/CartItem.php): `app/Models/CartItem.php`
- [Orders](https://github.com/gungooner/marketplace/blob/main/app/Models/Order.php): `app/Models/Order.php`
- [Vendor orders](https://github.com/gungooner/marketplace/blob/main/app/Models/VendorOrder.php): `app/Models/VendorOrder.php`
- [Commission calculator](https://github.com/gungooner/marketplace/blob/main/app/Contracts/CommissionCalculator.php): `app/Contracts/CommissionCalculator.php`
- [Order status rules](https://github.com/gungooner/marketplace/blob/main/app/Enums/OrderStatus.php): `app/Enums/OrderStatus.php`
- [User role enum](https://github.com/gungooner/marketplace/blob/main/app/Enums/UserRole.php): `app/Enums/UserRole.php`
- [Commerce exceptions](https://github.com/gungooner/marketplace/blob/main/app/Exceptions/InsufficientStockException.php): `app/Exceptions/InsufficientStockException.php`

### Other components

- **Buyer or visitor**
- **Vendor**
- **Admin**

## Connections

- Buyer or visitor → API routes: requests
- Vendor → API routes: requests
- Admin → API routes: requests
- API routes → Authentication: routes to (evidence: `routes/api.php`)
- API routes → Public catalogue: routes to (evidence: `routes/api.php`)
- API routes → Public stores: routes to (evidence: `routes/api.php`)
- API routes → Category management: routes to (evidence: `routes/api.php`)
- API routes → Vendor stores: routes to (evidence: `routes/api.php`)
- API routes → Vendor products: routes to (evidence: `routes/api.php`)
- API routes → Cart endpoints: routes to (evidence: `routes/api.php`)
- API routes → Checkout endpoint: routes to (evidence: `routes/api.php`)
- API routes → Vendor order management: routes to (evidence: `routes/api.php`)
- API routes → Admin earnings: routes to (evidence: `routes/api.php`)
- API routes → Vendor earnings: routes to (evidence: `routes/api.php`)
- Authentication → Auth service: delegates (evidence: `app/Http/Controllers/AuthController.php`)
- Cart endpoints → Cart service: delegates (evidence: `app/Http/Controllers/CartController.php`)
- Checkout endpoint → Checkout service: places order (evidence: `app/Http/Controllers/OrderController.php`)
- Vendor order management → Order status service: transitions status (evidence: `app/Http/Controllers/VendorOrderController.php`)
- Checkout service → Commission calculator: calculates commission (evidence: `app/Services/CheckoutService.php`)
- Checkout service → Orders: creates order (evidence: `app/Services/CheckoutService.php`)
- Checkout service → Vendor orders: creates vendor orders (evidence: `app/Services/CheckoutService.php`)
- Checkout service → Products: reserves stock (evidence: `app/Services/CheckoutService.php`)
- Checkout service → Cart and items: reads cart (evidence: `app/Services/CheckoutService.php`)
- Checkout service → Cart item: reads items (evidence: `app/Services/CheckoutService.php`)
- Checkout service → Commerce exceptions: raises stock error (evidence: `app/Services/CheckoutService.php`)
- Cart service → Cart and items: uses cart (evidence: `app/Services/CartService.php`)
- Cart service → Cart item: manages items (evidence: `app/Services/CartService.php`)
- Cart service → Products: checks product (evidence: `app/Services/CartService.php`)
- Users and roles → User role enum: casts role (evidence: `app/Models/User.php`)
- Products → Stores: belongs to (evidence: `app/Models/Product.php`)
- Products → Categories: belongs to (evidence: `app/Models/Product.php`)
- Stores → Products: has products (evidence: `app/Models/Store.php`)
- Stores → Vendor orders: has vendor orders (evidence: `app/Models/Store.php`)
- Orders → Vendor orders: has vendor orders (evidence: `app/Models/Order.php`)
- Vendor order management → Order status rules: parses status (evidence: `app/Http/Controllers/VendorOrderController.php`)
