This piece of content was created for the purposes of entering the H0 Hackathon, using Vercel v0 and AWS Databases integration.
The Idea
If you have ever managed ad campaigns across Google, Meta, TikTok, Amazon or other retail media platforms for multiple clients, you know the most common question that is asked is, "Why did this campaign fail?"
The Problem
When a campaign underperforms, the reality is that diagnosing the root cause is often a manual and time-consuming process. The honest answer is it usually takes a few hours, sometimes a day or two, to dig through dashboards, compare performance metrics, review historical reports, and sometimes even try to recall whether a similar issue occurred before.
The knowledge of what went wrong, why it happened, and how it was fixed typically does not live in any accessible knowledge base. Instead, it lives in dashboards, spreadsheets, Slack conversations, documentation scattered across different tools, or simply in the minds of experienced account managers. As agencies grow, that becomes a real operational challenge. Every new issue often triggers the same investigation all over again, even if a nearly identical one had already been solved months earlier.
This led us to a simple question:
Can campaign diagnosis become an automated process instead of a manual investigation?
Our answer was yes!
That's where Campaign Failure Intelligence (CFI) comes in.
The Solution
Instead of treating every campaign issue as a new investigation, CFI approaches it the way an experienced account manager would.
It first analyzes the campaign's current performance signals for metrics such as ROAS, CTR, CPM, CPC, frequency, reach, spend, and seasonal context to understand what the data is indicating. It then compares those findings against historically similar situations to determine whether the agency has encountered this pattern before. Finally, it recommends the actions that previously worked in comparable situations.
CFI is a B2B tool for ad agencies that does three things:
- Detects campaigns that are beginning to underperform using configurable business rules such as declining ROAS, rising CPM, frequency spikes, or other performance thresholds.
- Diagnoses the likely root cause by analyzing campaign metrics, identifying behavioral patterns, and validating those findings against historically similar situations.
- Recommends fixes that previously worked for comparable situations, ranking them by historical effectiveness and providing supporting evidence rather than generic best practices.
The Dataset
To prototype the diagnosis engine, we started with a public Kaggle dataset containing roughly 1,800 daily observations across Google Ads, Meta Ads, and TikTok Ads. Rather than using synthetic metrics, we wanted CFI to learn from realistic campaign behavior across multiple industries and platforms.
From there, we built a Python/pandas data pipeline that transformed raw campaign reports into a structured knowledge base that the diagnosis engine could reason over.
The Pipeline
Mapped the raw campaign data into a relational schema:
clients → campaigns → daily_metrics → situations → situation_embeddings → risk_rules → campaign_seasons
Automatically detected underperforming patterns using the same threshold logic CFI would use in production. Any campaign day where ROAS dropped below 2.0x was flagged as a situation, with severity tiers (critical, high, medium) assigned based on how far performance deviated from the target.
Performed root cause analysis (RCA) on every detected situation by analyzing surrounding metric patterns. For example, prolonged high frequency combined with declining CTR was classified as creative fatigue, while shrinking reach paired with rising frequency indicated audience saturation. Each inferred root cause was stored alongside a confidence score and historical frequency, allowing the system to explain why a situation likely occurred rather than simply flagging that it had occurred.
Grouped campaigns into seasons (Back to School, Summer Sale, Black Friday, Q1/New Year, Spring Launch). This allows CFI to compare campaign behavior across different clients during the same seasonal period, surfacing cross-client trends that individual account managers would rarely have visibility into.
The resulting dataset contains 5 clients, 60 campaigns, ~1,800 daily metric records, and around 60 detected situations, each enriched with root causes, severity, historical context, and seasonality.
Rather than hardcoded examples, CFI learns from real campaign behavior, turning every historical situation into reusable diagnostic knowledge.
The Backend (AWS Architecture)
The diagnosis layer runs entirely on AWS production-grade infrastructure.
Each situation is embedded using Amazon Titan Embeddings v2 (via AWS Bedrock) and stored in Amazon Aurora PostgreSQL Serverless v2 using the pgvector extension.
No separate vector database is required — embeddings live directly inside the relational database.
When a new situation comes in, the flow is:
- Embed the new context (metrics, platform, season, and triggering pattern)
- Run a pgvector similarity search against stored embeddings to retrieve the top 3 most similar historical situations (along with causes, fixes, and resolution timelines)
- Pass the new context plus retrieved matches into an AI agent (Amazon Nova Lite via Bedrock) that reasons over the combined context
- The agent returns the likely root cause, supporting evidence, and recommended actionable fixes grounded in what worked before
This entire pipeline:
embed → retrieve similar situations → reason with an LLM → recommend a fix
is already working end-to-end on the dataset described above. It is not yet connected to live ad accounts, but the retrieval-augmented reasoning loop itself is fully functional and tested.
The Frontend
The frontend was scaffolded using Vercel v0, generating a production-ready Next.js application.
This enabled rapid development of:
- campaign dashboards
- situation exploration views
- diagnostic timelines
- recommendation panels
The UI is designed around how account managers actually investigate performance:
start broad → drill into metrics → analyze root cause → apply fix
Tech Stack
Frontend
- Framework: TanStack Start (SSR, file-based routing)
- React: React 19
- Styling: Tailwind CSS 4 + shadcn/ui + Radix UI primitives
- Build Tool: Vite 8
- Package Manager: npm
- Theme System: Dark mode by default, toggled via CSS classes
- Icons: Lucide React
- Charts: Recharts
Backend
- Amazon Aurora PostgreSQL Serverless v2
- pgvector
- AWS Bedrock (Titan Embeddings + Nova Lite)
Closing Thought
Most agencies don’t lack data — they lose context.
CFI brings that context back, turning every past situation into a reference point for the next decision.
Top comments (0)