AI Image QA Pipeline/AI Systems
Next.js | Firebase | Python | PydanticAI SystemsView Brief ↗
AD-5 Creative

AI Image QA Pipeline

AI-powered product image generation with seven automated quality gates, built-in content safety, and a system that improves with every batch.

$0.01-0.24
Per Production Image
vs. $50-500 traditional photography
0
Inappropriate Images to Reviewers
Dedicated safety gate quarantines before human eyes
↓ Every Batch
Rejection Rate Over Time
System learns from every correction automatically
QA Feedback Loop diagram showing 7 pipeline layers cycling from Prompt Assembly through Autonomous Learning Loop
How it works — 7 automated gates

Production LLM assembles the generation prompt from layered rules stored in Firestore. Base template + client rules + category rules + SKU overrides + learned rejection rules. This is where infrastructure investment eliminates most errors before anything else runs.

Production LLM
Sonnet / Opus
Base Prompt Template
Core photography instructions
Client Rules
Firestore document per client
Category Rules
Learned from rejection data
SKU Overrides
Individual product corrections
Firestore Paths
clients/{clientId}/config
clients/{clientId}/categories/{catId}/rules
clients/{clientId}/skus/{skuId}/overrides

Pre-generation validation gate. The assembled prompt is validated against Pydantic models encoding domain knowledge and safety rules. Catches known-bad prompts (red raw lobster, missing clothing descriptions, invalid aspect ratios) before burning image generation credits. Contracts expand over time from rejection data.

Domain Contracts
Color/state, composition, proportions
Safety Contracts
Clothing required, content boundaries
Format Contracts
Aspect ratio, resolution, model params
Validation Engine
Python / Pydantic v2

The validated prompt hits the image generation API. This is the most expensive step in the pipeline, which is why Layers 1 and 2 exist to prevent wasted generation credits. Only prompts that pass assembly logic and contract validation reach this point.

Nano Banana Pro
Default production model
Nano Banana Standard
Draft/preview tier
API Router
Model selection per project config
Firestore Paths
batches/{batchId}/images/{imageId}

Non-negotiable binary gate. Every generated image runs through content safety evaluation before entering any queue. Uses a lightweight vision LLM for a focused safety-only check. Failed images are quarantined and logged but never shown to reviewers. No inappropriate image has ever reached a client reviewer through this pipeline.

Vision Safety LLM
Haiku 3.5 / Gemini Flash
Safety Checklist
Clothing, content, appropriateness
Quarantine Queue
Failed images logged, never shown
Prompt Trace Log
Root cause analysis per failure
Firestore Paths
batches/{batchId}/quarantined/{imageId}

Server-side quality evaluation at full resolution. A vision-capable LLM evaluates the image against structured criteria: color accuracy vs reference, label readability, composition rules, background consistency, material finish. Returns structured JSON with per-criterion pass/fail and confidence scores. Checklist-driven, not subjective.

Eval LLM
Sonnet (vision)
Reference Comparison
Product photos, color swatches
Category Criteria
Loaded from Firestore rules
Structured Eval Output
JSON per-criterion scores
Firestore Paths
batches/{batchId}/images/{imageId}/eval

Product experts review images that pass all automated gates. On rejection, a conversational AI guides the expert through structured feedback extraction instead of free-text. The AI probes until it has machine-actionable data, then enables submission. Feedback quality is consistent regardless of who is reviewing.

Review Interface
Next.js web application
Feedback AI
Haiku 3.5 (conversational)
Structured Extraction
Rejection schema with categories
Submit Gate
Cannot submit until data is complete
Firestore Paths
batches/{batchId}/images/{imageId}/rejections/{rejId}

Cloud Functions triggered by Firestore writes. Structured rejections are analyzed, rule updates are generated, and corrections are written back to the rules database. Future prompt assembly automatically includes learned rules. Each product category accumulates knowledge over time. Rejection rates decrease with every batch without human intervention.

Cloud Function Triggers
On rejection write
Rule Generation LLM
Sonnet
Category Rule Updates
Written to Firestore
Contract Expansion
New validators from patterns
Firestore Paths
clients/{clientId}/categories/{catId}/rules
system/learning_log/{entryId}
↑ Learning feeds back to Layer 1 ↑
Based on Nate B. Jones' Five Levels of AI Coding framework
Five Levels of AI Coding — Human role shifts from doing to designing
Infrastructure
Frontend
Next.js + TypeScript
React
Tailwind CSS
Backend
Firebase Firestore
Firebase Storage
Cloud Functions
LLM Layer
Haiku 3.5 (guided feedback)
Sonnet (eval + rules)
Python + Pydantic v2
AD-5 CREATIVE LLC — AI IMAGE QA PIPELINE V1.0