> ## 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 Generate Product Prompts endpoint

## Purpose

Generates visibility tracking prompts for products. These prompts are used by the daily cron to check if products are being recommended by AI platforms.

## Architecture

```mermaid theme={null}
flowchart TD
    Request["POST /api/cron/generate-product-prompts"]
    
    subgraph generation [Prompt Generation]
        ForEach["For each product"]
        CallGemini["Call Gemini"]
        Generate["Generate 10 search queries"]
    end
    
    subgraph save [Database]
        SavePrompts["Save to entity_prompts_tracker"]
    end
    
    Request --> ForEach
    ForEach --> CallGemini
    CallGemini --> Generate
    Generate --> SavePrompts
    SavePrompts --> Response["Return counts"]
```

## Pipeline Flow

This endpoint is the second step in a 3-step product pipeline:

```
1. discover-products
   └── Extract products from content
   └── Return entity_ids

2. generate-product-prompts (this endpoint)
   └── Takes entity_ids from step 1
   └── Generates 10 prompts per product
   └── Saves to entity_prompts_tracker

3. generate-product-llms-txt
   └── Takes entity_ids from step 1
   └── Generates /llms/{slug}.txt files
```

## How Prompts Are Used

These prompts are later used by the daily cron job:

1. **Sample prompts** - Cron samples 10 prompts per day
2. **Check visibility** - Query 8 AI platforms with each prompt
3. **Store results** - Update `entity_prompts_tracker` with pass/fail per platform
4. **Calculate score** - Aggregate into visibility score

## Code Location

```
src/app/apis/cron/generate_product_prompts/routes.py
src/app/shared/products/discover.py  # generate_prompts_for_product()
src/app/shared/prompts/service.py    # Underlying prompt generation
```
