serpapi-reference-architecture
Production architecture for SerpApi search services with caching, monitoring, and multi-engine support. Use when designing search features, building SERP tracking systems, or architecting search-powered applications. Trigger: "serpapi architecture", "serpapi project structure", "serpapi design".
- License 许可
- MIT
- 最近更新
- 2026-07-13
- Stars
- ★ 1
- Forks
- 0
01 前言 Front Matter
- name
- serpapi-reference-architecture
- tags
- [ "saas", "search", "seo", "serpapi" ]
- author
- Jeremy Longshore <jeremy@intentsolutions.io>
- license
- MIT
- version
- 1.0.0
- description
- Production architecture for SerpApi search services with caching, monitoring, and multi-engine support. Use when designing search features, building SERP tracking systems, or architecting search-powered applications. Trigger: "serpapi architecture", "serpapi project structure", "serpapi design".
- allowed-tools
- Read, Grep
- compatible-with
- claude-code
03 SKILL.md 正文
SerpApi Reference Architecture
Overview
Production architecture for search-powered applications using SerpApi. Core components: cached search service, multi-engine abstraction, SERP monitoring pipeline, and credit budget management.
Architecture Diagram
┌──────────────────────────────────┐
│ API Layer │
│ /search /track /health │
├──────────────────────────────────┤
│ Search Service │
│ Multi-engine Caching Parsing │
├──────────────────────────────────┤
│ SerpApi Client │
│ Rate Limiting Retry Archive │
├──────────────────────────────────┤
│ Infrastructure │
│ Redis Cache PostgreSQL Cron │
└──────────────────────────────────┘
│
▼
┌──────────────────────────────────┐
│ SerpApi REST API │
│ google youtube bing news │
│ 1 credit/search, 100-50K/mo │
└──────────────────────────────────┘
Project Structure
search-service/
├── src/
│ ├── serpapi/
│ │ ├── client.ts # Cached search with rate limiting
│ │ ├── engines.ts # Engine-specific param mapping
│ │ └── types.ts # Typed result interfaces
│ ├── services/
│ │ ├── search.ts # Multi-engine search facade
│ │ ├── tracking.ts # Keyword rank tracking
│ │ └── credits.ts # Usage monitoring
│ ├── api/
│ │ ├── search.ts # /search proxy endpoint
│ │ └── health.ts # /health with credit check
│ └── jobs/
│ └── rank-tracker.ts # Daily keyword monitoring
├── tests/
│ ├── fixtures/ # Recorded SerpApi responses
│ └── search.test.ts # Fixture-based tests
└── config/
Key Components
Search Service Facade
class SearchService {
constructor(private client: CachedSerpApiClient, private db: Database) {}
async search(query: string, options?: { engine?: string; num?: number }) {
const engine = options?.engine || 'google';
const result = await this.client.cachedSearch({
engine, q: query, num: options?.num || 5,
});
// Normalize across engines
return {
results: result.organic_results || result.video_results || [],
answer_box: result.answer_box || null,
knowledge_graph: result.knowledge_graph || null,
search_id: result.search_metadata.id,
cached: result._cached || false,
};
}
async trackKeyword(keyword: string, domain: string) {
const result = await this.client.cachedSearch({
engine: 'google', q: keyword, num: 100,
});
const position = result.organic_results?.findIndex(
(r: any) => r.link?.includes(domain)
);
await this.db.saveRanking(keyword, domain, position >= 0 ? position + 1 : null);
}
}
Credit Budget Manager
class CreditBudget {
async check(): Promise<{ ok: boolean; remaining: number }> {
const account = await fetch(
`https://serpapi.com/account.json?api_key=${process.env.SERPAPI_API_KEY}`
).then(r => r.json());
return {
ok: account.plan_searches_left > 100,
remaining: account.plan_searches_left,
};
}
}
Error Handling
| Component | Failure | Recovery |
|---|---|---|
| Search API | Credits exhausted | Return cached results, alert ops |
| Cache | Redis down | Fall through to API (graceful degradation) |
| Rank tracker | Query fails | Skip and retry next cycle |
| Health check | API unreachable | Report degraded status |
Resources
Next Steps
See individual skill docs for deep-dives on each component.
04 同仓库更多 Skills
zustand-store-creator
Create zustand store creator operations. Auto-activating skill for Frontend Development. Triggers on: zustand store creator, zustand store creator Part of the Frontend Development skill category. Use when working with zustand store creator functionality. Trigger with phrases like "zustand store creator", "zustand creator", "zustand".
zero-trust-config-helper
Configure with zero trust config helper operations. Auto-activating skill for Security Advanced. Triggers on: zero trust config helper, zero trust config helper Part of the Security Advanced skill category. Use when configuring systems or services. Trigger with phrases like "zero trust config helper", "zero helper", "zero".
zapier-integration-helper
Assist with zapier integration helper operations. Auto-activating skill for Business Automation. Triggers on: zapier integration helper, zapier integration helper Part of the Business Automation skill category. Use when working with APIs or building integrations. Trigger with phrases like "zapier integration helper", "zapier helper", "zapier".
yaml-config-validator
Validate yaml config validator operations. Auto-activating skill for DevOps Basics. Triggers on: yaml config validator, yaml config validator Part of the DevOps Basics skill category. Use when configuring systems or services. Trigger with phrases like "yaml config validator", "yaml validator", "yaml".
xvary-stock-research
Thesis-driven equity analysis from public SEC EDGAR and market data; /analyze, /score, /compare workflows with bundled Python tools (Claude Code, Cursor, Codex).
xss-vulnerability-scanner
Scan xss vulnerability scanner operations. Auto-activating skill for Security Fundamentals. Triggers on: xss vulnerability scanner, xss vulnerability scanner Part of the Security Fundamentals skill category. Use when working with xss vulnerability scanner functionality. Trigger with phrases like "xss vulnerability scanner", "xss scanner", "xss".