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.
// 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
Configurable Items
Media Assets
Price Re-eval Latency
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
Validation Log & Receipt
// 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.
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
Bypasses Vercel Serverless timeout thresholds. Media requests (images, video renders) are served from optimized external VPS clusters running Nginx file stream buffers.
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.
Target Model: Relational SQL
Normalized relational tables mapping options, products, price rules, and orders.
// ENGINEERING BLUEPRINTS
Technical Deep-Dive
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));
}// ENGINEERING HURDLES
Challenges & Resolutions
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.
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.