> ## 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.

# Scoring

<Note>
  **Internal Service** — This is not an HTTP endpoint. It's called by the analyze-visibility orchestrator.
</Note>

## Purpose

Calculates visibility scores from raw platform results. Converts boolean arrays into percentages and overall scores.

## Functions

### calculate\_platform\_scores

```python theme={null}
def calculate_platform_scores(summary: dict) -> dict[str, int]
```

Converts summary counts to percentage scores per platform:

```python theme={null}
{
    "chatgpt": 75,   # 75% of prompts visible
    "claude": 50,
    "gemini": 80,
    # ...
}
```

### calculate\_overall\_score

```python theme={null}
def calculate_overall_score(summary: dict, total_queries: int) -> tuple[int, int]
```

Returns `(overall_score, total_visible)`:

* **overall\_score**: 0-100, weighted average across platforms
* **total\_visible**: Total number of (prompt, platform) pairs where visible

### calculate\_summary\_stats

```python theme={null}
def calculate_summary_stats(results: list[dict]) -> dict
```

Aggregates results into counts per platform:

```python theme={null}
{
    "chatgpt": {"visible": 15, "total": 20},
    "claude": {"visible": 10, "total": 20},
    # ...
}
```

## Score Formula

```
overall_score = (total_visible / (total_queries * 8)) * 100
```

Where 8 is the number of AI platforms tracked.

## Code Location

```
src/app/apis/cron/analyze_visibility/scoring.py
```
