This project is currently a work in progress.
- π€ AI-powered assistant (Vercel AI SDK)
- π’ Advanced admin management via Sanity App SDK
- π Activities & Venues dynamic pages
- π Production deployment
- πΊοΈ Location-Based Search - Find classes within your preferred radius using advanced geographic filtering
- π Smart Filtering - Filter by category, venue, instructor, subscription tier, and more
- π Calendar View - Visualize your bookings in an interactive calendar
- π€ AI Assistant - Chat with an AI assistant to find classes and get recommendations
- π± Responsive Design - Works seamlessly on mobile, tablet, and desktop
- β‘ Real-Time Updates - See new classes and availability changes instantly
- π« Subscription Tiers - Basic, Performance, and Champion tiers with different booking limits
- β Attendance Tracking - Confirm attendance after classes
- πΊοΈ Interactive Maps - See venue locations on an interactive map
- π Content Management - Manage activities, sessions, and venues through Sanity Studio
- πΌοΈ Image Management - Upload and manage images with automatic optimization
- π Session Management - Create and schedule class sessions with capacity management
- π’ Venue Management - Add venues with addresses and amenities
- π Publish/Unpublish - Draft and publish workflow for content
- Next.js 16 - React framework with App Router and Server Components
- React 19 - UI library with React Compiler
- TypeScript - Type-safe development
- Tailwind CSS 4 - Utility-first styling
- Radix UI - Accessible component primitives
- Leaflet - Interactive maps
- Zustand - Lightweight state management
- Sanity CMS - Headless content management system
- GROQ - Query language for Sanity
- Sanity Live - Real-time content updates
- Next.js Server Actions - Server-side mutations
- Clerk - Authentication and user management
- Clerk Billing - Subscription tier management
- Vercel AI SDK 6 - AI agent framework
- OpenAI GPT-4o-mini - Language model
- Tool Calling - Database query tools for AI
- Biome - Fast linter and formatter
- TypeScript - Static type checking
- Sanity Typegen - Auto-generated types
Before you begin, ensure you have the following installed:
- Node.js 20.x or higher
- pnpm (recommended) or npm/yarn
- Git
-
Clone the repository
git clone https://github.com/yourusername/class-booking-app.git cd class-booking-app -
Install dependencies
pnpm install # or npm install -
Set up environment variables
Create a
.env.localfile in the root directory:# Sanity CMS NEXT_PUBLIC_SANITY_PROJECT_ID=your_project_id NEXT_PUBLIC_SANITY_DATASET=production NEXT_PUBLIC_SANITY_API_VERSION=2025-12-15 SANITY_API_READ_TOKEN=your_read_token SANITY_API_WRITE_TOKEN=your_write_token # Clerk Authentication NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=your_publishable_key CLERK_SECRET_KEY=your_secret_key # OpenAI (for AI chat) OPENAI_API_KEY=your_openai_api_key # Optional: Mapbox (for address search in admin) NEXT_PUBLIC_MAPBOX_ACCESS_TOKEN=your_mapbox_token
-
Generate TypeScript types
pnpm typegen
-
Run the development server
pnpm dev
-
Open your browser
Navigate to http://localhost:3000
# Development
pnpm dev # Start development server
# Production
pnpm build # Build for production
pnpm start # Start production server
# Code Quality
pnpm lint # Run linter
pnpm format # Format code
# Type Generation
pnpm typegen # Generate Sanity TypeScript typesclass-booking-app/
βββ app/ # Next.js App Router
β βββ (app)/ # User-facing routes
β β βββ classes/ # Browse and book classes
β β βββ bookings/ # Manage bookings
β β βββ profile/ # User profile & preferences
β β βββ onboarding/ # First-time setup
β β βββ upgrade/ # Subscription management
β βββ (admin)/ # Admin panel routes
β β βββ admin/ # Content management
β βββ api/ # API routes
β β βββ chat/ # AI chat endpoint
β βββ studio/ # Sanity Studio (CMS)
β
βββ components/ # React components
β βββ app/ # User-facing components
β βββ admin/ # Admin panel components
β βββ ui/ # Reusable UI primitives
β
βββ lib/ # Business logic
β βββ actions/ # Server actions
β βββ ai/ # AI agent & tools
β βββ constants/ # App constants
β βββ hooks/ # Custom React hooks
β βββ store/ # Zustand stores
β βββ utils/ # Utility functions
β
βββ sanity/ # Sanity CMS configuration
βββ lib/ # Sanity client & queries
βββ schemaTypes/ # Content schemas
| Variable | Description | Where to Get It |
|---|---|---|
NEXT_PUBLIC_SANITY_PROJECT_ID |
Sanity project ID | Sanity Dashboard |
NEXT_PUBLIC_SANITY_DATASET |
Sanity dataset name | Usually production or development |
SANITY_API_READ_TOKEN |
Sanity read token | Sanity Dashboard β API β Tokens |
SANITY_API_WRITE_TOKEN |
Sanity write token | Sanity Dashboard β API β Tokens |
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY |
Clerk publishable key | Clerk Dashboard |
CLERK_SECRET_KEY |
Clerk secret key | Clerk Dashboard β API Keys |
OPENAI_API_KEY |
OpenAI API key | OpenAI Platform |
| Variable | Description |
|---|---|
NEXT_PUBLIC_MAPBOX_ACCESS_TOKEN |
Mapbox token for address search in admin panel |
The app uses a two-step geographic filtering system for fast, accurate location-based search:
- Bounding Box (Database-level): Fast rectangular filter reduces 100k+ sessions to ~100-500
- Haversine Formula (Client-side): Precise circular distance calculation for accuracy
This approach makes location-based search 10-100x faster than naive implementations.
Content updates automatically when:
- New sessions are added
- Bookings are created/cancelled
- Availability changes
- Content is published in Sanity Studio
Powered by Sanity Live for seamless real-time synchronization.
Chat with an AI assistant to:
- Search for classes by natural language
- Get personalized recommendations
- Check your bookings
- Find venues near you
The AI uses tool calling to query the database in real-time.
Three subscription tiers with different benefits:
- Basic: 5 classes/month, Basic-tier classes only
- Performance: 12 classes/month, Basic + Performance classes
- Champion: Unlimited classes, All classes
Higher tiers can access lower-tier classes (hierarchical access).
Access the content management interface at /studio:
- Start the dev server:
pnpm dev - Navigate to http://localhost:3000/studio
- Sign in with your Sanity account
- Manage activities, sessions, venues, and more
-
Push to GitHub
git push origin main
-
Import to Vercel
- Go to vercel.com
- Click "New Project"
- Import your repository
-
Add Environment Variables
- Add all required environment variables in Vercel dashboard
- Deploy
-
Configure Sanity CORS
- In Sanity Dashboard β API β CORS Origins
- Add your Vercel domain:
https://your-app.vercel.app
pnpm build
pnpm start-
Create Sanity Schema (if needed)
- Add schema in
sanity/schemaTypes/ - Run
pnpm typegento generate types
- Add schema in
-
Create GROQ Query
- Add query in
sanity/lib/queries/ - Use
defineQueryfor type safety
- Add query in
-
Create Server Action (if needed)
- Add action in
lib/actions/ - Use
"use server"directive
- Add action in
-
Create Components
- Add components in
components/ - Use Server Components by default
- Only use Client Components when needed
- Add components in
- Linting: Run
pnpm lintbefore committing - Formatting: Code is auto-formatted with Biome
- Type Safety: TypeScript is required, no
anytypes
- Comprehensive Technical Walkthrough - Complete technical documentation covering architecture, implementation details, design decisions, and code examples
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request