/projects/Dec 1, 2025

Patrik Products Export API

Product data pipeline that syncs from PNV, enriches with live stock and pricing from Metakocka, AI-categorizes with Gemini, and exports to CSV, JSON, and XML for Shopify, Recharge, and custom integrations.

node.jsexpressmongodbgeminin8n

The shape of the problem

Patrik runs product data across two systems: PNV for the catalog and Metakocka for live stock and pricing. Downstream consumers — Shopify, Recharge, custom integrations — each want a different format. Manually exporting and reformatting was a recurring source of data staleness and human error.

What I built

An Express API that owns the full product data lifecycle. PNV exports arrive as CSV; the API parses, normalises, and upserts to MongoDB. Metakocka warehouse and pricelist APIs are called on demand to enrich each product with live stock levels and pricing. Google Gemini 2.5 Flash handles AI categorization in batch, with results cached to avoid redundant API spend.

Exports are served in three formats — CSV, JSON, XML — with named preset templates for each consumer. n8n triggers syncs via webhook on a schedule; there's no internal cron to drift.

Lessons

  • Webhook-driven sync (n8n → API) keeps scheduling logic outside the service, where it can be changed without a deploy.
  • AI categorization with caching is a practical pattern: expensive on first run, nearly free on subsequent syncs when the catalog is stable.
  • Separating sync (write path) from export (read path) means consumers never wait on an in-progress PNV pull.