---
name: serpapi-reference-architecture
description: 'Design a governed SerpAPI search service with engine adapters, policy enforcement, caching, capacity management, observability, and privacy boundaries. Use when conducting architecture review. Trigger with "design a SerpAPI architecture".'
argument-hint: "[use-case] [engines] [data-classification]"
allowed-tools: Read, Glob, Grep, WebFetch, Write, Edit
version: 1.6.0
author: Jeremy Longshore <jeremy@intentsolutions.io>
license: MIT
tags: [ saas, serpapi, architecture, governance, reliability ]
model: inherit
effort: high
compatibility: Designed for Claude Code; architecture output is a review artifact and does not authorize infrastructure, account, or production changes
title: serpapi-reference-architecture
canonical_url: https://skilld.dev/gh/jeremylongshore/tons-of-skills-marketplace/serpapi-reference-architecture
last_updated: 2026-10-07T06:06:28.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> If the user asked to install this Skill, run `npx skilld install jeremylongshore/tons-of-skills-marketplace/serpapi-reference-architecture`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/serpapi-reference-architecture`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/jeremylongshore/tons-of-skills-marketplace/serpapi-reference-architecture) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/serpapi-reference-architecture`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/serpapi-reference-architecture --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/serpapi-reference-architecture --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# SerpAPI Governed Reference Architecture

## Overview

Place SerpAPI behind an application boundary that controls identity, parameters, data, allowance, and failure behavior for every engine.

## Prerequisites

- Business use cases, caller identities, engines, data classes, freshness and latency objectives
- Volume model, account contract, downstream systems, and regulatory/retention requirements
- Security, product, finance, reliability, and platform owners

## Tool Discipline

Use `Read`, `Glob`, and `Grep` to ground the design in repository and infrastructure topology, `WebFetch` to verify current vendor contracts, and `Write` or `Edit` for diagrams, decision records, interfaces, threat models, and rollout evidence.

## Current Contract

SerpAPI has engine-specific requests and variable response sections, private-key authentication, account-level search and throughput capacity, optional async/archive processing, one-hour exact-query server caching, and Enterprise ZeroTrace. Async depends on archive retrieval, while ZeroTrace intentionally prevents stored search records.

## Authentication

Keep `SERPAPI_KEY` in a server-side secret boundary. Authenticate application callers independently and enforce use-case authorization before the gateway maps input to allowlisted vendor parameters.

## Instructions

1. Map callers, trust zones, engines, queries, results, stores, consumers, data classes, and systems of record.
2. Define an authenticated gateway with use-case-specific input schemas, engine adapters, output projections, and policy enforcement.
3. Add an application cache with credential-free semantic keys, freshness TTLs, encryption and retention appropriate to the data class.
4. Coordinate admission, concurrency, pagination, retries, and background work against live Account API capacity.
5. Separate synchronous calls from async/archive jobs and prove that any ZeroTrace path does not rely on archive replay.
6. Emit safe metrics and search-ID correlation without query, result, key-bearing URL, or account leakage.
7. Design fixture-first tests, canary, reconciliation, degradation, support escalation, key rotation, disaster recovery, and rollback.
8. Record alternatives, constraints, approvals, unresolved risks, and a staged implementation plan.

## Approval Boundaries

Do not provision infrastructure, expose routes, create secrets, enable account features, or send production searches from an architecture exercise.

## Output

Return context and container diagrams, trust/data flows, gateway and adapter contracts, cache/capacity design, privacy decision, failure model, test/rollout plan, risks, and decision owners.

## Error Handling

| Condition | Response |
|---|---|
| Gateway is a generic parameter pass-through | Replace it with use-case schemas and allowlists. |
| Capacity is managed per instance only | Add shared admission control across credential-sharing workers. |
| ZeroTrace path requires replay | Redesign the diagnostic and recovery model. |
| Search results become a system of record | Define provenance, refresh, deletion, and reconciliation explicitly. |

## Example

```text
caller -> authenticated policy gateway -> engine adapter -> capacity limiter -> SerpAPI
                                      \-> semantic cache
search metadata -> redacted telemetry; normalized results -> governed consumer
```

## Resources

- [SerpAPI documentation](https://serpapi.com/)
- [Account API](https://serpapi.com/account-api)
- [ZeroTrace Mode](https://serpapi.com/zero-trace-mode)
- [Searches Archive API](https://serpapi.com/searches-archive-api)

## Next Steps

Validate the design with security, product, finance, and reliability owners before creating an implementation tranche.
