nBrain

Ads Intelligence Platform

AI-Powered Marketing Analytics with Industry Context Integration

Production Live Version 1.0 October 21, 2025

Executive Summary

Unified Marketing Analytics with AI Intelligence

Ads Intelligence Platform is an enterprise-grade analytics and intelligence system that combines Google Analytics 4 (GA4), Meta Ads, and Google Ads data with real-time industry insights. The platform provides AI-powered marketing intelligence, enabling marketing teams to understand their digital performance in the context of broader market trends with actionable recommendations powered by GPT-4.

3
Data Sources Unified
GPT-4
AI Analysis
RAG
Industry Context
Multi
Property Support

Key Value Propositions

DA

Unified Dashboard

Single interface for GA4, Meta Ads, and Google Ads data

AI

AI-Powered Insights

GPT-4-driven analysis connecting metrics to causation

IC

Industry Context

RAG-powered correlation with market trends

Platform Overview

Intelligent Marketing Analytics & Industry Insights

What It Does

  • Unified Analytics - GA4, Meta Ads, Google Ads in one dashboard
  • Natural Language Queries - Ask questions in plain English
  • Deep-Dive Analysis - Automatic correlation of related metrics
  • Industry Context - RAG-powered news correlation
  • Multi-Property Management - Portfolio view across properties
  • Streaming Responses - Real-time AI analysis delivery

Intent Classification

GPT-4 automatically classifies and routes queries:

Analytics Only
"Show me my users last month"
Industry Only
"What's new in the market?"
Hybrid
"Why did my traffic drop?"

Complete Technology Stack

Python Flask with AI & Vector Search

Backend

Python 3.11.9
Flask Web Framework
SQLAlchemy ORM
PostgreSQL 14
Gunicorn WSGI Server

AI & Data

GPT-4 Turbo Analysis
text-embed-3-small Vectors
Pinecone Vector DB
AWS S3 Data Lake
Pandas Analysis

Integrations

Google Analytics 4 API
Meta Ads CSV Import
Google Ads CSV Import
MCP Server Protocol
RSS Feeds Industry Data

System Architecture

Multi-Layer Architecture with RAG Integration

┌────────────────────────────────────────────────────┐ │ Flask Application Layer │ │ ┌────────────┐ ┌────────────┐ ┌────────────┐ │ │ │ Routes │ │ Agents │ │ Analysis │ │ │ │ (main/) │ │ (AI Logic) │ │ (insights) │ │ │ └────────────┘ └────────────┘ └────────────┘ │ └────────────────────┬───────────────────────────────┘ │ ┌────────────┴────────────┐ ▼ ▼ ┌──────────────────────┐ ┌──────────────────────┐ │ Data Integration │ │ AI Intelligence │ │ ┌────────┐ ┌──────┐│ │ ┌──────┐ ┌────────┐│ │ │ MCP │ │ S3 ││ │ │GPT-4 │ │Pinecone││ │ │ Server │ │Client││ │ │Turbo │ │ Vector ││ │ └────────┘ └──────┘│ │ └──────┘ └────────┘│ │ ┌────────┐ ┌──────┐│ │ RAG Server │ │ │ Athena │ │ DB ││ │ (Industry News) │ │ └────────┘ └──────┘│ └──────────────────────┘ └──────────────────────┘ │ ▼ ┌──────────────────────────────────────────────────┐ │ Data Sources │ │ ┌──────┐ ┌──────┐ ┌────────┐ ┌────────────┐ │ │ │ GA4 │ │ Meta │ │ Google │ │ Industry │ │ │ │ API │ │ Ads │ │ Ads │ │ RSS │ │ │ └──────┘ └──────┘ └────────┘ └────────────┘ │ └──────────────────────────────────────────────────┘

Data Flow

1. User Query
Natural language question
2. GPT-4 Parser
Extract metrics, dates, intent
3. Data Retrieval
MCP/S3/Athena/PostgreSQL fallback
4. Industry Context (Optional)
Pinecone vector search for news
5. AI Synthesis
GPT-4 generates insights & recommendations
6. Streaming Response
Server-Sent Events to client

Core Features

Comprehensive Marketing Intelligence Tools

Unified Analytics Dashboard

Single interface combining Google Analytics 4, Meta Ads, and Google Ads performance data.

  • GA4 metrics (users, sessions, conversions)
  • Meta Ads (spend, clicks, CTR, CPM)
  • Google Ads (spend, leads, impressions)
  • Cross-platform comparison
  • Multi-property support
Production Live

Natural Language Queries

Ask questions in plain English and get structured insights with AI-powered analysis.

  • GPT-4 query parsing
  • Metric synonym mapping
  • Relative date handling
  • Intent classification
  • Streaming responses
Active

Deep-Dive Analysis

Automatic correlation of related metrics to explain performance changes with root cause analysis.

  • Related metrics mapping
  • Ad campaign correlation
  • Efficiency calculations
  • Business impact assessment
  • Actionable recommendations
Operational

Industry Context Integration

RAG-powered system correlating performance data with real-time market trends and news.

  • RSS feed monitoring
  • Pinecone vector search
  • Semantic article matching
  • Trend correlation analysis
  • Market context synthesis
Live

Multi-Property Management

Manage and analyze multiple properties across all platforms with unified interface.

  • Property selector
  • Cross-property comparison
  • Portfolio analytics
  • Performance ranking
  • Aggregated views
Active

Data Lake Architecture

Multiple data access patterns with MCP, S3 CSV, Athena, and PostgreSQL fallback.

  • MCP Server integration
  • S3 CSV direct queries
  • AWS Athena support
  • PostgreSQL fallback
  • Flexible data routing
Operational

AI & RAG System

GPT-4 Analysis with Industry Knowledge Base

GPT-4 Turbo Integration

Advanced AI for query parsing and insight generation

Capabilities:
  • ✓ Natural language parsing
  • ✓ Intent classification
  • ✓ Metric extraction
  • ✓ Date range inference
  • ✓ Insight synthesis
  • ✓ Recommendation generation
User Query ↓ GPT-4 Parser • Extract metrics • Determine dates • Classify intent ↓ Data Retrieval (4 fallback layers) ↓ GPT-4 Synthesis • Calculate insights • Root cause analysis • Recommendations ↓ Streaming Response (SSE)

RAG Industry Knowledge Base

Pinecone-powered semantic search for market trends

Configuration:
• Index: adsintell-industry-vector
• Dimensions: 1536
• Metric: Cosine similarity
• Top-K: 2 matches
Data Sources:
  • ✓ Industry RSS feeds
  • ✓ Market research articles
  • ✓ News embeddings
  • ✓ Trend analysis

Supported Metrics

GA4 Metrics

  • • totalUsers
  • • sessions
  • • engagementRate
  • • conversions
  • • bounceRate
  • • avgSessionDuration

Meta Ads Metrics

  • • meta_ad_spend
  • • meta_ad_clicks
  • • meta_ad_impressions
  • • meta_ad_ctr
  • • meta_ad_cpm
  • • meta_ad_conversions

Google Ads Metrics

  • • google_ad_spend
  • • google_ad_clicks
  • • google_ad_impressions
  • • google_ad_ctr
  • • google_ad_cpm
  • • google_ad_leads

Database Schema

PostgreSQL with SQLAlchemy ORM

ga4_data - Analytics Metrics

Google Analytics 4 performance data

• property_id, date
• metric_name, metric_value
• Indexed on (property_id, date)

meta_campaign_data - Meta Ads

Facebook/Instagram advertising data

• campaign_name, account_id
• cost, clicks, impressions, conversions
• ctr, cpm, cost_per_conversion

google_ads_data - Google Ads

Google advertising campaign data

• customer_id, date
• cost, link_clicks, impressions
• website_leads, ctr, cpm, cpc

chat_history - Conversations

User query and response history

• user_id, session_id
• query, response
• timestamp tracking

Security & Authentication

Enterprise-Grade Security

Authentication

  • ✓ Flask-Login sessions
  • ✓ Bcrypt password hashing
  • ✓ Secure session cookies
  • ✓ Persistent login support

Content Security

  • ✓ CSP headers
  • ✓ XSS protection
  • ✓ Code injection prevention
  • ✓ Sanitized outputs

Data Security

  • ✓ HTTPS/TLS enforced
  • ✓ Encrypted at rest
  • ✓ SQL injection prevention
  • ✓ User data isolation

Deployment Infrastructure

Cloud Platform with Managed PostgreSQL

Web Service

Live Python Flask
Runtime: Python 3.11.9 Framework: Flask + Gunicorn Build: pip install -r requirements.txt Migrate: flask db upgrade Start: gunicorn --timeout 120 Region: Oregon (us-west)

Database

Live Managed PostgreSQL
Database: PostgreSQL 14 ORM: SQLAlchemy Backups: Daily automatic Recovery: 7-day point-in-time Connections: 25 max concurrent SSL: TLS 1.3 encrypted

Data Access Layers

MCP Server
Optimized protocol
S3 CSV Direct
No DB overhead
AWS Athena
Serverless SQL
PostgreSQL
Reliable fallback

Real-World Use Cases

Solving Marketing Intelligence Challenges

Use Case: Performance Review

Scenario: Monthly marketing performance analysis

Query Submission
"Show me all metrics for last month vs prior"
GPT-4 Parsing
Extract metrics, dates, classify intent
Data Retrieval
Query GA4, Meta, Google Ads data
Comparison Analysis
Calculate percentage changes
AI Synthesis
Generate insights table with recommendations
Sample Results:
• Users: +10.9% (market growth)
• Sessions: +10.6% (aligned with users)
• Conversions: -5.4% (quality issue detected)
• Ad Spend: +7.1% (budget increase)

Use Case: Deep Dive Analysis

Scenario: Understanding conversion drop root cause

Analysis Process:
✓ Click "Deep Dive" on conversions metric
✓ System queries related metrics (bounce, engagement)
✓ Analyzes ad campaign changes
✓ GPT-4 synthesizes root cause
✓ Generates specific recommendations
Example Insight:
"Traffic increased 10.9% but conversions dropped 5.4% - indicating a quality issue. Bounce rate up 15% and engagement down 18% suggest new traffic from Meta campaigns is less qualified."

Use Case: Industry Trend Correlation

Scenario: Understanding market-driven performance changes

Hybrid Query
"Why did my traffic drop last week?"
Analytics Data
Total users decreased 22%
Vector Search
Pinecone finds industry news (mortgage rates)
Correlation Analysis
Links 22% drop to market slowdown
Recommendations
Adjust messaging, increase retargeting

Use Case: Multi-Property Portfolio

Scenario: Managing 15 properties across platforms

Workflow:
✓ Select "All Properties" aggregated view
✓ Ask: "Which properties had best ROI?"
✓ System calculates cost per conversion
✓ Ranks properties by efficiency
✓ Identifies underperformers
✓ Provides specific improvement actions
15
Properties Managed
Instant
Portfolio Analysis

Platform Metrics

Performance & Capabilities

Performance

Query Response <500ms
Database Query ~12ms avg
Vector Search ~200ms
Uptime 99.9%

Data Sources

  • Google Analytics 4 API
  • Meta Ads (CSV/API)
  • Google Ads (CSV/API)
  • Industry RSS Feeds

Capabilities

  • Multi-property support
  • Natural language queries
  • Streaming AI responses
  • 4-layer data fallback

Platform Statistics

Metric Value
Database Tables7 core tables with indexes
Supported Metrics18+ metrics across 3 platforms
Query Methods4 data access patterns (MCP, S3, Athena, PostgreSQL)
Vector IndexPinecone 1536-dim embeddings
AI ModelsGPT-4 Turbo + text-embedding-3-small
Response DeliveryServer-Sent Events (streaming)
SecurityFlask-Login + Bcrypt + CSP headers

Key Takeaways

What Makes This Platform Unique

Technology Highlights

  • GPT-4 Turbo for natural language queries
  • RAG architecture with Pinecone vectors
  • Multi-layer data access (MCP/S3/Athena/DB)
  • Flask + SQLAlchemy Python backend
  • Streaming responses with SSE
  • Intent classification for smart routing

Business Value

  • Unified view of GA4, Meta, Google Ads
  • Natural language interface (no SQL needed)
  • Deep-dive automatic correlation analysis
  • Industry context for market-driven insights
  • Multi-property portfolio management
  • Actionable AI-generated recommendations

Platform Status

Production Live Version 1.0 October 21, 2025

Project Details

Platform: Ads Intelligence Platform
Industry: Marketing Analytics
Type: Enterprise SaaS
Project Scope: AI-powered marketing intelligence platform
Deployment: Cloud-hosted Flask application
Technologies: Python, Flask, GPT-4, Pinecone, PostgreSQL, GA4/Meta/Google Ads
Ads Intelligence Platform
Unified Marketing Analytics with AI-Powered Insights
Last Updated: October 21, 2025 | Version 1.0