A complete interactive scheduling and booking system built with Next.js 16, TypeScript, Supabase, Stripe payment integration, and AI-powered chat support.
- π Interactive Calendar - Dynamic date and time slot selection with real-time availability
- π³ Stripe Payment Processing - Real payment integration with Stripe Elements
- π€ AI Chat Widget - Floating chat assistant powered by OpenAI GPT-4o-mini with conversation history and semantic memory
- π Trilingual Support - Full i18n support (English, Portuguese, Spanish)
- π§ Contextual Memory - Embedding-based recall of previous conversations stored in Supabase pgvector
- π Booking Management - Create, view, and cancel appointments with persistent storage
- π¨ Modern UI/UX - Beautiful, responsive design with Tailwind CSS
- π Database Persistence - PostgreSQL database via Supabase with Row Level Security
- π§ Payment Webhooks - Automatic payment confirmation via Stripe webhooks
- π¬ Conversation History - Chat messages stored in Supabase for context-aware responses
- π Web Scraping Toolkit - Built-in utilities for collecting and analysing external website data
- β‘ Edge Functions Ready - Supabase Edge Functions prepared for serverless chat processing
- π Semantic Search - Real-time embeddings and pgvector similarity search powering the chat agent
- Next.js 16.0.1 - React framework with App Router
- React 19.2.0 - Latest React version
- TypeScript - Static type checking
- Tailwind CSS - Utility-first CSS framework
- Zustand - Lightweight state management
- Lucide React - Icon library
- Supabase - Backend as a Service (PostgreSQL database)
- Edge Functions - Serverless functions (Deno runtime) for chat processing
- pgvector - Vector similarity search powering semantic memory
- Stripe - Payment processing and webhooks
- OpenAI API - GPT-4o-mini for AI chat responses
- pgvector - Embedding storage for semantic recall
- Cheerio - HTML parsing for web scraping and data extraction
- Custom Web Scraper - Helper utilities for keyword extraction, metadata parsing, and reading-time analysis
- date-fns - Date manipulation library
- clsx - Conditional className utility
npm installCreate .env.local file in the root:
# Supabase
NEXT_PUBLIC_SUPABASE_URL=your_project_url
NEXT_PUBLIC_SUPABASE_ANON_KEY=your_anon_key
# Stripe
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_test_...
STRIPE_SECRET_KEY=sk_test_...
STRIPE_WEBHOOK_SECRET=whsec_...
# OpenAI (for chat widget)
OPENAI_API_KEY=sk-...- Create a Supabase project at supabase.com
- Run migrations in SQL Editor:
- Execute
supabase/schema.sqlto create booking tables - Execute
supabase/rls.sqlto set up security policies - Execute
supabase/chat_schema.sqlto create chat tables - Execute each file in
supabase/migrations(or runsupabase db push) to apply incremental schema updates, including semantic memory support (chat_memories)
- Execute
- Get your OpenAI API key from platform.openai.com
- Add
OPENAI_API_KEYto your.env.localfile - The chat widget will automatically appear on the landing page
For detailed setup: See SUPABASE_SETUP.md and STRIPE_SETUP.md
npm run devOpen http://localhost:3000 in your browser.
src/
βββ app/ # Next.js App Router (Routes & Pages)
β βββ api/ # API Routes (Backend)
β β βββ slots/ # GET: Available time slots
β β βββ appointments/ # CRUD: Booking operations
β β βββ payment-intent/ # POST: Create Stripe Payment Intent
β β βββ chat/ # POST: Chat API proxy
β β βββ webhooks/stripe/# POST: Stripe webhook handler
β βββ schedule/[serviceId]/ # Scheduling page
β βββ appointments/ # Booking list page
β βββ confirmation/[id]/ # Confirmation page
β βββ page.tsx # Landing page (with chat widget)
βββ components/ # Reusable UI Components
β βββ Calendar/ # Calendar components
β βββ Form/ # Booking & Payment forms
β βββ ChatWidget.tsx # AI chat widget component
β βββ LanguageSelector.tsx
βββ lib/ # Core Logic & Services
β βββ supabase/ # Supabase integration
β β βββ client.ts # Browser client
β β βββ server.ts # Server client
β β βββ database.ts # Database operations
β βββ stripe/ # Stripe integration
β β βββ client.ts # Frontend Stripe.js
β β βββ server.ts # Backend Stripe SDK
β βββ api-service.ts # HTTP client
β βββ services.ts # Service definitions
β βββ time-utils.ts # Time slot utilities
βββ context/ # React Context Providers
β βββ AppointmentContext.tsx
β βββ LanguageContext.tsx # i18n provider
βββ locales/ # Translation Files (en/pt/es)
βββ types/ # TypeScript definitions
supabase/
βββ functions/ # Supabase Edge Functions (Deno)
β βββ chat/ # Chat Edge Function (alternative to API route)
β βββ index.ts # Edge Function handler
β βββ deno.json # Deno configuration
βββ schema.sql # Main database schema
βββ rls.sql # Row Level Security policies
βββ chat_schema.sql # Chat tables schema
- Landing Page β View services, select service, or chat with AI assistant
- Schedule Page β Select date and time slot (dynamic availability)
- Booking Form β Enter customer details β Stripe payment
- Payment Processing β Stripe processes β Webhook confirms payment
- Confirmation Page β Success with booking ID and details
- Appointments Page β View and manage bookings
- User clicks chat widget icon (bottom-right corner)
- Selects a quick question or types custom message
- Message sent to OpenAI via Next.js API route
- Response saved to Supabase for conversation history
- Context-aware responses using short-term history plus pgvector-backed semantic memories
- Embeddings stored in
chat_memoriesfor future recall
- Available hours: 9h-11h (morning) and 14h-16h (afternoon)
- No appointments after 5 PM
- Maximum 3 consultations per day
- Real-time availability checking from Supabase
- Past bookings cannot be cancelled
- Success:
4242 4242 4242 4242 - Declined:
4000 0000 0000 9995 - 3D Secure:
4000 0025 0000 3155
Use any future expiry date and any 3-digit CVC.
- SUPABASE_SETUP.md - Supabase configuration
- STRIPE_SETUP.md - Stripe configuration
- CHAT_SETUP.md - Chat widget setup guide
- Switch Stripe keys from
testtolive - Configure production webhook in Stripe Dashboard
- Verify Supabase RLS policies
- Test payment flow end-to-end
- Configure environment variables in hosting platform
- Set up OpenAI API key with usage limits
- Test chat widget functionality
- Verify chat tables exist in Supabase
- Apply latest migrations (
supabase/migrations) to provisionchat_memories(semantic memory)
- Chat widget works in offline mode if Supabase tables are not configured
- Semantic recall gracefully falls back to conversation history if embeddings or vector table are unavailable
- Dynamic time slots support 30/60/90 minute durations
- Calendar is fully responsive with horizontal scroll on tablets
- All UI components support trilingual display
- Edge Functions: Supabase Edge Functions are prepared but currently using Next.js API routes for easier deployment
- Web Scraping Utilities:
src/lib/web-scraper.tsprovides helpers for collecting and analysing external content - Semantic Memory:
src/lib/ai/memory.tsmanages embeddings, semantic search, and Supabase persistence
Built with Next.js 16, TypeScript, Supabase, Stripe, and OpenAI