Skip to content

Donivanes/developers

Β 
Β 

Repository files navigation

Movie Search Application

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

πŸš€ Quick Start

Prerequisites

  • Node.js 22+ (look at .nvmrc for the exact version)
  • pnpm (recommended) or npm/yarn

Installation & Setup

  1. Clone the repository

    git clone <repository-url>
    cd developers
  2. Install dependencies

    pnpm install
  3. Environment Configuration

    Create a .env file 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)

  4. Start the development server

    pnpm dev
  5. Open your browser

    Navigate to http://localhost:5173 to view the application.

🎯 Features

Core Functionality

  • 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

Technical Features

  • 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

πŸ› οΈ Technology Stack

Frontend Framework

  • React 19 - Latest React with modern hooks and concurrent features
  • TypeScript - Type-safe development
  • Vite - Fast build tool and development server

State Management & Data Fetching

  • TanStack React Query - Server state management and caching
  • Axios - HTTP client with interceptors

Styling & UI

  • Styled Components - CSS-in-JS with theming
  • Lucide React - Modern icon library
  • Responsive Design - Mobile-first approach

Testing & Quality

  • 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

Development Tools

  • Husky - Git hooks for code quality
  • Lint-staged - Pre-commit linting

πŸ“ Project Structure

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

🎬 Application Flow

Search Page (/)

  • 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

Movie Detail Page (/movie/:id)

  • 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

πŸ”§ Available Scripts

Development

pnpm dev          # Start development server
pnpm build        # Build for production
pnpm preview      # Preview production build

Testing

pnpm 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 report

End-to-End Testing

pnpm cypress:open # Open Cypress test runner
pnpm cypress:run  # Run Cypress tests headlessly

Code Quality

pnpm lint         # Check code with BiomeJS
pnpm lint:fix     # Fix linting issues
pnpm format       # Format code
pnpm check        # Run all quality checks

πŸ”Œ API Integration

This application integrates with The Movie Database (TMDb) API to fetch movie data:

Endpoints Used

  • GET /movie/popular - Fetch popular movies
  • GET /search/movie - Search movies by query
  • GET /movie/{id} - Get detailed movie information

πŸ§ͺ Testing Strategy

Unit Tests

  • 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

Integration Tests

  • Page Components: Testing complete page functionality
  • API Integration: Testing service layer with mocked responses

E2E Tests

  • User Flows: Complete user journey testing with Cypress
  • Cross-browser: Ensuring compatibility across different browsers

πŸ”„ State Management

React Query Implementation

  • Caching: Intelligent caching of API responses
  • Error Boundaries: Graceful error handling
  • Loading States: Built-in loading state management

Custom Hooks

  • useMovies: Movie search and fetching logic
  • useDebounce: Input debouncing for search optimization
  • usePagination: Pagination state management
  • useSearchState: Search input and results state

πŸ”„ CI/CD

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

Environment Configuration

  • 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

🎨 Design System

Theme Configuration

  • Colors: Consistent color palette throughout the application
  • Typography: Responsive font sizes and weights
  • Spacing: Consistent spacing scale
  • Breakpoints: Mobile-first responsive design

Styling Architecture

  • 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.

Bundle Analysis

pnpm build
pnpm preview

πŸ”’ Environment Variables

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

πŸ“ License

This project is part of a technical assessment and is for demonstration purposes.

πŸ”— Useful Links


About

Information about development, engineering, work and life in Mews.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 93.7%
  • JavaScript 6.1%
  • Other 0.2%