โ† Back to Portfolio

๐Ÿ“ฑ PhotoAI Advantage 2.0

AI-Powered Ad Creation SaaS ยท Pre-launch

15,915files
194routes
114pages
5languages

A full-stack AI platform that generates 6 ready-to-publish ad variants from a single product photo in under 60 seconds. No prompt needed โ€” all information comes from the user forms. Our cost: ~$0.15 per generation (6 ads). The user gets editable text placement, colors, sizes, and effects. Agencies charge $200-500 per ad concept.

๐Ÿ—๏ธ

Admin Control Platform

67 pages ยท 93 API routes ยท built FIRST

Built before the user-facing app. The operational backbone where marketing, finance, support, and product teams operate independently โ€” without engineering tickets.

๐Ÿ‘ฅ

User Management

Search by 10+ filters, credit operations with reason tracking, full activity history, suspend/reactivate with audit logging, internal notes, VIP segmentation.

โš™๏ธDev

No manual DB queries. Safe credit operations without touching SQL. One person operates the whole user base in seconds.

๐Ÿ“ŠBusiness

See which countries spend most โ†’ target marketing budget. See usage vs subscription limit โ†’ spot upsell timing (user at 50% mid-month = personalized offer).

๐ŸŽฏMarketing

Segment users by revenue, country, plan, risk score. Identify VIP accounts for retention campaigns. Spot churn risk before it happens.

๐ŸŽ„

Seasonal Themes

Christmas, Valentine's, Easter, Halloween. 3 decoration levels (colors โ†’ particles โ†’ animations). Per-page control. Auto-scheduling. Multi-country support โ€” different themes for different markets simultaneously.

โš™๏ธDev

Built at the start because retrofitting CSS theming across 70+ pages later costs 10ร— more. Per-page level control (no decorations on checkout). Set once, runs every year.

๐Ÿ“ŠBusiness

Different countries celebrate different holidays โ†’ Mexico, US, UK can each see their own seasonal theme simultaneously. Multi-market from day 1, not a retrofit.

๐ŸŽฏMarketing

We are a visual platform that generates images. Premium visual feel is not optional โ€” it's mandatory. Users see seasonal themes and think 'they know what they're doing.' Trust โ†’ retention โ†’ revenue.

๐Ÿ›

Error Monitoring

built vs. Sentry

Fingerprint grouping (deduplicate), deploy-aware analysis ("new since last deploy"), flood protection (10 err/min cap), exact file + line failure, payload sanitization.

โš™๏ธDev

Exact code location on failure โ†’ debug in minutes, not hours. 'New since last deploy' counter catches regressions immediately. Built-in flood protection prevents log explosion.

๐Ÿ“ŠBusiness

Why not Sentry? $26/mo at scale + external dependency + data leaves your infrastructure. Custom = $0/mo, integrated with our deploy pipeline, we control the data. Build cost < 1 year of Sentry.

๐ŸŽฏMarketing

Every hour of downtime = lost users. Fast debug = less downtime = users never see broken features for long. Reliability builds trust.

๐ŸŽฏ

Promotion Engine

Full lifecycle (draft โ†’ pending โ†’ approved โ†’ active โ†’ expired). Founder approval gate. Bulk coupon generation. Referral programs. ROI tracking per promotion.

โš™๏ธDev

Approval workflow prevents unauthorized discounts from hitting production. No one can accidentally give 90% off to everyone. Financial safety built into the architecture.

๐Ÿ“ŠBusiness

Track ROI per promotion before committing budget. Test regional pricing. Referral programs = viral loop operated from admin UI, not code. Financial governance without meetings.

๐ŸŽฏMarketing

Run campaigns instantly without engineering tickets. A/B test offers per country. Schedule promotions weeks in advance. Marketing team operates independently.

๐Ÿ’ฐFinancial Ops

  • Revenue: daily/weekly/monthly/yearly
  • MRR tracking + budget management
  • Per-service profit analysis โ€” know if you're making or losing money on each feature
  • CSV/PDF export for accounting

๐Ÿท๏ธBanners

  • Target by page/country/plan/language
  • Different offers per country simultaneously
  • Scheduled with performance tracking
  • Real-time in-app messaging without code changes

๐ŸšฉFeature Flags

  • Gradual rollout 0-100%
  • Environment + user targeting
  • Kill switch without deployment
  • Ship code without releasing it

๐ŸงชA/B Testing

  • Experiment creation + variant allocation
  • Conversion tracking + results dashboard
  • Test pricing before committing

๐Ÿ“‹Audit Trail

  • Every action: who, what, when, where
  • Before/after JSONB snapshots
  • Partitioned monthly for performance at scale

โค๏ธโ€๐ŸฉนSystem Health

  • Test all integrations without code
  • Background job + AI service health
  • Per-provider API cost tracking
Every feature has three reasons: a development reason (build it now or pay 10ร— later), a business reason (revenue, cost, governance), and a marketing reason (retention, trust, conversion). The admin panel is where all three meet.
๐Ÿ”’

Security Architecture

two separate systems ยท user vs admin

Regular users and admins have completely separate security models. Users go through Supabase Auth (standard SaaS pattern). Admins go through a custom 5-layer system โ€” because they have service_role access that bypasses all RLS policies and can see every user's data.

๐Ÿ‘ค

Regular User

1 layer ยท Supabase Auth + RLS

User โ†’ Supabase Auth (JWT) โ†’ RLS Policies โ†’ Own data only
  • JWT tokens (short-lived, auto-refreshed)
  • httpOnly secure cookies
  • Middleware session check on every request
  • 420+ RLS policies โ€” users see ONLY their own records
  • Standard SaaS pattern for customer data isolation
๐Ÿ›ก๏ธ

Admin Panel

5 layers ยท custom security ยท service_role

Auth โ†’ IP Check โ†’ 2FA โ†’ Redis Session โ†’ CSRF โ†’ Permission โ†’ service_role
  • IP Whitelist โ€” CIDR + wildcard, checked every request (not just login)
  • TOTP 2FA โ€” mandatory, 10 backup codes, lockout after 5 fails
  • Redis Sessions โ€” 30min sliding TTL, revocable instantly
  • CSRF โ€” timing-safe comparison, rotated after every mutation
  • 68 permissions across 5 roles + full audit trail

Why two systems?

UserSupabase authenticated role โ€” RLS enforced, sees own data only
AdminSupabase service_role โ€” bypasses ALL RLS, sees everything

Admins use service_role because they need to see all user data, manage billing, and operate the platform. That god-mode access is exactly why they need 5 layers of protection instead of 1.

Admin Request Flow โ€” /admin/* (every single request)

Edge โ†’ cookie? โœ— redirect โ†’ Auth โ†’ admin_users table? โœ— rejected โ†’ IP โ†’ whitelist match? โœ— session killed โ†’ 2FA โ†’ TOTP verified? โœ— redirect โ†’ Session โ†’ Redis valid? โ†’ CSRF โ†’ timing-safe match? โ†’ Permission โ†’ role has access? โ†’โœ“ execute โ†’ audit log โ†’ response
๐ŸŽจ

Ad Generation Engine

7 steps ยท 60 seconds ยท ~$0.15/generation ยท zero prompts

The user never writes a prompt. A 7-step wizard collects everything the AI needs โ€” company identity, product details, campaign goal, creative direction, and platform. Every form field has a purpose in the generation pipeline.

1๐ŸขCompany

Brand name, colors, fonts, industry

2๐Ÿ“ฆProduct

Name, price, benefit, audience, description

3๐Ÿ“ทImage

Product photo(s) โ€” background auto-removed

4๐ŸŽฏGoal

Sales/Traffic/Messages + creative style + platform

5โšกGenerate

AI Director + 2 scenes + 6 variants (auto)

6๐Ÿ–ผ๏ธResults

6 ads with scores, like/dislike, edit, download

7๐ŸŒExport

Multi-language ร— multi-platform ร— custom copy

Every form field has a destination

company โ†’ brand voice, colors, fonts for overlayproduct name + benefit โ†’ core message for all 6 variantsproduct image โ†’ sent to AI as visual referencecampaign goal โ†’ CTA text + neuro color psychologycreative approach โ†’ scene style directionplatform โ†’ dimensions + text layout rules
๐Ÿ“ธ

Upload

Product photo

๐Ÿง 

AI Director

Creative plan

๐ŸŽญ

2 Scenes

Parallel gen

๐Ÿ“

Spatial AI

Grid analysis

๐ŸŽฏ

Template

54 matched

๐ŸŽจ

Neuro Color

Psychology

โœจ

Render

Satori + CSS

๐Ÿ–ผ๏ธ

6 Ads

Ready to publish

๐Ÿง AI Creative Director

$0.008

Vision-capable LLM analyzes the product image, generates a complete creative brief, plans 2 scene compositions, and writes 6 ad copy variants โ€” each with a unique persuasion angle (urgency, social proof, emotional, features, value, use-case). One call, complete plan.

๐ŸŽญParallel Image Generation

$0.078

2 scenes generated simultaneously. 8 visual styles ร— 20 mood variations = the user never sees the same result twice. Triple fallback chain guarantees output even if primary AI fails.

๐Ÿ“Spatial Intelligence

proprietary

Proprietary system that mathematically determines optimal text placement and contrast colors for each generated scene. No guessing, no manual positioning โ€” the algorithm handles it. WCAG-compliant output.

๐ŸŽจNeuromarketing Engine

proprietary

CTA colors are psychologically optimized per campaign goal and harmonized with the scene palette. Sales โ†’ warm reds (impulse). Traffic โ†’ blues (trust). Messages โ†’ greens (conversational).

industry standard

1:1

1 AI generation = 1 ad
New size? Pay again. New language? Pay again.

โ†’

my architecture

2:6

Text as HTML/CSS, separate from images
Resize = free. Translate = near-zero. 3ร— output.

By rendering text as HTML/CSS separate from AI-generated images, a single generation produces multiple ad variants, any format size, and translation at near-zero cost. One technical choice โ†’ three revenue advantages.
๐Ÿ—„๏ธ

Database Architecture

Supabase (PostgreSQL) ยท 215 tables

215Tables
139RPC Functions
107Triggers
43Enums
420+RLS Policies

๐Ÿ‘คUser Data

Users, companies, products, services. Multi-company support. AI-generated metadata.

๐Ÿค–AI Generation

Image jobs, orchestrator state, director output, scene compositions, cost tracking per generation.

๐Ÿ’ณCommerce

Credits ledger (atomic RPCs โ€” no race conditions), Stripe webhooks (idempotent), transaction export.

๐Ÿ—๏ธAdmin

12 tables: audit_log (partitioned monthly), sessions, team, permissions, promotions, coupons, banners, themes.

๐ŸŽจContent

54+ overlay templates with neuro-scores, font pairings, color palettes, quality metrics.

๐Ÿ”’Security

420+ RLS policies, per-table rules, admin via controlled RPCs only, IP whitelist with CIDR.

๐Ÿ’ก

Technology Decisions & Cost Engineering

why this exact stack ยท cost at scale

Why Supabase?

$0 dev ยท $25/mo prod

PostgreSQL relational integrity for 215 tables with FK, joins, transactions. RLS (420+ policies) = security at the DB, not just the app. 139 RPCs as stored procedures. Built-in auth. MongoDB lacks RLS and relational joins. Firebase locks you into Google.

Why Cloudflare R2?

$0 egress forever

Zero egress fees. S3 charges $0.09/GB transfer. At 10K users: S3 = $12,150/mo in egress. R2 = ~$4.50/mo. At 1M users: S3 egress = ~$1.2M/year. R2 = $0. This single decision saves 6 figures annually at scale.

Why Upstash Redis?

$0 dev ยท $10/mo prod

Serverless, per-request pricing. Powers: admin sessions, rate limiting (7 configs), CSRF storage, account lockout, feature flag caching. Self-hosted Redis = 24/7 server. Upstash = $0 to start.

Why Railway?

$0 when idle

Background removal needs Python + 2GB ML container. Vercel has 50MB limit + 10s timeout. Railway: containerized, sleeps to $0 when idle, wakes on demand. ~$0.002 per image.

Why Inngest?

$0 dev (25K events/mo)

7 pipeline steps where any can fail. Inngest retries step 4 without re-running 1-3. Concurrency limiting, event-driven, automatic backoff. BullMQ needs self-hosted Redis + persistent worker.

Why Vercel?

$0 dev ยท $20/mo prod

Next.js optimized: zero-config deploy, edge functions, image optimization, ISR. Free tier: 100GB bandwidth + serverless + HTTPS. AWS equivalent requires CloudFront + Lambda@Edge + cert management.

๐Ÿ“Š Monthly Infrastructure Cost โ€” Our Stack vs AWS vs Azure vs Google Cloud

We evaluated all three major cloud providers. Estimates based on equivalent services at each scale tier.

10K Users
100K Users
1M Users
โœ… Our Stack
~$75
~$350
~$2,500
โ˜๏ธ AWS (EC2 + RDS + S3 + CloudFront + Lambda)
~$800
~$8,000
~$95,000
๐Ÿ”ท Azure (App Service + SQL + Blob + CDN + Functions)
~$650
~$6,500
~$78,000
๐Ÿ”ต Google Cloud (Cloud Run + Cloud SQL + GCS + CDN)
~$550
~$5,800
~$72,000
๐Ÿ’ฐ Annual Savings vs cheapest cloud
$5,700
$65,400
$834K

"But what about..." โ€” common enterprise concerns

๐ŸŒ Multi-Region Deployment

Vercel deploys to edge locations globally โ€” USA, Europe, Asia, automatically. Cloudflare R2 serves assets from 300+ PoPs worldwide. Supabase runs in the region closest to your primary market. Users in London, New York, and Tokyo all get sub-100ms responses without configuring anything.

๐Ÿ’พ Data Backup & Redundancy

Supabase runs on AWS infrastructure with daily automated backups and point-in-time recovery (Pro plan). Cloudflare R2 stores data across multiple availability zones โ€” data is never in a single location. Vercel deployments are immutable โ€” every deploy is a snapshot you can roll back to instantly.

๐Ÿ”’ Security at Scale

Our stack doesn't compromise on security. 420+ RLS policies enforce data isolation at the database level. Vercel provides DDoS protection and WAF. Cloudflare adds another security layer. Upstash Redis handles rate limiting. The 12-layer admin security is custom-built โ€” more thorough than what most companies implement even on AWS.

๐Ÿ“ˆ Scalability (100 to 10M users)

Every service in our stack auto-scales: Vercel serverless functions scale to zero and up to millions. Supabase connection pooling handles concurrent users. R2 has no bandwidth limits. Inngest queues handle burst loads. The same stack that costs $0 in dev handles 1M users โ€” no re-platforming, no migration, no architecture change.

We didn't pick the cheapest option. We picked the stack that gives us enterprise-grade reliability, global distribution, and security โ€” at startup-grade cost. Every free tier was chosen strategically: the same platforms scale to millions without re-platforming.
๐ŸŒ

Why These 5 Languages

market-driven language selection ยท not random

Most competitors deploy in English only. We broke that barrier โ€” but not randomly. Each language was chosen based on e-commerce market size, growth trajectory, and competitive gap (how underserved that market is by existing ad tools).

๐Ÿ‡ฌ๐Ÿ‡ง
English$5.5T+Global

Largest e-commerce market. Baseline โ€” every competitor serves this.

๐Ÿ‡ช๐Ÿ‡ธ
Spanish$200B+Spain, LATAM, US Hispanic

580M+ speakers. US Hispanic e-commerce alone is $100B+. Most ad tools have poor Spanish support โ€” we serve this natively.

๐Ÿ‡ง๐Ÿ‡ท
Portuguese$180B+Brazil, Portugal

Brazil is the largest e-commerce market in LATAM. 260M+ speakers. Very few AI ad tools support Portuguese properly.

๐Ÿ‡ฉ๐Ÿ‡ช
German$150B+Germany, Austria, Switzerland

Germany is Europe's largest e-commerce market. High purchasing power. German speakers expect native-quality text โ€” bad translations kill trust.

๐Ÿ‡ณ๐Ÿ‡ฑ
Dutch$35B+Netherlands, Belgium, Suriname

Highest e-commerce spend per capita in the EU. Small market but extremely high-value users. Almost zero competition in Dutch ad tools.

The competitive advantage

With 5 languages we cover ~$6.1 trillion in combined e-commerce markets and 2.5+ billion speakers. Our architecture makes translation a near-zero-cost upsell (text is separate from images). A competitor adding one language needs to rebuild their rendering pipeline. We already support five โ€” and adding more is a database entry, not a code change.

stack: Next.js 16 ยท React 19 ยท TypeScript strict ยท Supabase ยท PostgreSQL ยท Stripe ยท Cloudflare R2 ยท Upstash Redis ยท Inngest ยท Railway ยท Fabric.js ยท Satori ยท Puppeteer ยท Tailwind CSS v4 ยท 5 languages

See It Live

Real recordings from the production app. Not mockups โ€” this is photoaiadvantage.com running live.

The app is live and public

Create a free account and try the ad generation yourself. This is a real SaaS, not a demo.

Try PhotoAI Advantage โ†’

Admin Panel Walkthrough

2FA login, user management, promotions, financial dashboard, error monitoring, feature flags, audit trail, seasonal themes โ€” navigating the full 70+ page admin panel.

Ad Generation Demo

Complete flow: company form โ†’ product form โ†’ image upload โ†’ goal selection โ†’ AI generates 6 ad variants โ†’ open editor โ†’ edit text placement, colors, effects.