Architect
Demo Site: Implemented Integrations
This guide documents the third-party integrations implemented in the Demo Site, including AI search, analytics, and other services.
AI Search Integration
Azure OpenAI + Algolia
Purpose: AI-powered search with context-aware responses
Implementation:
- Azure OpenAI for AI responses
- Algolia for content search
- Streaming responses
- CMS-configured prompts
Configuration:
- AI Search Configuration content model
- Configurable system prompts
- Search tool integration
Features:
- Natural language search
- Context-aware responses
- Streaming responses
- Search result integration
Analytics Integration
PostHog
Purpose: Analytics and A/B testing
Features:
- Feature flags for A/B testing
- Analytics tracking
- Server-side feature flag evaluation
- Client-side analytics
Implementation:
- PostHog Node.js client for server-side
- PostHog JS for client-side
- Feature flag evaluation in components
- Event tracking
A/B Testing Integration
PostHog Feature Flags
Purpose: A/B testing for components
Implementation:
- ABTestHero component
- Server-side feature flag evaluation
- Variant selection
- Analytics tracking
Pattern:
- Component fetches variants from CMS
- Evaluates PostHog feature flag server-side
- Selects variant based on flag
- Renders selected variant
- Tracks analytics
Internationalization
Multi-Locale Support
Locales:
- English (en-us) - Default
- French (fr) - Secondary
Implementation:
- Locale-based routing
- Locale-specific content
- Fallback to default locale
- URL pattern:
/fr/blogfor French
Performance Integrations
CDN Integration
Agility CDN:
- Asset delivery via CDN
- Automatic image optimization
- Global edge locations
Caching Integration
Next.js Caching:
- Cache tags for invalidation
- Time-based revalidation
- Webhook-triggered revalidation
Integration Patterns
API Route Pattern
Custom API routes for integrations:
/api/ai/search- AI search endpoint/api/ai/agent- AI agent endpoint/api/revalidate- Cache revalidation
Middleware Pattern
Middleware handles:
- Preview mode
- Redirects
- Locale routing
- Search params encoding
Best Practices
- Environment Variables: All keys in environment variables
- Type Safety: TypeScript for integration types
- Error Handling: Graceful error handling
- Monitoring: Monitor integration health
- Documentation: Document integration patterns
Back to: Architecture Overview