Offers System Overview

Overview of the IP licensing offers backend

What is the Offers System?

The Offers System enables content creators (buyers) to submit licensing offers to account owners (sellers) for use of their IP — such as AI-generated images for ads, voice-over for radio spots, or video content. Buyers discover sellers via Z-links (e.g. /z/alex-rivera-a3f2), fill out an offer form, and submit. Sellers review offers in their Agent dashboard and can accept, reject, or counter them.

Key Features

  • Authenticated offer submission: Buyers must be logged in; buyerAccountId is resolved from auth cookie
  • Seller management: Authenticated sellers list and respond to offers
  • Status lifecycle: PENDING → ACCEPTED | REJECTED | COUNTERED (with counter → ACCEPTED | REJECTED)
  • Rich offer payload: Campaign description, types (Radio, Billboards, etc.), script, usage, sharing preferences, price
  • CORS support: All endpoints support cross-origin requests for zooly-app2 (Vite) calling zooly-app (Next.js)

System Components

1. Database Layer (packages/db)

  • Schema: offers table with offer_status enum
  • Access functions: createOffer, getOfferById, listOffersBySellerAccount, updateOfferStatus

2. API Layer (apps/zooly-app)

  • Submit (POST /api/offers/submit): Auth required; creates offer from slug + authenticated buyer
  • List (GET /api/offers/list): Auth required; returns offers for authenticated seller
  • Respond (POST /api/offers/respond): Auth required; accept/reject/counter

3. Client API (apps/zooly-app2)

  • submitOffer(), fetchOffers(), respondToOffer() in appApi.ts

4. UI Integration

  • ZLinkPage: Collects offer data, calls submitOffer() on submit
  • AgentLayout / AgentSidebar / AgentDetailPage: Fetch offers, display list, respond actions
  • Sidebar: Shows real pending offer count badge