System Design

Built for scale

End-to-end transaction flow from frontend to fulfillment, powered by Aurora DSQL for transaction safety and Anthropic API for dynamic pricing.

Primary Flow

Request Pipeline

1. Client
Next.js

React UI on Vercel

Live counter updates

SSE real-time sync

POST
2. Backend
Server

purchaseDrop action

Validate request

Begin transaction

TX
3. Database
Aurora DSQL

SERIALIZABLE TX

OCC conflict detect

Conditional UPDATE

Secondary Flow

Dynamic Pricing & Fulfillment

1. State
DSQL
Live data updated atomically on each purchase
Signal
2. AI Agent
Anthropic

Analyze metrics

Price logic

Update version

Checkout
3. Payments
Stripe

Process payments

Webhook confirm

Fulfill orders

Core Entities

Database Schema

drops
id uuid (PK)
status 'live'|'ended'
released_units int
sold_units int (OCC)
current_price int
price_version int
created_at timestamp
orders
id uuid (PK)
drop_id uuid (FK)
buyer_id uuid
quantity int
price_version int
status string
created_at timestamp
ledger_entries
id uuid (PK)
drop_id uuid (FK)
order_id uuid (FK)
amount int (cents)
reason string
created_at timestamp
Safety Guarantees

Transaction Safety

SERIALIZABLE Isolation

All transactions execute serially. Aurora DSQL detects conflicts at COMMIT time using Optimistic Concurrency Control. No locks, pure conflict detection and retry.

Conditional Updates

purchaseDrop updates drops table only if: sold_units + qty <= released_units. If condition fails, transaction rolls back. Buyer gets "sold out" error.

Atomicity

Order creation and ledger entry succeed or fail together. No partial state. Idempotency keys prevent duplicate charges under any failure scenario.

Zero Overselling

Under 2000+ concurrent buyers, Aurora DSQL ensures exactly inventory count succeeds. Proven with load testing at /api/demo/loadtest.

Infrastructure

Deployment Stack

Frontend

Vercel (auto-deploy from git)

Next.js 16 with App Router

Server Components + Actions

SSE for live real-time

Database

Aurora DSQL (Multi-region)

SERIALIZABLE TX (default)

OCC for conflict detection

Automatic failover

Integrations

Stripe for payments

Anthropic API for pricing

Vercel Analytics tracking

Monitoring

Real-time transaction logs

Ledger auditing for compliance

Server action error tracking