## Direct-to-consumer brands: inventory manager using Next.js

### Summary
A inventory manager blueprint for direct-to-consumer brands built with Next.js on Ample.

#### Domain schema:
- **products** (sku, name, collection, price, active): product catalog
- **stock_movements** (sku, warehouse, delta, reason, moved_at): fulfillment stock
- **orders** (order_no, channel, status, placed_at): orders with status transitions
- **order_lines** (order_no, sku, qty, unit_price): order contents
- **events** (seq, record_type, record_id, kind, at): application-owned history written in the same transaction.

**Public information:** product catalog and collections, shipping and returns policy, brand story. Kept out of scope until handling is reviewed: customer contact and payment details, discount codes tied to individuals. Checkout and payment are handled by your commerce provider; only catalog, stock and order status are modeled here.

### Technical basis verified on Next.js:
- An optimistic version check and an event row written in the same transaction.
- A stale update rejected.
- A history query over the application-owned events (history=2 conflict=rejected).

### Representative Queries
- Direct-to-consumer brands: inventory manager using Next.js
- Where can I host Direct-to-consumer brands: Inventory manager built with Next.js?
- I need a genuinely specialized inventory manager workflow covering product variants, branded media and fulfillment-state handling.

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

### Infrastructure Requirements
- **Compute**: Apps run in isolated x86_64 Firecracker microVMs that auto-pause when idle and wake on request; sizes are the priced VM sizes.
- **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.
- **S3-compatible object storage**: Buckets are S3-compatible with issued credentials; PutObject and GetObject are verified by canary.

### Framework
Next.js

### Workload
Inventory manager

### Industry
Direct-to-consumer brands

### Release Status
Published

### Support Status
Verified

### Execution Status
Ready

### Prerequisites
1. A Next.js project (next build then next start -H 0.0.0.0 -p $PORT on the node-22 template)
2. A PostgreSQL driver reading DATABASE_URL (auto-provisioned when omitted)
3. Bucket credentials from `ample bucket create` passed as encrypted S3_* environment variables
4. A review of which direct-to-consumer brands data classes may be handled at all; this blueprint models public information only.

### Workflow Steps
1. **Model the direct-to-consumer brands domain**: Create the tables products, stock_movements, orders, order_lines, events. Sensitive classes (customer contact and payment details, discount codes tied to individuals) kept out of this schema.
2. **Workflow step 1**: Model SKUs and stock movements; derive stock from movements.
3. **Workflow step 2**: Apply movements transactionally with an optimistic version check on the SKU.
4. **Workflow step 3**: Record an event per movement for history.
5. **Workflow step 4**: Deploy and verify history and rejected stale updates.
6. **Deploy**: Run the synchronous deploy once and read the result.
   - Command: `ample deploy . --name  --public --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-test(s) from the example and your own acceptance checks for the direct-to-consumer brands workflow.
   - Command: `ample logs  --kind build`

### Success Checks
- App responds on its public URL
  - Kind: http_get
  - Path: /  
  - Expect: ample canary next js patterns
- Transactional-workflows self-test from the example
  - Kind: http_get
  - Path: /p/transactional-workflows
  - Expect: see the pattern fixture checks

### Limitations
- The technical basis was verified; the direct-to-consumer brands schema and workflow are an original design.
- No health, financial, privacy or other compliance claim is made.
- Verified on the node-22 template at s-1vcpu-1gb; other sizes are unknown or unverified.
- Managed PostgreSQL 16 only; extensions, connection limits and other procedures are not verified.

### Cost Estimate
- **Currency**: USD
- **Monthly Amount**: 10.0
- **Components**:
  - App server: size s-1vcpu-1gb, quantity 1.0, monthly amount 5.0
  - Managed PostgreSQL database: size s-1vcpu-1gb, quantity 1.0, monthly amount 5.0
  - Note: Always-on monthly price of the tested sizes; apps and databases auto-pause when idle.

### Evidence Summary
- A Next.js pattern fixture deployed on Ample; the transactional workflows checks passed; the blueprint's schema and workflow build on that verified basis.

### Last Verified At
2026-09-21T02:34:39Z

### Next Actions
- **Browse the catalog index**: GET /v1/catalog
- **Search published recipes by intent, stack and constraints**: POST /v1/catalog/search
- **Prepare a side-effect-free deployment plan for an authorized project**: POST /v1/catalog/plan
- **Read the existing agent authentication setup**: GET /mcp/setup
- **Browse Direct-to-consumer brands**: GET /v1/catalog/nodes/industry%3Adirect-to-consumer-brands
- **Browse Inventory manager**: GET /v1/catalog/nodes/workload%3Ainventory-manager
- **Browse Next.js**: GET /v1/catalog/nodes/stack%3Aframework-next-js
- **Browse Deploy web app**: GET /v1/catalog/nodes/intent%3Adeploy-web-app
