Zoniraz Commerce

Engineering a highly configurable production-scale commerce platform for luxury jewelry, featuring a formula-driven pricing engine, multi-variant structures, and optimized media pipelines.

Next.js App RouterPostgreSQLMongoDB Schema RedesignRazorpay IntegrationNextAuth SecurityCloudinary CDNExternal VPS CDN StorageDocker ContainerizationDokploy EngineMongoDB Atlas

// PRODUCTION OVERVIEW

Architecting Luxury Commerce

Zoniraz is a founding engineering project designed to capture, value, and coordinate high-end jewelry sales. Traditional e-commerce models manage products as static catalog items. In luxury commerce, however, products are highly custom and depend on gold/silver weight options, gemstone sizes, wastage indexes, and active market rates.

To support this variability at scale, Zoniraz implements a custom **Configurable Variant and Formula-driven pricing model**. With 650+ core products, 6500+ optimized media assets, and server-validated Razorpay checkout endpoints, this architecture bridges strict relational state control with sub-second page performance.

Product Metrics

650+

Configurable Items

6500+

Media Assets

<200ms

Price Re-eval Latency

Zero

Price Tamper Incidents

// COMMERCE ARCHITECTURE

System Architecture & Data Flows

Follow the data flow tracing how external commodity feeds refresh price caches, validate transaction values securely on the server-side, and check signatures against Razorpay webhooks.

Live Commodity Feed

APIs Webhooks

Pricing Cache Layer

Redis / Server State

Dynamic SKU Generator

Catalog Configurator

Razorpay Checkout

User Action

Server Validation

Anti-Tamper Layer

Order Database

Relational Ledger

// PRICING SIMULATION ENGINE

Dynamic Cost Formulas in Real-Time

Zoniraz dynamically calculates client-facing prices using market indices. Adjust the parameters below to preview the pricing outputs in real time, replicating the server-side validation mechanics:

Pricing Parameters Configuration

Metal Weight (g)6.5g
Wastage Buffer10%
Making Charges ($)$120
Gemstone Valuation ($)$350
Business Rules Markup+15%

Validation Log & Receipt

Live Rate (per g):$58.88
Raw Metal Cost:$382.69
Wastage Cost (10%):+$38.27
Making Charges:+$120.00
Gemstone Cost:+$350.00
Aggregate Cost:$890.96
Margin Markup (15%):+$133.64
Server-Validated Store Checkout Price$1024.60
Price checked against live metadata structures: VALID

// CATALOG ENGINE

Configurable Product Engine

Each product represented in the catalog is not a simple SKU record, but a multi-dimensional variant model. A single jewelry design, such as an engagement ring, expands dynamically into dozens of variants based on client customization selections:

  • Metal Configuration: Gold (14k, 18k, 22k in Yellow, White, or Rose shades) and Platinum.
  • Gemstone Attributes: Carat weights, clarity grades, and certified cuts (Brilliant, Oval, Cushion).
  • Physical Sizing: Standard ring sizing scales. Sizing changes adjust metal weights dynamically on the fly.
Variant Schema Structure (SQL DDL)
CREATE TABLE products (
  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  name VARCHAR(255) NOT NULL,
  slug VARCHAR(255) UNIQUE NOT NULL,
  base_making_charge DECIMAL(10, 2) NOT NULL
);

CREATE TABLE product_skus (
  id UUID PRIMARY KEY,
  product_id UUID REFERENCES products(id),
  sku_code VARCHAR(100) UNIQUE NOT NULL,
  metal_type VARCHAR(50) NOT NULL,
  metal_weight DECIMAL(8, 3) NOT NULL,
  gemstone_type VARCHAR(100),
  gemstone_weight DECIMAL(8, 3),
  inventory_count INT NOT NULL DEFAULT 0
);

Media Optimization Node Configurations

Self-Hosted VPS Media Storage

Bypasses Vercel Serverless timeout thresholds. Media requests (images, video renders) are served from optimized external VPS clusters running Nginx file stream buffers.

Dynamic CDN Invalidation Webhooks

Admin uploads trigger auto-transformaton tasks (Cloudinary resizing/webp compression) and immediately invalidate Edge caches via API webhooks.

// MEDIA & CMS PIPELINE

Dynamic Media Hosting

Luxury products require high-fidelity visualization, resulting in **6,500+ rich media assets** (including multi-angle high-res photos and detailed 3D jewelry renders). Storing these inside standard Next.js packages leads to massive repo bloated assets.

Zoniraz solves this by separating assets into an **external VPS media storage block**. All media is pushed dynamically to this cluster, optimized at the edge with WebP conversions, and cached on CDN pipelines. The administrator CMS panel synchronizes metadata with Next.js page models seamlessly.

// DATA ARCHITECTURE MIGRATION

Migrating MongoDB schemas to Relational SQL Databases

Explore the technical analysis behind shifting from MongoDB document architectures to strict relational PostgreSQL engines to eliminate inventory mismatch states:

Previous Model: MongoDB Schemas

Initially structured as nested JSON documents to allow flexible attribute definitions.

Catalog BloatDuplicate structures representing slightly different weights and carat grades led to massive JSON storage footprints.
Consistency HazardsUpdating a live metal price formula forced multi-document transactional updates, risking partial pricing failure states.

Target Model: Relational SQL

Normalized relational tables mapping options, products, price rules, and orders.

Strict ConstraintsEnforced foreign key constraints preventing orders from referencing deleted SKUs or orphaned inventory entries.
Sub-Second Price UpdatesActive rate rules are isolated to a single row query in a metal index table, immediately recalculating all SKU calculations on index shifts.

// ENGINEERING BLUEPRINTS

Technical Deep-Dive

Implementation: pricing engine

Dynamic Pricing Engine (Server-side validation)

This logic computes raw metal prices from active rates, adds wastage percentages, and applies business markups. It handles checkout calculations in backend Route Handlers to ensure price validity.

// Server Pricing Validation Engine
export async function calculateLiveSkuPrice(
  skuId: string, 
  liveGoldRate: number
): Promise<number> {
  const sku = await db.productSku.findUnique({
    where: { id: skuId },
    include: { product: true }
  });
  
  if (!sku) throw new Error("SKU not found");

  const rawMetalCost = Number(sku.metalWeight) * liveGoldRate;
  const wastageCost = rawMetalCost * (Number(sku.wastagePercent) / 100);
  const aggregateCost = rawMetalCost + wastageCost + Number(sku.makingCharges) + Number(sku.gemstoneValuation);
  
  // Apply business rules markup from DB configuration
  const markup = await db.markupConfig.findFirst();
  const finalPrice = aggregateCost * (1 + Number(markup?.percentage || 0) / 100);
  
  return parseFloat(finalPrice.toFixed(2));
}
Deployment: Docker Standard ClusterQA Certified

// ENGINEERING HURDLES

Challenges & Resolutions

The Challenge:

Commodity API rate updates occur frequently. Recalculating prices for 650+ core configurations on active client requests caused document locks, raising transaction latency and database resource spikes.

The Solution:

Engineered a pre-calculated index database updater. Rates are polled in the background via n8n workflows and stored in a redis-based price rules table. An asynchronous worker thread calculates the modified SKU values and caches them. The client reads from the static cached values, maintaining sub-second load speeds during rate shifts.

// ENGINEERING RETROSPECTIVE

Lessons & Key Learnings

// ARCHITECTURAL REFLECTION

Relational Integrity Over Flex Schema

While document stores like MongoDB are convenient during early prototyping phases, strict relational models (SQL) are highly superior for managing financial ledger data and multi-variant products.

Normalizing data schemas, enforcing foreign keys, and using SQL transaction isolations prevented orphaned SKUs or corrupted stock records, proving that structural database design is crucial for commerce platforms.

// INFRASTRUCTURE REFLECTION

Self-Hosting Benefits & Scalability

Using Docker containers and deployment control panels like Dokploy on a dedicated VPS server significantly cuts infrastructure costs compared to serverless providers.

It allows direct control over memory configurations, lets media stream through Nginx reverse proxy buffers directly, and provides isolated database caches for sub-second page performance.