Overview
The frontend is built with React 18, TypeScript, and modern web development tools. It follows a component-based architecture with hooks for state management, lazy loading for performance, and a clean separation between UI and business logic.Project Structure
Application Entry Point
The application starts infrontend/project/src/main.tsx:1-11:
frontend/project/src/main.tsx
Root Component and Routing
TheApp component configures routing and global providers (frontend/project/src/App.tsx:1-50):
frontend/project/src/App.tsx
Key Features:
- Lazy loading for code splitting and faster initial load
- TanStack Query for data fetching with caching
- Error boundaries for graceful error handling
- Clean URL routes (e.g.,
/page/1instead of/?page=1)
State Management
TanStack Query (React Query)
The application uses TanStack Query for server state management: Configuration:- Retry: 3 attempts on failed requests
- Stale Time: 5 minutes (data cached for 5 min before refetch)
- Refetch on Focus: Disabled to prevent unnecessary requests
API Client
The base API client (frontend/project/src/hooks/api/api-client.ts:1-73) handles all HTTP communication:
frontend/project/src/hooks/api/api-client.ts
Component Architecture
Layout Component
The Layout component (frontend/project/src/components/Layout.tsx:1-233) provides the application shell:
Features:
- Responsive navigation with mobile menu
- Version update notifications
- Changelog display modal
- Dynamic color scheme based on route
- Footer with branding
frontend/project/src/components/Layout.tsx
CatalogGrid Component
Displays content items in a responsive grid (frontend/project/src/components/CatalogGrid.tsx:1-79):
frontend/project/src/components/CatalogGrid.tsx
Performance Optimization:
- First image loaded eagerly for better LCP (Largest Contentful Paint)
- Remaining images lazy loaded to reduce initial bandwidth
- Skeleton loading states for better perceived performance
Page Components
CatalogPage
Manages catalog display with filtering and pagination (frontend/project/src/pages/CatalogPage.tsx:1-162):
frontend/project/src/pages/CatalogPage.tsx
- URL-driven state (no local state for filters)
- Deep search support
- Image preloading for first item
- Optimized callbacks with
useCallback
Custom Hooks
API Hooks
Hooks are organized by domain in thehooks/api/ directory:
useCatalog Hook
useMovieDetail Hook
UI Hooks
usePagination Hook
hooks/ui/use-pagination.ts
Utility Hooks
useDebounce Hook
hooks/utils/use-debounce.ts
Routing Strategy
The application uses React Router v7 with:Clean URLs
Navigation Patterns
- Hash-free URLs: No hash routing for better SEO
- SPA fallback: Backend serves
index.htmlfor all routes - Lazy loading: Route components loaded on demand
- Prefetching: TanStack Query prefetches related data
Styling Architecture
TailwindCSS Configuration
Custom design system with neon/space theme:tailwind.config.js
Component Styling Patterns
- Utility-first: TailwindCSS utilities for most styling
- Responsive: Mobile-first responsive design
- Dark theme: Space/neon aesthetic throughout
- Glow effects: Custom text-glow and box-glow utilities
Performance Optimizations
Code Splitting
Lazy loading with React.lazy() and Suspense
Image Optimization
Lazy loading images except first (LCP optimization)
Query Caching
5-minute stale time reduces redundant API calls
Debouncing
Search inputs debounced to reduce API calls
Memoization
useCallback and useMemo prevent unnecessary renders
Preloading
First catalog image preloaded for better LCP
Error Handling
Error Boundary
components/ErrorBoundary.tsx
API Error Handling
Build and Deployment
Vite Configuration
Optimized build settings for production:vite.config.ts
Production Build
dist/ directory.
Related Documentation
- Backend Architecture - API integration details
- Component Guide - Detailed component usage