# CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
## Project Overview
Black Canyon Tickets React Rebuild is a frontend-only React application focused on learning modern UI/UX patterns. This is a complete rebuild using React 18, TypeScript, and Tailwind CSS with a sophisticated glassmorphism design system. The project serves as a production-ready demo of premium ticketing platform interfaces without live database or payment integrations.
**🎉 PROJECT STATUS: Phase 3 Substantially Complete (August 2025)**
The project has evolved far beyond the original scope with 80+ React components, advanced analytics, territory management, QR scanning, and enterprise features. See REBUILD_PLAN.md for detailed status.
## Development Commands
```bash
# Development
npm run dev # Start development server at localhost:5173 (binds to 0.0.0.0)
npm run build # Type check and build for production with chunk optimization
npm run preview # Preview production build locally
# Code Quality
npm run lint # Run ESLint with unused disable directives report
npm run lint:ci # CI-specific linting with max warnings
npm run lint:fix # Run ESLint with auto-fix
npm run lint:check # Run ESLint with reports only
npm run typecheck # Run TypeScript type checking (noEmit)
npm run quality # Run all quality checks (typecheck + lint + format:check)
npm run quality:fix # Run all quality fixes (typecheck + lint:fix + format)
# Formatting
npm run format # Format code with Prettier
npm run format:check # Check code formatting without changes
# Testing - Comprehensive Playwright Suite
npm run test # Run all Playwright end-to-end tests
npm run test:ci # Run tests in CI mode (single worker)
npm run test:ci:full # Full CI pipeline (typecheck + tests)
npm run test:ui # Run tests with Playwright UI
npm run test:headed # Run tests with visible browser
npm run test:qa # Run QA test suite with custom runner
npm run test:smoke # Run critical path smoke tests
# Specific Test Suites
npm run test:auth # Authentication flow tests
npm run test:theme # Theme switching and persistence
npm run test:responsive # Cross-device responsive testing
npm run test:components # Component interaction testing
npm run test:navigation # Route and navigation testing
npm run test:scanner # QR scanner offline functionality
npm run test:performance # Battery and performance tests
npm run test:mobile # Mobile UX testing
npm run test:field # Field testing suite (PWA, offline, mobile, gate ops)
# Theme and Design Validation
npm run validate:theme # Validate design token consistency
npm run check:colors # Check for hardcoded colors in codebase
# Firebase Integration (for deployment)
npm run firebase:emulators # Start Firebase emulators
npm run firebase:deploy:functions # Deploy cloud functions only
npm run firebase:deploy:hosting # Deploy hosting only
npm run firebase:deploy:all # Deploy functions + hosting
npm run firebase:deploy:preview # Deploy to staging channel
```
## Tech Stack
### Core Technologies
- **React 18** with TypeScript for strict typing and modern patterns
- **Vite 6.0** for lightning-fast development builds, HMR, and optimized production bundles
- **Tailwind CSS 3.4** with comprehensive design token system and prettier plugin
- **React Router v6** for client-side routing with protected routes and lazy loading
- **Zustand** for lightweight, scalable state management across domain stores
### State & Data Management
- **React Query/TanStack Query** for server state simulation and caching
- **Zustand Stores** for event, ticket, order, and customer domain state
- **Context Providers** for auth, theme, and organization state
- **React Hook Form** with Zod validation for type-safe form handling
### UI/Animation Libraries
- **Framer Motion** for smooth animations and micro-interactions
- **Lucide React** for consistent, scalable SVG icons (460+ icons)
- **Date-fns** for date manipulation and formatting
- **clsx + tailwind-merge** for conditional styling utilities
- **IDB** for client-side storage and offline capabilities
### Development & Testing Tools
- **TypeScript 5.6** with strict configuration and path aliases (@/ imports)
- **ESLint 9.x** with comprehensive React/TypeScript/accessibility rules
- **Prettier 3.x** with Tailwind plugin for code formatting
- **Playwright** for comprehensive end-to-end testing with visual regression
- **Firebase SDK** for deployment and cloud functions (optional backend)
- **Sentry** for error tracking and performance monitoring (configurable)
## Architecture
### Design Token System
Comprehensive design system built on CSS custom properties and JSON tokens:
- **Base Tokens**: Foundational design tokens in `/src/design-tokens/base.json` (spacing, typography, radius, shadows, blur, opacity)
- **Theme Tokens**: Semantic color tokens in `/src/theme/tokens.ts` with light/dark variants
- **Automatic Theme Switching**: System preference detection with manual toggle override
- **WCAG AA Compliance**: 4.5:1+ contrast ratios across all color combinations
- **Glassmorphism Effects**: Sophisticated backdrop blur, transparency, and glass surface tokens
- **CSS Variable Integration**: All tokens available as CSS custom properties and Tailwind utilities
### Component Architecture
- **Atomic Design Pattern**: UI primitives (Button, Input, Card) → Business components (EventCard, TicketTypeRow) → Page layouts
- **Token-Based Styling**: All components consume design tokens, no hardcoded colors/spacing
- **TypeScript Interfaces**: Strict typing for props, variants, and component APIs
- **Error Boundaries**: Graceful error handling with AppErrorBoundary and component-level boundaries
- **Accessibility First**: WCAG AA compliance with proper ARIA labels, focus management, and keyboard navigation
- **Lazy Loading**: Route-based code splitting with React.lazy and Suspense boundaries
### Route Structure & Navigation
```
/ or /dashboard - Protected dashboard with event overview and analytics
/events - Event management interface (events:read permission)
/tickets - Ticket type and pricing management (tickets:read permission)
/customers - Customer database and management (customers:read permission)
/analytics - Revenue and sales analytics dashboard (analytics:read permission)
/settings - User account and organization settings
/admin/* - Super admin panel (super_admin role required)
/gate-ops - QR scanner and gate operations interface
/login - Authentication portal with role selection
/home - Public homepage with branding showcase
/showcase - Live design system component showcase
/docs - Interactive theme and token documentation
```
### Mock Authentication & Permission System
Sophisticated role-based access control with realistic permission granularity:
- **User Role**: Basic event access, ticket purchasing, profile management
- **Admin Role**: Full event management, ticket configuration, customer access, analytics
- **Super Admin Role**: Platform administration, organization management, system settings
- **Permission Granularity**: Read/write permissions for events, tickets, customers, analytics
- **Context Aware**: AuthContext + OrganizationContext for multi-tenant simulation
- **Protected Routes**: ProtectedRoute component with role checking and permission validation
## File Structure
```
src/
├── app/ # App configuration and routing
│ ├── router.tsx # React Router configuration with lazy routes
│ ├── providers.tsx # Context providers (Auth, Theme, React Query)
│ └── lazy-routes.tsx # Lazy-loaded route components
├── components/
│ ├── ui/ # Reusable UI primitives (15+ components)
│ │ ├── Button.tsx # Primary action component with variants (primary, secondary, gold)
│ │ ├── Input.tsx # Form input with validation states and accessibility
│ │ ├── Card.tsx # Container component with glass effects and variants
│ │ ├── Alert.tsx # Status message component with semantic colors
│ │ ├── Badge.tsx # Small status indicators with theme support
│ │ ├── Select.tsx # Dropdown selection with proper focus management
│ │ └── Modal.tsx # Accessible modal with backdrop and focus trapping
│ ├── layout/ # Application layout system
│ │ ├── AppLayout.tsx # Main layout wrapper with sidebar and header
│ │ ├── Header.tsx # Top navigation with user menu and theme toggle
│ │ ├── Sidebar.tsx # Collapsible navigation with route highlighting
│ │ └── MainContainer.tsx # Content area with proper spacing and scrolling
│ ├── auth/ # Authentication components
│ │ └── ProtectedRoute.tsx # Route guards with role and permission checking
│ ├── loading/ # Loading states and skeleton components
│ │ ├── Skeleton.tsx # Reusable skeleton loader
│ │ └── LoadingSpinner.tsx # Animated loading indicator
│ ├── skeleton/ # Domain-specific skeleton loaders
│ │ ├── EventCardsSkeleton.tsx # Event grid skeleton
│ │ ├── FormSkeleton.tsx # Form loading skeleton
│ │ └── TableSkeleton.tsx # Data table skeleton
│ ├── errors/ # Error handling components
│ │ └── AppErrorBoundary.tsx # Application-level error boundary
│ ├── events/ # Event management components
│ │ ├── EventCard.tsx # Event display card with glassmorphism
│ │ ├── EventCreationWizard.tsx # Multi-step event creation
│ │ └── EventDetailsStep.tsx # Event details form step
│ ├── features/ # Business domain features
│ │ ├── scanner/ # QR scanning functionality with offline support
│ │ ├── territory/ # Territory management for enterprise features
│ │ ├── tickets/ # Ticket type management and creation
│ │ ├── orders/ # Order management and refunds
│ │ └── customers/ # Customer management interface
│ ├── tickets/ # Ticketing components
│ ├── checkout/ # Purchase flow components
│ ├── billing/ # Payment and fee breakdown
│ └── scanning/ # QR scanning components
├── pages/ # Route components (20+ pages)
│ ├── DashboardPage.tsx # Main dashboard with analytics
│ ├── EventsPage.tsx # Event management interface
│ ├── LoginPage.tsx # Authentication portal
│ └── admin/ # Admin-specific pages
├── contexts/ # React Context providers
│ ├── AuthContext.tsx # Authentication state management
│ ├── ThemeContext.tsx # Theme switching and persistence
│ └── OrganizationContext.tsx # Multi-tenant organization context
├── stores/ # Zustand state stores
│ ├── eventStore.ts # Event domain state
│ ├── ticketStore.ts # Ticket and pricing state
│ ├── orderStore.ts # Order and customer state
│ └── currentOrg.ts # Current organization state
├── hooks/ # Custom React hooks (10+ hooks)
│ ├── useTheme.ts # Theme switching and system preference detection
│ ├── useCheckout.ts # Checkout flow state management
│ └── useScanner.ts # QR scanning functionality
├── types/ # TypeScript type definitions
│ ├── auth.ts # Authentication and user types
│ ├── business.ts # Business domain types (Event, Ticket, Order)
│ └── organization.ts # Multi-tenant organization types
├── design-tokens/ # Design system token definitions
│ └── base.json # Foundation tokens (spacing, typography, radius, blur)
├── theme/ # Theme system implementation
│ ├── tokens.ts # Semantic color tokens and theme variants
│ ├── cssVariables.ts # CSS custom property utilities
│ └── applyBranding.ts # Dynamic branding application
├── styles/ # CSS files and utilities
│ ├── tokens.css # CSS custom properties generated from tokens
│ └── poster-tokens.css # Poster-specific theme overrides
├── lib/ # Utility libraries
│ ├── utils.ts # General utility functions
│ ├── firebase.ts # Firebase configuration (optional)
│ └── qr-generator.ts # QR code generation utilities
└── utils/ # Additional utilities
├── contrast.ts # Color contrast calculation for accessibility
└── prefetch.ts # Route prefetching utilities
```
## Design System
### Token-Based Design System Architecture
The design system is built on a comprehensive token system with multiple layers:
**Foundation Tokens** (`/src/design-tokens/base.json`):
- **Spacing Scale**: `xs` (0.25rem) to `8xl` (6rem) for consistent rhythm
- **Typography Scale**: Font sizes, weights, and line heights with Inter + JetBrains Mono
- **Radius System**: `sm` (0.125rem) to `full` (9999px) for consistent corner rounding
- **Shadow Tokens**: Glass shadows, glow effects, and inner highlights
- **Blur Values**: `xs` (2px) to `5xl` (96px) for glassmorphism effects
- **Opacity Scales**: Glass opacity variants from subtle (0.05) to heavy (0.3)
**Semantic Tokens** (`/src/theme/tokens.ts`):
- **Dual Theme Support**: Complete light and dark theme token sets
- **Semantic Naming**: background.primary, text.secondary, accent.gold, surface.raised
- **Brand Colors**: Warm gray primary, gold accents (#d99e34), purple secondary
- **Glass System**: Sophisticated backdrop blur tokens with proper transparency
- **Accessibility**: WCAG AA compliant contrast ratios built into token definitions
### Theme System Features
- **Automatic Detection**: System preference detection with manual override
- **CSS Custom Properties**: All tokens exported as CSS variables for runtime theming
- **Tailwind Integration**: Custom Tailwind utilities generated from design tokens
- **TypeScript Safety**: Strongly typed theme tokens with IntelliSense support
- **Runtime Switching**: Instant theme switching without page reload
- **Persistent Preferences**: Theme selection saved to localStorage
### Component Usage Patterns
```tsx
// Token-based component variants
Description