command: for f in specs/01-DATABASE-SCHEMA.md specs/02-API-ROUTES.md specs/03-ADMIN-UI.md specs/04-STOREFRONT-UI.md specs/05-BUSINESS-LOGIC.md specs/06-AUTH-AND-SECURITY.md specs/07-SEEDERS-AND-TEST-DATA.md specs/08-PLAYWRIGHT-E2E-PLAN.md; do echo "--- $f"; rg -n '^#{1,4} ' "$f"; done

stdout:
--- specs/01-DATABASE-SCHEMA.md
1:# 01 - Database Schema Specification
7:## Conventions
23:## Epic 1 - Foundation and Multi-Store Tenancy
25:### organizations
43:### stores
68:### store_domains
90:### users
119:### store_users
139:### store_settings
153:## Epic 2 - Catalog, Collections, Inventory, and Media
155:### products
187:### product_options
205:### product_option_values
223:### product_variants
256:### variant_option_values
275:### inventory_items
297:### collections
321:### collection_products
340:### product_media
367:## Epic 3 - Themes, Storefront, and Localization
369:### themes
391:### theme_files
411:### theme_settings
423:### pages
447:### navigation_menus
467:### navigation_items
490:## Epic 4 - Search
492:### search_settings
505:### search_queries
526:## Epic 5 - Cart, Checkout, Discounts, Shipping, and Taxes
528:### carts
553:### cart_lines
577:### checkouts
612:### shipping_zones
632:### shipping_rates
658:### tax_settings
672:### discounts
704:## Epic 6 - Payments, Orders, Fulfillment, and Customers
706:### customers
730:### customer_addresses
751:### orders
790:### order_lines
818:### payments
846:### refunds
869:### fulfillments
892:### fulfillment_lines
912:## Epic 7 - Analytics
914:### analytics_events
943:### analytics_daily
969:## Epic 8 - Apps and Webhooks
971:### apps
988:### app_installations
1009:### oauth_clients
1028:### oauth_tokens
1048:### webhook_subscriptions
1070:### webhook_deliveries
1094:## Laravel Framework Tables
1098:### sessions
1109:### cache
1117:### cache_locks
1125:### jobs
1137:### job_batches
1152:### failed_jobs
1164:### personal_access_tokens
1179:### password_reset_tokens
1189:### customer_password_reset_tokens
1202:## Entity Relationship Diagrams
1204:### Epic 1 - Foundation and Tenancy
1251:### Epic 2 - Catalog, Collections, Inventory, and Media
1318:### Epic 3 - Themes, Storefront, and Localization
1367:### Epics 5-6 - Cart, Checkout, Orders, and Payments
1428:### Epics 7-8 - Analytics, Apps, and Webhooks
1482:## SQLite-Specific Configuration Requirements
1486:### Required PRAGMA Settings
1496:### Laravel Configuration Requirements
1507:## Migration Dependency Graph
1641:### Batch Details
1653:## Index Strategy Rationale
1669:## Table Count Summary
--- specs/02-API-ROUTES.md
1:# API and Routing Specification
9:## 1. Web Routes (Blade/Livewire Pages)
11:### 1.1 Admin Auth Routes
29:### 1.2 Admin Routes
38:#### Dashboard
44:#### Products
52:#### Inventory
58:#### Collections
66:#### Orders
73:#### Customers
80:#### Discounts
88:#### Settings
96:#### Themes and Online Store
103:#### Pages
111:#### Navigation
117:#### Apps
124:#### Developers
132:#### Analytics
138:#### Search Settings
146:### 1.3 Storefront Routes
162:#### Customer Account Routes
173:#### Customer Auth Routes (no auth required)
186:### 1.4 Checkout Routes
197:## 2. Storefront REST API
207:### 2.1 Cart Endpoints
209:#### POST /api/storefront/v1/carts
255:#### GET /api/storefront/v1/carts/{cartId}
313:#### POST /api/storefront/v1/carts/{cartId}/lines
354:#### PUT /api/storefront/v1/carts/{cartId}/lines/{lineId}
386:#### DELETE /api/storefront/v1/carts/{cartId}/lines/{lineId}
415:### 2.2 Checkout Endpoints
417:#### Checkout Flow Sequence Diagram
458:#### POST /api/storefront/v1/checkouts
524:#### GET /api/storefront/v1/checkouts/{checkoutId}
541:#### PUT /api/storefront/v1/checkouts/{checkoutId}/address
661:#### PUT /api/storefront/v1/checkouts/{checkoutId}/shipping-method
721:#### PUT /api/storefront/v1/checkouts/{checkoutId}/payment-method
767:#### POST /api/storefront/v1/checkouts/{checkoutId}/apply-discount
829:#### DELETE /api/storefront/v1/checkouts/{checkoutId}/discount
846:### 2.3 Payment Endpoint
848:#### POST /api/storefront/v1/checkouts/{checkoutId}/pay
956:### 2.4 Order Endpoints
958:#### GET /api/storefront/v1/orders/{orderNumber}
1017:### 2.5 Search Endpoints
1019:#### GET /api/storefront/v1/search
1097:#### GET /api/storefront/v1/search/suggest
1141:### 2.6 Analytics Endpoints
1143:#### POST /api/storefront/v1/analytics/events
1206:## 3. Admin REST API
1218:### 3.1 Platform Management (Super-Admin Only)
1222:#### POST /api/admin/v1/platform/organizations
1263:#### POST /api/admin/v1/platform/stores
1316:#### POST /api/admin/v1/stores/{storeId}/invites
1357:#### GET /api/admin/v1/stores/{storeId}/me
1393:### 3.2 Products
1395:#### Admin Products Endpoint Summary
1406:#### GET /api/admin/v1/stores/{storeId}/products
1457:#### POST /api/admin/v1/stores/{storeId}/products
1547:#### GET /api/admin/v1/stores/{storeId}/products/{productId}
1645:#### PUT /api/admin/v1/stores/{storeId}/products/{productId}
1672:#### DELETE /api/admin/v1/stores/{storeId}/products/{productId}
1694:#### POST /api/admin/v1/stores/{storeId}/products/{productId}/media/presign-upload
1736:### 3.3 Collections
1738:#### Admin Collections Endpoint Summary
1747:#### GET /api/admin/v1/stores/{storeId}/collections
1789:#### POST /api/admin/v1/stores/{storeId}/collections
1825:#### PUT /api/admin/v1/stores/{storeId}/collections/{collectionId}
1840:#### DELETE /api/admin/v1/stores/{storeId}/collections/{collectionId}
1860:### 3.4 Orders
1862:#### Admin Orders Endpoint Summary
1871:#### GET /api/admin/v1/stores/{storeId}/orders
1928:#### GET /api/admin/v1/stores/{storeId}/orders/{orderId}
2016:#### POST /api/admin/v1/stores/{storeId}/orders/{orderId}/fulfillments
2077:#### POST /api/admin/v1/stores/{storeId}/orders/{orderId}/refunds
2132:### 3.5 Discounts
2134:#### Admin Discounts Endpoint Summary
2143:#### GET /api/admin/v1/stores/{storeId}/discounts
2192:#### POST /api/admin/v1/stores/{storeId}/discounts
2243:#### PUT /api/admin/v1/stores/{storeId}/discounts/{discountId}
2258:#### DELETE /api/admin/v1/stores/{storeId}/discounts/{discountId}
2278:### 3.6 Shipping
2280:#### Admin Shipping Endpoint Summary
2289:#### GET /api/admin/v1/stores/{storeId}/shipping/zones
2337:#### POST /api/admin/v1/stores/{storeId}/shipping/zones
2365:#### PUT /api/admin/v1/stores/{storeId}/shipping/zones/{zoneId}
2380:#### POST /api/admin/v1/stores/{storeId}/shipping/zones/{zoneId}/rates
2414:### 3.7 Tax Settings
2416:#### Admin Tax Endpoint Summary
2423:#### GET /api/admin/v1/stores/{storeId}/tax/settings
2460:#### PUT /api/admin/v1/stores/{storeId}/tax/settings
2492:### 3.8 Themes
2494:#### Admin Themes Endpoint Summary
2502:#### POST /api/admin/v1/stores/{storeId}/themes
2535:#### POST /api/admin/v1/stores/{storeId}/themes/{themeId}/publish
2558:#### PUT /api/admin/v1/stores/{storeId}/themes/{themeId}/settings
2598:### 3.9 Pages
2600:#### Admin Pages Endpoint Summary
2609:#### GET /api/admin/v1/stores/{storeId}/pages
2648:#### POST /api/admin/v1/stores/{storeId}/pages
2678:#### PUT /api/admin/v1/stores/{storeId}/pages/{pageId}
2693:#### DELETE /api/admin/v1/stores/{storeId}/pages/{pageId}
2713:### 3.10 Search Admin
2715:#### Admin Search Endpoint Summary
2722:#### POST /api/admin/v1/stores/{storeId}/search/reindex
2743:#### GET /api/admin/v1/stores/{storeId}/search/status
2764:### 3.11 Analytics and Exports
2766:#### Admin Analytics Endpoint Summary
2774:#### GET /api/admin/v1/stores/{storeId}/analytics/summary
2834:#### POST /api/admin/v1/stores/{storeId}/exports/orders
2868:#### GET /api/admin/v1/stores/{storeId}/exports/{exportId}
2897:## 4. Webhook Receiver Endpoints
2903:## 5. OAuth Endpoints (App Ecosystem)
2911:### GET /oauth/authorize
2931:### POST /oauth/token
2977:### App API Endpoints
2991:## 6. Middleware Stack
2993:### 6.1 Route Group Middleware
2995:#### Web (default)
3008:#### Admin
3019:#### Storefront
3027:#### API Storefront
3036:#### API Admin
3048:### 6.2 Custom Middleware Definitions
3050:#### `store.resolve`
3066:#### `role.check`
3074:## 7. Rate Limiting Configuration
3076:### Rate Limit Tiers
3088:### Rate Limit Response
3107:### Per-Endpoint Rate Limit Mapping
3134:## 8. Checkout State Machine
3154:### Checkout Status Transition Table
3169:## 9. API Versioning Strategy
3180:## 10. Error Response Format
3184:### Validation Errors (422)
3196:### Authorization Errors (403)
3204:### Not Found Errors (404)
3212:### Conflict Errors (409)
3222:### Business Logic Errors (400)
3231:### Server Errors (500, 502)
--- specs/03-ADMIN-UI.md
1:# 03 - Admin Panel UI/UX Specification
11:## 1. Admin Layout Shell
15:### 1.1 Route Prefix
19:### 1.2 Sidebar Navigation
25:#### Component Requirements
36:#### Wireframe
77:#### Navigation Structure
103:#### Flux Component Mapping
111:#### Responsive Behavior
116:### 1.3 Top Bar
122:#### Component Requirements
134:#### Wireframe
153:#### Interaction Flows
159:#### Flux Component Mapping
171:### 1.4 Main Content Area
179:### 1.5 Toast Notifications
194:### 1.6 Dark Mode
202:## 2. Dashboard
210:### Component Requirements
242:### Wireframe
271:### Layout Description
277:### KPI Tiles Row
288:### Orders Chart
296:### Top Products Table
304:### Conversion Funnel
313:### Flux Component Mapping
326:### View States
337:## 3. Products List
345:### Component Requirements
374:### Wireframe
396:### Table Column Definitions
409:### Bulk Action Bar
417:### Empty State
425:### Delete Confirmation Modal
436:### Flux Component Mapping
453:### View States
464:## 4. Product Create/Edit
472:### Component Requirements
511:### Validation Rules
527:### Two-Column Layout Wireframe
579:### Left Column Sections
581:#### Title Input
586:#### Description
591:#### Media Section
603:#### Variants Section
626:#### SEO Section
631:### Right Column Sections
633:#### Status Card
637:#### Publishing Card
641:#### Product Organization Card
646:#### Collections Card
651:### Sticky Save Bar
658:### Delete Confirmation Modal (Edit Only)
669:### Flux Component Mapping
688:### View States
700:## 5. Collections List and Edit
702:### 5.1 Collections List
710:#### Component Requirements
726:#### Layout
733:#### Table Columns
744:### 5.2 Collection Edit/Create
752:#### Component Requirements
776:#### Layout Wireframe
819:## 6. Inventory Management
827:### Component Requirements
838:### Wireframe
854:### Layout
862:## 7. Orders List
870:### Component Requirements
889:### Wireframe
908:### Filter Tabs
912:### Table Column Definitions
925:### Flux Component Mapping
936:## 8. Order Detail
944:### Component Requirements
968:### Two-Column Layout Wireframe
1007:### Left Column Sections
1009:#### Order Heading
1015:#### Action Buttons
1021:#### Fulfillment Guard
1029:#### Timeline
1034:#### Order Lines Table
1044:#### Order Summary
1049:#### Payment Details
1057:#### Fulfillment Cards
1067:### Right Column Sections
1069:#### Customer Card
1076:#### Shipping Address Card
1081:#### Billing Address Card
1084:### Fulfillment Modal
1100:### Refund Modal
1115:### Flux Component Mapping
1134:## 9. Customers List and Detail
1136:### 9.1 Customers List
1144:#### Component Requirements
1154:#### Layout
1161:### 9.2 Customer Detail
1169:#### Component Requirements
1186:#### Two-Column Layout Wireframe
1215:#### Address Modal
1233:## 10. Discounts List and Form
1235:### 10.1 Discounts List
1243:#### Component Requirements
1254:#### Layout
1259:#### Table Columns
1270:### 10.2 Discount Form
1278:#### Component Requirements
1307:#### Layout Wireframe (Single Column)
1351:#### Section Details
1378:## 11. Settings Pages
1380:### 11.1 General Settings
1388:#### Component Requirements
1402:#### Layout
1421:### 11.2 Domains Settings
1429:#### Component Requirements
1443:#### Layout
1458:#### Add Domain Modal
1471:### 11.3 Shipping Settings
1479:#### Component Requirements
1505:#### Layout Wireframe
1545:#### Zone Modal
1558:#### Rate Modal
1577:#### Test Shipping Address Tool
1588:### 11.4 Tax Settings
1596:#### Component Requirements
1612:#### Layout Wireframe
1655:## 12. Themes Management
1657:### 12.1 Themes List
1665:#### Component Requirements
1677:#### Layout Wireframe
1714:### 12.2 Theme Editor
1722:#### Component Requirements
1741:#### Layout Wireframe (Full Width, Three-Panel)
1803:## 13. Pages Management
1805:### 13.1 Pages List
1813:#### Component Requirements
1823:#### Layout
1830:### 13.2 Page Form
1838:#### Component Requirements
1854:#### Layout (Two-Column)
1869:## 14. Navigation Management
1877:### Component Requirements
1901:### Layout Wireframe
1939:#### Menu Item Form Modal
1957:## 15. Apps Page
1965:### Component Requirements
1975:### Layout Wireframe
2009:## 16. Developers Page
2017:### Component Requirements
2037:### Layout Wireframe
2081:#### Generate Token Modal
2107:#### Webhook Modal
2122:## 17. Analytics Page
2130:### Component Requirements
2157:### Layout Wireframe
2209:## 18. Search Settings
2217:### Component Requirements
2235:### Layout Wireframe
2292:## 19. Common Patterns and Conventions
2294:### 19.1 List Pages
2305:### 19.2 Form Pages
2318:### 19.3 Delete Confirmations
2326:### 19.4 Toast Notifications
2330:### 19.5 Breadcrumbs
2337:### 19.6 Loading States
2344:### 19.7 Card Pattern
2352:### 19.8 Responsive Design
2360:### 19.9 Accessibility
2372:## 20. Flash / Toast Messages
2398:## 21. Livewire Component Summary
--- specs/04-STOREFRONT-UI.md
1:# 04 - Storefront UI/UX Specification
7:## Conventions
21:## Currency Formatting
43:## 1. Theme System Architecture
45:### 1.1 View Organization
58:### 1.2 Layout Hierarchy
62:### 1.3 Theme Settings
74:### 1.4 Section-Based Architecture
86:### 1.5 Blade Components
92:## 2. Base Layout
94:### 2.1 Document Head
110:### 2.2 Skip Link
116:### 2.3 Announcement Bar
129:### 2.4 Header
181:### 2.5 Main Content Area
185:### 2.6 Footer
210:### 2.7 Cart Drawer (Livewire)
214:### 2.8 Dark Mode
237:## 3. Home Page (GET /)
247:### 3.1 Hero Banner Section
282:### 3.2 Featured Collections Section
317:### 3.3 Featured Products Section
332:### 3.4 Newsletter Signup Section
364:### 3.5 Rich Text Section
376:## 4. Collection Page (GET /collections/{handle})
380:### 4.1 Collection Header
389:### 4.2 Toolbar
424:### 4.3 Filter Sidebar
463:### 4.4 Product Grid
471:### 4.5 Product Card (Component)
521:### 4.6 Pagination
532:### 4.7 Empty State
555:## 5. Product Page (GET /products/{handle})
559:### 5.1 Layout
582:### 5.2 Image Gallery (Left Column)
621:### 5.3 Product Info (Right Column)
623:#### Breadcrumbs
627:#### Product Title
631:#### Price Display
641:#### Variant Selector
675:#### Stock Messaging
688:#### Quantity Selector
705:#### Add to Cart Button
723:#### Product Description
728:#### Tags
734:### 5.4 Accessibility Summary
746:## 6. Cart Drawer
750:### 6.1 Trigger and Animation
760:### 6.2 Drawer Header
775:### 6.3 Cart Line Items
801:### 6.4 Discount Code Section
829:### 6.5 Totals Section
848:### 6.6 Action Buttons
855:### 6.7 Empty Cart State
874:### 6.8 Accessibility
887:## 7. Full Cart Page (GET /cart)
893:### 7.1 Desktop Layout
924:### 7.2 Totals and Actions
932:### 7.3 Empty State
938:## 8. Checkout Page (GET /checkout/{checkoutId})
942:### 8.1 Layout
964:### 8.2 Checkout Steps
978:#### Step 1 - Contact Information
986:#### Step 2 - Shipping Address
1021:#### Step 3 - Shipping Method
1042:#### Step 4 - Payment Method & Pay
1116:### 8.3 Order Summary Sidebar (Right Column)
1147:### 8.4 Accessibility
1160:## 9. Order Confirmation (GET /checkout/{checkoutId}/confirmation)
1162:### 9.1 Layout
1198:### 9.2 Order Details
1207:#### Bank Transfer Instructions (shown only when `payment_method = bank_transfer`)
1230:### 9.3 Actions
1240:## 10. Customer Account Pages
1244:### 10.1 Login (GET /account/login)
1274:### 10.2 Register (GET /account/register)
1306:### 10.3 Account Dashboard (GET /account)
1332:### 10.4 Order History (GET /account/orders)
1342:### 10.5 Order Detail (GET /account/orders/{orderNumber})
1379:### 10.6 Address Book (GET /account/addresses)
1408:## 11. Search
1410:### 11.1 Search Modal
1448:### 11.2 Search Results Page (GET /search?q=)
1466:## 12. Content Pages (GET /pages/{handle})
1468:### 12.1 Layout
1479:## 13. Error Pages
1481:### 13.1 404 Page
1504:### 13.2 503 / Maintenance Page
1525:## 14. Responsive Breakpoints
1537:### Key Responsive Behaviors
1550:### Touch Considerations
1560:## 15. Accessibility Checklist
1562:### Global (All Pages)
1576:### Page-Specific Accessibility
1587:### Keyboard Interactions
1605:## 16. Component Library
1607:### storefront-layout
1616:### storefront-product-card
1628:### storefront-price
1640:### storefront-badge
1660:### storefront-quantity-selector
1672:### storefront-address-form
1681:### storefront-order-summary
1690:### storefront-breadcrumbs
1705:### storefront-pagination
1723:## 17. Livewire Component Summary
1742:## 18. Browser Event Communication
1757:## 19. SEO and Structured Data
1759:### Meta Tags
1771:### Open Graph Tags
1785:### JSON-LD Structured Data
1795:## 20. User Flow Diagrams
1797:### Browse to Purchase Flow
1826:### Account Management Flow
1847:### Cart Management Flow
1872:### Component State Diagram
1908:## 21. Flash / Toast Messages
--- specs/05-BUSINESS-LOGIC.md
1:# 05 - Business Logic Specification
7:## Conventions
20:## 1. Multi-Tenancy and Store Isolation
22:### 1.1 Tenant Resolution Middleware
28:#### Storefront Route Resolution (from request hostname)
37:#### Admin Route Resolution (from session)
66:### 1.2 Store Scoping
82:### 1.3 Role-Based Access Control
111:## 2. Product Lifecycle
113:### 2.1 Status Transitions
148:### 2.2 Variant and Option Matrix
180:### 2.3 SKU Uniqueness
187:### 2.4 Handle/Slug Generation
199:## 3. Inventory Management
201:### 3.1 Tracking Model
211:### 3.2 Inventory Policy
220:### 3.3 Inventory Operations
245:### 3.4 Concurrency
251:## 4. Cart Service
253:### 4.1 Cart Lifecycle
285:### 4.2 Cart Operations
314:### 4.3 Cart Version (Optimistic Concurrency)
326:### 4.4 Line Amount Calculation
336:### 4.5 Cart Expiration
347:## 5. Pricing Engine
349:### 5.1 Calculation Order (deterministic pipeline)
374:### 5.2 Output Structure
396:### 5.3 Rounding Strategy
403:### 5.4 Determinism and Snapshotting
411:## 6. Checkout State Machine
413:### 6.1 States
437:### 6.2 Transitions and Validation
441:#### Transition: started -> addressed
471:#### Transition: addressed -> shipping_selected
487:#### Transition: shipping_selected -> payment_selected
502:#### Transition: payment_selected -> completed
578:#### Transition: Any active state -> expired
589:### 6.3 Events
600:## 7. Discount Engine
602:### 7.1 Discount Types
615:### Discount Status Lifecycle
630:### 7.2 Value Types
640:### 7.3 Rules
653:### 7.4 Validation Flow
679:### 7.5 Error Codes
690:### 7.6 Discount Allocation
722:### 7.7 Usage Tracking
730:## 8. Tax Calculation
732:### 8.1 Tax Provider Architecture
746:### 8.2 Manual Tax Mode
761:### 8.3 Prices Include Tax
765:#### Tax-inclusive pricing (prices_include_tax = true)
782:#### Tax-exclusive pricing (prices_include_tax = false)
796:### 8.4 Stripe Tax Provider (Stub)
809:### 8.5 Discount-Before-Tax Semantics
823:## 9. Shipping Calculation
825:### 9.1 Zone Matching
860:### 9.2 Rate Types
864:#### Flat rate
870:#### Weight-based rate
888:#### Price-based rate
904:#### Carrier-calculated rate (stub)
911:### 9.3 Requires Shipping Check
921:### 9.4 Free Shipping Discount Override
929:## 10. Payment Processing (Mock PSP)
931:### 10.1 Mock Payment Provider Architecture
945:### 10.2 Supported Payment Methods
955:### 10.3 Magic Card Numbers (Credit Card Testing)
968:### 10.4 Mock Payment Flow
1000:### 10.5 Payment State Machine
1014:### 10.6 Bank Transfer Instructions
1028:### 10.7 Admin: Confirm Payment (Bank Transfer)
1041:### 10.8 Auto-Cancel Unpaid Bank Transfer Orders
1058:## 11. Order Management
1060:### 11.1 Order Creation (from Completed Checkout)
1079:### 11.2 Order Numbering
1086:### 11.3 Order Statuses
1119:### 11.4 Refund Processing
1167:### 11.5 Fulfillment
1171:#### Fulfillment Guard
1186:#### Creating a Fulfillment
1223:#### Fulfillment Status Transitions (Admin Button Actions)
1253:### 11.6 Fulfillment Guard - Inventory Behavior per Payment Method
1264:### 11.7 Auto-Fulfillment for Digital Products
1279:### 11.6 Order Export
1289:## 12. Customer Accounts
1291:### 12.1 Registration
1307:### 12.2 Authentication
1319:### 12.3 Data Access
1325:### 12.4 Guest Cart to Customer Linking
1345:## 13. Webhook Delivery System
1347:### 13.1 Subscription Model
1364:### 13.2 Delivery Process
1401:### 13.3 Retry Logic
1418:### 13.4 Circuit Breaker
1430:## 14. Analytics
1432:### 14.1 Event Ingestion
1470:### 14.2 Aggregation
1490:## 15. Media Processing
1492:### 15.1 Upload Flow
1504:### 15.2 Processing
1525:### 15.3 Cleanup
1531:## 16. Search (SQLite FTS5)
1533:### 16.1 Index Setup
1547:### 16.2 Index Synchronization
1562:### 16.3 Search Query
1582:### 16.4 Search Logging
1588:## 17. Event and Listener Registry
1614:## 18. Scheduled Jobs Registry
1634:## 19. Service Class Registry
1660:## 20. Contracts (Interfaces)
1669:## 21. Enum Registry
1694:## 22. Value Object Registry
--- specs/06-AUTH-AND-SECURITY.md
1:# 06 - Authentication and Security Specification
7:## 1. Authentication
11:### 1.1 Admin Authentication
22:#### Admin Login Flow
59:#### Remember Me
66:#### Admin Password Reset Flow
105:#### Admin Logout
111:#### Session Lifetime
120:### 1.2 Customer Authentication
131:#### Customer Login Flow
165:#### Customer Registration Flow
187:#### Customer Store Scoping
194:#### Customer Password Reset
206:### 1.3 API Authentication (Sanctum)
218:#### Token Lifecycle
242:#### Token Abilities (Scopes)
269:### 1.4 Guard Configuration
273:#### Guards Data Dictionary
281:#### Providers Data Dictionary
288:#### Password Brokers Data Dictionary
299:## 2. Authorization
301:### 2.1 Role Enum
322:### 2.2 Permission Matrix
375:#### Role Group Shorthand
388:### 2.3 Role Checking Trait
406:### 2.4 Laravel Policies
415:#### ProductPolicy
429:#### OrderPolicy
442:#### CollectionPolicy
454:#### DiscountPolicy
466:#### CustomerPolicy
476:#### ThemePolicy
489:#### PagePolicy
501:#### StorePolicy
511:#### FulfillmentPolicy
523:#### RefundPolicy
533:#### NavigationMenuPolicy
544:### 2.5 Gates (Non-Model Operations)
570:### 2.6 Policy and Gate Usage Patterns
572:#### In Livewire Components
578:#### In API Controllers
584:#### In Blade Templates
591:## 3. Middleware Stack
593:### 3.1 Middleware Registration
607:### 3.2 Route Middleware Groups
621:### 3.3 Custom Middleware Specifications
623:#### ResolveStore
659:#### CheckStoreRole
691:#### CustomerAuthenticate
713:## 4. Security Controls
715:### 4.1 CSRF Protection
732:### 4.2 Rate Limiting
758:### 4.3 Encryption at Rest
778:### 4.4 Input Validation
782:#### Form Request Inventory
807:### 4.5 XSS Prevention
817:#### HTML Sanitization Requirements
840:### 4.6 SQL Injection Prevention
849:#### FTS5 Input Sanitization
859:### 4.7 Mass Assignment Protection
869:### 4.8 Password Security
896:## 5. Session Configuration
916:## 6. CORS Configuration
933:## 7. Webhook Signature Verification
935:### 7.1 Inbound Payment Webhooks
941:### 7.2 Platform Webhooks (Outbound)
975:## 8. Audit Logging
977:### 8.1 Logging Channel
990:### 8.2 Log Entry Format
1009:### 8.3 Events to Log
1011:#### Authentication Events
1022:#### Admin Resource Events
1035:#### Security Events
1046:### 8.4 Audit Logger Service
1071:### 8.5 Integration with Laravel Events
1075:#### Auth Event Listeners
1085:#### Model Observers
1091:## 9. Security Checklist Summary
--- specs/07-SEEDERS-AND-TEST-DATA.md
1:# 07 - Seeders and Test Data Specification
7:## 1. DatabaseSeeder Orchestration
69:## 2. Factory Definitions
75:### 2.1 OrganizationFactory
90:### 2.2 StoreFactory
114:### 2.3 StoreDomainFactory
138:### 2.4 UserFactory
160:### 2.5 ProductFactory
194:### 2.6 ProductVariantFactory
225:### 2.7 InventoryItemFactory
249:### 2.8 CollectionFactory
274:### 2.9 CartFactory
298:### 2.10 CartLineFactory
318:### 2.11 CheckoutFactory
352:### 2.12 OrderFactory
394:### 2.13 OrderLineFactory
417:### 2.14 PaymentFactory
447:### 2.15 RefundFactory
471:### 2.16 FulfillmentFactory
495:### 2.16b FulfillmentLineFactory
511:### 2.17 CustomerFactory
534:### 2.18 CustomerAddressFactory
555:### 2.19 DiscountFactory
591:### 2.20 ShippingZoneFactory
608:### 2.21 ShippingRateFactory
631:### 2.22 ThemeFactory
653:### 2.23 PageFactory
677:### 2.24 NavigationMenuFactory
693:### 2.25 NavigationItemFactory
718:### 2.26 AnalyticsEventFactory
743:## 3. Demo Seed Scenario (Exact Data)
749:### 3.1 OrganizationSeeder
760:### 3.2 StoreSeeder
788:### 3.3 StoreDomainSeeder
807:### 3.4 UserSeeder
819:### 3.5 StoreUserSeeder
831:### 3.6 StoreSettingsSeeder
853:### 3.7 TaxSettingsSeeder
870:### 3.8 ShippingSeeder
910:### 3.9 CollectionSeeder
930:### 3.10 ProductSeeder
932:#### Acme Fashion - 20 Products
1388:#### Product Summary Table (Acme Fashion)
1417:#### Acme Electronics - 5 Products (minimal seed for tenant isolation)
1435:### 3.11 DiscountSeeder
1456:### 3.12 CustomerSeeder
1499:### 3.13 OrderSeeder
1853:#### Order Summary Table (Acme Fashion)
1885:### 3.14 ThemeSeeder
1939:### 3.15 PageSeeder
1971:### 3.16 NavigationSeeder
2003:### 3.17 AnalyticsSeeder
2075:### 3.18 SearchSettingsSeeder
2093:## 4. Collection-Product Assignments Summary
2115:## 5. Test Credentials Summary
2192:## 6. Implementation Notes
2194:### Idempotency
2198:### Performance
2202:### Timestamps
2206:### Variant-Option Wiring
2216:### Inventory Items
2220:### Order Line Snapshots
2224:### Address JSON Structure
2243:### Discount Allocation on Order Lines
--- specs/08-PLAYWRIGHT-E2E-PLAN.md
1:# 08 - Playwright E2E Test Plan
7:## Test Suite Summary
33:## Test Infrastructure Requirements
35:### Framework
42:### Pest v4 Browser Testing API Reference
58:### Environment Configuration
72:### Prerequisites Before Running
81:## Seeded Data Dependency Table
108:## Test Execution Matrix
144:## Test Directory Structure
172:## Suite 1: Smoke Tests
180:### Test 1.1: Loads the storefront home page
193:### Test 1.2: Loads a collection page
206:### Test 1.3: Loads a product page
220:### Test 1.4: Loads the cart page
233:### Test 1.5: Loads the customer login page
246:### Test 1.6: Loads the admin login page
259:### Test 1.7: Loads the about page
272:### Test 1.8: Loads the search page
285:### Test 1.9: Loads all collections listing
298:### Test 1.10: Has no errors on critical pages (batch)
312:## Suite 2: Admin Authentication
318:### Authentication Flow
338:### Test 2.1: Can log in as admin
354:### Test 2.2: Shows error for invalid credentials
370:### Test 2.3: Shows error for empty email
385:### Test 2.4: Shows error for empty password
400:### Test 2.5: Redirects unauthenticated users to login from dashboard
413:### Test 2.6: Redirects unauthenticated users to login from products
426:### Test 2.7: Can log out
444:### Test 2.8: Can navigate through admin sidebar sections
470:### Test 2.9: Can navigate to analytics from sidebar
487:### Test 2.10: Can navigate to themes from sidebar
508:## Suite 3: Admin Product Management
514:### Product Lifecycle States
528:### Test 3.1: Shows the product list with seeded products
546:### Test 3.2: Can create a new product
571:### Test 3.3: Can edit an existing product title
591:### Test 3.4: Can archive a product
619:### Test 3.5: Shows draft products only in admin, not storefront
640:### Test 3.6: Can search products in admin
656:### Test 3.7: Can filter products by status in admin
676:## Suite 4: Admin Order Management
682:### Order State Transitions (via admin actions)
700:### Test 4.1: Shows the order list with seeded orders
715:### Test 4.2: Can filter orders by status
735:### Test 4.3: Shows order detail with line items and totals
755:### Test 4.4: Shows order timeline events
772:### Test 4.5: Can create a fulfillment
793:### Test 4.6: Can process a refund
814:### Test 4.7: Shows customer information in order detail
830:### Test 4.8: Can confirm bank transfer payment
851:### Test 4.9: Shows fulfillment guard for unpaid order
868:### Test 4.10: Can mark fulfillment as shipped
886:### Test 4.11: Can mark fulfillment as delivered
906:## Suite 5: Admin Discount Management
912:### Discount Types
922:### Test 5.1: Shows seeded discount codes
939:### Test 5.2: Can create a new percentage discount code
962:### Test 5.3: Can create a fixed amount discount code
982:### Test 5.4: Can create a free shipping discount code
1001:### Test 5.5: Can edit a discount
1019:### Test 5.6: Shows discount status indicators
1037:## Suite 6: Admin Settings
1043:### Settings Page Structure
1060:### Test 6.1: Can view store settings
1076:### Test 6.2: Can update store name
1094:### Test 6.3: Can view shipping zones
1112:### Test 6.4: Can add a new shipping rate to existing zone
1133:### Test 6.5: Can view tax settings
1149:### Test 6.6: Can update tax inclusion setting
1167:### Test 6.7: Can view domain settings
1185:## Suite 7: Storefront Browsing
1191:### Storefront Page Map
1207:### Test 7.1: Shows featured products on home page
1222:### Test 7.2: Shows collection with product grid
1236:### Test 7.3: Can navigate from collection to product
1252:### Test 7.4: Shows product detail with variant options
1268:### Test 7.5: Shows size and color option values
1282:### Test 7.6: Updates price when variant changes on product with compare-at pricing
1298:### Test 7.7: Shows search results for valid query
1311:### Test 7.8: Shows no results message for invalid query
1324:### Test 7.9: Does not show draft products on storefront collections
1337:### Test 7.10: Does not show draft products in search results
1350:### Test 7.11: Shows out of stock messaging for deny-policy product
1364:### Test 7.12: Shows backorder messaging for continue-policy product
1378:### Test 7.13: Shows new arrivals collection
1391:### Test 7.14: Shows static about page
1404:### Test 7.15: Navigates between pages using the main navigation
1421:## Suite 8: Cart Flow
1427:### Cart Interaction Flow
1443:### Discount Code Validation Matrix
1456:### Test 8.1: Can add product to cart
1473:### Test 8.2: Can view cart with added item
1492:### Test 8.3: Can update quantity in cart
1513:### Test 8.4: Can remove item from cart
1532:### Test 8.5: Can add multiple different products
1552:### Test 8.6: Can apply valid discount code WELCOME10
1574:### Test 8.7: Shows error for invalid discount code
1593:### Test 8.8: Shows error for expired discount code
1612:### Test 8.9: Shows error for maxed out discount code
1631:### Test 8.10: Can apply free shipping discount
1651:### Test 8.11: Can apply FLAT5 discount for fixed amount off
1671:### Test 8.12: Shows subtotal and total in cart
1691:## Suite 9: Checkout Flow
1697:### Checkout Step Flow
1720:### Checkout Step Detail
1730:### Totals Calculation Reference
1752:### Test 9.1: Completes full checkout with credit card
1790:### Test 9.2: Shows shipping methods based on German address
1818:### Test 9.3: Shows international shipping methods for non-DE address
1845:### Test 9.4: Applies discount during checkout
1879:### Test 9.5: Validates required contact email
1898:### Test 9.6: Validates required shipping address fields
1919:### Test 9.7: Validates invalid postal code format
1946:### Test 9.8: Prevents checkout with empty cart
1960:### Test 9.9: Completes checkout with PayPal
1982:### Test 9.10: Completes checkout with bank transfer
2005:### Test 9.11: Shows error for declined credit card (magic number)
2031:### Test 9.12: Shows error for insufficient funds (magic number)
2056:### Test 9.13: Switches between payment method forms
2078:## Suite 10: Customer Account
2084:### Customer Account Flow
2103:### Test 10.1: Can register a new customer
2121:### Test 10.2: Shows validation errors for duplicate email registration
2139:### Test 10.3: Shows validation errors for mismatched passwords
2157:### Test 10.4: Can log in as existing customer
2174:### Test 10.5: Shows error for invalid customer credentials
2190:### Test 10.6: Redirects unauthenticated customers to login
2203:### Test 10.7: Shows order history for logged-in customer
2222:### Test 10.8: Shows order detail for customer order
2240:### Test 10.9: Can view addresses
2255:### Test 10.10: Can add a new address
2280:### Test 10.11: Can edit an existing address
2299:### Test 10.12: Can log out
2319:## Suite 11: Inventory Enforcement
2325:### Inventory Policy Decision Matrix
2336:### Test 11.1: Blocks add-to-cart for out-of-stock deny-policy product
2350:### Test 11.2: Allows add-to-cart for out-of-stock continue-policy product
2368:### Test 11.3: Shows correct stock status for in-stock product
2383:### Test 11.4: Prevents adding more than available stock for deny-policy product
2403:## Suite 12: Tenant Isolation
2409:### Isolation Requirements
2432:### Test 12.1: Store 1 only shows Store 1 products
2447:### Test 12.2: Store 1 collections only contain Store 1 products
2461:### Test 12.3: Admin cannot access other store data
2481:### Test 12.4: Search only returns current store products
2495:### Test 12.5: Customer accounts are scoped to their store
2514:## Suite 13: Responsive / Mobile
2520:### Viewport Definitions
2529:### Test 13.1: Storefront home works on mobile viewport
2546:### Test 13.2: Product page stacks layout on mobile
2561:### Test 13.3: Can add to cart on mobile
2578:### Test 13.4: Cart page works on mobile
2597:### Test 13.5: Checkout flow works on mobile
2626:### Test 13.6: Admin login works on tablet viewport
2643:### Test 13.7: Admin sidebar navigation works on tablet
2662:### Test 13.8: Collection page works on mobile with filters
2680:## Suite 14: Accessibility
2686:### Accessibility Requirements Checklist
2700:### Test 14.1: Home page has no JavaScript errors or console warnings
2713:### Test 14.2: Home page has proper heading hierarchy
2728:### Test 14.3: Product page has proper ARIA labels for variant selector
2742:### Test 14.4: Product page images have alt text
2755:### Test 14.5: Customer login form has accessible labels
2769:### Test 14.6: Admin login form has accessible labels
2783:### Test 14.7: Checkout form has accessible labels
2802:### Test 14.8: Checkout validation errors are accessible
2822:### Test 14.9: Can navigate storefront with keyboard only
2838:### Test 14.10: Cart page has no console errors or warnings
2851:### Test 14.11: Search page has proper form labels
2866:## Suite 15: Admin Collections Management
2874:### Test 15.1: Shows the collection list with seeded collections
2890:### Test 15.2: Can create a new collection
2910:### Test 15.3: Can edit a collection
2930:## Suite 16: Admin Customer Management
2938:### Test 16.1: Shows the customer list
2954:### Test 16.2: Shows customer detail with order history
2972:### Test 16.3: Shows customer addresses
2990:## Suite 17: Admin Pages Management
2998:### Test 17.1: Shows the pages list
3013:### Test 17.2: Can create a new page
3032:### Test 17.3: Can edit an existing page
3052:## Suite 18: Admin Analytics Dashboard
3058:### Analytics Dashboard Sections
3070:### Test 18.1: Shows the analytics dashboard
3085:### Test 18.2: Shows sales data
3101:### Test 18.3: Shows conversion funnel data
3118:## Test Count Summary
3144:## Test Execution Commands
3157:## Implementation Notes for the Coding Agent


text:
Script completed
Wall time 0.1 seconds
Output:

text:
--- specs/01-DATABASE-SCHEMA.md
1:# 01 - Database Schema Specification
7:## Conventions
23:## Epic 1 - Foundation and Multi-Store Tenancy
25:### organizations
43:### stores
68:### store_domains
90:### users
119:### store_users
139:### store_settings
153:## Epic 2 - Catalog, Collections, Inventory, and Media
155:### products
187:### product_options
205:### product_option_values
223:### product_variants
256:### variant_option_values
275:### inventory_items
297:### collections
321:### collection_products
340:### product_media
367:## Epic 3 - Themes, Storefront, and Localization
369:### themes
391:### theme_files
411:### theme_settings
423:### pages
447:### navigation_menus
467:### navigation_items
490:## Epic 4 - Search
492:### search_settings
505:### search_queries
526:## Epic 5 - Cart, Checkout, Discounts, Shipping, and Taxes
528:### carts
553:### cart_lines
577:### checkouts
612:### shipping_zones
632:### shipping_rates
658:### tax_settings
672:### discounts
704:## Epic 6 - Payments, Orders, Fulfillment, and Customers
706:### customers
730:### customer_addresses
751:### orders
790:### order_lines
818:### payments
846:### refunds
869:### fulfillments
892:### fulfillment_lines
912:## Epic 7 - Analytics
914:### analytics_events
943:### analytics_daily
969:## Epic 8 - Apps and Webhooks
971:### apps
988:### app_installations
1009:### oauth_clients
1028:### oauth_tokens
1048:### webhook_subscriptions
1070:### webhook_deliveries
1094:## Laravel Framework Tables
1098:### sessions
1109:### cache
1117:### cache_locks
1125:### jobs
1137:### job_batches
1152:### failed_jobs
1164:### personal_access_tokens
1179:### password_reset_tokens
1189:### customer_password_reset_tokens
1202:## Entity Relationship Diagrams
1204:### Epic 1 - Foundation and Tenancy
1251:### Epic 2 - Catalog, Collections, Inventory, and Media
1318:### Epic 3 - Themes, Storefront, and Localization
1367:### Epics 5-6 - Cart, Checkout, Orders, and Payments
1428:### Epics 7-8 - Analytics, Apps, and Webhooks
1482:## SQLite-Specific Configuration Requirements
1486:### Required PRAGMA Settings
1496:### Laravel Configuration Requirements
1507:## Migration Dependency Graph
1641:### Batch Details
1653:## Index Strategy Rationale
1669:## Table Count Summary
--- specs/02-API-ROUTES.md
1:# API and Routing Specification
9:## 1. Web Routes (Blade/Livewire Pages)
11:### 1.1 Admin Auth Routes
29:### 1.2 Admin Routes
38:#### Dashboard
44:#### Products
52:#### Inventory
58:#### Collections
66:#### Orders
73:#### Customers
80:#### Discounts
88:#### Settings
96:#### Themes and Online Store
103:#### Pages
111:#### Navigation
117:#### Apps
124:#### Developers
132:#### Analytics
138:#### Search Settings
146:### 1.3 Storefront Routes
162:#### Customer Account Routes
173:#### Customer Auth Routes (no auth required)
186:### 1.4 Checkout Routes
197:## 2. Storefront REST API
207:### 2.1 Cart Endpoints
209:#### POST /api/storefront/v1/carts
255:#### GET /api/storefront/v1/carts/{cartId}
313:#### POST /api/storefront/v1/carts/{cartId}/lines
354:#### PUT /api/storefront/v1/carts/{cartId}/lines/{lineId}
386:#### DELETE /api/storefront/v1/carts/{cartId}/lines/{lineId}
415:### 2.2 Checkout Endpoints
417:#### Checkout Flow Sequence Diagram
458:#### POST /api/storefront/v1/checkouts
524:#### GET /api/storefront/v1/checkouts/{checkoutId}
541:#### PUT /api/storefront/v1/checkouts/{checkoutId}/address
661:#### PUT /api/storefront/v1/checkouts/{checkoutId}/shipping-method
721:#### PUT /api/storefront/v1/checkouts/{checkoutId}/payment-method
767:#### POST /api/storefront/v1/checkouts/{checkoutId}/apply-discount
829:#### DELETE /api/storefront/v1/checkouts/{checkoutId}/discount
846:### 2.3 Payment Endpoint
848:#### POST /api/storefront/v1/checkouts/{checkoutId}/pay
956:### 2.4 Order Endpoints
958:#### GET /api/storefront/v1/orders/{orderNumber}
1017:### 2.5 Search Endpoints
1019:#### GET /api/storefront/v1/search
1097:#### GET /api/storefront/v1/search/suggest
1141:### 2.6 Analytics Endpoints
1143:#### POST /api/storefront/v1/analytics/events
1206:## 3. Admin REST API
1218:### 3.1 Platform Management (Super-Admin Only)
1222:#### POST /api/admin/v1/platform/organizations
1263:#### POST /api/admin/v1/platform/stores
1316:#### POST /api/admin/v1/stores/{storeId}/invites
1357:#### GET /api/admin/v1/stores/{storeId}/me
1393:### 3.2 Products
1395:#### Admin Products Endpoint Summary
1406:#### GET /api/admin/v1/stores/{storeId}/products
1457:#### POST /api/admin/v1/stores/{storeId}/products
1547:#### GET /api/admin/v1/stores/{storeId}/products/{productId}
1645:#### PUT /api/admin/v1/stores/{storeId}/products/{productId}
1672:#### DELETE /api/admin/v1/stores/{storeId}/products/{productId}
1694:#### POST /api/admin/v1/stores/{storeId}/products/{productId}/media/presign-upload
1736:### 3.3 Collections
1738:#### Admin Collections Endpoint Summary
1747:#### GET /api/admin/v1/stores/{storeId}/collections
1789:#### POST /api/admin/v1/stores/{storeId}/collections
1825:#### PUT /api/admin/v1/stores/{storeId}/collections/{collectionId}
1840:#### DELETE /api/admin/v1/stores/{storeId}/collections/{collectionId}
1860:### 3.4 Orders
1862:#### Admin Orders Endpoint Summary
1871:#### GET /api/admin/v1/stores/{storeId}/orders
1928:#### GET /api/admin/v1/stores/{storeId}/orders/{orderId}
2016:#### POST /api/admin/v1/stores/{storeId}/orders/{orderId}/fulfillments
2077:#### POST /api/admin/v1/stores/{storeId}/orders/{orderId}/refunds
2132:### 3.5 Discounts
2134:#### Admin Discounts Endpoint Summary
2143:#### GET /api/admin/v1/stores/{storeId}/discounts
2192:#### POST /api/admin/v1/stores/{storeId}/discounts
2243:#### PUT /api/admin/v1/stores/{storeId}/discounts/{discountId}
2258:#### DELETE /api/admin/v1/stores/{storeId}/discounts/{discountId}
2278:### 3.6 Shipping
2280:#### Admin Shipping Endpoint Summary
2289:#### GET /api/admin/v1/stores/{storeId}/shipping/zones
2337:#### POST /api/admin/v1/stores/{storeId}/shipping/zones
2365:#### PUT /api/admin/v1/stores/{storeId}/shipping/zones/{zoneId}
2380:#### POST /api/admin/v1/stores/{storeId}/shipping/zones/{zoneId}/rates
2414:### 3.7 Tax Settings
2416:#### Admin Tax Endpoint Summary
2423:#### GET /api/admin/v1/stores/{storeId}/tax/settings
2460:#### PUT /api/admin/v1/stores/{storeId}/tax/settings
2492:### 3.8 Themes
2494:#### Admin Themes Endpoint Summary
2502:#### POST /api/admin/v1/stores/{storeId}/themes
2535:#### POST /api/admin/v1/stores/{storeId}/themes/{themeId}/publish
2558:#### PUT /api/admin/v1/stores/{storeId}/themes/{themeId}/settings
2598:### 3.9 Pages
2600:#### Admin Pages Endpoint Summary
2609:#### GET /api/admin/v1/stores/{storeId}/pages
2648:#### POST /api/admin/v1/stores/{storeId}/pages
2678:#### PUT /api/admin/v1/stores/{storeId}/pages/{pageId}
2693:#### DELETE /api/admin/v1/stores/{storeId}/pages/{pageId}
2713:### 3.10 Search Admin
2715:#### Admin Search Endpoint Summary
2722:#### POST /api/admin/v1/stores/{storeId}/search/reindex
2743:#### GET /api/admin/v1/stores/{storeId}/search/status
2764:### 3.11 Analytics and Exports
2766:#### Admin Analytics Endpoint Summary
2774:#### GET /api/admin/v1/stores/{storeId}/analytics/summary
2834:#### POST /api/admin/v1/stores/{storeId}/exports/orders
2868:#### GET /api/admin/v1/stores/{storeId}/exports/{exportId}
2897:## 4. Webhook Receiver Endpoints
2903:## 5. OAuth Endpoints (App Ecosystem)
2911:### GET /oauth/authorize
2931:### POST /oauth/token
2977:### App API Endpoints
2991:## 6. Middleware Stack
2993:### 6.1 Route Group Middleware
2995:#### Web (default)
3008:#### Admin
3019:#### Storefront
3027:#### API Storefront
3036:#### API Admin
3048:### 6.2 Custom Middleware Definitions
3050:#### `store.resolve`
3066:#### `role.check`
3074:## 7. Rate Limiting Configuration
3076:### Rate Limit Tiers
3088:### Rate Limit Response
3107:### Per-Endpoint Rate Limit Mapping
3134:## 8. Checkout State Machine
3154:### Checkout Status Transition Table
3169:## 9. API Versioning Strategy
3180:## 10. Error Response Format
3184:### Validation Errors (422)
3196:### Authorization Errors (403)
3204:### Not Found Errors (404)
3212:### Conflict Errors (409)
3222:### Business Logic Errors (400)
3231:### Server Errors (500, 502)
--- specs/03-ADMIN-UI.md
1:# 03 - Admin Panel UI/UX Specification
11:## 1. Admin Layout Shell
15:### 1.1 Route Prefix
19:### 1.2 Sidebar Navigation
25:#### Component Requirements
36:#### Wireframe
77:#### Navigation Structure
103:#### Flux Component Mapping
111:#### Responsive Behavior
116:### 1.3 Top Bar
122:#### Component Requirements
134:#### Wireframe
153:#### Interaction Flows
159:#### Flux Component Mapping
171:### 1.4 Main Content Area
179:### 1.5 Toast Notifications
194:### 1.6 Dark Mode
202:## 2. Dashboard
210:### Component Requirements
242:### Wireframe
271:### Layout Description
277:### KPI Tiles Row
288:### Orders Chart
296:### Top Products Table
304:### Conversion Funnel
313:### Flux Component Mapping
326:### View States
337:## 3. Products List
345:### Component Requirements
374:### Wireframe
396:### Table Column Definitions
409:### Bulk Action Bar
417:### Empty State
425:### Delete Confirmation Modal
436:### Flux Component Mapping
453:### View States
464:## 4. Product Create/Edit
472:### Component Requirements
511:### Validation Rules
527:### Two-Column Layout Wireframe
579:### Left Column Sections
581:#### Title Input
586:#### Description
591:#### Media Section
603:#### Variants Section
626:#### SEO Section
631:### Right Column Sections
633:#### Status Card
637:#### Publishing Card
641:#### Product Organization Card
646:#### Collections Card
651:### Sticky Save Bar
658:### Delete Confirmation Modal (Edit Only)
669:### Flux Component Mapping
688:### View States
700:## 5. Collections List and Edit
702:### 5.1 Collections List
710:#### Component Requirements
726:#### Layout
733:#### Table Columns
744:### 5.2 Collection Edit/Create
752:#### Component Requirements
776:#### Layout Wireframe
819:## 6. Inventory Management
827:### Component Requirements
838:### Wireframe
854:### Layout
862:## 7. Orders List
870:### Component Requirements
889:### Wireframe
908:### Filter Tabs
912:### Table Column Definitions
925:### Flux Component Mapping
936:## 8. Order Detail
944:### Component Requirements
968:### Two-Column Layout Wireframe
1007:### Left Column Sections
1009:#### Order Heading
1015:#### Action Buttons
1021:#### Fulfillment Guard
1029:#### Timeline
1034:#### Order Lines Table
1044:#### Order Summary
1049:#### Payment Details
1057:#### Fulfillment Cards
1067:### Right Column Sections
1069:#### Customer Card
1076:#### Shipping Address Card
1081:#### Billing Address Card
1084:### Fulfillment Modal
1100:### Refund Modal
1115:### Flux Component Mapping
1134:## 9. Customers List and Detail
1136:### 9.1 Customers List
1144:#### Component Requirements
1154:#### Layout
1161:### 9.2 Customer Detail
1169:#### Component Requirements
1186:#### Two-Column Layout Wireframe
1215:#### Address Modal
1233:## 10. Discounts List and Form
1235:### 10.1 Discounts List
1243:#### Component Requirements
1254:#### Layout
1259:#### Table Columns
1270:### 10.2 Discount Form
1278:#### Component Requirements
1307:#### Layout Wireframe (Single Column)
1351:#### Section Details
1378:## 11. Settings Pages
1380:### 11.1 General Settings
1388:#### Component Requirements
1402:#### Layout
1421:### 11.2 Domains Settings
1429:#### Component Requirements
1443:#### Layout
1458:#### Add Domain Modal
1471:### 11.3 Shipping Settings
1479:#### Component Requirements
1505:#### Layout Wireframe
1545:#### Zone Modal
1558:#### Rate Modal
1577:#### Test Shipping Address Tool
1588:### 11.4 Tax Settings
1596:#### Component Requirements
1612:#### Layout Wireframe
1655:## 12. Themes Management
1657:### 12.1 Themes List
1665:#### Component Requirements
1677:#### Layout Wireframe
1714:### 12.2 Theme Editor
1722:#### Component Requirements
1741:#### Layout Wireframe (Full Width, Three-Panel)
1803:## 13. Pages Management
1805:### 13.1 Pages List
1813:#### Component Requirements
1823:#### Layout
1830:### 13.2 Page Form
1838:#### Component Requirements
1854:#### Layout (Two-Column)
1869:## 14. Navigation Management
1877:### Component Requirements
1901:### Layout Wireframe
1939:#### Menu Item Form Modal
1957:## 15. Apps Page
1965:### Component Requirements
1975:### Layout Wireframe
2009:## 16. Developers Page
2017:### Component Requirements
2037:### Layout Wireframe
2081:#### Generate Token Modal
2107:#### Webhook Modal
2122:## 17. Analytics Page
2130:### Component Requirements
2157:### Layout Wireframe
2209:## 18. Search Settings
2217:### Component Requirements
2235:### Layout Wireframe
2292:## 19. Common Patterns and Conventions
2294:### 19.1 List Pages
2305:### 19.2 Form Pages
2318:### 19.3 Delete Confirmations
2326:### 19.4 Toast Notifications
2330:### 19.5 Breadcrumbs
2337:### 19.6 Loading States
2344:### 19.7 Card Pattern
2352:### 19.8 Responsive Design
2360:### 19.9 Accessibility
2372:## 20. Flash / Toast Messages
2398:## 21. Livewire Component Summary
--- specs/04-STOREFRONT-UI.md
1:# 04 - Storefront UI/UX Specification
7:## Conventions
21:## Currency Formatting
43:## 1. Theme System Architecture
45:### 1.1 View Organization
58:### 1.2 Layout Hierarchy
62:### 1.3 Theme Settings
74:### 1.4 Section-Based Architecture
86:### 1.5 Blade Components
92:## 2. Base Layout
94:### 2.1 Document Head
110:### 2.2 Skip Link
116:### 2.3 Announcement Bar
129:### 2.4 Header
181:### 2.5 Main Content Area
185:### 2.6 Footer
210:### 2.7 Cart Drawer (Livewire)
214:### 2.8 Dark Mode
237:## 3. Home Page (GET /)
247:### 3.1 Hero Banner Section
282:### 3.2 Featured Collections Section
317:### 3.3 Featured Products Section
332:### 3.4 Newsletter Signup Section
364:### 3.5 Rich Text Section
376:## 4. Collection Page (GET /collections/{handle})
380:### 4.1 Collection Header
389:### 4.2 Toolbar
424:### 4.3 Filter Sidebar
463:### 4.4 Product Grid
471:### 4.5 Product Card (Component)
521:### 4.6 Pagination
532:### 4.7 Empty State
555:## 5. Product Page (GET /products/{handle})
559:### 5.1 Layout
582:### 5.2 Image Gallery (Left Column)
621:### 5.3 Product Info (Right Column)
623:#### Breadcrumbs
627:#### Product Title
631:#### Price Display
641:#### Variant Selector
675:#### Stock Messaging
688:#### Quantity Selector
705:#### Add to Cart Button
723:#### Product Description
728:#### Tags
734:### 5.4 Accessibility Summary
746:## 6. Cart Drawer
750:### 6.1 Trigger and Animation
760:### 6.2 Drawer Header
775:### 6.3 Cart Line Items
801:### 6.4 Discount Code Section
829:### 6.5 Totals Section
848:### 6.6 Action Buttons
855:### 6.7 Empty Cart State
874:### 6.8 Accessibility
887:## 7. Full Cart Page (GET /cart)
893:### 7.1 Desktop Layout
924:### 7.2 Totals and Actions
932:### 7.3 Empty State
938:## 8. Checkout Page (GET /checkout/{checkoutId})
942:### 8.1 Layout
964:### 8.2 Checkout Steps
978:#### Step 1 - Contact Information
986:#### Step 2 - Shipping Address
1021:#### Step 3 - Shipping Method
1042:#### Step 4 - Payment Method & Pay
1116:### 8.3 Order Summary Sidebar (Right Column)
1147:### 8.4 Accessibility
1160:## 9. Order Confirmation (GET /checkout/{checkoutId}/confirmation)
1162:### 9.1 Layout
1198:### 9.2 Order Details
1207:#### Bank Transfer Instructions (shown only when `payment_method = bank_transfer`)
1230:### 9.3 Actions
1240:## 10. Customer Account Pages
1244:### 10.1 Login (GET /account/login)
1274:### 10.2 Register (GET /account/register)
1306:### 10.3 Account Dashboard (GET /account)
1332:### 10.4 Order History (GET /account/orders)
1342:### 10.5 Order Detail (GET /account/orders/{orderNumber})
1379:### 10.6 Address Book (GET /account/addresses)
1408:## 11. Search
1410:### 11.1 Search Modal
1448:### 11.2 Search Results Page (GET /search?q=)
1466:## 12. Content Pages (GET /pages/{handle})
1468:### 12.1 Layout
1479:## 13. Error Pages
1481:### 13.1 404 Page
1504:### 13.2 503 / Maintenance Page
1525:## 14. Responsive Breakpoints
1537:### Key Responsive Behaviors
1550:### Touch Considerations
1560:## 15. Accessibility Checklist
1562:### Global (All Pages)
1576:### Page-Specific Accessibility
1587:### Keyboard Interactions
1605:## 16. Component Library
1607:### storefront-layout
1616:### storefront-product-card
1628:### storefront-price
1640:### storefront-badge
1660:### storefront-quantity-selector
1672:### storefront-address-form
1681:### storefront-order-summary
1690:### storefront-breadcrumbs
1705:### storefront-pagination
1723:## 17. Livewire Component Summary
1742:## 18. Browser Event Communication
1757:## 19. SEO and Structured Data
1759:### Meta Tags
1771:### Open Graph Tags
1785:### JSON-LD Structured Data
1795:## 20. User Flow Diagrams
1797:### Browse to Purchase Flow
1826:### Account Management Flow
1847:### Cart Management Flow
1872:### Component State Diagram
1908:## 21. Flash / Toast Messages
--- specs/05-BUSINESS-LOGIC.md
1:# 05 - Business Logic Specification
7:## Conventions
20:## 1. Multi-Tenancy and Store Isolation
22:### 1.1 Tenant Resolution Middleware
28:#### Storefront Route Resolution (from request hostname)
37:#### Admin Route Resolution (from session)
66:### 1.2 Store Scoping
82:### 1.3 Role-Based Access Control
111:## 2. Product Lifecycle
113:### 2.1 Status Transitions
148:### 2.2 Variant and Option Matrix
180:### 2.3 SKU Uniqueness
187:### 2.4 Handle/Slug Generation
199:## 3. Inventory Management
201:### 3.1 Tracking Model
211:### 3.2 Inventory Policy
220:### 3.3 Inventory Operations
245:### 3.4 Concurrency
251:## 4. Cart Service
253:### 4.1 Cart Lifecycle
285:### 4.2 Cart Operations
314:### 4.3 Cart Version (Optimistic Concurrency)
326:### 4.4 Line Amount Calculation
336:### 4.5 Cart Expiration
347:## 5. Pricing Engine
349:### 5.1 Calculation Order (deterministic pipeline)
374:### 5.2 Output Structure
396:### 5.3 Rounding Strategy
403:### 5.4 Determinism and Snapshotting
411:## 6. Checkout State Machine
413:### 6.1 States
437:### 6.2 Transitions and Validation
441:#### Transition: started -> addressed
471:#### Transition: addressed -> shipping_selected
487:#### Transition: shipping_selected -> payment_selected
502:#### Transition: payment_selected -> completed
578:#### Transition: Any active state -> expired
589:### 6.3 Events
600:## 7. Discount Engine
602:### 7.1 Discount Types
615:### Discount Status Lifecycle
630:### 7.2 Value Types
640:### 7.3 Rules
653:### 7.4 Validation Flow
679:### 7.5 Error Codes
690:### 7.6 Discount Allocation
722:### 7.7 Usage Tracking
730:## 8. Tax Calculation
732:### 8.1 Tax Provider Architecture
746:### 8.2 Manual Tax Mode
761:### 8.3 Prices Include Tax
765:#### Tax-inclusive pricing (prices_include_tax = true)
782:#### Tax-exclusive pricing (prices_include_tax = false)
796:### 8.4 Stripe Tax Provider (Stub)
809:### 8.5 Discount-Before-Tax Semantics
823:## 9. Shipping Calculation
825:### 9.1 Zone Matching
860:### 9.2 Rate Types
864:#### Flat rate
870:#### Weight-based rate
888:#### Price-based rate
904:#### Carrier-calculated rate (stub)
911:### 9.3 Requires Shipping Check
921:### 9.4 Free Shipping Discount Override
929:## 10. Payment Processing (Mock PSP)
931:### 10.1 Mock Payment Provider Architecture
945:### 10.2 Supported Payment Methods
955:### 10.3 Magic Card Numbers (Credit Card Testing)
968:### 10.4 Mock Payment Flow
1000:### 10.5 Payment State Machine
1014:### 10.6 Bank Transfer Instructions
1028:### 10.7 Admin: Confirm Payment (Bank Transfer)
1041:### 10.8 Auto-Cancel Unpaid Bank Transfer Orders
1058:## 11. Order Management
1060:### 11.1 Order Creation (from Completed Checkout)
1079:### 11.2 Order Numbering
1086:### 11.3 Order Statuses
1119:### 11.4 Refund Processing
1167:### 11.5 Fulfillment
1171:#### Fulfillment Guard
1186:#### Creating a Fulfillment
1223:#### Fulfillment Status Transitions (Admin Button Actions)
1253:### 11.6 Fulfillment Guard - Inventory Behavior per Payment Method
1264:### 11.7 Auto-Fulfillment for Digital Products
1279:### 11.6 Order Export
1289:## 12. Customer Accounts
1291:### 12.1 Registration
1307:### 12.2 Authentication
1319:### 12.3 Data Access
1325:### 12.4 Guest Cart to Customer Linking
1345:## 13. Webhook Delivery System
1347:### 13.1 Subscription Model
1364:### 13.2 Delivery Process
1401:### 13.3 Retry Logic
1418:### 13.4 Circuit Breaker
1430:## 14. Analytics
1432:### 14.1 Event Ingestion
1470:### 14.2 Aggregation
1490:## 15. Media Processing
1492:### 15.1 Upload Flow
1504:### 15.2 Processing
1525:### 15.3 Cleanup
1531:## 16. Search (SQLite FTS5)
1533:### 16.1 Index Setup
1547:### 16.2 Index Synchronization
1562:### 16.3 Search Query
1582:### 16.4 Search Logging
1588:## 17. Event and Listener Registry
1614:## 18. Scheduled Jobs Registry
1634:## 19. Service Class Registry
1660:## 20. Contracts (Interfaces)
1669:## 21. Enum Registry
1694:## 22. Value Object Registry
--- specs/06-AUTH-AND-SECURITY.md
1:# 06 - Authentication and Security Specification
7:## 1. Authentication
11:### 1.1 Admin Authentication
22:#### Admin Login Flow
59:#### Remember Me
66:#### Admin Password Reset Flow
105:#### Admin Logout
111:#### Session Lifetime
120:### 1.2 Customer Authentication
131:#### Customer Login Flow
165:#### Customer Registration Flow
187:#### Customer Store Scoping
194:#### Customer Password Reset
206:### 1.3 API Authentication (Sanctum)
218:#### Token Lifecycle
242:#### Token Abilities (Scopes)
269:### 1.4 Guard Configuration
273:#### Guards Data Dictionary
281:#### Providers Data Dictionary
288:#### Password Brokers Data Dictionary
299:## 2. Authorization
301:### 2.1 Role Enum
322:### 2.2 Permission Matrix
375:#### Role Group Shorthand
388:### 2.3 Role Checking Trait
406:### 2.4 Laravel Policies
415:#### ProductPolicy
429:#### OrderPolicy
442:#### CollectionPolicy
454:#### DiscountPolicy
466:#### CustomerPolicy
476:#### ThemePolicy
489:#### PagePolicy
501:#### StorePolicy
511:#### FulfillmentPolicy
523:#### RefundPolicy
533:#### NavigationMenuPolicy
544:### 2.5 Gates (Non-Model Operations)
570:### 2.6 Policy and Gate Usage Patterns
572:#### In Livewire Components
578:#### In API Controllers
584:#### In Blade Templates
591:## 3. Middleware Stack
593:### 3.1 Middleware Registration
607:### 3.2 Route Middleware Groups
621:### 3.3 Custom Middleware Specifications
623:#### ResolveStore
659:#### CheckStoreRole
691:#### CustomerAuthenticate
713:## 4. Security Controls
715:### 4.1 CSRF Protection
732:### 4.2 Rate Limiting
758:### 4.3 Encryption at Rest
778:### 4.4 Input Validation
782:#### Form Request Inventory
807:### 4.5 XSS Prevention
817:#### HTML Sanitization Requirements
840:### 4.6 SQL Injection Prevention
849:#### FTS5 Input Sanitization
859:### 4.7 Mass Assignment Protection
869:### 4.8 Password Security
896:## 5. Session Configuration
916:## 6. CORS Configuration
933:## 7. Webhook Signature Verification
935:### 7.1 Inbound Payment Webhooks
941:### 7.2 Platform Webhooks (Outbound)
975:## 8. Audit Logging
977:### 8.1 Logging Channel
990:### 8.2 Log Entry Format
1009:### 8.3 Events to Log
1011:#### Authentication Events
1022:#### Admin Resource Events
1035:#### Security Events
1046:### 8.4 Audit Logger Service
1071:### 8.5 Integration with Laravel Events
1075:#### Auth Event Listeners
1085:#### Model Observers
1091:## 9. Security Checklist Summary
--- specs/07-SEEDERS-AND-TEST-DATA.md
1:# 07 - Seeders and Test Data Specification
7:## 1. DatabaseSeeder Orchestration
69:## 2. Factory Definitions
75:### 2.1 OrganizationFactory
90:### 2.2 StoreFactory
114:### 2.3 StoreDomainFactory
138:### 2.4 UserFactory
160:### 2.5 ProductFactory
194:### 2.6 ProductVariantFactory
225:### 2.7 InventoryItemFactory
249:### 2.8 CollectionFactory
274:### 2.9 CartFactory
298:### 2.10 CartLineFactory
318:### 2.11 CheckoutFactory
352:### 2.12 OrderFactory
394:### 2.13 OrderLineFactory
417:### 2.14 PaymentFactory
447:### 2.15 RefundFactory
471:### 2.16 FulfillmentFactory
495:### 2.16b FulfillmentLineFactory
511:### 2.17 CustomerFactory
534:### 2.18 CustomerAddressFactory
555:### 2.19 DiscountFactory
591:### 2.20 ShippingZoneFactory
608:### 2.21 ShippingRateFactory
631:### 2.22 ThemeFactory
653:### 2.23 PageFactory
677:### 2.24 NavigationMenuFactory
693:### 2.25 NavigationItemFactory
718:### 2.26 AnalyticsEventFactory
743:## 3. Demo Seed Scenario (Exact Data)
749:### 3.1 OrganizationSeeder
760:### 3.2 StoreSeeder
788:### 3.3 StoreDomainSeeder
807:### 3.4 UserSeeder
819:### 3.5 StoreUserSeeder
831:### 3.6 StoreSettingsSeeder
853:### 3.7 TaxSettingsSeeder
870:### 3.8 ShippingSeeder
910:### 3.9 CollectionSeeder
930:### 3.10 ProductSeeder
932:#### Acme Fashion - 20 Products
1388:#### Product Summary Table (Acme Fashion)
1417:#### Acme Electronics - 5 Products (minimal seed for tenant isolation)
1435:### 3.11 DiscountSeeder
1456:### 3.12 CustomerSeeder
1499:### 3.13 OrderSeeder
1853:#### Order Summary Table (Acme Fashion)
1885:### 3.14 ThemeSeeder
1939:### 3.15 PageSeeder
1971:### 3.16 NavigationSeeder
2003:### 3.17 AnalyticsSeeder
2075:### 3.18 SearchSettingsSeeder
2093:## 4. Collection-Product Assignments Summary
2115:## 5. Test Credentials Summary
2192:## 6. Implementation Notes
2194:### Idempotency
2198:### Performance
2202:### Timestamps
2206:### Variant-Option Wiring
2216:### Inventory Items
2220:### Order Line Snapshots
2224:### Address JSON Structure
2243:### Discount Allocation on Order Lines
--- specs/08-PLAYWRIGHT-E2E-PLAN.md
1:# 08 - Playwright E2E Test Plan
7:## Test Suite Summary
33:## Test Infrastructure Requirements
35:### Framework
42:### Pest v4 Browser Testing API Reference
58:### Environment Configuration
72:### Prerequisites Before Running
81:## Seeded Data Dependency Table
108:## Test Execution Matrix
144:## Test Directory Structure
172:## Suite 1: Smoke Tests
180:### Test 1.1: Loads the storefront home page
193:### Test 1.2: Loads a collection page
206:### Test 1.3: Loads a product page
220:### Test 1.4: Loads the cart page
233:### Test 1.5: Loads the customer login page
246:### Test 1.6: Loads the admin login page
259:### Test 1.7: Loads the about page
272:### Test 1.8: Loads the search page
285:### Test 1.9: Loads all collections listing
298:### Test 1.10: Has no errors on critical pages (batch)
312:## Suite 2: Admin Authentication
318:### Authentication Flow
338:### Test 2.1: Can log in as admin
354:### Test 2.2: Shows error for invalid credentials
370:### Test 2.3: Shows error for empty email
385:### Test 2.4: Shows error for empty password
400:### Test 2.5: Redirects unauthenticated users to login from dashboard
413:### Test 2.6: Redirects unauthenticated users to login from products
426:### Test 2.7: Can log out
444:### Test 2.8: Can navigate through admin sidebar sections
470:### Test 2.9: Can navigate to analytics from sidebar
487:### Test 2.10: Can navigate to themes from sidebar
508:## Suite 3: Admin Product Management
514:### Product Lifecycle States
528:### Test 3.1: Shows the product list with seeded products
546:### Test 3.2: Can create a new product
571:### Test 3.3: Can edit an existing product title
591:### Test 3.4: Can archive a product
619:### Test 3.5: Shows draft products only in admin, not storefront
640:### Test 3.6: Can search products in admin
656:### Test 3.7: Can filter products by status in admin
676:## Suite 4: Admin Order Management
682:### Order State Transitions (via admin actions)
700:### Test 4.1: Shows the order list with seeded orders
715:### Test 4.2: Can filter orders by status
735:### Test 4.3: Shows order detail with line items and totals
755:### Test 4.4: Shows order timeline events
772:### Test 4.5: Can create a fulfillment
793:### Test 4.6: Can process a refund
814:### Test 4.7: Shows customer information in order detail
830:### Test 4.8: Can confirm bank transfer payment
851:### Test 4.9: Shows fulfillment guard for unpaid order
868:### Test 4.10: Can mark fulfillment as shipped
886:### Test 4.11: Can mark fulfillment as delivered
906:## Suite 5: Admin Discount Management
912:### Discount Types
922:### Test 5.1: Shows seeded discount codes
939:### Test 5.2: Can create a new percentage discount code
962:### Test 5.3: Can create a fixed amount discount code
982:### Test 5.4: Can create a free shipping discount code
1001:### Test 5.5: Can edit a discount
1019:### Test 5.6: Shows discount status indicators
1037:## Suite 6: Admin Settings
1043:### Settings Page Structure
1060:### Test 6.1: Can view store settings
1076:### Test 6.2: Can update store name
1094:### Test 6.3: Can view shipping zones
1112:### Test 6.4: Can add a new shipping rate to existing zone
1133:### Test 6.5: Can view tax settings
1149:### Test 6.6: Can update tax inclusion setting
1167:### Test 6.7: Can view domain settings
1185:## Suite 7: Storefront Browsing
1191:### Storefront Page Map
1207:### Test 7.1: Shows featured products on home page
1222:### Test 7.2: Shows collection with product grid
1236:### Test 7.3: Can navigate from collection to product
1252:### Test 7.4: Shows product detail with variant options
1268:### Test 7.5: Shows size and color option values
1282:### Test 7.6: Updates price when variant changes on product with compare-at pricing
1298:### Test 7.7: Shows search results for valid query
1311:### Test 7.8: Shows no results message for invalid query
1324:### Test 7.9: Does not show draft products on storefront collections
1337:### Test 7.10: Does not show draft products in search results
1350:### Test 7.11: Shows out of stock messaging for deny-policy product
1364:### Test 7.12: Shows backorder messaging for continue-policy product
1378:### Test 7.13: Shows new arrivals collection
1391:### Test 7.14: Shows static about page
1404:### Test 7.15: Navigates between pages using the main navigation
1421:## Suite 8: Cart Flow
1427:### Cart Interaction Flow
1443:### Discount Code Validation Matrix
1456:### Test 8.1: Can add product to cart
1473:### Test 8.2: Can view cart with added item
1492:### Test 8.3: Can update quantity in cart
1513:### Test 8.4: Can remove item from cart
1532:### Test 8.5: Can add multiple different products
1552:### Test 8.6: Can apply valid discount code WELCOME10
1574:### Test 8.7: Shows error for invalid discount code
1593:### Test 8.8: Shows error for expired discount code
1612:### Test 8.9: Shows error for maxed out discount code
1631:### Test 8.10: Can apply free shipping discount
1651:### Test 8.11: Can apply FLAT5 discount for fixed amount off
1671:### Test 8.12: Shows subtotal and total in cart
1691:## Suite 9: Checkout Flow
1697:### Checkout Step Flow
1720:### Checkout Step Detail
1730:### Totals Calculation Reference
1752:### Test 9.1: Completes full checkout with credit card
1790:### Test 9.2: Shows shipping methods based on German address
1818:### Test 9.3: Shows international shipping methods for non-DE address
1845:### Test 9.4: Applies discount during checkout
1879:### Test 9.5: Validates required contact email
1898:### Test 9.6: Validates required shipping address fields
1919:### Test 9.7: Validates invalid postal code format
1946:### Test 9.8: Prevents checkout with empty cart
1960:### Test 9.9: Completes checkout with PayPal
1982:### Test 9.10: Completes checkout with bank transfer
2005:### Test 9.11: Shows error for declined credit card (magic number)
2031:### Test 9.12: Shows error for insufficient funds (magic number)
2056:### Test 9.13: Switches between payment method forms
2078:## Suite 10: Customer Account
2084:### Customer Account Flow
2103:### Test 10.1: Can register a new customer
2121:### Test 10.2: Shows validation errors for duplicate email registration
2139:### Test 10.3: Shows validation errors for mismatched passwords
2157:### Test 10.4: Can log in as existing customer
2174:### Test 10.5: Shows error for invalid customer credentials
2190:### Test 10.6: Redirects unauthenticated customers to login
2203:### Test 10.7: Shows order history for logged-in customer
2222:### Test 10.8: Shows order detail for customer order
2240:### Test 10.9: Can view addresses
2255:### Test 10.10: Can add a new address
2280:### Test 10.11: Can edit an existing address
2299:### Test 10.12: Can log out
2319:## Suite 11: Inventory Enforcement
2325:### Inventory Policy Decision Matrix
2336:### Test 11.1: Blocks add-to-cart for out-of-stock deny-policy product
2350:### Test 11.2: Allows add-to-cart for out-of-stock continue-policy product
2368:### Test 11.3: Shows correct stock status for in-stock product
2383:### Test 11.4: Prevents adding more than available stock for deny-policy product
2403:## Suite 12: Tenant Isolation
2409:### Isolation Requirements
2432:### Test 12.1: Store 1 only shows Store 1 products
2447:### Test 12.2: Store 1 collections only contain Store 1 products
2461:### Test 12.3: Admin cannot access other store data
2481:### Test 12.4: Search only returns current store products
2495:### Test 12.5: Customer accounts are scoped to their store
2514:## Suite 13: Responsive / Mobile
2520:### Viewport Definitions
2529:### Test 13.1: Storefront home works on mobile viewport
2546:### Test 13.2: Product page stacks layout on mobile
2561:### Test 13.3: Can add to cart on mobile
2578:### Test 13.4: Cart page works on mobile
2597:### Test 13.5: Checkout flow works on mobile
2626:### Test 13.6: Admin login works on tablet viewport
2643:### Test 13.7: Admin sidebar navigation works on tablet
2662:### Test 13.8: Collection page works on mobile with filters
2680:## Suite 14: Accessibility
2686:### Accessibility Requirements Checklist
2700:### Test 14.1: Home page has no JavaScript errors or console warnings
2713:### Test 14.2: Home page has proper heading hierarchy
2728:### Test 14.3: Product page has proper ARIA labels for variant selector
2742:### Test 14.4: Product page images have alt text
2755:### Test 14.5: Customer login form has accessible labels
2769:### Test 14.6: Admin login form has accessible labels
2783:### Test 14.7: Checkout form has accessible labels
2802:### Test 14.8: Checkout validation errors are accessible
2822:### Test 14.9: Can navigate storefront with keyboard only
2838:### Test 14.10: Cart page has no console errors or warnings
2851:### Test 14.11: Search page has proper form labels
2866:## Suite 15: Admin Collections Management
2874:### Test 15.1: Shows the collection list with seeded collections
2890:### Test 15.2: Can create a new collection
2910:### Test 15.3: Can edit a collection
2930:## Suite 16: Admin Customer Management
2938:### Test 16.1: Shows the customer list
2954:### Test 16.2: Shows customer detail with order history
2972:### Test 16.3: Shows customer addresses
2990:## Suite 17: Admin Pages Management
2998:### Test 17.1: Shows the pages list
3013:### Test 17.2: Can create a new page
3032:### Test 17.3: Can edit an existing page
3052:## Suite 18: Admin Analytics Dashboard
3058:### Analytics Dashboard Sections
3070:### Test 18.1: Shows the analytics dashboard
3085:### Test 18.2: Shows sales data
3101:### Test 18.3: Shows conversion funnel data
3118:## Test Count Summary
3144:## Test Execution Commands
3157:## Implementation Notes for the Coding Agent


exec

status: completed

input:
const r = await tools.exec_command({cmd:"printf '%s\\n' '--- routes/api.php'; sed -n '1,320p' routes/api.php; printf '%s\\n' '--- routes/web.php'; sed -n '1,360p' routes/web.php; printf '%s\\n' '--- app/Http/Controllers/Api/AdminController.php'; sed -n '1,420p' app/Http/Controllers/Api/AdminController.php; printf '%s\\n' '--- admin livewire files'; rg --files app/Livewire/Admin | sort; printf '%s\\n' '--- storefront livewire files'; rg --files app/Livewire/Storefront | sort","workdir":"/Users/wesner/Herd/shop","yield_time_ms":10000,"max_output_tokens":40000});
text(r.output);


type: CommandExecution

command: printf '%s\n' '--- routes/api.php'; sed -n '1,320p' routes/api.php; printf '%s\n' '--- routes/web.php'; sed -n '1,360p' routes/web.php; printf '%s\n' '--- app/Http/Controllers/Api/AdminController.php'; sed -n '1,420p' app/Http/Controllers/Api/AdminController.php; printf '%s\n' '--- admin livewire files'; rg --files app/Livewire/Admin | sort; printf '%s\n' '--- storefront livewire files'; rg --files app/Livewire/Storefront | sort

api.php

type: read

cmd: sed -n '1,320p' routes/api.php

web.php

cmd: sed -n '1,360p' routes/web.php

AdminController.php

cmd: rg --files app/Livewire/Admin

path: Admin

cmd: rg --files app/Livewire/Storefront

path: Storefront

status: completed

stdout:
--- routes/api.php
<?php

use App\Http\Controllers\Api\AdminController;
use App\Http\Controllers\Api\StorefrontAnalyticsController;
use App\Http\Controllers\Api\StorefrontCartController;
use App\Http\Controllers\Api\StorefrontCheckoutController;
use Illuminate\Session\Middleware\StartSession;
use Illuminate\Support\Facades\Route;

Route::prefix('storefront/v1')->middleware([StartSession::class, 'store.resolve', 'throttle:api.storefront'])->group(function (): void {
    Route::post('carts', [StorefrontCartController::class, 'store']);
    Route::get('carts/{cartId}', [StorefrontCartController::class, 'show']);
    Route::post('carts/{cartId}/lines', [StorefrontCartController::class, 'addLine']);
    Route::put('carts/{cartId}/lines/{lineId}', [StorefrontCartController::class, 'updateLine']);
    Route::delete('carts/{cartId}/lines/{lineId}', [StorefrontCartController::class, 'removeLine']);
    Route::post('checkouts', [StorefrontCheckoutController::class, 'store'])->middleware('throttle:checkout');
    Route::get('checkouts/{checkoutId}', [StorefrontCheckoutController::class, 'show'])->middleware('throttle:checkout');
    Route::put('checkouts/{checkoutId}/address', [StorefrontCheckoutController::class, 'address'])->middleware('throttle:checkout');
    Route::put('checkouts/{checkoutId}/shipping-method', [StorefrontCheckoutController::class, 'shippingMethod'])->middleware('throttle:checkout');
    Route::put('checkouts/{checkoutId}/payment-method', [StorefrontCheckoutController::class, 'paymentMethod'])->middleware('throttle:checkout');
    Route::post('checkouts/{checkoutId}/apply-discount', [StorefrontCheckoutController::class, 'applyDiscount'])->middleware('throttle:checkout');
    Route::post('checkouts/{checkoutId}/pay', [StorefrontCheckoutController::class, 'pay'])->middleware('throttle:checkout');
    Route::post('analytics/events', [StorefrontAnalyticsController::class, 'store']);
});

Route::prefix('admin/v1/stores/{storeId}')->middleware([StartSession::class, 'auth', 'store.resolve', 'role.check:owner,admin,staff,support', 'throttle:api.admin'])->group(function (): void {
    Route::get('products', [AdminController::class, 'products']);
    Route::post('products', [AdminController::class, 'storeProduct'])->middleware('role.check:owner,admin,staff');
    Route::get('products/{productId}', [AdminController::class, 'showProduct']);
    Route::put('products/{productId}', [AdminController::class, 'updateProduct'])->middleware('role.check:owner,admin,staff');
    Route::delete('products/{productId}', [AdminController::class, 'deleteProduct'])->middleware('role.check:owner,admin,staff');
    Route::get('collections', [AdminController::class, 'collections']);
    Route::post('collections', [AdminController::class, 'storeCollection'])->middleware('role.check:owner,admin,staff');
    Route::put('collections/{collectionId}', [AdminController::class, 'updateCollection'])->middleware('role.check:owner,admin,staff');
    Route::delete('collections/{collectionId}', [AdminController::class, 'deleteCollection'])->middleware('role.check:owner,admin,staff');
    Route::get('orders', [AdminController::class, 'orders']);
    Route::get('orders/{orderId}', [AdminController::class, 'showOrder']);
    Route::get('customers', [AdminController::class, 'customers']);
    Route::get('discounts', [AdminController::class, 'discounts']);
});
--- routes/web.php
<?php

use App\Livewire\Admin\Analytics\Index as AdminAnalyticsIndex;
use App\Livewire\Admin\Apps\Index as AdminAppsIndex;
use App\Livewire\Admin\Apps\Show as AdminAppsShow;
use App\Livewire\Admin\Auth\ForgotPassword as AdminForgotPassword;
use App\Livewire\Admin\Auth\Login as AdminLogin;
use App\Livewire\Admin\Auth\ResetPassword as AdminResetPassword;
use App\Livewire\Admin\Collections\Create as AdminCollectionsCreate;
use App\Livewire\Admin\Collections\Edit as AdminCollectionsEdit;
use App\Livewire\Admin\Collections\Index as AdminCollectionsIndex;
use App\Livewire\Admin\Customers\Index as AdminCustomersIndex;
use App\Livewire\Admin\Customers\Show as AdminCustomersShow;
use App\Livewire\Admin\Dashboard as AdminDashboard;
use App\Livewire\Admin\Developers\Index as AdminDevelopersIndex;
use App\Livewire\Admin\Discounts\Form as AdminDiscountForm;
use App\Livewire\Admin\Discounts\Index as AdminDiscountsIndex;
use App\Livewire\Admin\Inventory\Index as AdminInventoryIndex;
use App\Livewire\Admin\Navigation\Index as AdminNavigationIndex;
use App\Livewire\Admin\Orders\Index as AdminOrdersIndex;
use App\Livewire\Admin\Orders\Show as AdminOrdersShow;
use App\Livewire\Admin\Pages\Create as AdminPagesCreate;
use App\Livewire\Admin\Pages\Edit as AdminPagesEdit;
use App\Livewire\Admin\Pages\Index as AdminPagesIndex;
use App\Livewire\Admin\Products\Form as AdminProductForm;
use App\Livewire\Admin\Products\Index as AdminProductsIndex;
use App\Livewire\Admin\Search\Settings as AdminSearchSettings;
use App\Livewire\Admin\Settings\General as AdminSettingsGeneral;
use App\Livewire\Admin\Settings\Shipping as AdminSettingsShipping;
use App\Livewire\Admin\Settings\Taxes as AdminSettingsTaxes;
use App\Livewire\Admin\Themes\Editor as AdminThemesEditor;
use App\Livewire\Admin\Themes\Index as AdminThemesIndex;
use App\Livewire\Storefront\Account\Addresses\Index as AccountAddresses;
use App\Livewire\Storefront\Account\Auth\ForgotPassword as CustomerForgotPassword;
use App\Livewire\Storefront\Account\Auth\Login as CustomerLogin;
use App\Livewire\Storefront\Account\Auth\Register as CustomerRegister;
use App\Livewire\Storefront\Account\Auth\ResetPassword as CustomerResetPassword;
use App\Livewire\Storefront\Account\Dashboard as AccountDashboard;
use App\Livewire\Storefront\Account\Orders\Index as AccountOrders;
use App\Livewire\Storefront\Account\Orders\Show as AccountOrderShow;
use App\Livewire\Storefront\Cart\Show as CartShow;
use App\Livewire\Storefront\Checkout\Confirmation as CheckoutConfirmation;
use App\Livewire\Storefront\Checkout\Show as CheckoutShow;
use App\Livewire\Storefront\Collections\Index as CollectionsIndex;
use App\Livewire\Storefront\Collections\Show as CollectionShow;
use App\Livewire\Storefront\Home;
use App\Livewire\Storefront\Pages\Show as PageShow;
use App\Livewire\Storefront\Products\Show as ProductShow;
use App\Livewire\Storefront\Search\Index as SearchIndex;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Route;

Route::view('dashboard', 'dashboard')
    ->middleware(['auth', 'verified'])
    ->name('dashboard');

require __DIR__.'/settings.php';

Route::get('/favicon.ico', fn (): \Symfony\Component\HttpFoundation\Response => response('', 204))->name('favicon');

Route::middleware('store.resolve')->group(function (): void {
    Route::livewire('/', Home::class)->name('home');
    Route::livewire('/collections', CollectionsIndex::class)->name('collections.index');
    Route::livewire('/collections/{handle}', CollectionShow::class)->name('collection.show');
    Route::livewire('/products/{handle}', ProductShow::class)->name('product.show');
    Route::livewire('/cart', CartShow::class)->name('cart.show');
    Route::livewire('/search', SearchIndex::class)->name('search');
    Route::livewire('/pages/{handle}', PageShow::class)->name('page.show');
    Route::livewire('/checkout/{checkoutId}', CheckoutShow::class)->name('checkout.show');
    Route::livewire('/checkout/{checkoutId}/confirmation', CheckoutConfirmation::class)->name('checkout.confirmation');
    Route::livewire('/account/login', CustomerLogin::class)->middleware('throttle:login')->name('account.login');
    Route::livewire('/account/register', CustomerRegister::class)->name('account.register');
    Route::livewire('/forgot-password', CustomerForgotPassword::class)->name('password.request');
    Route::livewire('/reset-password/{token}', CustomerResetPassword::class)->name('password.reset');
    Route::post('/account/logout', function (): \Illuminate\Http\RedirectResponse {
        Auth::guard('customer')->logout();
        request()->session()->invalidate();
        request()->session()->regenerateToken();

        return redirect()->route('home');
    })->name('account.logout');

    Route::middleware('auth:customer')->group(function (): void {
        Route::livewire('/account', AccountDashboard::class)->name('account.dashboard');
        Route::livewire('/account/orders', AccountOrders::class)->name('account.orders');
        Route::livewire('/account/orders/{orderNumber}', AccountOrderShow::class)->name('account.order.show');
        Route::livewire('/account/addresses', AccountAddresses::class)->name('account.addresses');
    });
});

Route::livewire('/admin/login', AdminLogin::class)->middleware('throttle:login')->name('admin.login');
Route::livewire('/admin/forgot-password', AdminForgotPassword::class)->middleware('throttle:login')->name('admin.password.request');
Route::livewire('/admin/reset-password/{token}', AdminResetPassword::class)->name('admin.password.reset');
Route::post('/admin/logout', function (): \Illuminate\Http\RedirectResponse {
    Auth::guard('web')->logout();
    request()->session()->invalidate();
    request()->session()->regenerateToken();

    return redirect()->route('admin.login');
})->name('admin.logout');

Route::prefix('admin')->middleware(['auth', 'verified', 'store.resolve', 'role.check:owner,admin,staff,support'])->group(function (): void {
    Route::livewire('/', AdminDashboard::class)->name('admin.dashboard');
    Route::livewire('/products', AdminProductsIndex::class)->name('admin.products.index');
    Route::livewire('/products/create', AdminProductForm::class)->middleware('role.check:owner,admin,staff')->name('admin.products.create');
    Route::livewire('/products/{product}/edit', AdminProductForm::class)->middleware('role.check:owner,admin,staff')->name('admin.products.edit');
    Route::livewire('/orders', AdminOrdersIndex::class)->name('admin.orders.index');
    Route::livewire('/orders/{order}', AdminOrdersShow::class)->name('admin.orders.show');
    Route::livewire('/customers', AdminCustomersIndex::class)->name('admin.customers.index');
    Route::livewire('/customers/{customer}', AdminCustomersShow::class)->name('admin.customers.show');
    Route::livewire('/discounts', AdminDiscountsIndex::class)->name('admin.discounts.index');
    Route::livewire('/discounts/create', AdminDiscountForm::class)->middleware('role.check:owner,admin,staff')->name('admin.discounts.create');
    Route::livewire('/discounts/{discount}/edit', AdminDiscountForm::class)->middleware('role.check:owner,admin,staff')->name('admin.discounts.edit');
    Route::livewire('/settings', AdminSettingsGeneral::class)->middleware('role.check:owner,admin')->name('admin.settings');
    Route::livewire('/settings/shipping', AdminSettingsShipping::class)->middleware('role.check:owner,admin')->name('admin.settings.shipping');
    Route::livewire('/settings/taxes', AdminSettingsTaxes::class)->middleware('role.check:owner,admin')->name('admin.settings.taxes');
    Route::livewire('/inventory', AdminInventoryIndex::class)->name('admin.inventory');
    Route::livewire('/collections', AdminCollectionsIndex::class)->name('admin.collections');
    Route::livewire('/collections/create', AdminCollectionsCreate::class)->middleware('role.check:owner,admin,staff')->name('admin.collections.create');
    Route::livewire('/collections/{collection}/edit', AdminCollectionsEdit::class)->middleware('role.check:owner,admin,staff')->name('admin.collections.edit');
    Route::livewire('/themes', AdminThemesIndex::class)->name('admin.themes');
    Route::livewire('/themes/{theme}/editor', AdminThemesEditor::class)->name('admin.themes.editor');
    Route::livewire('/pages', AdminPagesIndex::class)->name('admin.pages');
    Route::livewire('/pages/create', AdminPagesCreate::class)->middleware('role.check:owner,admin')->name('admin.pages.create');
    Route::livewire('/pages/{page}/edit', AdminPagesEdit::class)->middleware('role.check:owner,admin')->name('admin.pages.edit');
    Route::livewire('/navigation', AdminNavigationIndex::class)->name('admin.navigation');
    Route::livewire('/apps', AdminAppsIndex::class)->name('admin.apps');
    Route::livewire('/apps/{installation}', AdminAppsShow::class)->name('admin.apps.show');
    Route::livewire('/developers', AdminDevelopersIndex::class)->name('admin.developers');
    Route::livewire('/analytics', AdminAnalyticsIndex::class)->name('admin.analytics');
    Route::livewire('/search/settings', AdminSearchSettings::class)->name('admin.search.settings');
});
--- app/Http/Controllers/Api/AdminController.php
<?php

namespace App\Http\Controllers\Api;

use App\Enums\ProductStatus;
use App\Http\Controllers\Controller;
use App\Models\Collection;
use App\Models\Customer;
use App\Models\Discount;
use App\Models\Order;
use App\Models\Product;
use App\Services\ProductService;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Str;

class AdminController extends Controller
{
    public function products(Request $request, int $storeId): JsonResponse
    {
        $this->assertStore($storeId);
        $data = $request->validate(['status' => ['nullable', 'in:draft,active,archived'], 'query' => ['nullable', 'string'], 'per_page' => ['nullable', 'integer', 'min:1', 'max:100']]);
        $products = Product::withoutGlobalScopes()->where('store_id', $storeId)->with(['variants.inventory', 'collections'])->when($data['status'] ?? null, fn ($query, string $status) => $query->where('status', $status))->when($data['query'] ?? null, fn ($query, string $queryText) => $query->where(function ($nested) use ($queryText): void {
            $nested->where('title', 'like', '%'.$queryText.'%')->orWhere('vendor', 'like', '%'.$queryText.'%')->orWhereHas('variants', fn ($variants) => $variants->where('sku', 'like', '%'.$queryText.'%'));
        }))->latest('updated_at')->paginate($data['per_page'] ?? 25);

        return $this->paginated($products);
    }

    public function storeProduct(Request $request, int $storeId, ProductService $products): JsonResponse
    {
        $this->assertStore($storeId);
        $data = $request->validate(['title' => ['required', 'string', 'max:255'], 'handle' => ['nullable', 'string', 'max:255'], 'description' => ['nullable', 'string'], 'vendor' => ['nullable', 'string', 'max:255'], 'product_type' => ['nullable', 'string', 'max:255'], 'status' => ['nullable', 'in:draft,active,archived'], 'variants' => ['nullable', 'array']]);
        $product = $products->create(app('current_store'), [...$data, 'status' => ProductStatus::from($data['status'] ?? ProductStatus::Draft->value)]);

        return response()->json(['data' => $product->load('variants')->toArray()], 201);
    }

    public function showProduct(int $storeId, int $productId): JsonResponse
    {
        $this->assertStore($storeId);
        $product = Product::withoutGlobalScopes()->where('store_id', $storeId)->with(['variants.inventory', 'options.values', 'media', 'collections'])->findOrFail($productId);

        return response()->json(['data' => $product->toArray()]);
    }

    public function updateProduct(Request $request, int $storeId, int $productId, ProductService $products): JsonResponse
    {
        $this->assertStore($storeId);
        $product = Product::withoutGlobalScopes()->where('store_id', $storeId)->findOrFail($productId);
        $data = $request->validate(['title' => ['sometimes', 'string', 'max:255'], 'description' => ['sometimes', 'nullable', 'string'], 'vendor' => ['sometimes', 'nullable', 'string', 'max:255'], 'product_type' => ['sometimes', 'nullable', 'string', 'max:255'], 'status' => ['sometimes', 'in:draft,active,archived']]);

        return response()->json(['data' => $products->update($product, $data)->toArray()]);
    }

    public function deleteProduct(int $storeId, int $productId, ProductService $products): JsonResponse
    {
        $this->assertStore($storeId);
        $product = Product::withoutGlobalScopes()->where('store_id', $storeId)->findOrFail($productId);
        $products->transitionStatus($product, ProductStatus::Archived);

        return response()->json(['message' => 'Product archived']);
    }

    public function collections(Request $request, int $storeId): JsonResponse
    {
        $this->assertStore($storeId);
        $data = $request->validate(['query' => ['nullable', 'string'], 'per_page' => ['nullable', 'integer', 'min:1', 'max:100']]);
        $collections = Collection::withoutGlobalScopes()->where('store_id', $storeId)->withCount('products')->when($data['query'] ?? null, fn ($query, string $queryText) => $query->where('title', 'like', '%'.$queryText.'%'))->latest()->paginate($data['per_page'] ?? 25);

        return $this->paginated($collections);
    }

    public function storeCollection(Request $request, int $storeId): JsonResponse
    {
        $this->assertStore($storeId);
        $data = $request->validate(['title' => ['required', 'string', 'max:255'], 'handle' => ['nullable', 'string', 'max:255'], 'description_html' => ['nullable', 'string'], 'status' => ['nullable', 'in:draft,active,archived'], 'product_ids' => ['nullable', 'array']]);
        $collection = Collection::withoutGlobalScopes()->create(['store_id' => $storeId, 'title' => $data['title'], 'handle' => $data['handle'] ?? Str::slug($data['title']), 'description' => $data['description_html'] ?? null, 'status' => $data['status'] ?? 'active']);
        $this->syncCollectionProducts($collection, $data['product_ids'] ?? [], $storeId);

        return response()->json(['data' => $collection->load('products')->toArray()], 201);
    }

    public function updateCollection(Request $request, int $storeId, int $collectionId): JsonResponse
    {
        $this->assertStore($storeId);
        $collection = Collection::withoutGlobalScopes()->where('store_id', $storeId)->findOrFail($collectionId);
        $data = $request->validate(['title' => ['sometimes', 'string', 'max:255'], 'description_html' => ['sometimes', 'nullable', 'string'], 'status' => ['sometimes', 'in:draft,active,archived'], 'product_ids' => ['sometimes', 'array']]);
        $collection->update(array_filter(['title' => $data['title'] ?? null, 'description' => $data['description_html'] ?? null, 'status' => $data['status'] ?? null], fn ($value): bool => $value !== null));

        if (array_key_exists('product_ids', $data)) {
            $this->syncCollectionProducts($collection, $data['product_ids'], $storeId);
        }

        return response()->json(['data' => $collection->load('products')->toArray()]);
    }

    public function deleteCollection(int $storeId, int $collectionId): JsonResponse
    {
        $this->assertStore($storeId);
        Collection::withoutGlobalScopes()->where('store_id', $storeId)->findOrFail($collectionId)->delete();

        return response()->json(['message' => 'Collection deleted']);
    }

    public function orders(Request $request, int $storeId): JsonResponse
    {
        $this->assertStore($storeId);
        $data = $request->validate(['status' => ['nullable', 'string'], 'financial_status' => ['nullable', 'string'], 'per_page' => ['nullable', 'integer', 'min:1', 'max:100']]);
        $orders = Order::withoutGlobalScopes()->where('store_id', $storeId)->with('customer')->when($data['status'] ?? null, fn ($query, string $status) => $query->where('status', $status))->when($data['financial_status'] ?? null, fn ($query, string $status) => $query->where('financial_status', $status))->latest('placed_at')->paginate($data['per_page'] ?? 25);

        return $this->paginated($orders);
    }

    public function showOrder(int $storeId, int $orderId): JsonResponse
    {
        $this->assertStore($storeId);
        $order = Order::withoutGlobalScopes()->where('store_id', $storeId)->with(['customer', 'lines', 'payments', 'refunds', 'fulfillments.lines'])->findOrFail($orderId);

        return response()->json(['data' => $order->toArray()]);
    }

    public function customers(Request $request, int $storeId): JsonResponse
    {
        $this->assertStore($storeId);
        $data = $request->validate(['query' => ['nullable', 'string'], 'per_page' => ['nullable', 'integer', 'min:1', 'max:100']]);
        $customers = Customer::withoutGlobalScopes()->where('store_id', $storeId)->when($data['query'] ?? null, fn ($query, string $queryText) => $query->where(function ($nested) use ($queryText): void {
            $nested->where('email', 'like', '%'.$queryText.'%')->orWhere('first_name', 'like', '%'.$queryText.'%')->orWhere('last_name', 'like', '%'.$queryText.'%');
        }))->latest()->paginate($data['per_page'] ?? 25);

        return $this->paginated($customers);
    }

    public function discounts(Request $request, int $storeId): JsonResponse
    {
        $this->assertStore($storeId);

        return $this->paginated(Discount::withoutGlobalScopes()->where('store_id', $storeId)->latest()->paginate($request->integer('per_page', 25)));
    }

    private function assertStore(int $storeId): void
    {
        abort_unless((int) app('current_store')->getKey() === $storeId, 404);
    }

    private function syncCollectionProducts(Collection $collection, array $productIds, int $storeId): void
    {
        $validIds = Product::withoutGlobalScopes()->where('store_id', $storeId)->whereIn('id', $productIds)->pluck('id')->all();
        $collection->products()->sync(array_fill_keys($validIds, ['position' => 0]));
    }

    private function paginated($paginator): JsonResponse
    {
        return response()->json(['data' => $paginator->items(), 'meta' => ['current_page' => $paginator->currentPage(), 'per_page' => $paginator->perPage(), 'total' => $paginator->total(), 'last_page' => $paginator->lastPage()]]);
    }
}
--- admin livewire files
app/Livewire/Admin/Analytics/Index.php
app/Livewire/Admin/Apps/Index.php
app/Livewire/Admin/Apps/Show.php
app/Livewire/Admin/Auth/ForgotPassword.php
app/Livewire/Admin/Auth/Login.php
app/Livewire/Admin/Auth/ResetPassword.php
app/Livewire/Admin/Collections/Create.php
app/Livewire/Admin/Collections/Edit.php
app/Livewire/Admin/Collections/Index.php
app/Livewire/Admin/Customers/Index.php
app/Livewire/Admin/Customers/Show.php
app/Livewire/Admin/Dashboard.php
app/Livewire/Admin/Developers/Index.php
app/Livewire/Admin/Discounts/Form.php
app/Livewire/Admin/Discounts/Index.php
app/Livewire/Admin/Inventory/Index.php
app/Livewire/Admin/Navigation/Index.php
app/Livewire/Admin/Orders/Index.php
app/Livewire/Admin/Orders/Show.php
app/Livewire/Admin/Pages/Create.php
app/Livewire/Admin/Pages/Edit.php
app/Livewire/Admin/Pages/Index.php
app/Livewire/Admin/Products/Form.php
app/Livewire/Admin/Products/Index.php
app/Livewire/Admin/Search/Settings.php
app/Livewire/Admin/Section.php
app/Livewire/Admin/Settings/General.php
app/Livewire/Admin/Settings/Shipping.php
app/Livewire/Admin/Settings/Taxes.php
app/Livewire/Admin/Themes/Editor.php
app/Livewire/Admin/Themes/Index.php
--- storefront livewire files
app/Livewire/Storefront/Account/Addresses/Index.php
app/Livewire/Storefront/Account/Auth/ForgotPassword.php
app/Livewire/Storefront/Account/Auth/Login.php
app/Livewire/Storefront/Account/Auth/Register.php
app/Livewire/Storefront/Account/Auth/ResetPassword.php
app/Livewire/Storefront/Account/Dashboard.php
app/Livewire/Storefront/Account/Orders/Index.php
app/Livewire/Storefront/Account/Orders/Show.php
app/Livewire/Storefront/Cart/Show.php
app/Livewire/Storefront/Checkout/Confirmation.php
app/Livewire/Storefront/Checkout/Show.php
app/Livewire/Storefront/Collections/Index.php
app/Livewire/Storefront/Collections/Show.php
app/Livewire/Storefront/Home.php
app/Livewire/Storefront/Pages/Show.php
app/Livewire/Storefront/Products/Show.php
app/Livewire/Storefront/Search/Index.php
app/Livewire/Storefront/Search/Modal.php