Skip to content
Rehan.dev

AI-Native SaaS · Shopify Ad Automation · UGC Marketplace

JAIM Ad Co-Pilot

AI-Powered Shopify Marketing & Ad Automation SaaS

Built a complete AI-powered Shopify marketing SaaS. Store owners connect their shop, and the platform generates AI ad creatives and 30-second video ads, writes niche-specific copy, and launches campaigns on Facebook/Meta and TikTok — with a built-in UGC creator marketplace, Stripe Connect payouts, and real-time chat.

Role
Solo Full-Stack Developer
Year
2025 — 2026
Type
Full-Stack SaaS · Shopify App · AI Ad Generation · Video Generation · UGC Marketplace
20+
Backend modules
40+
Database entities
120+
API endpoints
7
Platform integrations

Quick summary

Shopify store owners connect their store, and the platform automatically analyzes products, generates AI ad creatives (images via Google Gemini Imagen + text overlays via Sharp), creates 30-second vertical video ads (Google Veo-3.1 — problem/solution, testimonial, unboxing formats), generates niche-specific ad copy (OpenAI GPT-4), and publishes campaigns to Facebook/Meta and TikTok Ads APIs. A built-in UGC creator marketplace lets merchants hire real creators for product ad content, with Stripe Connect payouts, real-time Socket.io chat, and a full order/revision/dispute workflow.

The problem

Shopify store owners struggle with digital advertising at scale:

  • Designing platform-specific ad creatives (1:1, 9:16, 4:5) requires a designer
  • Writing compelling ad copy for different niches takes hours per product
  • Launching on Facebook AND TikTok means two separate dashboards
  • Video ads — the highest-converting format — require expensive production
  • Finding UGC creators who understand your product is a manual, scattered process
  • Monitoring performance and re-testing ad variants requires constant attention

The goal: one platform where a store owner connects their Shopify store, selects a product, gets AI-generated images, videos, and copy, and launches campaigns in five minutes.

My role

Solo full-stack developer, end-to-end ownership:

  • System architecture across 4 separate codebases (backend, dashboard, landing page, Shopify app)
  • 20+ NestJS backend modules with 120+ API endpoints
  • Two complete frontend applications (merchant + creator dashboards, 25+ pages)
  • Conversion-optimized landing page
  • Shopify embedded app (Remix) — OAuth flow + store data bridge
  • AI integrations: OpenAI, Google Gemini Imagen, Google Veo-3.1, Pinecone
  • Platform integrations: Facebook Ads API, TikTok Ads API, Stripe Connect
  • Real-time features via Socket.io (marketplace chat, notifications)
  • Background job processing via BullMQ + Redis
  • Production-grade structured logging via Winston

Architecture

Four coordinated applications:

  • jam-ad-co-pilot (landing page) — React 19 + Vite + TypeScript
  • jam-app (Shopify embedded app) — Remix + Shopify CLI, OAuth callback, webhooks
  • jam-shopify (dashboard frontend) — React 19 + Vite + Zustand + Socket.io-client, split into a merchant dashboard and a UGC creator dashboard
  • jam-shopify-backend (NestJS 11 API) — PostgreSQL + TypeORM + BullMQ + Redis + Socket.io

The backend fans out to seven external systems: OpenAI, Google Gemini, Veo-3.1, Facebook Ads API, TikTok Ads API, Shopify API/webhooks, and Stripe.

What was built — module by module

  1. Shopify Integration — embedded app OAuth, Admin GraphQL product/store sync, webhook handlers, local product catalog cache for fast ad generation.
  2. Nano Banana image engine — custom Gemini Imagen 3 prompt-assembly pipeline; 5 platform presets (Facebook, TikTok, Instagram Square/Story, Twitter); ad-type, brand-tone, and color-mood modifiers; AI-suggested creative parameters from product data alone; Sharp/canvas text-overlay rendering with safe-zone detection.
  3. Veo-3.1 video pipeline — 3-segment video generation (problem/solution, testimonial, unboxing variants), GPT-4o prompt generation per segment with diversity checks, 9:16 vertical 10s segments (~30s total), safety-filter retry with progressive prompt sanitization, automatic fallback to a Video Gen API on quota exhaustion.
  4. Facebook/Meta Ads automation — full campaign/ad-set/creative CRUD, AI-generated variant creation, image/copy regeneration for underperformers, Apify-sourced trend insights, scheduled auto-generation, per-product-hash caching.
  5. TikTok Ads automation — mirrors the Facebook flow with its own entity tree (campaign/ad group/ad variant) and 9:16 video/vertical-image formats.
  6. Growth Mode — automated campaign optimization: monitors performance, spawns re-generation jobs via BullMQ on a cron schedule, user-configurable ROAS/frequency/refresh rules.
  7. UGC Creator Marketplace — creator profiles, service listings, portfolios; merchant browse/hire flow; a 9-state order lifecycle with revisions, disputes, and reviews; Stripe Connect payouts.
  8. Real-time chat — Socket.io gateway for per-order chat rooms plus the separate AI Co-Pilot conversation channel.
  9. AI Chat Co-Pilot — context-aware ad-strategy assistant with conversation history, extracted insights, and a thumbs up/down feedback loop.
  10. Trend Pulse — Apify-scraped social trend detection mapped to specific products, with one-click apply to a campaign.
  11. Centralized Ad Content Generation — a single service for all ad copy across 14 product niches, each with distinct copywriting style and seasonal context awareness.
  12. Authentication — JWT + Passport, Google and Facebook OAuth, role-based access (merchant/creator/admin).
  13. Performance & Analytics — Facebook analytics sync at campaign/ad-set/ad level, cross-platform aggregation, top-performer identification.
  14. Notifications — persistent + real-time (Socket.io) notifications for orders, campaigns, generation completion, and messages.
  15. Suggested Ads — proactive, AI-ranked recommendations for which products to advertise next.
  16. Content Calendar — scheduled generation jobs, platform-distribution statistics, a unified weekly/monthly campaign view.

Core features — technical deep dive

Veo-3.1 three-segment video pipeline. Each video ad is built from three sequential segments, and the key engineering challenge is that Veo requires the previous segment as input for each extension:

// 1. Generate opening segment
let openingOp = await this.ai.models.generateVideos({
  model: 'veo-3.1-generate-preview',
  prompt: buildFinalPrompt(shopContext, sections.opening),
  config: { numberOfVideos: 1, resolution: '720p', aspectRatio: '9:16', duration: '10s' },
});
openingOp = await this.pollUntilDone(openingOp);
const openingVideo = this.extractVideo(openingOp);
await this.waitForVideoProcessing(openingVideo, 'opening');

// 2. Extend to middle segment — previous segment is the input
let middleOp = await this.ai.models.generateVideos({
  model: 'veo-3.1-generate-preview',
  video: openingVideo,
  prompt: buildFinalPrompt(shopContext, sections.middle),
  config: { /* ... */ },
});
// 3. Extend to ending, same pattern, then download the final MP4

Veo has a processing lag between generating a segment and it being usable as an extension input — not documented in the API docs, discovered through testing. waitForVideoProcessing() retries with configurable delay until the segment is actually ready.

Quota-exceeded fallback. Veo's daily quota errors arrive nested inside stringified JSON rather than as a clean HTTP exception, so detection needs three layers: check error.code directly, parse the message as JSON and check nested error.code, then check error.details.operationError. On a confirmed quota error, the service falls back automatically to a second video provider (Higgsfield's Video Gen API) and records which provider generated the result so status polling routes correctly afterward.

UGC marketplace order state machine. Orders move through a formal 9-state machine (pending → accepted → in_progress → revision_requested → completed → reviewed, plus disputed, cancelled, refunded) with an explicit allowed-transitions table — any invalid transition throws before it can corrupt order state, and every transition is logged to an activity audit trail.

Stripe Connect payout sequencing. Payment is authorized (not captured) at order creation via capture_method: 'manual', captured only when the order reaches completed, and cancelled cleanly if the order is refunded — so funds are held safely for the whole order lifecycle before any creator payout is released via Stripe Connect transfer.

Two authentication systems converging on one record. The Shopify embedded app authenticates via Shopify session tokens; the main SaaS dashboard uses its own JWT. The Shopify app exchanges its session token for the platform's JWT right after OAuth (POST /api/save-shop, backend validates the Shopify HMAC, saves the store, returns the JWT), so both systems converge at the store record in Postgres.

Key numbers

MetricValue
Backend modules20+ NestJS modules
Database entities40+ TypeORM entities (PostgreSQL)
API endpoints120+ REST endpoints
UI pages25+ across 2 dashboards
AI integrationsOpenAI GPT-4, Google Gemini Imagen, Google Veo-3.1, Pinecone
Platform integrationsFacebook Ads API, TikTok Ads API, Shopify API, Stripe, Socket.io, BullMQ/Redis, Apify
Video ad variants3 per product (problem/solution, testimonial, unboxing)

Build timeline (from git history)

8 continuous months of active solo development, 334 commits, first commit 2025-08-30 and last 2026-04-15 — image generation and core dashboard shipped first (Aug–Sep 2025), the Veo pipeline and Facebook API landed in the most active month (Oct 2025), the marketplace and Stripe Connect followed (Nov 2025), then Growth Mode, Pinecone RAG, and TikTok (Dec 2025), with the AI co-pilot, analytics, and Trend Pulse refined through Q1 2026.

What this demonstrates

  • Multi-platform AI product building — four AI providers (text, image, video, vector search) integrated with production-ready fallback chains and safety-filter handling not covered in official docs.
  • Complex backend architecture — 20+ NestJS modules, 40+ TypeORM entities, BullMQ job queues for async generation at scale, and unattended Growth Mode automation.
  • Multi-platform ad API integration — full CRUD against both Facebook Ads API and TikTok Ads API, each with its own entity tree and creative-format rules.
  • A full marketplace platform (like Fiverr for ad creators) — a 9-state order machine, held-funds Stripe Connect payouts, real-time chat, and a dispute/review system.
  • Production full-stack delivery — 4 coordinated applications, 25+ hand-built UI pages, real-time features via WebSockets, structured logging throughout, and a Shopify App Store-ready embedded app.

JAIM Ad Co-Pilot — Shopify marketing automation platform with AI ad generation and a UGC creator marketplace. Built end-to-end as a solo developer.