The Merch App powers the fan-facing custom merchandise experience. It supports three distinct conceptual journeys:
The UI is served by apps/zooly-app/ under /merch (the former apps/zooly-merch/ Vite wrapper has been removed), with client code in packages/merch/client/, server logic in packages/merch/srv/, admin builder in packages/merch-admin/, payment integration via @zooly/srv-stripe-payment, and a Drizzle-backed API on apps/zooly-app/.
isPersonalized). Personalized designs utilize selfies and AI generation; Branded designs skip selfie-capture and generation entirely to apply template artwork directly.catalogProductIds./create route combines AI generation, art selection, cart review, and reselfie — internal states (loading, art selection, cart) without extra navigations; reselfie is an inline overlay.catalog_renderer_config, including media-managed preview/clean outputs and background-mask reuse./cart deep link; admins triage remaining carts in zooly-stats. See Abandoned Cart Recovery.The merch UI is mounted by apps/zooly-app/ at /merch (app/(pages)/merch/ lazy-imports the client package). All React code lives in packages/merch/client/ (@zooly/merch-client) — 15 page routes, 22 components, 6 hooks, MerchContext for state management. Styled with DM Sans font and --merch-* CSS custom properties.
20 Next.js API routes (thin wrappers) handling campaign config, session management, image upload/verification, AI generation, art candidate selection, mockup rendering, pricing, payment, and order completion.
@zooly/merch-srv — 25 service files covering AI art generation, image processing pipeline, order creation, email delivery, lifecycle FSM, and analytics tracking.
@zooly/srv-stripe-payment handles merch payment processing: createMerchPaymentIntent for PI creation with audit trail and idempotency, and completePaymentFromClient for server-side payment verification and revenue distribution.
Mounted by apps/zooly-app/ at /admin/merch (app/(pages)/admin/merch/ lazy-imports @zooly/merch-admin-client). V2 campaign builder with URL-routed tabs (Setup, Design, Simulation, Translation, Benchmark). Uses Zustand for state management. The Design tab supports a 3-level hierarchy: Design (base settings) → Product Variation → Demographic Variation, with config merging at each level.
The Benchmark tab (/benchmark) mounts @zooly/merch-benchmark-client for AI model/prompt comparison runs through the production generation pipeline. See Image Generation Benchmark.
The Templates screen (/templates) is Template Studio (v2) — a staged admin pipeline for reusable personalized templates (display image → blue/green dummy → replace prompts → optional talent bake → benchmark → activate). See Template Studio (v2).
25 Drizzle tables across two schema files, 19 enums, 14 access files. Campaign data is normalized into satellite tables (branding, studio, legal, config, copy). Designs support a 3-level hierarchy with config inheritance. Covers campaigns, products, sessions, selfies, cart items, designs, generation cache, orders, analytics, tracking, AI models, and audit logs.
| Domain | App | Purpose |
|---|---|---|
merch.zooly.ai | reverse proxy to app.zooly.ai/merch | Production merch |
localhost:3004/merch | zooly-app | Merch UI + backend API (local) |
localhost:3004/admin/merch | zooly-app | Merch admin (local) |
Fan browser (merch UI at /merch, served by zooly-app)
| fetch() (same-origin)
zooly-app API routes
| delegates to @zooly/merch-srv + @zooly/srv-stripe-payment
PostgreSQL (merch_* + stripe_payments tables)
| S3 (media), Vercel AI Gateway (generation), fal.ai/BRIA (background removal), Stripe (payments), SendGrid (email)
On This Page
What is the Merch App?Key FeaturesSystem Components1. Frontend (mounted in zooly-app)2. Backend API (zooly-app)3. Server Logic (packages/merch/srv)4. Payment Integration (packages/srv-stripe-payment)5. Admin Builder (packages/merch-admin)6. Database LayerDomain TopologyData FlowNext Steps