Skip to content

Latest commit

 

History

13 Commits

Folders and files

Repository files navigation

CampaignGraph AI

Counterfactual marketing intelligence for Experience Cloud-style ecosystems. Independent reference implementation; not affiliated with Adobe. Explore hypothetical interventions using a graph of audiences, channels, campaigns, creatives, journeys, experiments and policies. Compare paired synthetic outcomes, inspect the evidence trail, and approve a proposed analysis without activating campaigns.

Product architecture at a glance

CampaignGraph AI system architecture

What is implemented

  • Persistent multi-tenant SQLite property graph with bounded transactional imports and provenance.
  • TF-IDF ranking, optional OpenAI semantic embeddings, bounded two-hop graph traversal, relationship paths and evidence citations.
  • Native LangGraph supervisor, four compiled specialist subgraphs, parallel fan-out and explicit fan-in, deterministic simulator, evaluator and synthesizer.
  • Optional LLM evidence-grounded commentary with citation ID validation; deterministic default and fallback. The LLM never controls numerical results or approval.
  • Counterfactual scenarios with shared Monte Carlo draws, saturating channel response, uncertain propensity, fatigue, audience overlap and creative/journey multipliers.
  • FastAPI REST API, validated inputs, API-key roles, independent reviewer approvals, persistent history and audit events.
  • Responsive browser dashboard with scenario form, baseline/proposed metrics, evidence graph, traces and review controls.
  • Docker Compose, automated test suite and GitHub Actions configuration.

Run

Python 3.11/3.12 recommended. Docker is the simplest route:

docker compose up --build

Open http://localhost:8000 (dashboard), or http://localhost:8000/docs (OpenAPI). Development-only API keys: demo-analyst, demo-reviewer, demo-admin. The default browser form uses the analyst key. Use a separate reviewer key to approve an analysis. No messaging, ad buying or Adobe activation endpoints exist.

Alternatively:

python -m venv .venv
source .venv/bin/activate
pip install -r requirements-dev.txt
uvicorn app.main:app --host 127.0.0.1 --port 8000
python -m pytest -q

The database lives in data/campaign.db by default. To use .env.example, copy it to .env, set values and export them via your shell or deployment platform; the application reads environment variables, not the file automatically. The Compose configuration does not automatically pass arbitrary .env variables to the container.

Example request

curl -s http://localhost:8000/api/simulations \
  -H 'X-API-Key: demo-analyst' \
  -H 'Content-Type: application/json' \
  --data @examples/scenario.json

This scenario shifts $6,000 from paid search into email, keeps total media spend at $30,000, and tests an offer creative with an email-first journey. Results depend on synthetic assumptions. The question is retrieval context only: numerical interventions come from the explicit scenario fields, not automatic natural-language interpretation.

Simulation visualizations

Synthetic counterfactual simulation and baseline versus proposed budget allocation

Example output from 2,000 paired synthetic Monte Carlo draws. The displayed revenue and conversion changes are modelled, not observed causal lift or a validated forecast.

Campaign knowledge graph

Selected campaign knowledge graph relationships

The diagram shows selected actual relationships from app/seed.py, including campaign targets, creative and journey usage, illustrative holdout evidence, and channel consent restrictions.

Architecture

flowchart TD
    UI[Scenario dashboard] --> API[FastAPI / tenant and role checks]
    API --> S[Supervisor]
    S --> A[Audience subgraph]
    S --> C[Campaign subgraph]
    S --> CR[Creative and journey subgraph]
    S --> G[Governance subgraph]
    KG[(Persistent property graph)] --> A & C & CR & G
    A & C & CR & G --> J[Fan-in and paired simulation]
    J --> E[Policy and evidence evaluator]
    E --> F[Synthesizer / optional LLM]
    F --> H[(Run history and audit)]
    H --> R[Independent human review]
Loading

The list-form LangGraph edge waits for all four specialist branches before running simulation. Branches write distinct state keys and append trace entries with a reducer. Graph retrieval expands from query-ranked nodes and explicit scenario entity anchors, preserving edge paths and sources. The graph supplies context and governance evidence; the numerical response model is not learned from the graph.

API

Method Route Role
GET /health Public
GET /api/graph Authenticated
POST /api/graph/import Admin
POST /api/simulations Analyst / admin
GET /api/simulations Authenticated
GET /api/simulations/{id} Authenticated
POST /api/simulations/{id}/decision Independent reviewer / admin
GET /api/simulations/{id}/audit Authenticated

Every protected route derives tenant scope from the API key, never from a request parameter. Imported edge endpoints must exist in the same tenant. Approvals are atomic and only permitted on pending runs. Approval is of the analysis only, not campaign execution. See integration guide, simulation methodology, and deployment notes.

Repository layout

app/
  main.py          API, roles, lifecycle
  models.py        Strict input schemas
  store.py         Graph and audit persistence
  seed.py          Synthetic demo graph
  retrieval.py     GraphRAG ranking and traversal
  simulation.py    Paired counterfactual simulator
  workflow.py      Supervisor, subgraphs, evaluator
  narrative.py     Optional LLM commentary
  static/          HTML, CSS, JavaScript dashboard
tests/             Core and API tests
examples/          Sample scenario and import
docs/              Architecture and operating guidance

Google Ads engineering — repository-specific visual design gallery

Existing paired Monte Carlo and evidence-grounded campaign scenarios; proposed Google Ads adaptation. The following ten diagrams are independent design proposals, not claims of implemented Google connectors or measured performance. Conceptual data inputs: Google Ads campaign reports, GA4 conversion aggregates, BigQuery scenario inputs.

Adaptation strategy for the current repository

Reuse app/models.py, retrieval.py, simulation.py, workflow.py and store.py. Add a read-only Ads/GA4 ingestion layer and calibrated scenario parameter contract. The existing paired simulator models hypothetical outcomes, not Google's auction or causal lift.

Google integration references: Google Ads reporting · GA4 Data API. These are proposed adapter contracts; live data access and field compatibility must be validated separately.

01. Scenario compiler

CampaignGraphAI: Scenario compiler

What this graphic shows: Pin the baseline revision and validate budget, channel and intervention assumptions. Use identical random draws to compare counterfactual outcomes.

Reading the diagram: Baseline campaign → intervention budget → channel constraints → seeded draws → scenario report. The flow represents proposed processing or decision dependencies, not external API execution.

Step-by-step workflow: Validate baseline budget, intervention amounts, channel response parameters and entity anchors. Pin a graph revision and seed; compile explicit numeric inputs into paired simulation jobs.

How to adapt the current repository: Extend models.py with an Ads scenario input schema and normalized campaign IDs. Keep simulation.py numeric inputs explicit rather than letting the LLM infer spend.

Outputs, failure handling and validation: Reject negative budgets, currency mismatch and missing parameters; verify identical inputs and seed yield identical results.

02. Campaign causal-assumption graph

CampaignGraphAI: Campaign causal-assumption graph

What this graphic shows: Connect campaign to channel, audience overlap and creative multipliers. These are modeling relationships and assumptions, not causal relationships learned from Google data.

Reading the diagram: Campaign · Channel · Audience overlap · Creative · Journey · Outcome. Links are conceptual associations; use the accompanying text for direction and semantics.

Step-by-step workflow: Connect campaigns to channels, audiences, creatives and journeys; attach evidence and consent constraints. Identify which edges inform assumptions versus metadata relationships.

How to adapt the current repository: Reuse the SQLite property graph and retrieval.py bounded traversal. Add source-qualified Ads resource IDs and edge types for reporting context; do not treat links as causal DAG identification.

Outputs, failure handling and validation: Test endpoint integrity and provenance; label each response multiplier as assumed, estimated or experimentally measured.

03. Specialist scenario orchestration

CampaignGraphAI: Specialist scenario orchestration

What this graphic shows: Parallel evidence checks and bounded retrieval prepare inputs for deterministic simulation. The language model may explain but must not determine numeric outputs.

Reading the diagram: Scenario request → graph specialist / parallel alternative: assumptions specialist / parallel alternative: policy specialist → simulator → evaluator. The flow represents proposed processing or decision dependencies, not external API execution.

Step-by-step workflow: Supervisor fans out to audience, campaign, creative/journey and governance specialists. Their distinct state keys join before the simulator; evaluator checks policy and evidence before narrative.

How to adapt the current repository: Reuse native LangGraph workflow.py, including list-edge barrier; extend specialists to understand Google channel labels and conversion definitions.

Outputs, failure handling and validation: Test missing specialist results, concurrent writes and evaluator rejection; ensure the narrative cannot override numeric output.

04. Paired Monte Carlo model

CampaignGraphAI: Paired Monte Carlo model

What this graphic shows: Shared random draws reduce variance in comparisons. Report distributions and uncertainty instead of a single guaranteed ROAS estimate.

Reading the diagram: Common seed → baseline draws / parallel alternative: intervention draws → paired delta → quantiles. The flow represents proposed processing or decision dependencies, not external API execution.

Step-by-step workflow: Generate a common set of random draws, evaluate baseline and proposed spend under the same draw, subtract paired outcomes and summarize quantiles of the delta.

How to adapt the current repository: Retain simulation.py shared-random-number logic; introduce versioned, calibrated parameters from approved history or experiments only when available.

Outputs, failure handling and validation: Check zero-change delta, fixed-seed replay and distribution sensitivity; report intervals as conditional model uncertainty.

05. Spend-response sensitivity

CampaignGraphAI: Spend-response sensitivity

What this graphic shows: The simulator uses saturating response and overlap/fatigue assumptions. Stress-test parameters rather than interpreting a synthetic curve as calibrated auction behavior.

Reading the diagram: Spend cap → saturation curve → overlap adjustment → fatigue multiplier → modeled conversions. The flow represents proposed processing or decision dependencies, not external API execution.

Step-by-step workflow: Translate spend through a saturating response curve, adjust for overlap and fatigue, multiply by assumed conversion/revenue factors and compute modeled ROAS.

How to adapt the current repository: Reuse current simulator response functions; add campaign-type-specific parameter sets and disclose assumptions. Do not approximate proprietary Smart Bidding rules as fact.

Outputs, failure handling and validation: Sweep response slopes, fatigue and overlap; inspect budget conservation and diminishing marginal return under the chosen model.

06. Scenario verification

CampaignGraphAI: Scenario verification

What this graphic shows: Independent reviewers inspect reproducible metrics and evidence. Approval records an analysis decision only, never a live campaign activation.

Reading the diagram: Snapshot hash → replay draws → recompute revenue → check citations → approve analysis. The flow represents proposed processing or decision dependencies, not external API execution.

Step-by-step workflow: Re-run scenario from stored inputs and revision, reconcile revenue, spend and evidence, then present the result for an independent reviewer.

How to adapt the current repository: Reuse store.py history/audit and decision endpoints. Include source-report revisions and assumption IDs in the audit digest; approval remains analysis-only.

Outputs, failure handling and validation: Reject stale snapshots and changed inputs; verify reviewer role and no activation call is reachable.

07. Channel budget shift walkthrough

CampaignGraphAI: Channel budget shift walkthrough

What this graphic shows: Illustrative budget redistribution is conditional on explicit response assumptions. Do not equate the modeled result with actual Smart Bidding behavior.

Reading the diagram: Search baseline → proposed shift → Performance Max scenario → compare contribution → human review. The flow represents proposed processing or decision dependencies, not external API execution.

Step-by-step workflow: Create a hypothetical fixed-total-budget shift from Search to Performance Max; retrieve channel/creative evidence, simulate both allocations and compare modeled contribution and downside.

How to adapt the current repository: Map Google campaign IDs and campaign types into existing scenario schema; estimate inputs independently and do not infer auction behavior from campaign labels.

Outputs, failure handling and validation: Report spend conservation, paired delta quantiles and assumptions; human decides whether to run a real controlled experiment.

08. Campaign reporting integration

CampaignGraphAI: Campaign reporting integration

What this graphic shows: A read-only adapter would reconcile account timezone, cost micros, currency and conversion definitions before populating scenario inputs.

Reading the diagram: GAQL campaign aggregate → date/currency normalization → BigQuery scenarios → conversion aggregates → scenario store. The flow represents proposed processing or decision dependencies, not external API execution.

Step-by-step workflow: Query compatible campaign/day reporting fields, normalize cost_micros to account currency, reconcile conversion windows and align GA4 aggregate metrics. Stage partitioned features before importing.

How to adapt the current repository: Add app/google_ads.py and a GA4 reporting adapter as proposed modules; use store.py validated graph imports and maintain separate source metric definitions.

Outputs, failure handling and validation: Mock pagination/quota errors; reject mixed currencies, incompatible attribution windows and silently missing conversions.

09. Counterfactual validity boundaries

CampaignGraphAI: Counterfactual validity boundaries

What this graphic shows: Graph dependencies and simulations cannot establish causal uplift. Randomized experiments or suitable quasi-experimental methods are needed for causal validation.

Reading the diagram: Unobserved confounders · Attribution lag · Auction changes · Seasonality · Synthetic assumptions. Links are conceptual associations; use the accompanying text for direction and semantics.

Step-by-step workflow: Identify competing explanations for observed change: seasonality, demand, conversion lag and unobserved auction conditions. Separate scenario estimates from causal evidence.

How to adapt the current repository: Keep simulation outputs as model-based decision support. Add an experiment-evidence node type and require randomized or justified quasi-experimental estimates before making causal claims.

Outputs, failure handling and validation: Test that reports never label hypothetical uplift as observed; record assumptions, confidence limitations and alternative explanations.

10. Simulation regression suite

CampaignGraphAI: Simulation regression suite

What this graphic shows: Test reproducibility, budget conservation and numerical sensitivity. Define acceptance criteria before a real integration.

Reading the diagram: Fixed seed → zero-change baseline → conservation checks → parameter sweeps → confidence intervals. The flow represents proposed processing or decision dependencies, not external API execution.

Step-by-step workflow: Run no-op interventions, fixed seeds, extreme budget caps, sensitivity sweeps and review authorization tests. Compare exact numeric output or tolerance-defined values.

How to adapt the current repository: Extend tests/ with mocked Ads data and versioned golden scenarios; separate retrieval evaluation from simulation numerical accuracy.

Outputs, failure handling and validation: Use budget conservation, determinism, citation completeness and policy rejection as release gates; no measured Ads benchmark claimed.

Meta / Facebook engineering — repository-specific visual gallery

Meta campaign what-if and creative-placement simulation. Reuse app/models.py, retrieval.py, simulation.py, workflow.py and store.py; add scoped Meta campaign/ad-set/placement reports and explicit response assumptions. Paired simulation is not Meta auction emulation.

All diagrams are independent proposed adaptations, not live Meta integrations, internal Meta architecture, official affiliation or measured outcomes. Verify API version, app review, permissions and platform terms before implementation.

01. Campaign ad-set scenario graph

CampaignGraphAI: Campaign ad-set scenario graph

Concept and step-by-step workflow: Pin campaign/ad-set hierarchy, shared creative and placement relationships. Label outcome evidence separately from assumed response coefficients.

Diagram reading guide: Campaign objective → Ad set A; Campaign objective → Ad set B; Ad set A → Creative; Ad set B → Creative; Creative → Placement; Campaign objective → Outcome evidence. Arrows denote proposed dependencies or processing order, not proof of causal effects.

How to adapt the current repository: Extend existing property graph and scenario schema with account/ad-set IDs and source-qualified placement metadata.

Expected outputs, failure handling and validation: Validate hierarchy, spend scope and evidence; associations are not learned causal edges.

02. Budget redistribution compiler

CampaignGraphAI: Budget redistribution compiler

Concept and step-by-step workflow: Convert explicit proposed allocation into a typed scenario, check budget constraints and currency, pin revision and seed, then dispatch numerical simulator.

Diagram reading guide: Baseline ad-set budgets → Proposed allocation → Conservation check → Fixed seed → Scenario run. Arrows denote proposed dependencies or processing order, not proof of causal effects.

How to adapt the current repository: Reuse models.py and simulation.py; add campaign vs ad-set budget distinction and placement response inputs.

Expected outputs, failure handling and validation: Reject negative allocation, mixed currency and missing assumptions; no Ads Manager mutation.

03. Paired placement response model

CampaignGraphAI: Paired placement response model

Concept and step-by-step workflow: Evaluate both mixes on identical draws, account for explicit saturation/fatigue and overlap assumptions, summarize modeled contribution quantiles.

Diagram reading guide: Shared random draws → Baseline placement mix; Shared random draws → Proposed placement mix; Baseline placement mix → Paired outcome delta; Proposed placement mix → Paired outcome delta. Arrows denote proposed dependencies or processing order, not proof of causal effects.

How to adapt the current repository: Reuse paired Monte Carlo simulator; introduce versioned Meta placement parameters estimated only from approved data or controlled tests.

Expected outputs, failure handling and validation: Zero change yields zero delta; no claim to model proprietary delivery optimization.

04. Four-specialist scenario join

CampaignGraphAI: Four-specialist scenario join

Concept and step-by-step workflow: Dispatch four documented specialists and wait for all required outputs before deterministic simulation. Evaluate citations and policy before narrative.

Diagram reading guide: Scenario request → Audience evidence; Scenario request → Campaign evidence; Scenario request → Creative and journey; Scenario request → Governance evidence; Audience evidence → Simulation and evaluator; Campaign evidence → Simulation and evaluator; Creative and journey → Simulation and evaluator; Governance evidence → Simulation and evaluator. Arrows denote proposed dependencies or processing order, not proof of causal effects.

How to adapt the current repository: Reuse workflow.py fan-out/fan-in and store audit; extend source context for Facebook/Instagram placements.

Expected outputs, failure handling and validation: Test concurrent state writes and missing branch; LLM cannot alter modeled metrics.

05. Insights reporting normalization

CampaignGraphAI: Insights reporting normalization

Concept and step-by-step workflow: Retrieve allowed aggregate fields; separate action types and attribution windows, reconcile spend/value and report date before building assumptions.

Diagram reading guide: Meta Insights report → Attribution setting → Currency and day grain → Versioned assumptions → Scenario inputs. Arrows denote proposed dependencies or processing order, not proof of causal effects.

How to adapt the current repository: Implement app/meta_ads.py as proposed read adapter and staging schema; keep observed metrics distinct from simulated outputs.

Expected outputs, failure handling and validation: Reject incompatible attribution settings and missing action definitions; test pagination and quota handling.

06. Creative fatigue sensitivity

CampaignGraphAI: Creative fatigue sensitivity

Concept and step-by-step workflow: Vary explicit response/fatigue inputs on identical budget and seed, compare modeled downside and identify fragile recommendations.

Diagram reading guide: Independent evaluation dimensions: Frequency assumption; Placement saturation; Response slope; Creative reuse; Audience overlap; Value per conversion. No measured values are implied.

How to adapt the current repository: Reuse simulator response functions and scenario stress tests; store assumption provenance and bounds.

Expected outputs, failure handling and validation: Frequency association alone does not prove fatigue; report conditional sensitivities, not observed uplift.

07. Analysis review lifecycle

CampaignGraphAI: Analysis review lifecycle

Concept and step-by-step workflow: Recompute numeric results and verify source revision, then bind reviewer decision to exact scenario. Export a hypothesis for a controlled experiment.

Diagram reading guide: Scenario compiled → Simulation replayed → Evidence checked → Independent decision → Manual experiment proposal. Arrows denote proposed dependencies or processing order, not proof of causal effects.

How to adapt the current repository: Reuse current run history and decision endpoints; add Meta campaign reference to analysis-only export.

Expected outputs, failure handling and validation: Reject stale revision and self-approval; no campaign activation or bid change.

08. Counterfactual validation matrix

CampaignGraphAI: Counterfactual validation matrix

Concept and step-by-step workflow: Compare known synthetic fixtures, sweep response parameters and explicitly separate causal experiment evidence from scenario estimates.

Diagram reading guide: Independent evaluation dimensions: Budget conservation; Fixed seed; No-op delta; Parameter sensitivity; Attribution limitations; Review integrity. No measured values are implied.

How to adapt the current repository: Extend existing simulation tests with mocked Insights report fixtures and placement fields.

Expected outputs, failure handling and validation: No actual ROAS uplift claimed; require controlled experiment or justified causal method for causal conclusions.

Official references: Meta Marketing API · Insights API · Graph API.

Microsoft / Azure engineering — repository-specific visual gallery

Microsoft Advertising counterfactual planning. Reuse app/models.py, retrieval.py, simulation.py, workflow.py and store.py. Add permitted campaign/ad-group/keyword/goal reports and explicit response assumptions; simulation is not proprietary bidding or causal measurement.

Independent proposed adaptations; no claim of live Microsoft integration, internal architecture, certification or measured results.

01. Microsoft campaign dependency graph

CampaignGraphAI: Microsoft campaign dependency graph

Concept and step-by-step workflow: Model campaign hierarchy and source-qualified conversion goal associations. Separate reporting evidence from hypothetical response coefficients and pin graph revision.

Diagram reading guide: Campaign → Ad group; Ad group → Keyword or asset; Campaign → Conversion goal; Conversion goal → Reporting evidence. Arrows describe proposed processing/dependencies, with branching semantics explained above.

How to adapt the current repository: Extend existing property graph and scenario schema with Microsoft Advertising resource IDs and goal definitions; keep bounded traversal.

Expected outputs, failure handling and validation: Reject orphan resources and incompatible goal/report mapping; metadata links are not causal edges.

02. Asynchronous reporting import

CampaignGraphAI: Asynchronous reporting import

Concept and step-by-step workflow: Request permitted report, poll within bounded deadline, parse downloaded rows and normalize account currency, time aggregation and conversion columns; validate completeness before commit.

Diagram reading guide: Report request → Poll report status; Poll report status → Download approved report; Download approved report → Normalize metrics; Normalize metrics → Versioned snapshot. Arrows describe proposed processing/dependencies, with branching semantics explained above.

How to adapt the current repository: Implement proposed app/microsoft_ads.py Reporting adapter and staging contract; use store.py validated snapshot import and safe retry for reads.

Expected outputs, failure handling and validation: Partial or expired report cannot advance revision; test duplicate rows, quota and mismatched currency.

03. Budget scenario compiler

CampaignGraphAI: Budget scenario compiler

Concept and step-by-step workflow: Create explicit fixed-total-budget alternative across eligible campaign types, validate nonnegative spend and pin common seed. Use approved parameter assumptions only.

Diagram reading guide: Baseline allocation → Proposed Search allocation; Baseline allocation → Proposed PMax allocation; Proposed Search allocation → Budget conservation; Proposed PMax allocation → Budget conservation; Budget conservation → Paired simulation. Arrows describe proposed processing/dependencies, with branching semantics explained above.

How to adapt the current repository: Reuse simulation.py paired Monte Carlo and models.py scenario inputs; extend campaign-type response parameters without modeling Microsoft's internal auction.

Expected outputs, failure handling and validation: No-op delta zero, spend conserved; no live budget change.

04. Conversion goal scenario sensitivity

CampaignGraphAI: Conversion goal scenario sensitivity

Concept and step-by-step workflow: Keep goal definitions distinct, align attribution and value assumptions, run comparable scenario outputs only if metrics support comparison. Show uncertainty.

Diagram reading guide: Pinned scenario → Conversion definition A; Pinned scenario → Conversion definition B; Conversion definition A → Comparable value assumptions; Conversion definition B → Comparable value assumptions; Comparable value assumptions → Modeled delta. Arrows describe proposed processing/dependencies, with branching semantics explained above.

How to adapt the current repository: Reuse response and sensitivity functions; add explicit goal-level parameter provenance and distinguish AllConversions versus selected conversion columns.

Expected outputs, failure handling and validation: Reject incompatible denominators; no observed ROAS or causal lift claim.

05. Four-specialist scenario workflow

CampaignGraphAI: Four-specialist scenario workflow

Concept and step-by-step workflow: Run required existing specialist roles on pinned graph, validate all outputs before deterministic simulation and replay. Diagram groups creative/governance for readability.

Diagram reading guide: Scenario goal → Audience context; Scenario goal → Campaign evidence; Scenario goal → Creative and governance; Audience context → Evaluator and synthesis; Campaign evidence → Evaluator and synthesis; Creative and governance → Evaluator and synthesis. Arrows describe proposed processing/dependencies, with branching semantics explained above.

How to adapt the current repository: Reuse workflow.py native fan-in and evaluator; extend typed evidence with report request/version IDs, keeping model unable to alter numeric outputs.

Expected outputs, failure handling and validation: Test missing required role and stale report; bounded retry or abstain.

06. Counterfactual experiment handoff

CampaignGraphAI: Counterfactual experiment handoff

Concept and step-by-step workflow: Review modeled contribution quantiles and downside, distinguish hypothetical estimates from experiment evidence, bind independent decision to exact scenario and propose a controlled test.

Diagram reading guide: Paired scenario results → Review assumptions; Review assumptions → Independent decision; Independent decision → Controlled test proposal; Controlled test proposal → Manual export. Arrows describe proposed processing/dependencies, with branching semantics explained above.

How to adapt the current repository: Reuse store.py audit/review endpoints; add Microsoft campaign identifiers and experiment evidence fields only when supported.

Expected outputs, failure handling and validation: No actual campaign mutation or claimed lift; test reproducibility and review integrity.

References: Microsoft Advertising report types · Customer Insights · Universal Event Tracking.

Amazon / AWS engineering — repository-specific visual gallery

Counterfactual campaign simulation using existing app/models.py, retrieval.py, simulation.py, workflow.py and store.py; no proprietary Amazon bidding model.

Independent proposed adaptations; no live access, internal Amazon architecture, production certification or measured outcomes. Confirm permissions, API version, data terms and marketplace before implementation.

01. Sponsored campaign graph

CampaignGraphAI: Sponsored campaign graph

Concept and step-by-step workflow: Pin hierarchy and source-qualified product/goal associations, separate observed data from assumptions.

Diagram reading guide: Advertiser → Campaign; Campaign → Ad group; Ad group → Advertised ASIN; Campaign → Goal evidence. Arrows denote proposed dependencies, not causal proof.

How to adapt the current repository: Extend typed property graph with Amazon Ads profile, marketplace and report revision.

Expected outputs, failure handling and validation: Reject orphan links and incompatible currency; associations are not causal.

02. Asynchronous Ads report import

CampaignGraphAI: Asynchronous Ads report import

Concept and step-by-step workflow: Use permitted reporting API; poll within deadline and normalize time, attribution and currency before import.

Diagram reading guide: Report request → Poll status; Poll status → Download; Download → Normalize metrics; Normalize metrics → Atomic revision. Arrows denote proposed dependencies, not causal proof.

How to adapt the current repository: Add app/amazon_ads.py read adapter and store.py staging, verify supported report version.

Expected outputs, failure handling and validation: Expired URL or partial report retains prior valid snapshot.

03. Paired budget simulation

CampaignGraphAI: Paired budget simulation

Concept and step-by-step workflow: Compare baseline and alternatives using shared random draws and explicit response assumptions.

Diagram reading guide: Fixed budget → Sponsored Products mix; Fixed budget → Sponsored Brands mix; Sponsored Products mix → Common draws; Sponsored Brands mix → Common draws; Common draws → Modeled delta. Arrows denote proposed dependencies, not causal proof.

How to adapt the current repository: Reuse simulation.py paired Monte Carlo; add campaign-type response parameters and provenance.

Expected outputs, failure handling and validation: Test zero-change delta, budget conservation; no live writes.

04. Retail inventory sensitivity

CampaignGraphAI: Retail inventory sensitivity

Concept and step-by-step workflow: Vary inventory availability and margin assumptions; distinguish attributed order value from fulfilled profit.

Diagram reading guide: Scenario → In-stock case; Scenario → Stockout case; In-stock case → Margin and returns; Stockout case → Margin and returns; Margin and returns → Downside. Arrows denote proposed dependencies, not causal proof.

How to adapt the current repository: Extend scenario schema with independently supplied inventory and return-rate parameters.

Expected outputs, failure handling and validation: Reject invalid units; modeled sensitivity is not forecast.

05. Campaign evidence fan-in

CampaignGraphAI: Campaign evidence fan-in

Concept and step-by-step workflow: Join required specialists and validate input evidence before deterministic computation and replay.

Diagram reading guide: Scenario → Audience evidence; Scenario → Creative and product evidence; Scenario → Governance evidence; Audience evidence → Simulation evaluator; Creative and product evidence → Simulation evaluator; Governance evidence → Simulation evaluator. Arrows denote proposed dependencies, not causal proof.

How to adapt the current repository: Reuse workflow.py native join and evaluator; record report and parameter versions.

Expected outputs, failure handling and validation: Missing branch blocks completion; model cannot alter numbers.

06. Experiment review

CampaignGraphAI: Experiment review

Concept and step-by-step workflow: Review uncertainty and propose controlled validation where feasible; bind review to exact scenario.

Diagram reading guide: Modeled comparison → Assumption review; Assumption review → Independent decision; Independent decision → Controlled test proposal; Controlled test proposal → Manual export. Arrows denote proposed dependencies, not causal proof.

How to adapt the current repository: Reuse audit/review ledger and analysis-only export with Amazon campaign IDs.

Expected outputs, failure handling and validation: No measured uplift or real mutation; reject stale approval.

References: Amazon Ads API · Amazon Marketing Cloud.

Netflix engineering — repository-specific visual gallery

Streaming advertising and title-promotion counterfactual analysis. Reuse app/models.py, retrieval.py, simulation.py, workflow.py and store.py. Separate Netflix-as-advertiser title promotion from hypothetical streaming ad inventory planning.

Independent proposed adaptations inspired by public engineering writing; no private Netflix access, deployed integration, certification or measured results. Examples use fictional or appropriately licensed data.

01. Title promotion campaign graph

CampaignGraphAI: Title promotion campaign graph

Concept and step-by-step architecture: Map a fictional launch title, eligible markets, assets and spend to explicit outcome definitions. Observations and modeled response coefficients are distinct graph properties.

Diagram reading guide: Title launch → Market plan; Title launch → Promotional creative; Market plan → Channel allocation; Promotional creative → Channel allocation; Channel allocation → Outcome evidence. Arrows represent proposed processing dependencies; conditions and joins follow the workflow above.

How to adapt the current repository: Extend typed property graph with title, territory, creative version and marketing objective. Add synthetic report adapter, not an internal Netflix campaign connector.

Expected outputs, failure handling and validation: Validate territory, currency and attribution; no causal conclusion from hierarchy.

02. Streaming ad inventory scenario

CampaignGraphAI: Streaming ad inventory scenario

Concept and step-by-step architecture: Construct supplied inventory and eligible impression assumptions, enforce frequency constraints as model inputs and evaluate delivery under explicit demand and fill scenarios.

Diagram reading guide: Hypothetical ad breaks → Eligible impressions; Eligible impressions → Frequency constraints; Frequency constraints → Allocation assumptions; Allocation assumptions → Modeled delivery. Arrows represent proposed processing dependencies; conditions and joins follow the workflow above.

How to adapt the current repository: Extend scenario schema and simulator with inventory/fill assumptions where implemented, validate units before execution; keep title marketing scenario separate.

Expected outputs, failure handling and validation: No access to ad server or private member events; reject negative inventory and invalid probabilities.

03. Paired launch budget simulation

CampaignGraphAI: Paired launch budget simulation

Concept and step-by-step architecture: Compare alternate launch allocations under equal budget and shared random draws, model stated saturation and uncertainty, report paired quantiles.

Diagram reading guide: Fixed baseline budget → Market A allocation; Fixed baseline budget → Market B allocation; Market A allocation → Shared draws; Market B allocation → Shared draws; Shared draws → Modeled contribution delta. Arrows represent proposed processing dependencies; conditions and joins follow the workflow above.

How to adapt the current repository: Reuse simulation.py paired Monte Carlo and scenario compiler; introduce market-specific response parameters and source provenance.

Expected outputs, failure handling and validation: Test no-op delta, deterministic seed and spend conservation; no measured subscriber lift.

04. Creative and inventory sensitivity

CampaignGraphAI: Creative and inventory sensitivity

Concept and step-by-step architecture: Perturb explicitly declared assumptions and distinguish launch marketing efficiency from ad-inventory supply economics. Report only comparable metrics within each scenario type.

Diagram reading guide: Pinned launch scenario → Lower artwork response; Pinned launch scenario → Lower ad inventory; Pinned launch scenario → Higher acquisition cost; Lower artwork response → Downside range; Lower ad inventory → Downside range; Higher acquisition cost → Downside range. Arrows represent proposed processing dependencies; conditions and joins follow the workflow above.

How to adapt the current repository: Reuse sensitivity functions; add separate typed scenario families with explicit units and guardrails.

Expected outputs, failure handling and validation: Reject incompatible metric combinations; conditional model not a calibrated forecast.

05. Campaign evidence synchronization

CampaignGraphAI: Campaign evidence synchronization

Concept and step-by-step architecture: Dispatch existing specialist roles on pinned graph, wait for required evidence, verify scenario assumptions and replay simulator before narrative.

Diagram reading guide: Campaign question → Audience evidence; Campaign question → Creative evidence; Campaign question → Market and policy evidence; Audience evidence → Numerical replay and evaluator; Creative evidence → Numerical replay and evaluator; Market and policy evidence → Numerical replay and evaluator. Arrows represent proposed processing dependencies; conditions and joins follow the workflow above.

How to adapt the current repository: Reuse workflow.py join and evaluator; record source revision, title ID and scenario family. Keep model unable to override numerical result.

Expected outputs, failure handling and validation: Missing branch blocks full answer; stale report triggers bounded retry or abstention.

06. Experiment design handoff

CampaignGraphAI: Experiment design handoff

Concept and step-by-step architecture: Review uncertainty, identify differences in title availability, artwork exposure and market baseline; propose appropriately randomized study and predeclared guardrails.

Diagram reading guide: Modeled result → Confounder review; Confounder review → Independent reviewer; Independent reviewer → Controlled test proposal; Controlled test proposal → Manual export. Arrows represent proposed processing dependencies; conditions and joins follow the workflow above.

How to adapt the current repository: Reuse review ledger and scenario digest, add experiment proposal schema and analysis-only export.

Expected outputs, failure handling and validation: No live campaign mutation, real traffic or statistical significance claim.

Public inspiration: Netflix Technology Blog. The diagrams are independent application proposals, not a reproduction of Netflix's architecture.