Skip to content

BernardoAguayoOrtega/frontend_challenge

Repository files navigation

Frontend Challenge

This project is a movie listing application built with Next.js, React, and TypeScript. It allows users to search for movies, view details, and manage their favorite movies. The application uses The Movie Database (TMDb) API for fetching movie data.

Table of Contents

Features

  • User authentication with NextAuth.js
  • Search for movies
  • View movie details
  • Add and remove movies from favorites
  • Responsive design
  • Lazy loading for infinite scroll
  • Protected routes for authenticated users
  • Tags for movie genres
  • Each movie has a rating and release date
  • Real-time search results

Deployment

The application is deployed on Vercel and can be accessed at FinspheraFlix.

App

Project Structure

API Structure

API Structure

Components Structure

Components Structure

Context and Favorites

Context and Favorites

Genre, HOCs, Login, Movie, Movies, Search, and Signup Pages

Genre, HOCs, Login, Movie, Movies, Search, and Signup Pages

Types and Miscellaneous Files

Types and Miscellaneous Files

Scripts

  • dev: Starts the development server.
    npm run dev
  • build: Builds the application for production.
    npm run build
  • start: Starts the production server.
      npm start
  • lint: Lints the project files.
    npm run lint
  • test: Checks tests.
      npm run test
  • Format: Checks TypeScript types in watch mode.
      npm run format
    

Environment Variables

To run this project, you will need to add the following environment variables to your .env file or to the Vercel project settings.

NEXT_PUBLIC_TMDB_API_KEY=<your-tmdb-api-key>
NEXT_PUBLIC_TMDB_AUTH_TOKEN=<your-tmdb-auth-token>
NEXTAUTH_SECRET=<your-nextauth-secret>

Scaling the Application

Application Architecture

The application architecture is designed to be modular and scalable. The project is organized into several main directories:

  • app: Contains the main application logic, including API routes, components, context providers, and page components.
  • public: Contains static assets like images and fonts.
  • styles: Contains global styles and Tailwind CSS configurations.

Scaling Strategies

Global State

  1. Server State Management:
    • Use React Query for efficient server state management. It helps in caching, synchronizing, and updating server state.

Component Architecture

  1. Component Reusability:

    • Break down large components into smaller, reusable components.
    • Use a component library (e.g., Storybook) to document and showcase components.
  2. Code Splitting:

    • Use dynamic imports (React.lazy and Suspense) to split code and load components only when needed.
    • Implement route-based code splitting to reduce the initial load time.

Backend Integration

  1. API Gateway:

    • Implement an API gateway to manage and route API requests.
    • Use serverless functions (e.g., AWS Lambda, Vercel Serverless Functions) to handle backend logic and integrate with third-party services.
  2. Microservices Architecture:

    • Split the backend into microservices to handle different domains (e.g., user authentication, movie data, payment processing).
    • Use a message broker (e.g., RabbitMQ, Kafka) for communication between microservices.

Performance Optimization

  1. Caching:

    • Implement caching strategies using React Query, SWR, or a custom cache layer.
    • Use a CDN (Content Delivery Network) to cache and deliver static assets.
  2. Image Optimization:

    • Use Next.js Image component for automatic image optimization.
    • Serve responsive images to reduce bandwidth usage on different devices.

Deployment and Infrastructure

  1. CI/CD Pipeline:

    • Set up a CI/CD pipeline using GitHub Actions, CircleCI, or GitLab CI for automated testing, building, and deployment.
    • Use automated testing tools (e.g., Jest, Testing Library) to ensure code quality.
  2. Scalable Hosting:

    • Use containerization (e.g., Docker) to manage and deploy microservices efficiently.
  3. Monitoring and Logging:

    • Implement monitoring tools (e.g., Sentry, LogRocket) to track application performance and errors.
    • Use logging services (e.g., ELK Stack, Loggly) to aggregate and analyze logs.

License

This project is licensed under the MIT License.