Architect
Demo Site: Component Architecture
This guide documents the component architecture of the Demo Site, including all 20 components and their design patterns.
Component Overview
The Demo Site includes 20 registered components organized by category:
Content Display (4)
- PostListing, PostDetails, Testimonials, TeamListing
Hero Components (4)
- Hero, BackgroundHero, ABTestHero, PersonalizedBackgroundHero
Interactive (3)
- Carousel, ContactUs, FrequentlyAskedQuestions
Layout (3)
- BentoSection, LogoStrip, PersonalizedLogoStrip
Data Display (3)
- CompanyStats, PricingCards, PricingTable
Navigation (1)
- Header
Utility (2)
- RichTextArea, Testimonial (single)
Component Design Patterns
Pattern 1: Simple Component
Example: Hero
- Direct field mapping
- Minimal data fetching
- Fast rendering
Pattern 2: Content List Component
Example: PostListing
- Links to content list
- Supports filtering/sorting
- Pagination support
Pattern 3: Nested Component
Example: BentoSection
- Parent component with nested content
- Fetches nested content separately
- Complex nested structure
Pattern 4: Personalized Component
Example: PersonalizedBackgroundHero
- Audience/region filtering
- Query parameter handling
- Fallback content
Pattern 5: A/B Test Component
Example: ABTestHero
- PostHog feature flag integration
- Server-side variant selection
- Analytics tracking
Component Architecture Decisions
Server vs Client Components
Server Components:
- Data fetching
- Content rendering
- SEO optimization
Client Components:
- Interactive features
- Form handling
- Animations
Pattern:
- Server component fetches data
- Passes data to client component
- Client component handles interactivity
Component Registration
All components registered in src/components/agility-components/index.ts:
const allModules = [ { name: "ComponentName", module: ComponentName }, // ... 19 more components ]
Note: The variable name
allModulesand propertymoduleare from the Next.js SDK's legacy terminology. In Agility CMS, these are now called "components" and "component models."
Key Architectural Patterns
Nested Content Pattern
BentoSection Example:
- Fetch parent component content
- Extract nested reference name
- Fetch nested content list separately
- Render nested content
Personalization Pattern
PersonalizedBackgroundHero Example:
- Detect audience/region from URL params
- Fetch component content
- Filter personalized items by audience/region
- Fallback to default content
A/B Testing Pattern
ABTestHero Example:
- Fetch component content with variants
- Evaluate PostHog feature flag server-side
- Select variant based on flag
- Render selected variant
- Track analytics
Component Reusability
Reusable Components
Components designed for reuse:
- Hero variants: Used across multiple pages
- Content display: PostListing, Testimonials used in multiple contexts
- Layout components: BentoSection, LogoStrip reusable
Component Composition
Pages built by composing components:
- Home Page: PersonalizedBackgroundHero + BentoSection + Testimonials
- Blog Page: PostListing component
- Pricing Page: Hero + PricingCards + FAQ
Best Practices Applied
- Focused Components: Each component has single purpose
- Reusability: Components designed for reuse
- Type Safety: Full TypeScript support
- Performance: Optimized for performance
- Accessibility: Semantic HTML and ARIA labels
Next: Integrations - Implemented integrations