# 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