Arianova | Luxury Wine Distribution Portal
Ideation, Design & Fullstack (AI-Assisted) · June 16, 2026
Project Overview
Arianova is a highly complex, B2B and D2C Luxury Wine Distribution Portal. It connects heritage Italian wine estates directly with professional retail, hospitality buyers, and elite collectors.
The goal was to create an experience that felt as premium as the product line. We embraced a Neoclassical Aesthetic—featuring a curated palette of Deep Burgundy (#4A0404), Antique Cream (#F9F6EE), and Harvest Gold (#B8860B)—paired with Framer Motion for tactile, immersive transitions.
[!NOTE] Interactive UI showcases and walkthrough media are currently being compiled while the system goes through final staging verification.
The Architectural Pivot: The Xero Migration
Behind the neoclassical minimalism is a resilient commerce engine. Originally integrated with Cin7 Core, the platform underwent a major architectural migration in June 2026 to deprecate Cin7 Core and move entirely to Xero as the unified ERP, inventory ledger, and invoicing engine. This migration eliminated high monthly SaaS overhead while establishing a unified ledger.
Under this new architecture:
- Xero serves as the singular “Source of Truth” for physical stock (
QuantityOnHand), Retail (Stripe-reconciled) invoicing, and B2B (Net-30) invoicing. - Sanity CMS handles dynamic storefront catalog management, partner estate editorial profiles, and optimistic checkout locking.
- Clerk governs B2B “Trade Account” authentication and client loyalty tier tracking.
Engineering Challenges & Solutions
1. Zero-Overselling & Ghost Inventory Locking
To guarantee zero overselling of highly limited vintage allocations without sacrificing load speeds, we engineered a dual-database Ghost Locking state machine.
When a user initiates checkout, the API route bypasses the Sanity CDN cache to verify stock. It evaluates a definitive Hierarchy of Truth: if the item is explicitly tracked in Xero, it reads the live QuantityOnHand via Xero’s API; if untracked or if Xero times out, it falls back to Sanity’s cached physical_stock. It then applies an Optimistic Soft Lock in Sanity, incrementing the wine’s committed_stock for a strict 30-minute window.
// --- THE SOFT LOCK MUTATION ---
// We increment `committed_stock` to reserve these bottles for THIS session.
// We use `ifRevisionID` to guarantee that nobody else changed this document
// in the millisecond between our fetch and our patch.
tx.patch(item.id, {
ifRevisionID: dbWine._rev,
setIfMissing: { committed_stock: 0 },
inc: { committed_stock: item.quantity }
})
If the checkout session expires or fails, a self-healing process instantly releases the soft lock, ensuring physical stock and the Xero ledger remain completely untouched.
1. Checkout Initiation
Client starts checkout. The system bypasses cache to query live QuantityOnHand from Xero.
2. Optimistic Soft Lock
If stock is available, an optimistic lock (incrementing committed_stock) is applied in Sanity CMS for 30 minutes.
3. Stripe Checkout Session
A Stripe Checkout Session is generated and the client is redirected to complete payment.
4A. Payment Success (Commit)
Stripe webhook signals success. An authorized invoice is created in Xero (automatically reducing stock ledger) and the Sanity soft lock is released.
4B. Abandonment or Failure (Release)
If the session expires or fails, the 30-minute lock in Sanity is released. Xero is untouched, guaranteeing zero overselling.
2. B2B Wholesale Portal
Wholesale buyers are provisioned via Clerk (user.publicMetadata.role === "wholesale") on an admin-invite only basis. Unlike D2C buyers, B2B users:
- Access private wholesale pricing, dynamically protected from public GROQ queries.
- Bypass Stripe checkout entirely and order on account via
/api/b2b/checkout. - Are subject to a strict 12-bottle Minimum Order Quantity (MOQ).
- Automatically trigger a synchronous invoice creation in Xero with
AUTHORISEDstatus and a Net-30 credit termDueDate.
3. Webhook Resiliency & Serverless Tuning
Handling order handoffs between Stripe, Xero, and Sanity in a serverless environment required custom optimization to prevent data loss:
- Stripe Webhook Retry Integration: Instead of running a scheduled background worker to retry failed Xero pushes (which risks concurrency conflicts), the system returns a
500 Internal Server Errorto Stripe if Xero is down. Stripe’s native exponential retry engine handles the re-delivery. The webhook processor uses SanityIntegration Logsto check if the Sanity mutations already succeeded, allowing it to skip duplicate database changes and safely retry only the Xero push. - Vercel Hobby Tier Workarounds: Vercel Hobby containers suspend execution immediately after a response is sent, which crashes asynchronous background utilities like Next.js’s
after(). To resolve this, we restructured the webhook to run Xero token rotation and invoicing synchronously before returning a 200 OK. We raised Vercel’s execution ceiling toexport const maxDuration = 60to accommodate this. - Neon Serverless Postgres Connection Safety: Neon Postgres connections can terminate abruptly when Vercel freezes idle containers, throwing exit code 129. We refactored our database clients to be strictly instantiated (
createClient()) and torn down (await client.end()) insidefinallyblocks within every serverless handler.
Results
| Metric | Before | After | Change |
|---|---|---|---|
| Inventory Sync Accuracy | N/A | 100% | Zero Overselling |
| B2B Order Processing | Manual | Automated | Net-30 Invoices Sent to Xero |
| Operational Overhead | High | Low | Cin7 Core SaaS Fees Eliminated |
| Data Consistency | Low | Absolute | Idempotent transaction systems |
Tech Stack Deep Dive
- Framework: Next.js 16.2 (Turbopack) with App Router
- Styling: Vanilla CSS & Tailwind 4.0 with custom luxury design tokens
- Auth: Clerk (Custom B2B “Trade Account” and wholesale roles)
- CMS: Sanity.io (Catalog, Partner Estates, Integration Logging)
- ERP & Accounting: Xero (Unified stock inventory, invoices, and ledgers)
- Payments: Stripe (D2C retail checkout with automated clearing reconciliation)
- Email: Resend & React Email (Automated allocation confirmations)
- Motion: Framer Motion for premium, tactile UI transitions