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".
Best use case
algolia-reference-architecture is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
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".
Teams using algolia-reference-architecture should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/algolia-reference-architecture/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How algolia-reference-architecture Compares
| Feature / Agent | algolia-reference-architecture | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
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".
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
Related Guides
Best AI Skills for Claude
Explore the best AI skills for Claude and Claude Code across coding, research, workflow automation, documentation, and agent operations.
ChatGPT vs Claude for Agent Skills
Compare ChatGPT and Claude for AI agent skills across coding, writing, research, and reusable workflow execution.
SKILL.md Source
# 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.
## 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
```typescript
// src/algolia/indices.ts
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`, // Internal search only (never expose to frontend)
} as const;
export type IndexName = typeof INDICES[keyof typeof INDICES];
```
### Pattern 2: Record Transformer (Source → Algolia)
```typescript
// src/algolia/transforms/product.ts
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[]; // Algolia convention: filterable tags
}
export function transformProduct(product: Product): AlgoliaProduct {
return {
objectID: product.id,
name: product.name,
description: product.description?.substring(0, 5000) || '', // Truncate
category: product.category.name,
brand: product.brand.name,
price: product.price / 100, // Cents → dollars
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
```typescript
// src/algolia/settings/products.ts
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)',
],
};
// src/algolia/settings/apply.ts
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
```typescript
// src/services/search.ts
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;
}
}
```
## 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
- [Algolia Architecture Guide](https://www.algolia.com/doc/guides/getting-started/how-algolia-works/)
- [Index Design Best Practices](https://www.algolia.com/doc/guides/sending-and-managing-data/prepare-your-data/)
- [Multi-Index Search](https://www.algolia.com/doc/guides/building-search-ui/ui-and-ux-patterns/multi-index-search/js/)
## Next Steps
For multi-environment setup, see `algolia-multi-env-setup`.Related Skills
workhuman-reference-architecture
Workhuman reference architecture for employee recognition and rewards API. Use when integrating Workhuman Social Recognition, or building recognition workflows with HRIS systems. Trigger: "workhuman reference architecture".
wispr-reference-architecture
Wispr Flow reference architecture for voice-to-text API integration. Use when integrating Wispr Flow dictation, WebSocket streaming, or building voice-powered applications. Trigger: "wispr reference architecture".
windsurf-reference-architecture
Implement Windsurf reference architecture with optimal project structure and AI configuration. Use when designing workspace configuration for Windsurf, setting up team standards, or establishing architecture patterns that maximize Cascade effectiveness. Trigger with phrases like "windsurf architecture", "windsurf project structure", "windsurf best practices", "windsurf team setup", "optimize for cascade".
windsurf-architecture-variants
Choose workspace architectures for different project scales in Windsurf. Use when deciding how to structure Windsurf workspaces for monorepos, multi-service setups, or polyglot codebases. Trigger with phrases like "windsurf workspace strategy", "windsurf monorepo", "windsurf project layout", "windsurf multi-service", "windsurf workspace size".
webflow-reference-architecture
Implement Webflow reference architecture — layered project structure, client wrapper, CMS sync service, webhook handlers, and caching layer for production integrations. Trigger with phrases like "webflow architecture", "webflow project structure", "how to organize webflow", "webflow integration design", "webflow best practices".
vercel-reference-architecture
Implement a Vercel reference architecture with layered project structure and best practices. Use when designing new Vercel projects, reviewing project structure, or establishing architecture standards for Vercel applications. Trigger with phrases like "vercel architecture", "vercel project structure", "vercel best practices layout", "how to organize vercel project".
vercel-architecture-variants
Choose and implement Vercel architecture blueprints for different scales and use cases. Use when designing new Vercel projects, choosing between static, serverless, and edge architectures, or planning how to structure a multi-project Vercel deployment. Trigger with phrases like "vercel architecture", "vercel blueprint", "how to structure vercel", "vercel monorepo", "vercel multi-project".
veeva-reference-architecture
Veeva Vault reference architecture for REST API and clinical operations. Use when working with Veeva Vault document management and CRM. Trigger: "veeva reference architecture".
vastai-reference-architecture
Implement Vast.ai reference architecture for GPU compute workflows. Use when designing ML training pipelines, structuring GPU orchestration, or establishing architecture patterns for Vast.ai applications. Trigger with phrases like "vastai architecture", "vastai design pattern", "vastai project structure", "vastai ml pipeline".
twinmind-reference-architecture
Production architecture for meeting AI systems using TwinMind: transcription pipeline, memory vault, action item workflow, and calendar integration. Use when implementing reference architecture, or managing TwinMind meeting AI operations. Trigger with phrases like "twinmind reference architecture", "twinmind reference architecture".
together-reference-architecture
Together AI reference architecture for inference, fine-tuning, and model deployment. Use when working with Together AI's OpenAI-compatible API. Trigger: "together reference architecture".
techsmith-reference-architecture
TechSmith reference architecture for Snagit COM API and Camtasia automation. Use when working with TechSmith screen capture and video editing automation. Trigger: "techsmith reference architecture".