## Wholesale distributors: product catalog using Django

### Summary
A product catalog blueprint for wholesale distributors built with Django 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 the catalog with case sizes, minimum order and delivery terms, and trade account application.

### Technical Basis
Verified on Django with:
- An optimistic version check
- An event row written in the same transaction
- A stale update rejected
- A history query over the application-owned events (history=2 conflict=rejected).

### Resource Requirements
- **Compute**
- **Postgres**
- **S3-compatible object storage**

### Infrastructure Requirements
1. **Compute**  
   Apps run in isolated x86_64 Firecracker microVMs that auto-pause when idle and wake on request; sizes are the priced VM sizes.
2. **Postgres**  
   Managed PostgreSQL 16 runs in its own microVM and is auto-provisioned when an app needs a database and no DATABASE_URL is supplied.
3. **S3-compatible object storage**  
   Buckets are S3-compatible with issued credentials; PutObject and GetObject are verified by canary. Other S3 operations are not verified.

### 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 sensitive classes (account pricing tiers, credit terms, delivery addresses) out of this schema.
2. **Workflow step 1**  
   Model the SKU catalog with versioned updates.
3. **Workflow step 2**  
   Record every catalog change as an event in the same transaction.
4. **Workflow step 3**  
   Reject stale concurrent updates.
5. **Workflow step 4**  
   Deploy and verify history and conflict handling.
6. **Deploy**  
   Run the synchronous deploy once and read the result. Re-running with no change is a no-op.
   
   Command: `ample deploy . --name --public --start "python3 run.py" --env S3_ENDPOINT=... --env S3_REGION=... --env S3_BUCKET=... --env S3_ACCESS_KEY_ID=... --env S3_SECRET_ACCESS_KEY=...`
7. **Verify**  
   Run the pattern self-tests from the example and your own acceptance checks for the wholesale distributors workflow.
   
   Command: `ample logs --kind build`

### Examples
- **Django pattern fixture**  
  Verified transactional workflows basis for this blueprint.

### Success Checks
1. App responds on its public URL (expect: ample canary django patterns).
2. Transactional-workflows self-test from the example (expect: see the pattern fixture checks).

### Limitations
- The wholesale distributors schema and workflow are an original design for this blueprint and were not executed as a separate application.
- No health, financial, privacy or other compliance claim is made. Account-specific pricing and credit terms are confidential; the catalog shown publicly carries list prices only.
- Verified on the python-3.12 template at s-1vcpu-1gb; region, request-duration limits, and other sizes are unknown or unverified.

### Cost Estimate
- **Currency**: USD  
- **Monthly Amount**: 10.0  
- **Note**: Always-on monthly price of the tested sizes; apps and databases auto-pause when idle. Buckets are allocation-priced per quota and not included.

### Evidence Summary
- **Kind**: Canary run  
  Django pattern fixture deployed on Ample; the transactional workflows checks passed.

### Next Actions
1. **Browse the catalog index**  
   Method: `GET`  
   Relative Path: `/v1/catalog`
2. **Search published recipes by intent, stack, and constraints**  
   Method: `POST`  
   Relative Path: `/v1/catalog/search`
3. **Prepare a side-effect-free deployment plan for an authorized project**  
   Method: `POST`  
   Relative Path: `/v1/catalog/plan`
4. **Read the existing agent authentication setup**  
   Method: `GET`  
   Relative Path: `/mcp/setup`
5. **Browse Wholesale distributors**  
   Method: `GET`  
   Relative Path: `/v1/catalog/nodes/industry%3Awholesale-distributors`
6. **Browse Product catalog**  
   Method: `GET`  
   Relative Path: `/v1/catalog/nodes/workload%3Aproduct-catalog`
7. **Browse Django**  
   Method: `GET`  
   Relative Path: `/v1/catalog/nodes/stack%3Aframework-django`
8. **Browse Deploy web app**  
   Method: `GET`  
   Relative Path: `/v1/catalog/nodes/intent%3Adeploy-web-app`
