Skip to main content 首页 创作者 jeremylongshore tons-of-skills-marketplace algolia-reference-architecture
algolia-reference-architecture Implement Algolia reference architecture: index design, multi-index strategy,
data pipeline, search service layer, and frontend/backend separation.
Trigger: "algolia architecture", "algolia best practices", "algolia project structure",
"how to organize algolia", "algolia index design".
跳到安装 Skills Marketplace 发现并探索由社区构建的 Agent Skills
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/jeremylongshore/tons-of-skills-marketplace --skill algolia-reference-architecture命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
下载 Zip 下载中... 同仓库更多 Skills langchain-deploy-integration Deploy a LangChain 1.0 / LangGraph 1.0 app to Cloud Run, Vercel, or LangServe correctly — with timeouts sized for chain length, cold-start mitigation, SSE anti-buffering headers, and Secret Manager over .env. Use when prepping a first production deploy, debugging a stream that hangs behind a proxy, or diagnosing p99 latency spikes. Trigger with "langchain deploy", "langchain cloud run", "langchain vercel python", "langchain langserve", or "langchain docker".
langchain-langgraph-agents Build a correct LangGraph 1.0 ReAct agent with create_react_agent — typed tools, error propagation, recursion caps, and stop conditions that actually stop. Use when writing a first tool-calling agent, migrating from AgentExecutor or initialize_agent, or diagnosing an agent that loops on vague prompts. Trigger with "langgraph agent", "create_react_agent", "langgraph tool calling", "AgentExecutor migration", or "agent loop cost".
langchain-langgraph-human-in-loop Build LangGraph 1.0 human-in-the-loop approval flows with interrupt_before /
interrupt_after and Command(resume=...) — JSON-serializable state, clean
resume semantics, and UI wiring for approval decisions. Use when adding an
approval gate before an expensive tool call, wiring a Slack/web UI for agent
approvals, or debugging a graph that crashes on interrupt.
Trigger with "langgraph human in loop", "langgraph interrupt_before",
"langgraph approval flow", "Command resume", "langgraph HITL".
name algolia-reference-architecture description Implement Algolia reference architecture: index design, multi-index strategy,
data pipeline, search service layer, and frontend/backend separation.
Trigger: "algolia architecture", "algolia best practices", "algolia project structure",
"how to organize algolia", "algolia index design".
allowed-tools Read, Grep version 1.7.0 license MIT author Jeremy Longshore <jeremy@intentsolutions.io> tags ["saas","search","algolia"] compatibility Designed for Claude Code
Algolia Reference Architecture
Overview
Production-ready architecture for Algolia-powered search. Covers index design, data pipeline from source to Algolia, service layer patterns, and frontend integration.
Prerequisites
A source-of-truth datastore, an approved transformation boundary, and explicit ownership for indexing and search-serving services.
Separate Admin and search-only credentials, kept on the backend and frontend respectively.
An environment and index naming convention that permits safe rehearsal and rollback.
Instructions
Use the architecture, project layout, and design patterns as a composable reference. Keep indexing, settings management, and search serving as separately testable boundaries rather than coupling them to a frontend component.
Examples
The diagrams and TypeScript patterns below demonstrate the reference topology, record transformation, settings-as-code, and service-layer contracts. Adapt the interfaces to your source schema while preserving the key boundary between write and search credentials.
Architecture Overview
┌──────────────────────────────────────────────────────────────┐
│ Frontend │
│ InstantSearch.js / React InstantSearch │
│ Uses: liteClient (search-only key) │
│ Sends: search-insights events (clicks, conversions) │
└───────────────────────┬──────────────────────────────────────┘
│ Search + Events
▼
┌──────────────────────────────────────────────────────────────┐
│ Algolia Cloud │
│ ┌─────────┐ ┌──────────────┐ ┌─────────────┐ │
│ │ Search │ │ Analytics │ │ Recommend │ │
│ │ Engine │ │ + Insights │ │ (ML-based) │ │
│ └─────────┘ └──────────────┘ └─────────────┘ │
└───────────────────────▲──────────────────────────────────────┘
│ Indexing (admin key)
│
┌──────────────────────────────────────────────────────────────┐
│ Backend Service │
│ ┌────────────┐ ┌──────────────┐ ┌─────────────────┐ │
│ │ Search │ │ Indexing │ │ Settings │ │
│ │ Service │ │ Pipeline │ │ Manager │ │
│ └────────────┘ └──────┬───────┘ └─────────────────┘ │
│ │ │
│ ┌──────────────────────▼────────────────────────────┐ │
│ │ Source Database │ │
│ │ PostgreSQL / MongoDB / CMS / External API │ │
│ └────────────────────────────────────────────────────┘ │
└──────────────────────────────────────────────────────────────┘
Project Structure
src/
├── algolia/
│ ├── client.ts # Singleton client (see algolia-sdk-patterns)
│ ├── indices.ts # Index name constants + environment prefixing
│ ├── settings/
│ │ ├── products.ts # Products index settings
│ │ ├── articles.ts # Articles index settings
│ │ └── apply.ts # Script to apply all settings
│ └── transforms/
│ ├── product.ts # DB record → Algolia record transformer
│ └── article.ts # DB record → Algolia record transformer
├── services/
│ ├── search.ts # Search service (wraps Algolia client)
│ └── indexing.ts # Indexing pipeline (DB → transform → Algolia)
├── api/
│ ├── search.ts # Search endpoint (returns Algolia results)
│ └── reindex.ts # Admin endpoint to trigger reindex
└── jobs/
└── sync-algolia.ts # Cron job for periodic full sync
Index Design Patterns
Pattern 1: One Index Per Entity Type
const ENV = process.env .NODE_ENV === 'production' ? '' : `${process.env.NODE_ENV} _` ;
export const INDICES = {
products : `${ENV} products` ,
articles : `${ENV} articles` ,
faq : `${ENV} faq` ,
users : `${ENV} users` ,
} as const ;
export type IndexName = typeof INDICES [keyof typeof INDICES ];
Pattern 2: Record Transformer (Source → Algolia)
import type { Product } from '../db/types' ;
interface AlgoliaProduct {
objectID : string ;
name : string ;
description : string ;
category : string ;
brand : string ;
price : number ;
rating : number ;
review_count : number ;
in_stock : boolean ;
image_url : string ;
_tags : string [];
}
export function transformProduct (product : Product ): AlgoliaProduct {
return {
objectID : product.id ,
name : product.name ,
description : product.description ?.substring (0 , 5000 ) || '' ,
category : product.category .name ,
brand : product.brand .name ,
price : product.price / 100 ,
rating : product.avgRating ,
review_count : product.reviewCount ,
in_stock : product.inventory > 0 ,
image_url : product.images [0 ]?.url || '' ,
_tags : [
product.category .slug ,
...(product.isFeatured ? ['featured' ] : []),
...(product.isNew ? ['new-arrival' ] : []),
],
};
}
Pattern 3: Settings as Code
import type { IndexSettings } from 'algoliasearch' ;
export const productSettings : IndexSettings = {
searchableAttributes : [
'name' ,
'brand' ,
'category' ,
'unordered(description)' ,
],
attributesForFaceting : [
'searchable(brand)' ,
'category' ,
'filterOnly(price)' ,
'filterOnly(in_stock)' ,
'_tags' ,
],
customRanking : ['desc(review_count)' , 'desc(rating)' ],
attributesToRetrieve : ['name' , 'brand' , 'price' , 'image_url' , 'category' , 'rating' ],
attributesToHighlight : ['name' , 'description' ],
attributesToSnippet : ['description:30' ],
unretrievableAttributes : ['_tags' ],
distinct : 1 ,
attributeForDistinct : 'product_group_id' ,
replicas : [
'virtual(products_price_asc)' ,
'virtual(products_price_desc)' ,
'virtual(products_newest)' ,
],
};
import { getClient } from '../client' ;
import { INDICES } from '../indices' ;
import { productSettings } from './products' ;
async function applyAllSettings ( ) {
const client = getClient ();
await client.setSettings ({ indexName : INDICES .products , indexSettings : productSettings });
console .log ('All Algolia settings applied' );
}
Pattern 4: Search Service Layer
import { getClient } from '../algolia/client' ;
import { INDICES } from '../algolia/indices' ;
import { ApiError } from 'algoliasearch' ;
export class SearchService {
private client = getClient ();
async searchProducts (params : {
query: string ;
filters?: string ;
facetFilters?: string [][];
page?: number ;
hitsPerPage?: number ;
} ) {
try {
return await this .client .searchSingleIndex ({
indexName : INDICES .products ,
searchParams : {
query : params.query ,
filters : params.filters ,
facetFilters : params.facetFilters ,
page : params.page ?? 0 ,
hitsPerPage : params.hitsPerPage ?? 20 ,
facets : ['category' , 'brand' ],
clickAnalytics : true ,
},
});
} catch (error) {
if (error instanceof ApiError && error.status === 404 ) {
return { hits : [], nbHits : 0 , nbPages : 0 , page : 0 };
}
throw error;
}
}
async federatedSearch (query : string ) {
const { results } = await this .client .search ({
requests : [
{ indexName : INDICES .products , query, hitsPerPage : 5 },
{ indexName : INDICES .articles , query, hitsPerPage : 3 },
{ indexName : INDICES .faq , query, hitsPerPage : 3 },
],
});
return results;
}
}
Output The resulting system has explicit data flow, index ownership, settings deployment, and search-service contracts. It supports independent observability and rollback of indexing without exposing write credentials to end users.
Error Handling Issue Cause Solution Circular dependency Service imports client imports service Use lazy initialization Config drift Dashboard edits not in code Apply settings from code in CI Transform errors DB schema change Add validation in transformer Index name typo Hardcoded strings Use INDICES constants
Resources
Next Steps For multi-environment setup, see algolia-multi-env-setup.