> ## Documentation Index
> Fetch the complete documentation index at: https://docs.searchcompany.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Overview

> Architecture for the AI Recommendation Store webhook

## Purpose

Stores AI bot visits (recommendations) from tracking scripts embedded in AI-optimized sites. No authentication required.

## Architecture

```mermaid theme={null}
flowchart TD
    TrackingScript["Tracking Script"]
    
    subgraph identify [Bot Identification]
        IdentifyBot["identify_ai_bot()"]
    end
    
    subgraph lookup [Lookup]
        FindSite["Find AI site by domain"]
    end
    
    subgraph db [Database]
        AIRecommendations["ai_recommendations table"]
    end
    
    TrackingScript --> IdentifyBot
    IdentifyBot --> FindSite
    FindSite --> AIRecommendations
```

## Request Body

```json theme={null}
{
  "page_url": "https://business.searchcompany.dev/topic/",
  "page_type": "boosted_page",
  "page_title": "Topic Title",
  "user_agent": "...",
  "ip_address": "...",
  "referrer": "...",
  "screen_width": 1920,
  "screen_height": 1080,
  "language": "en-US",
  "timezone": "America/New_York"
}
```

## Bot Identification

The `identify_ai_bot()` function checks user agent patterns:

* ChatGPT
* Claude
* Gemini
* Perplexity
* Copilot
* DeepSeek
* Grok
* Google AI

Unidentified visits are stored with `platform_id='unknown'`.

## Code Location

```
src/app/webhooks/ai_platform_recommendations_store/routes.py
```
