AI-powered analytics agent for querying AppsFlyer performance data in BigQuery using natural language. Converts plain English questions into optimized SQL queries and computes metrics based on official AppsFlyer documentation.
Think of it as a conversational analyst for your AppsFlyer + BigQuery data.
- User asks: "Compare D7 ROAS for Meta vs Google last month."
- Intent classification (period_compare + roas_cohort)
- Schema context loaded (table + column manifest)
- LLM drafts SQL (safe template-driven)
- Validation: static rules + SQL parsing + dry-run cost
- BigQuery execution (SELECT-only)
- KPI enrichment (ROAS deltas, rankings)
- Summarization (plain-English narrative)
- Visualization spec assembly
- Response JSON with follow-up suggestions
User -> Chat/API -> Orchestrator
-> Intent + SQL Draft (LLM)
-> SQL Validator (rules + AST + cost dry-run)
-> BigQuery Runner
-> Metrics Post-Processor
-> Insight & Visualization Generator (LLM)
Prerequisites: GCP project, BigQuery dataset with AppsFlyer exports, Python 3.10+, LLM API key.
Environment (.env example):
GCP_PROJECT_ID=your-gcp-project
BQ_DATASET=your-gcp-dataset
GOOGLE_APPLICATION_CREDENTIALS=/path/to/service_account.json
Local setup:
git clone https://github.com/rivka14/bigquery-metrics-appsflyer-ai-agent.git
cd bigquery-metrics-appsflyer-ai-agent
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -r requirements.txt