This application provides an intuitive interface to search for movies and view detailed information using The Movie Database (TMDb) API.
The app is deployed on Netlify: https://tmdb-mews.netlify.app
- Node.js 22+ (look at
.nvmrcfor the exact version) - pnpm (recommended) or npm/yarn
-
Clone the repository
git clone <repository-url> cd developers
-
Install dependencies
pnpm install
-
Environment Configuration
Create a
.envfile in the root directory with your TMDb API credentials:VITE_TMDB_BASE_URL=https://api.themoviedb.org/3 VITE_TMDB_API_KEY=your_api_key_here VITE_ENABLE_MSW=false # Set to true to enable MSW mocking
Note: Get your free API key from The Movie Database (TMDb)
-
Start the development server
pnpm dev
-
Open your browser
Navigate to
http://localhost:5173to view the application.
- Movie Search: Real-time search with debounced input for optimal performance
- Movie Details: Comprehensive movie information including ratings, genres, and descriptions
- Responsive Design: Fully responsive interface that works on desktop, tablet, and mobile
- Pagination: Efficient navigation through search results
- Loading States: Skeleton screens and loading indicators for better UX
- Error Handling: Comprehensive error handling with user-friendly messages
- TypeScript: Full type safety throughout the application
- State Management: React Query for efficient server state management
- Styled Components: Component-scoped CSS with theming support
- Performance Optimization: Code splitting, memoization, and efficient re-renders
- Testing: Comprehensive unit and integration tests
- E2E Testing: Cypress for end-to-end testing
- Code Quality: BiomeJS for linting and formatting
- React 19 - Latest React with modern hooks and concurrent features
- TypeScript - Type-safe development
- Vite - Fast build tool and development server
- TanStack React Query - Server state management and caching
- Axios - HTTP client with interceptors
- Styled Components - CSS-in-JS with theming
- Lucide React - Modern icon library
- Responsive Design - Mobile-first approach
- Vitest - Fast unit testing framework
- Testing Library - Component testing utilities
- Cypress - End-to-end testing
- MSW (Mock Service Worker) - API mocking for tests
- BiomeJS - Linting and formatting
- Husky - Git hooks for code quality
- Lint-staged - Pre-commit linting
docs/
βββ images/ # Screenshots and documentation images
β βββ search-page.png
β βββ movie-detail.png
β βββ mobile-view.png
src/
βββ components/ # Reusable UI components
β βββ MovieCard/ # Example: Individual movie card component
β β βββ MovieCard.tsx
β β βββ MovieCard.styles.ts
β β βββ MovieCard.test.tsx
β β βββ index.ts
β βββ SearchInput/ # Debounced search input
β βββ Pagination/ # Pagination component
β βββ MovieGrid/ # Movie grid layout
β βββ ... # Other UI components
βββ constants/ # Application constants
β βββ errors.ts # Error messages and codes
β βββ routes.ts # Route definitions
βββ hooks/ # Custom React hooks
β βββ __tests__/ # Hook tests
β βββ useDebounce.ts # Input debounce hook
β βββ useMovies.ts # Movie management hook
β βββ usePagination.ts # Pagination state hook
β βββ useSearchState.ts # Search state hook
βββ lib/ # External library configurations
β βββ __tests__/ # External library tests
β βββ api.ts # Axios configuration
βββ pages/ # Page components
β βββ SearchPage/ # Example: Main search page
β β βββ SearchPage.tsx
β β βββ SearchPage.styles.ts
β β βββ SearchPage.test.tsx
β β βββ index.ts
β βββ MovieDetailPage/ # Movie detail page
β βββ NotFoundPage/ # 404 page
β βββ ... # Other pages
βββ services/ # API service layer
β βββ __tests__/ # API service layer tests
β βββ movieService.ts # TMDb API integration
βββ styles/ # Global styles and theming
β βββ GlobalStyles.ts # Global application styles
β βββ theme.ts # Theme configuration
β βββ styled.d.ts # Styled-components type definitions
βββ test/ # Test configuration and mocks
β βββ mocks/ # MSW handlers and fixtures
β βββ setup.ts # Test setup configuration
βββ types/ # TypeScript type definitions
β βββ movie.ts # Movie-related types
β βββ env.d.ts # Environment variable types
βββ utils/ # Utility functions
β βββ __tests__/ # Utility functions tests
β βββ movieUtils.ts # Movie-related utilities
βββ main.tsx # Application entry point
βββ vite-env.d.ts # Vite types
- Search Input: Debounced search with real-time results
- Popular Movies: Default view showing trending movies
- Movie Grid: Responsive grid layout with movie cards
- Pagination: Navigate through multiple pages of results
- Loading States: Skeleton cards during data fetching
- Detailed Information: Complete movie details including runtime, genres, and production info
- High-Quality Images: Backdrop and poster images from TMDb
- Rating System: User ratings and vote counts
- Navigation: Back to search functionality
pnpm dev # Start development server
pnpm build # Build for production
pnpm preview # Preview production buildpnpm test # Run unit tests in watch mode
pnpm test:run # Run unit tests once
pnpm test:ui # Open Vitest UI
pnpm test:coverage # Generate test coverage reportpnpm cypress:open # Open Cypress test runner
pnpm cypress:run # Run Cypress tests headlesslypnpm lint # Check code with BiomeJS
pnpm lint:fix # Fix linting issues
pnpm format # Format code
pnpm check # Run all quality checksThis application integrates with The Movie Database (TMDb) API to fetch movie data:
GET /movie/popular- Fetch popular moviesGET /search/movie- Search movies by queryGET /movie/{id}- Get detailed movie information
- Components: Testing component behavior and rendering
- Hooks: Testing custom hook logic and state management
- Services: Testing API integration and error handling
- Utilities: Testing helper functions
- Page Components: Testing complete page functionality
- API Integration: Testing service layer with mocked responses
- User Flows: Complete user journey testing with Cypress
- Cross-browser: Ensuring compatibility across different browsers
- Caching: Intelligent caching of API responses
- Error Boundaries: Graceful error handling
- Loading States: Built-in loading state management
- useMovies: Movie search and fetching logic
- useDebounce: Input debouncing for search optimization
- usePagination: Pagination state management
- useSearchState: Search input and results state
The project includes a comprehensive CI/CD pipeline that automatically runs both unit tests and end-to-end tests.
The CI pipeline is defined in .github/workflows/ci.yml
- Uses Node.js 22.x for consistent testing environment
- Uses pnpm for package management with caching
- Enables MSW (Mock Service Worker) for reliable API mocking in tests
- Colors: Consistent color palette throughout the application
- Typography: Responsive font sizes and weights
- Spacing: Consistent spacing scale
- Breakpoints: Mobile-first responsive design
- Co-located Styles: Styled components are kept in separate files alongside their React components to maintain better component cohesion, improve developer experience by keeping related code together, and facilitate maintenance. This approach works well for this application's scope and complexity.
pnpm build
pnpm preview| Variable | Description | Required |
|---|---|---|
VITE_TMDB_BASE_URL |
TMDb API base URL | Yes |
VITE_TMDB_API_KEY |
Your TMDb API key | Yes |
VITE_ENABLE_MSW |
Enable MSW mocking | No |
This project is part of a technical assessment and is for demonstration purposes.
- The Movie Database API
- React Documentation
- TypeScript Handbook
- TanStack Query
- Styled Components
- Vite Documentation