Skip to content
Case study

The Mad Space

In production2025 · présentPrint-on-demand e-commerce marketplace
Full-Stack Engineer (Contract)
Next.js 16TypeScriptPrismaPostgreSQLStripeGelatoSupabaseVercel

Print-on-demand marketplace connecting creators and consumers. ~15,000 LOC, 30+ API endpoints, custom session-based auth, Google OAuth 2.0, GDPR/Loi 25 compliance, 7+ B2B integrations and automated Gelato fulfillment.

01

The problem

The founder wanted to build a marketplace where creative ideas are valued, artists earn from their designs, and profit-sharing is transparent (10-20% for idea contributors, 20-35% for designers). The platform needed to handle 3 user roles (admin, creator, customer), 4 currencies (CAD, USD, EUR, GBP), 2 languages (FR, EN) and 7+ external integrations, all maintained by a single engineer. The initial request was WordPress. I recommended a custom Next.js stack, justified by the need for complex workflows, Edge Functions and multi-currency support.

02

Constraints

Tight deadlines (~3 months for MVP). Production payments from day one: security non-negotiable. GDPR, Quebec Loi 25 and Loi 96 (bilingualism) compliance required from the start. Documentation in parallel to enable onboarding of a future second developer. The client had no technical expertise: every architecture decision had to be explained and defended.

03

The solution

Layered architecture with Next.js 16 App Router (Server Components by default), Prisma as the data layer with 10+ relational models, and isolated business modules per workflow. Custom session-based auth with 6-digit email verification (rate limiting 3/h, 15 min expiry, max 5 attempts) and Google OAuth 2.0 with refresh token rotation. Multi-currency Stripe Checkout with HMAC webhook signatures, Gelato for automated fulfillment (live mockups, templates, shipping), Google Merchant Center synced via Supabase Edge Functions Deno with 5/batch pagination. Multi-category cookie consent with conditional GA4 and Google Ads loading based on consent. Auto-currency detection via Vercel/Cloudflare geolocation headers. Admin bulk upload with intelligent color detection on ZIP file patterns (gco_COLORNAME).

04

Tech stack

Next.js 16 (App Router)TypeScript strictPrisma + PostgreSQLTailwind CSS 4Stripe CheckoutGelato (print-on-demand)Google Merchant Center (OAuth 2.0)GA4 + Google AdsSupabase (DB + Storage + Edge Functions Deno)VercelFramer Motion
05

Outcomes

~15,000 LOC of production TypeScript. 30+ REST API endpoints. 10+ Prisma/PostgreSQL models. 17+ fully bilingual pages. 5 global React contexts (theme, cart, currency, cookie consent, auth). 4 business workflows shipped (order, return, inventory, loyalty) with 5-7 automated steps per workflow. 20-30 successful CI/CD deployments on Vercel. API latency 150-300 ms, Stripe→Gelato webhook processing 300-500 ms. Complex-order processing dropped from ~25 min to ~10 min. Marketplace live in 2 markets (Canada + USA) with functional profit-sharing.

06

Learnings

Choosing custom Next.js over WordPress made everything else possible: Edge Functions, Server Components, complex multi-currency. Strict separation of business workflows into isolated modules let me add the 4th workflow (loyalty) in a few days without touching the first 3. Securing a production payment system changes your mindset: going from "it works locally" to "it withstands 100 attempts in 1 minute". What I'd do differently: invest earlier in Playwright + Stripe test mode integration tests on payment paths. Stripe mocks don't capture every edge case (declined cards, duplicate webhooks).