Building GigDataServ: A Full-Stack E-Commerce Platform with Next.js 16

How we built a production e-commerce system with 160+ API routes, eBay marketplace integration, AI content enrichment, and self-hosted deployment — from the ground up.

GIGDATA LLC has been selling enterprise IT hardware since 2003. Over two decades, the business grew from a small operation into a top-rated eBay seller with 4,400+ reviews and a 99.9% positive feedback rating. Servers, switches, storage arrays, and components from Cisco, Dell, HP, IBM, Lenovo, and Ubiquiti — thousands of SKUs moving through a pipeline of testing, certification, listing, and fulfillment.

But eBay was always someone else's platform. Fees climb. Algorithm changes tank visibility overnight. Listing formats get deprecated. And you never truly own your customer relationships. So we built GigDataServ — a full-stack e-commerce platform that serves as a companion webstore to the eBay operation, giving the business a direct sales channel with complete control over the customer experience, pricing, and data.

This article is a technical deep-dive into what we built, the decisions we made, and why. If you're evaluating whether to build a custom e-commerce platform versus using Shopify or WooCommerce, this should give you a realistic picture of what's involved.

The Tech Stack

Framework Next.js 16 + React 19
Language TypeScript 5.8
Database PostgreSQL via Prisma 7.4 (60+ models)
Caching Redis (ioredis)
Styling Tailwind CSS 4.2
Payments Stripe (checkout, webhooks, refunds, auto tax)
Auth NextAuth v4 (credentials + Google OAuth + TOTP 2FA)
Deployment PM2 cluster mode, self-hosted on Proxmox VM
Monitoring Sentry + Redis-backed API performance tracking
Testing Vitest with 68+ unit tests

We chose Next.js over a decoupled SPA + API architecture because the server-side rendering and API route colocation dramatically reduces the operational surface area. When your product pages need to be indexable by Google and your API handlers live in the same repo, the deployment story is simpler and the developer experience is better. React 19's server components let us push data fetching to the server where it belongs, cutting client bundle sizes and eliminating loading spinner waterfalls.

TypeScript 5.8 isn't optional on a project this size. With 160+ API routes and 60+ Prisma models, the type system catches entire categories of bugs at compile time that would otherwise surface as runtime 500 errors in production. Prisma's generated types flow from the database schema all the way to the API response, creating a single source of truth.

Database Architecture: 60+ Models in Prisma

The Prisma schema has over 60 models, and that number reflects the real complexity of e-commerce. It's not just products and orders. It's products with variants, variant-specific pricing, inventory tracking per variant, bundle configurations, gift cards with balance ledgers, coupon rules with usage limits, abandoned cart snapshots, A/B test assignments, referral chains, shipping rate calculations, tax records, and audit logs.

One design decision that paid off early: we modeled inventory as a separate concern from products. A Product has many ProductVariant records, and each variant has an InventoryRecord with quantity, reserved quantity, and reorder thresholds. When a customer adds to cart, we create a stock reservation with a TTL. This prevents overselling without locking rows — the reservation expires if the customer abandons checkout, and a cron job cleans up stale reservations.

// Simplified reservation flow
const reservation = await prisma.stockReservation.create({
  data: {
    variantId,
    quantity,
    sessionId,
    expiresAt: new Date(Date.now() + 15 * 60 * 1000), // 15 min TTL
  },
});
await prisma.inventoryRecord.update({
  where: { variantId },
  data: { reserved: { increment: quantity } },
});

The inventory system also powers forecasting. We track sales velocity per SKU over 7, 30, and 90-day windows, calculate days-of-stock remaining, and surface reorder suggestions on the admin dashboard. For a hardware reseller dealing with unpredictable supply chains, knowing that you have 12 days of stock left on a hot-selling Cisco switch is the difference between continuous sales and a "sold out" page.

eBay Integration: The Bridge Between Two Worlds

The eBay integration was the most technically demanding piece of the entire project. GigDataServ doesn't replace the eBay store — it runs alongside it. That means inventory must stay synchronized across both channels, feedback from eBay needs to flow into the webstore as social proof, and pricing decisions need to be informed by real-time marketplace data.

Inventory Sync

Products listed on eBay are automatically imported into the webstore's catalog. When a sale happens on either channel, inventory decrements on both. This is handled through a combination of eBay's notification API (for eBay-side sales) and webhook-triggered sync jobs (for webstore sales). The sync runs on a cron schedule as a safety net, reconciling any drift every 30 minutes.

Market Research & Competitive Pricing

We use the eBay Browse API to pull completed listing data for competitive pricing intelligence. When listing a Cisco WS-C3850-24T switch, the system queries recent sold prices for the same model, calculates the median and range, and suggests a competitive price point. This isn't just a nice-to-have — in enterprise IT hardware, price differences of $20-50 determine who gets the sale.

Feedback Sync

Those 4,400+ positive reviews are a massive trust signal. A cron job pulls recent eBay feedback and surfaces it on the webstore as verified marketplace reviews. Customers on the webstore see the same track record that eBay buyers see, which is critical for conversion when you're asking someone to trust a standalone webstore with a $2,000 server purchase.

Payments: Stripe at Production Scale

Stripe handles all payment processing through checkout sessions. The integration goes beyond basic charges — we use Stripe's automatic tax calculation (critical for multi-state sales tax compliance), process refunds through the API, and handle the full webhook lifecycle for payment confirmation, disputes, and subscription events.

The webhook handler is one of the most carefully tested pieces of the codebase. Stripe sends webhooks for dozens of event types, and each one needs idempotent handling. A checkout.session.completed event triggers order creation, inventory decrement, confirmation email, and analytics tracking. If any step fails, the entire operation rolls back and the webhook returns a 500 so Stripe retries. We verify webhook signatures, reject replays, and log every event for audit purposes.

AI Content Enrichment via Grok API

Enterprise IT hardware has a thin content problem. A typical product listing might have a part number, a one-line description from the manufacturer, and some specs. That's not enough for SEO, and it's not enough to help a buyer understand why they should choose this specific switch over three alternatives.

We integrated the Grok API to automatically enrich product content. When a new product is imported (from eBay sync or manual entry) with minimal content, a background job sends the available data — part number, manufacturer, category, specs — to Grok and gets back a detailed product description, key features list, and use-case suggestions. The generated content goes into a review queue before publishing, but it cuts the time from "new SKU" to "fully described listing" from 15-20 minutes of manual writing down to 30 seconds of review.

The AI enrichment pipeline processes roughly 50-80 new SKUs per week. At 15 minutes of manual writing per SKU, that's 12-20 hours of content work eliminated every week — time that goes back into sourcing, testing, and shipping hardware.

Authentication & Security

NextAuth v4 handles authentication with both credentials-based login and Google OAuth. Admin accounts require TOTP-based two-factor authentication — non-negotiable when the admin panel controls inventory, pricing, refunds, and customer data.

Security runs deeper than auth. Every form submission is protected by Cloudflare Turnstile CAPTCHA. CSRF tokens are validated on all state-changing operations. Rate limiting (backed by Redis) prevents brute force attempts and API abuse. Input sanitization runs on every user-supplied value before it touches the database. These aren't features we added after launch — they were built into the architecture from day one.

The Abandoned Cart Recovery System

Cart abandonment in e-commerce runs 60-80%. For a store selling high-value IT hardware, recovering even a small percentage of abandoned carts has significant revenue impact. We built a three-email progressive recovery sequence:

Email 1 (2 hours after abandonment): A simple reminder. "You left something in your cart." No discount, no pressure. This catches people who genuinely got distracted.

Email 2 (24 hours): A follow-up with product-specific information — stock levels, recently sold count, specs summary. Creates informed urgency without fake scarcity tactics.

Email 3 (72 hours): An auto-generated coupon code with a modest discount. The coupon is unique per cart, single-use, and expires in 7 days. The system tracks which email in the sequence converted, so we can optimize timing and messaging over time.

The coupon generation system is shared with the broader gift card and promotional infrastructure. Coupons can be percentage-based, fixed-amount, free-shipping, or minimum-purchase-triggered. Each has usage limits, expiration dates, and product/category restrictions.

Social Proof & Conversion Optimization

We built several social proof mechanisms that run without manual intervention:

Recent purchase toasts: Non-intrusive notifications showing recent purchases ("Someone in Texas just bought a Dell PowerEdge R740"). These are real transactions, not fabricated — pulled from the last 24 hours of order data with location derived from shipping state.

Viewing counter: Shows approximate concurrent viewers on a product page, tracked via Redis with a 5-minute sliding window. "4 people are viewing this right now" is only shown when the number is genuinely above a threshold.

Sold count: Lifetime and recent (30-day) sold counts displayed on product pages. For popular SKUs, this is a powerful trust signal.

A/B Testing Framework

We didn't want to rely on third-party A/B testing tools that add JavaScript bloat and create privacy concerns. The built-in framework assigns users to test variants server-side (stored in a cookie and database), tracks conversion events, and calculates statistical significance using chi-squared tests. We can test headlines, CTAs, pricing display formats, and layout variations without any external dependencies.

Operational Infrastructure

Self-Hosted Deployment

GigDataServ runs on a Proxmox VM, not Vercel or AWS. PM2 manages the Node.js process in cluster mode, utilizing all available CPU cores. This was a deliberate choice: hosting costs for a high-traffic e-commerce site on Vercel's Pro plan would run $400-600/month with bandwidth and function invocation charges. Our self-hosted setup costs a fraction of that, and we have full control over the environment, SSL configuration, caching layers, and deployment process.

Eleven Cron Jobs

The platform runs 11 automated background tasks that keep everything in sync and healthy:

  • Stale stock reservation cleanup
  • eBay inventory reconciliation
  • eBay feedback sync
  • Google Merchant Center product feed sync
  • Abandoned cart email sequence triggers
  • Expired coupon cleanup
  • API performance metric aggregation
  • Low stock alert notifications
  • Session and token cleanup
  • Sitemap regeneration
  • AI content enrichment queue processing

Shipping: Pirate Ship Integration

Shipping integration uses a CSV export/import workflow with Pirate Ship. Orders ready to ship are exported in Pirate Ship's expected format, labels are purchased at commercial rates, and tracking numbers are imported back into the system. The tracking numbers propagate to order confirmation emails, customer dashboards, and (for eBay-synced orders) back to eBay's tracking system.

Monitoring & Observability

Sentry captures runtime errors with full stack traces, request context, and user information. But we also built a Redis-backed API performance monitoring layer that tracks request timing for every route. The admin dashboard shows p50, p95, and p99 response times, error rates, and throughput — broken down by route. When a specific API endpoint starts degrading, we know about it before customers notice.

Additional Platform Features

Gift card system: Digital gift cards with unique codes, balance tracking, partial redemption support, and expiration dates. Gift cards are treated as a payment method at checkout, combinable with other payment sources.

Product bundles: Create bundles of related products with combined pricing. A "Dell R740 Starter Kit" might include the server, rail kit, and bezel at a 10% discount versus buying individually. Bundles have their own inventory tracking that decrements component-level stock.

Referral program: Customers earn credits for referring new buyers. Referral links are tracked, attribution is handled server-side, and credits are applied automatically at checkout. The referral chain is auditable for fraud detection.

Built-in blog/CMS: A content management system for publishing blog posts, product guides, and technical documentation — all within the same Next.js application with no external CMS dependency.

Compliance & Privacy

E-commerce compliance isn't optional. The platform implements cookie consent management (tracking scripts only load after consent), CAN-SPAM compliant email with one-click unsubscribe, and data handling practices aligned with GDPR and CCPA requirements. Customer data export and deletion requests are handled through an admin workflow that produces a complete data package or provably removes all personal information.

By the Numbers

API Routes 160+
Prisma Models 60+
Unit Tests 68+ (Vitest)
Cron Jobs 11 automated tasks
eBay Reviews 4,400+ at 99.9% positive
Years in Operation 20+ (GIGDATA LLC since 2003)

What We Learned

Building a custom e-commerce platform is not the right choice for most businesses. Shopify exists for a reason. But when your business has specific integrations (eBay inventory sync), unique operational requirements (web/dropship overrides), and the technical capability to maintain a custom system, the payoff is substantial. You own the platform, you control the roadmap, and your margins improve because you're not paying per-transaction SaaS fees on every order.

The most underestimated part of the project wasn't any single feature — it was the cron jobs. Eleven background tasks that quietly keep the system healthy, data synchronized, and customers engaged. They don't show up in demos or screenshots, but they're the difference between a prototype and a production system.

GigDataServ is live at gigdataserv.com. If you're interested in building a custom e-commerce platform or need help integrating marketplace channels with a direct sales operation, get in touch.

← All Blog Posts Next: Building AI-Signed →

Need a custom e-commerce platform built for your business?

Start a Conversation