A modern, full-featured e-commerce demo site built with Next.js 15, Agility CMS, and Stripe. This project demonstrates best practices for headless CMS architecture, e-commerce functionality, AI-powered search, and internationalization.
- β Product Catalog - Full product management with variants (color, size)
- β Shopping Cart - Persistent cart with localStorage
- β Stripe Checkout - Secure payment processing
- β Customer Accounts - Magic link authentication
- β Order Management - Order history and customer portal
- β Agility CMS Integration - Headless CMS with inline editing
- β Dynamic Routing - CMS-driven page routing
- β Content Zones - Flexible page layouts
- β Preview Mode - Real-time content preview
- β AI-Powered Search - Streaming AI search with tool calling
- β Algolia Integration - Fast, relevant search results
- β AI Agent - Conversational interface with contact capture
- β Audience Targeting - Content personalization by audience
- β Regional Content - Location-based content variations
- β A/B Testing - Hero component with variant testing
- β Multi-Locale Support - Configurable locales
- β Locale Routing - Clean URL structure with locale prefixes
- β Language Switching - Seamless language transitions
- β PostHog Integration - Product analytics and feature flags
- β Google Analytics - Traditional analytics tracking
- β View Transitions - Smooth page transitions
- Framework: Next.js 15.5.3 (App Router)
- React: 19.1.1
- TypeScript: Full type safety
- CMS: Agility CMS (@agility/nextjs 15.0.7)
- Styling: Tailwind CSS v4
- Payments: Stripe (stripe 19.1.0)
- AI: Azure OpenAI / OpenAI with Algolia
- Analytics: PostHog, Google Analytics
- Animations: Motion (Framer Motion alternative)
- UI Components: Radix UI, Headless UI, shadcn/ui
- Icons: Heroicons, Lucide React, Tabler Icons
- Node.js 20+
- npm or yarn
- Agility CMS account
- Stripe account (for e-commerce features)
- (Optional) Azure OpenAI or OpenAI API key (for AI search)
- (Optional) Algolia account (for search)
- (Optional) PostHog account (for analytics)
git clone <repository-url>
cd democommerce2025
npm installCopy .env.example to .env.local and fill in your credentials:
# Agility CMS (Required)
AGILITY_GUID=your-guid-here
AGILITY_API_FETCH_KEY=your-fetch-key
AGILITY_API_PREVIEW_KEY=your-preview-key
AGILITY_SECURITY_KEY=your-security-key
AGILITY_LOCALES=en-us,fr-ca
AGILITY_SITEMAP=main-sitemap
AGILITY_FETCH_CACHE_DURATION=3600
AGILITY_PATH_REVALIDATE_DURATION=3600
# PostHog (Required)
NEXT_PUBLIC_POSTHOG_KEY=your-posthog-key
NEXT_PUBLIC_POSTHOG_HOST=https://app.posthog.com
# Stripe (Optional - for e-commerce)
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_test_...
STRIPE_SECRET_KEY=sk_test_...
STRIPE_WEBHOOK_SECRET=whsec_...
# AI Search (Optional)
AZURE_OPENAI_API_KEY=...
AZURE_OPENAI_ENDPOINT=...
# OR
OPENAI_API_KEY=...
# Algolia (Optional - for search)
NEXT_PUBLIC_ALGOLIA_APP_ID=...
NEXT_PUBLIC_ALGOLIA_SEARCH_KEY=...
ALGOLIA_ADMIN_KEY=...npm run devVisit http://localhost:3000
npm run prebuild # Rebuild redirect cache (IMPORTANT!)
npm run build
npm run startnpm run prebuild before building. This rebuilds the redirect cache from bloom filters.
src/
βββ app/ # Next.js App Router
β βββ [locale]/ # Internationalized routes
β β βββ [...slug]/ # Dynamic Agility CMS pages
β β βββ layout.tsx # Locale-specific layout
β βββ api/ # API routes
β βββ ai/ # AI search endpoints
β βββ checkout/ # Stripe checkout
β βββ products/ # Product API
β βββ webhooks/ # Stripe webhooks
βββ components/ # React components
β βββ agility-components/ # CMS-connected components
β βββ cart/ # Shopping cart
β βββ ai-search/ # AI search UI
β βββ ui/ # shadcn/ui components
βββ lib/ # Utilities and helpers
β βββ cms/ # Agility CMS functions
β βββ cart/ # Cart context
β βββ hooks/ # Custom React hooks
β βββ types/ # TypeScript definitions
β βββ utils/ # Utility functions
βββ middleware.ts # Next.js middleware
This project includes comprehensive documentation:
- QUICK_START.md - Get running in 15 minutes
- AGILITY_SETUP_GUIDE.md - Complete CMS setup guide
- ECOMMERCE_README.md - E-commerce implementation details
- CHECKOUT_FLOW.md - Checkout flow documentation
- CUSTOMER_SESSION_FLOW.md - Customer authentication flow
- IMPLEMENTATION_SUMMARY.md - Implementation overview
- ACCOUNT_SETUP.md - Account setup instructions
docs/AUDIENCE_REGION_SYSTEM.md- Personalization systemdocs/ENVIRONMENT_VARIABLES.md- Environment variable referencedocs/VIEW_TRANSITIONS.md- View transitions guide
- Products β Managed in Agility CMS with variants
- Cart β React Context with localStorage persistence
- Checkout β Stripe Checkout (hosted)
- Orders β Webhook processing and customer portal
See ECOMMERCE_README.md for details.
- Dynamic Pages: Routes generated from Agility sitemap
- Content Zones: Flexible page layouts
- Inline Editing: Edit content directly in the CMS
- Preview Mode: Real-time content preview
See AGILITY_SETUP_GUIDE.md for setup.
- Streaming Responses: Real-time AI search results
- Tool Calling: Integrates with Algolia for search
- Configurable: Settings managed in Agility CMS
- Floating UI: Accessible search interface
- Multi-Locale: Support for multiple languages
- Clean URLs: Locale prefixes in paths
- Query Params:
?lang=parameter support - Middleware: Automatic locale routing
npm run dev # Start dev server (Turbopack)
npm run prebuild # Rebuild redirect cache
npm run build # Production build
npm run start # Start production server
npm run lint # Run ESLint- TypeScript: Full type safety
- Prettier: Code formatting
- ESLint: Code linting
- Tailwind CSS: Utility-first styling
- Server Components: Default for data fetching
- Client Components: Use
"use client"for interactivity - Agility Components: Register in
src/components/agility-components/index.ts
See .cursorrules for detailed development guidelines.
All environment variables are validated via src/lib/env.ts. Use env.get('VAR_NAME') instead of process.env for type safety.
Required Variables:
- Agility CMS credentials
- PostHog keys
- Node environment
Optional Variables:
- Stripe keys (for e-commerce)
- AI provider keys (for AI search)
- Algolia keys (for search)
The middleware (src/middleware.ts) handles:
- Preview mode entry/exit
- Dynamic redirects by ContentID
- Redirect cache lookups
- Locale routing
- Search param encoding
- β
Run
npm run prebuildto rebuild redirect cache - β Set all environment variables in your hosting platform
- β Configure Stripe webhooks (production endpoint)
- β Set up PostHog project (if using analytics)
- β Configure Agility CMS preview URLs
- Vercel - Optimized for Next.js
- Netlify - Great DX
- AWS - Enterprise scale
- Follow the code style guidelines in
.cursorrules - Use TypeScript for all new code
- Register new Agility components in
index.ts - Add tests for new features
- Update documentation as needed
MIT License - see LICENSE file for details.
- Agility CMS - Headless CMS
- Next.js - React framework
- Stripe - Payment processing
- Tailwind CSS - Utility-first CSS
Need Help? Check the documentation files listed above or open an issue.