# ThrillWiki Frontend Vue.js SPA frontend for the ThrillWiki monorepo. ## ๐Ÿ—๏ธ Architecture Modern Vue 3 application with TypeScript and composition API: ``` frontend/ โ”œโ”€โ”€ src/ โ”‚ โ”œโ”€โ”€ components/ # Vue components โ”‚ โ”‚ โ”œโ”€โ”€ common/ # Shared components โ”‚ โ”‚ โ”œโ”€โ”€ parks/ # Park-specific components โ”‚ โ”‚ โ”œโ”€โ”€ rides/ # Ride-specific components โ”‚ โ”‚ โ””โ”€โ”€ moderation/ # Moderation components โ”‚ โ”œโ”€โ”€ views/ # Page components โ”‚ โ”œโ”€โ”€ router/ # Vue Router setup โ”‚ โ”œโ”€โ”€ stores/ # Pinia state management โ”‚ โ”œโ”€โ”€ composables/ # Vue 3 composables โ”‚ โ”œโ”€โ”€ services/ # API services โ”‚ โ”œโ”€โ”€ utils/ # Utility functions โ”‚ โ”œโ”€โ”€ types/ # TypeScript types โ”‚ โ””โ”€โ”€ assets/ # Static assets โ”œโ”€โ”€ public/ # Public assets โ””โ”€โ”€ tests/ # Frontend tests ``` ## ๐Ÿ› ๏ธ Technology Stack - **Vue 3** - Frontend framework with Composition API - **TypeScript** - Type safety and better developer experience - **Vite** - Fast build tool and dev server - **Vue Router** - Client-side routing - **Pinia** - State management - **Tailwind CSS** - Utility-first CSS framework - **Headless UI** - Unstyled, accessible UI components - **Heroicons** - Beautiful SVG icons - **Axios** - HTTP client for API requests ## ๐Ÿš€ Quick Start ### Prerequisites - Node.js 18+ - pnpm 8+ ### Setup 1. **Install dependencies** ```bash cd frontend pnpm install ``` 2. **Environment configuration** ```bash cp .env.example .env # Edit .env with your settings ``` 3. **Start development server** ```bash pnpm run dev ``` Frontend will be available at http://localhost:3000 ## ๐Ÿ”ง Configuration ### Environment Variables ```bash # API Configuration VITE_API_BASE_URL=http://localhost:8000/api # App Configuration VITE_APP_TITLE=ThrillWiki VITE_APP_DESCRIPTION=Your ultimate guide to theme parks # Feature Flags VITE_ENABLE_PWA=true VITE_ENABLE_ANALYTICS=false ``` ### Build Configuration - **Vite** configuration in `vite.config.ts` - **TypeScript** configuration in `tsconfig.json` - **Tailwind CSS** configuration in `tailwind.config.js` ## ๐Ÿงฉ Components ### Component Structure ```typescript // Example component structure ``` ### Shared Components - **AppHeader** - Navigation and user menu - **AppSidebar** - Main navigation sidebar - **LoadingSpinner** - Loading indicator - **ErrorMessage** - Error display component - **SearchBox** - Global search functionality ## ๐Ÿ—‚๏ธ State Management Using **Pinia** for state management: ```typescript // stores/auth.ts export const useAuthStore = defineStore('auth', () => { const user = ref(null) const isAuthenticated = computed(() => !!user.value) const login = async (credentials: LoginData) => { // Login logic } return { user, isAuthenticated, login } }) ``` ### Available Stores - **authStore** - User authentication - **parksStore** - Park data and operations - **ridesStore** - Ride information - **uiStore** - UI state (modals, notifications) - **themeStore** - Dark/light mode toggle ## ๐Ÿ›ฃ๏ธ Routing Vue Router setup with: - **Route guards** for authentication - **Lazy loading** for code splitting - **Meta fields** for page titles and permissions ```typescript // router/index.ts const routes = [ { path: '/', name: 'Home', component: () => import('@/views/Home.vue') }, { path: '/parks', name: 'Parks', component: () => import('@/views/parks/ParksIndex.vue') } ] ``` ## ๐ŸŽจ Styling ### Tailwind CSS - **Dark mode** support with class strategy - **Custom colors** for brand consistency - **Responsive design** utilities - **Component classes** for reusable styles ### Theme System ```typescript // composables/useTheme.ts export const useTheme = () => { const isDark = ref(false) const toggleTheme = () => { isDark.value = !isDark.value document.documentElement.classList.toggle('dark') } return { isDark, toggleTheme } } ``` ## ๐Ÿ”Œ API Integration ### Service Layer ```typescript // services/api.ts class ApiService { private client = axios.create({ baseURL: import.meta.env.VITE_API_BASE_URL, withCredentials: true, }) // API methods getParks(params?: ParkFilters) { return this.client.get('/parks/', { params }) } } ``` ### Error Handling - Global error interceptors - User-friendly error messages - Retry mechanisms for failed requests - Offline support indicators ## ๐Ÿงช Testing ### Test Structure ```bash tests/ โ”œโ”€โ”€ unit/ # Unit tests โ”œโ”€โ”€ e2e/ # End-to-end tests โ””โ”€โ”€ __mocks__/ # Mock files ``` ### Running Tests ```bash # Unit tests pnpm run test # E2E tests pnpm run test:e2e # Watch mode pnpm run test:watch ``` ### Testing Tools - **Vitest** - Unit testing framework - **Vue Test Utils** - Vue component testing - **Playwright** - End-to-end testing ## ๐Ÿ“ฑ Progressive Web App PWA features: - **Service Worker** for offline functionality - **App Manifest** for installation - **Push Notifications** for updates - **Background Sync** for data synchronization ## ๐Ÿ”ง Build & Deployment ### Development Build ```bash pnpm run dev ``` ### Production Build ```bash pnpm run build ``` ### Preview Production Build ```bash pnpm run preview ``` ### Build Output - Static assets in `dist/` - Optimized and minified code - Source maps for debugging - Chunk splitting for performance ## ๐ŸŽฏ Performance ### Optimization Strategies - **Code splitting** with dynamic imports - **Image optimization** with responsive loading - **Bundle analysis** with rollup-plugin-visualizer - **Lazy loading** for routes and components ### Core Web Vitals - First Contentful Paint (FCP) - Largest Contentful Paint (LCP) - Cumulative Layout Shift (CLS) ## โ™ฟ Accessibility - **ARIA labels** and roles - **Keyboard navigation** support - **Screen reader** compatibility - **Color contrast** compliance - **Focus management** ## ๐Ÿ› Debugging ### Development Tools - Vue DevTools browser extension - Vite's built-in debugging features - TypeScript error reporting - Hot module replacement (HMR) ### Logging ```typescript // utils/logger.ts export const logger = { info: (message: string, data?: any) => { if (import.meta.env.DEV) { console.log(message, data) } } } ``` ## ๐Ÿš€ Deployment See the [Deployment Guide](../shared/docs/deployment/) for production setup. ## ๐Ÿค Contributing 1. Follow Vue.js style guide 2. Use TypeScript for type safety 3. Write tests for components 4. Follow Prettier formatting 5. Use conventional commits