Overview
Film Fanatic provides a powerful search experience with real-time results, multi-category filtering, and advanced options for refining search queries.Search Interface
Location:src/routes/search.tsx
Search Bar Component
Location:src/components/ui/search-bar.tsx
The search bar is prominently featured on:
- Homepage - Main entry point for discovery
- Search Results Page - Persistent at top for query refinement
- All Pages - Via navigation (if implemented)
Features
- Debounced input (500ms default)
- Real-time URL updates
- Clear button (X icon)
- Loading spinner during fetch
- Auto-focus option
- Keyboard navigation (Escape to clear)
Behavior
- Updates URL query parameter
- Triggers search after delay
- Preserves query on page reload
- Navigate directly to results
- Form submission support
Search Bar Props
src/components/ui/search-bar.tsx:11-24
Search Results Page
URL Structure
query- Search term (optional, shows trending if absent)page- Page number (optional, defaults to 1)
src/routes/search.tsx:32-35
Page States
- No Query
- Loading
- Results
- No Results
- Error
When visiting
/search without a query parameter:- Shows “Trending Now” section
- Displays today’s trending content
- Encourages users to start searching
- Search bar is empty and ready for input
src/routes/search.tsx:159-197Search Categories
Multi-Category Results
Search queries return results from multiple categories:Movies
Feature films and documentaries
TV Shows
Series, miniseries, talk shows
People
Actors, directors, crew members(Filtered out by default)
Filtering by Type
Users can refine results by media type:- All
- Movies
- Series
Shows both movies and TV shows (people excluded).Button state:
type === nullsrc/routes/search.tsx:286-309
Filter Logic:
src/routes/search.tsx:92-102
Advanced Filtering
Minimum Rating Filter
Users can filter by minimum TMDB rating:- Any Rating
- 6+ Rating
- 7+ Rating
- 8+ Rating
- 9+ Rating
Show all results regardless of rating.Value:
"0"src/routes/search.tsx:311-332
Auto-Clear Filters
If filters become too restrictive (zero results):src/routes/search.tsx:104-110
Auto-clearing prevents users from getting stuck with impossible filter combinations. They can always reapply filters.
Search Query
API Integration
Location:src/lib/queries.ts:getSearchResult()
Search uses TMDB’s multi-search endpoint:
src/routes/search.tsx:63-71
Result Structure
Pagination
Location:src/components/ui/pagination.tsx
Pagination Controls
Previous
Navigate to previous page.Disabled on page 1.
Page Numbers
Current page indicator.Format: “Page X of Y”
Next
Navigate to next page.Disabled on last page.
Pagination Limits
TMDB imposes pagination limits:src/constants.ts and src/routes/search.tsx:114-155
Page Navigation
- Updates URL query parameter
- Triggers new API request
- Preserves search query
- Scrolls to top (browser default)
src/routes/search.tsx:112-130
Result Display
Media Cards
Location:src/components/media-card.tsx
Each result is displayed as a card with:
- Visual
- Metadata
- Actions
- Poster image (or placeholder)
- Aspect ratio preserved
- Hover effects
- Loading skeleton during fetch
Grid Layout
- Mobile: 2-3 columns
- Tablet: 4-5 columns
- Desktop: 6+ columns
src/constants.ts
Real-Time Search
Debounced Input
To reduce API calls and improve performance:Timer Completes
500ms of inactivity triggers:
- URL update with new query
- API request with search term
src/components/ui/search-bar.tsx:47-84
Manual Submission
Users can also press Enter to immediately submit:src/components/ui/search-bar.tsx:111-144
Trending Fallback
When no search query is provided, the page shows trending content:Trending Now
Today’s most popular movies and TV shows.
Discovery Prompt
Encourages users to search for specific content.
src/routes/search.tsx:73-81
Result Metadata
Total Results Counter
Displayed in top-right of results:src/routes/search.tsx:334-336
Search Performance Optimizations
Query Caching
- Stale Time
- Garbage Collection
- No Auto-Refetch
Results cached for 24 hours:Repeated searches for the same query are instant.
src/routes/search.tsx:67-70
Pending State
Prevents multiple simultaneous requests:src/routes/search.tsx:60, 120
Keyboard Navigation
Supported Keys
Escape
Clears search input and resets to trending view.Handler:
handleKeyDown in SearchBarEnter
Immediately submits search without waiting for debounce.Handler:
handleSubmit in SearchBarsrc/components/ui/search-bar.tsx:146-153
Error Handling
API Errors
API Errors
When TMDB API fails:User can reset to trending view.Location:
src/routes/search.tsx:229-248Empty Results
Empty Results
Differentiated messages based on context:
- No matches: “No movies or TV shows found matching your search”
- Filters too strict: “No movies or TV shows found with the selected filter”
src/routes/search.tsx:256-270Mobile Responsiveness
Search Bar
- Full width on mobile
- Font size: 16px (prevents iOS zoom)
- Touch-friendly clear button
- Proper input types for mobile keyboards
Filter Controls
- Horizontal scroll on mobile
- Compact button sizes
- Wrapped layout on small screens
Result Grid
- Fewer columns on mobile (2-3)
- Smaller card sizes
- Optimized image loading
