A comprehensive, end-to-end AI platform designed to extract, analyze, and cluster Meta (Facebook/Instagram) advertising creatives. It intercepts real-time Meta Ads Library data, extracts creative recipes using Multimodal AI, builds strategic brand playbooks, and clusters top-performing advertising patterns.
Meta Ads Library
β
βΌ
βββββββββββββββββββββββββββ
β Collector Agent β βββΊ Playwright + GraphQL Interception
βββββββββββββ¬ββββββββββββββ
β
βΌ
πΎ Storage (`storage/brands/<brand>/`)
β
βΌ
βββββββββββββββββββββββββββ
β Creative Agent β βββΊ Gemini AI / Creative Recipe Extraction
βββββββββββββ¬ββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββ
β Intelligence Engine β βββΊ Strategy Analysis, Clustering & Playbooks
βββββββββββββ¬ββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββ
β Frontend UI β βββΊ React + Vite Dashboard
βββββββββββββββββββββββββββ
Navigates the Meta Ads Library using Playwright, intercepts internal AdLibrarySearchPaginationQuery GraphQL responses, normalizes ad metadata, and downloads media assets locally.
-
Key Features:
- Headless/Headed browser operation with anti-bot detection patches.
- Intercepts raw GraphQL network payloads before rendering.
- Deduplicates ads across multiple test runs.
- Downloads high-resolution images, video files, and auto-generates thumbnails.
-
Output Structure:
collector_agent/storage/brands/<brand_slug>/ βββ brand_report.json # Summary: total ads, media count, duration βββ ads_index.jsonl # One JSON line per extracted ad βββ ads/ βββ <ad_id>/ βββ metadata.json # Flat, normalized AdRecord βββ raw_graphql.json # Original raw GraphQL payload βββ thumbnail.jpg # Preview image βββ image_0.jpg # Downloaded image asset(s) βββ video_0.mp4 # Downloaded video asset(s)
A dedicated command-line utility to test, inspect, and validate the Collector Agent's output without needing the frontend or full pipeline running.
Run the collector agent for any target brand (e.g., collect up to 5 ads):
python test_collector.py --brand "Nike" --max-ads 5Run with visible browser window (useful for visual debugging):
python test_collector.py --brand "Adidas" --max-ads 5 --no-headlessView all brands currently stored in local storage along with ad & media counts:
python test_collector.py --list-brandsInspect summary reports and extracted ads table without scraping again:
python test_collector.py --inspect --brand "Plix"Examine all metadata, copy text, downloaded files, and GraphQL payload for a single ad:
python test_collector.py --inspect --brand "Plix" --ad-id "1593449608624161"python collector_agent/run.py --brand "Zomato" --max-ads 10Uses Multimodal AI (Google Gemini / Azure GPT-4o) to analyze ad copy and media (images/videos) to extract Creative Recipes:
- Visual Hook & Copy Hook classification.
- Color palettes and design typography.
- Dominant advertising framework (PAS, AIDA, Social Proof, Urgency, etc.).
- CTA strategy & target audience intent.
Run recipe extraction for all collected ads of a brand (e.g. Plix):
python test_creative.py --brand "plix"python test_creative.py --brand "plix" --forcepython test_creative.py --brand "plix" --ad-id "1593449608624161"python test_creative.py --inspect --brand "plix"python test_creative.py --inspect --brand "plix" --ad-id "1593449608624161"python test_creative.py --list-brandsWhenever you run test commands using test_collector.py, test_creative.py, or test_intelligence.py, all generated reports, summaries, tables, and inspection outputs are automatically saved to test_results/ for future reference:
test_results/
βββ collector/
β βββ <brand_slug>_<timestamp>.txt # Timestamped collector test log
β βββ <brand_slug>_latest.txt # Most recent collector test log
βββ creative/
β βββ <brand_slug>_<timestamp>.txt # Timestamped creative agent test log
β βββ <brand_slug>_latest.txt # Most recent creative agent test log
βββ intelligence/
βββ <brand_slug>_<timestamp>.txt # Timestamped pipeline & data flow log
βββ <brand_slug>_latest.txt # Most recent intelligence test log
βββ <brand_slug>_data_flow.json # Complete JSON payload passed to Frontend UI
FastAPI backend service that aggregates creative recipes across brands to compute strategic insights:
- Brand Playbook: Dominant themes, messaging hooks, and asset distributions.
- Clustering & Confidence: Groups similar ad recipes and calculates confidence scores.
- API Endpoints:
GET /brandsβ List analyzed brands.GET /analyze/brandsβ Trigger strategy analysis.GET /analysis/<id>β Retrieve full strategic breakdown.
python test_intelligence.py --brand "plix"python test_intelligence.py --brand "plix,zomato"python test_intelligence.py --inspect --brand "plix"python test_intelligence.py --list-brandsReact + Vite UI displaying visual analytics, brand comparison metrics, creative recipe breakdowns, and playbook strategies.
- π For complete technical breakdown of frontend pages, navigation flow, API mapping, and data presentation specifications, see FRONTEND_DOCUMENTATION.md.
| Brand | Total Ads | Images | Videos | Last Test Status |
|---|---|---|---|---|
| Plix | 5 | 6 | 5 | β Completed (175.3s) |
| Zomato | 5 | 2 | 3 | β Completed |
| Purplle | 15 | 7 | 2 | β Completed |
| Samsung | 13 | 0 | 0 | β Completed |
| Nike | 10 | 25 | 0 | β Completed |
| Apple | 5 | 18 | 2 | β Completed |
| Nothing | 5 | 0 | 0 | β Completed |
-
Python Dependencies:
pip install -r collector_agent/requirements.txt playwright install chromium
-
Environment Configuration: Copy
.env.exampleto.envand set your API keys:GEMINI_API_KEY=your_gemini_api_key_here HEADLESS=true
-
Running the Full Pipeline Backend:
python -m intelligence_engine.run
-
Running the Frontend:
cd frontend npm run dev