How mesieou/simple_booking works
Project type and purpose
• This is a full-stack, server-rendered web application built with Next.js (app directory) that doubles as an AI-powered WhatsApp agent (“Skedy”).
• Core use cases:
• Customers interact via WhatsApp (Twilio webhook) or website UI for quoting, booking, calendar management.
• Backend uses Supabase (Postgres) for data, OpenAI GPT for chat and content analysis, Google Maps APIs for distance/geo, custom web/PDF content crawler for training data.
File structure
• Frontend (user-facing UI):
• app/(auth-pages), app/[providerId]/… and app/page.tsx (Next.js Server/Client components)
• components/, components/ui/** (reusable UI primitives)
• Backend API (Next.js Route Handlers):
• app/api/* folders (chat, content-crawler, maps, provider, seed, webhook, etc.)
• middleware.ts for auth/SSR
• Business logic and services (lib/):
• lib/chatbot-handlers (chat orchestration, task processors)
• lib/llm-actions (OpenAI config & function calls)
• lib/backend-actions/content-crawler (URL/PDF crawler + embedding pipeline)
• lib/database (Supabase client, migrations, models, seed scripts)
• lib/general-helpers (distance, cost calculators)
• Scripts:
• scripts/* for seeding, testing, uploading PDFs
• Config files:
• next.config.ts, tailwind.config.ts, jest.config.js, tsconfig.json
README for additional insights
• Emphasizes real-time quoting, booking, calendar management via AI/WhatsApp
• Mentions customizable, scalable deployment (likely Vercel + Supabase + OpenAI)
a. Main components
1. Client layer
• Web Browser (Next.js Frontend pages & components)
• WhatsApp Client (via Twilio)
2. API Layer (Next.js Route Handlers)
• /api/chat → Chat orchestration
• /api/webhook → WhatsApp webhook entry
• /api/maps → Google Maps wrapper
• /api/content-crawler → Trigger crawler jobs
3. Business Logic
• Chatbot Processor (lib/chatbot-handlers)
• LLM Functions (lib/llm-actions)
• Booking & Availability Services (lib/general-helpers + DB models)
• Content Crawler & Embedding Pipeline (lib/backend-actions)
4. Data Layer
• Supabase PostgreSQL (tables: users, providers, availability_slots, bookings, quotes, embeddings, crawl_sessions)
• Object Storage (PDFs, crawler artifacts)
5. External Services
• OpenAI API (Chat, Embeddings)
• Google Maps API (Geocode, Distance Matrix, Autocomplete)
• Twilio WhatsApp API
6. Background / CI-CD
• Vercel Serverless Functions (hosting API + frontend)
• Scheduler / Cron (to run content-crawler jobs)
b. Relationships & interactions
• User → (WhatsApp) Twilio → Next.js /api/webhook → Chatbot Processor → OpenAI → Response back via Twilio
• User → (Browser) Next.js Frontend → Next.js API (maps, provider info, booking) → Supabase
• Chatbot Processor or Web UI triggers Database reads/writes (bookings, availability, quotes)
• Admin or Seeder Scripts → run /api/seed or scripts/seed.ts → populate Supabase
• Crawler jobs fetch URLs/PDFs → process content → generate embeddings via OpenAI → store in Supabase
c. Architectural patterns & design principles
• Separation of concerns: UI / API / business logic / data layer in distinct folders
• Serverless microservices: Next.js route handlers act as independent functions
• Modular “lib/” code: reusable helpers, LLM wrappers, crawler modules
• Event-driven design: webhooks and background crawler pipelines
• Use of third-party PaaS: Supabase for data, Vercel for hosting
d. Technologies & frameworks
• Next.js (React, Server Components, API routes)
• TypeScript
• Supabase (Postgres, Auth, Storage)
• OpenAI API
• Google Maps REST APIs
• Twilio WhatsApp
• Tailwind CSS