# Wholesale distributors: order tracking using Laravel

## Summary
A order tracking blueprint for wholesale distributors built with Laravel on Ample. Domain schema: 
- **products** (sku, name, category, case_size, list_price, active): SKU catalog with case sizes;
- **stock_movements** (sku, warehouse, delta, reason, moved_at): receipts, picks and adjustments;
- **orders** (order_no, account_reference, status, placed_at): trade orders with status transitions;
- **order_lines** (order_no, sku, cases, unit_price): order contents;
- **events** (seq, record_type, record_id, kind, at): application-owned history written in the same transaction.

Public information includes: catalog with case sizes, minimum order and delivery terms, trade account application. Account-specific pricing and credit terms are confidential; the catalog shown publicly carries list prices only.

## Resource Requirements
- compute  
- postgres  
- s3-compatible-object-storage

## Infrastructure Requirements
- **Compute**
  - Status: verified
  - Summary: Apps run in isolated x86_64 Firecracker microVMs that auto-pause when idle and wake on request; sizes are the priced VM sizes.

- **Postgres**
  - Status: verified
  - Summary: Managed PostgreSQL 16 runs in its own microVM and is auto-provisioned when an app needs a database and no DATABASE_URL is supplied.

- **S3-compatible object storage**
  - Status: verified
  - Summary: Buckets are S3-compatible with issued credentials; PutObject and GetObject are verified by canary. Other S3 operations are not verified.

## Prerequisites
- A Laravel project (composer install --no-dev from composer.lock, then FrankenPHP serving public/ (php-server with the index.php fallback) reading PORT on the php-8.5 template)
- A PostgreSQL driver reading DATABASE_URL (auto-provisioned when omitted)
- Bucket credentials from `ample bucket create` passed as encrypted S3_* environment variables
- A review of which wholesale distributors data classes may be handled at all; this blueprint models public information only

## Workflow Steps
1. **Model the wholesale distributors domain**: Create the tables products, stock_movements, orders, order_lines, events. SKU catalog with case sizes lives in products; keep the sensitive classes (account pricing tiers, credit terms, delivery addresses) out of this schema.
2. **Model orders with explicit status transitions and order lines.**
3. **Apply status changes transactionally and record an event per change.**
4. **Expose status history to authorized callers only.**
5. **Deploy and verify history and conflict rejection.**
6. **Verify deployment**: Run the pattern self-test(s) from the example (/p/transactional-workflows) and your own acceptance checks for the wholesale distributors workflow.

## Success Checks
- App responds on its public URL
- Transactional-workflows self-test from the example

## Limitations
- The technical basis (transactional workflows on Laravel) was verified with the pattern fixture; the wholesale distributors schema and workflow are an original design for this blueprint and were not executed as a separate application.
- Account-specific pricing and credit terms are confidential; the catalog shown publicly carries list prices only.

## Cost Estimate
- **Currency**: USD
- **Monthly Amount**: 10.0
- **Components**:
  - App server: 5.0 monthly
  - Managed PostgreSQL database: 5.0 monthly

## Next Actions
- **Browse the catalog index**
- **Search published recipes by intent, stack and constraints**
- **Prepare a side-effect-free deployment plan for an authorized project**
- **Read the existing agent authentication setup**
