/netflix-gpt

NetflixGPT, implementing core frontend functionalities of netflix, along with proper user auth system backed by firebase, Integrated openAI api's for getting movie results via chatGPT AI

Primary LanguageJavaScript

Netflix-GPT

Cloning Front-end of Netflix using React/Redux along with Firebase, Also utilising Open AI GPT for empowering various features.

πŸš€ NetflixGPT Project Live Link πŸš€

Design Documentation (rough flow - Dev Only)

  • boilerPlate setup using create-react-app βœ…

  • cleanedUp the boilerPlate code to kickStart the project βœ…

  • added tailwindCSS config βœ…

  • creating components & utils folder βœ…

  • Login Component βœ…

    • App > Body (body is Home page) βœ…
    • Body > Login + Browse βœ…
    • Create routing in Body (Revise routing first) - βœ…
      • for / login
      • for /browse browse
    • added a errorPage also for unhandled routes βœ…
    • Login > Header(comman) βœ…
    • Developing Header βœ…
    • Login > Form(login/ignup) βœ…
    • Form validation βœ…
    • useRef Hook instead of local state for holding form states βœ…
    • creating utility validate.js for validating form, validating for name, email, password βœ…
    • showing error messages in UI as per validation βœ…
  • Adding Firebase as Backend & deploying it on Prod βœ…

    • create firebase project in firebase console, enable hosting also βœ…
    • set up as instructed, copy project config βœ…
    • you must enable authentication, enable it βœ…
    • host the project via firebase hosting βœ…
      • name your deployment folder as : build
      • rewrite all urls to index.html : no
      • set auto builds : no
  • Creating Sign UP user account in Firebase βœ…

    • in firebase docs find registering users βœ…
    • password based account > web modular api βœ…
    • getting get auth from a central place βœ…
    • write sign in and sign up logic following firebase docs βœ…
    • check if firebase is registering users βœ…
    • play with details returned after sign in/up βœ…
  • Setting up redux tool kit + Sign in/up/out functionlity via Firebase Auth βœ…

    • revise redux tool kit first βœ…
    • once the user in sign in / up, firebase returns a user object with access token βœ…
    • we will store that user into the redux store, to keep track of session βœ…
      • 2 actions, in user slice, adduser, and removeuser βœ…
    • then we will navigate the user to browse page
    • when user sign up/sign in : adduser, when sign out : removeuser βœ…
    • after sign in/up : navigate user to browser page βœ…
    • after sign out : navigate user to login page / βœ…
    • useNavigate() hook of react router dom βœ…
    • once the user logged in then only, browse page will be shown, otherwise make browse page protected βœ…
    • once user logs in / or sign up then only show & actigvate sign out button/functionlity in header βœ…
    • update profile via update api, once sign in/up with userName βœ…
    • display the user name + photo URL(s) [dummy as of now], in header once logged in βœ…
    • Fixed the bug > made login and browse protected via adding onAuthChange api from firebase, and navigation is handled by it only βœ…
    • Fixed another bug, added 2 users, 1 from redux store, 1 from firebase auth, to fix name collapsing issue βœ…
    • adding loader while signing up and siginig in for better and smooth UX βœ…
    • unsubscribed the onAuthChange subscription βœ…
    • constant file added for dummy strings and constant data βœ…
  • Creating Browse Page βœ…

    • registered and logged in on TMDB to use their API's [got access token and api key] βœ…
    • Copy NOW_PLAYING_MOVIES_API_OPTIONS into your constant file βœ…
    • in Browse page make the API call to get Now playing movies βœ…
    • creating a moviesSlice, and storing all our data into the moviesSlice βœ…
      • movieSlice will have initialState as: βœ…
        • nowPlayingMovies βœ…
        • trailerVideo βœ…
    • initailly do all these stuff -> fetch data from tmdb and then store it into redux in browser page βœ…
    • then create a custom hook to do so to keep browse component clean βœ…
    • create useNowPLayingMovies hook, in hooks folder βœ…
    • create browse page UI βœ…
    • plannning how to create the UI βœ…
    • Browse page UI (2 parts) βœ…
      • Maincontainer βœ…
        • Video BG of Movie βœ…
        • Video title & info βœ…
      • SecondaryContainer βœ…
        • MoviesCategories*n βœ…
          • MovieCards*n βœ…
    • as planned make 2 components, MainContainer + SecondaryContainer βœ…
    • MainContainer βœ…
      • fetch movies using useSelector from store βœ…
      • create 2 components βœ…
        • VideoTitle βœ…
        • VideoBackground βœ…
    • early retrurn is movies are not loaded βœ…
    • else first movie will be main movie for which title and video will be shown βœ…
    • destructure relevant info from object and passed it to videoTitle component as props βœ…
    • Now for videoBackground, nowplaying movies api won't have the trailer βœ…
    • We will use another API from tmdb, video api, which will take movie id and give video for that βœ…
      • pass movie id as a prop to video BG comp βœ…
    • in VideoBG comp make api call with movie id to get movie videos βœ…
    • out of all the clips returned, use type="trailer" as bg βœ…
    • in trailer is not there use any first video as bg (write logic) βœ…
    • trailer object contains youtube id, from youtube take the embedded code , handle the id dynamically
    • for storing trailer id, make use of redux not local state, put entire object into redux, and use from there only βœ…
    • make useMovieTrailer, to fetch trailer and store it in redux, make a custom hook for it, to make component cleaner βœ…
    • css to make video bg and title look like how fateflix does βœ…
    • building secondary container βœ…
    • planning building secondary conatiner βœ…
      • MovieList - Popular βœ…
        • moviescards*n βœ…
      • MovieList - nowPLaying βœ…
      • MovieList - Horror βœ…
    • Make 2 components, MovieList & MovieCard βœ…
    • pass movie list title from secondary container to movielist βœ…
    • looppver movieCards into movieLIst βœ…
    • use css to make it look like fateflix βœ…
    • create differetnt hooks for getting different categories, i.e popular, trending, etc βœ…
    • call those hooks also to browse page only > done via single hook only βœ…
    • accordingly different lists would be there βœ…
  • Creating GptSearchPage component Feature βœ…

    • in header > gpt search btn (only for signned in users) βœ…
    • on click of the btn > GptSearchPage component βœ…
    • GptSearchPage component > in browse component > accessble only on header btn click (build toggle functionilty) βœ…
    • to make the toggle functionlity work, store the reducer to toggle into redux store, create gptSlice in slices folder βœ…
    • create action toggleGptSearchView βœ…
    • GPT Search component planning
      • bg image same as of /login screen βœ…
      • GptSearchBar βœ…
        • form > search bar + btn βœ…
          • note : onSubmit > preventDefault behaviour βœ…
      • GptMoviesSuggestions βœ…
    • put bg image in constants if already not coming βœ…
    • translation into other languages using a constant file
      • create a constant file lang, store object of 2 languages hindi, english in the contant file, each word on your app/site must be in these languages hardcoaded here βœ…
      • then on header give an option to toggle from select options βœ…
      • on select handler change the language as should be coming dynamically from contant file βœ…
      • even options in the select option also should come from constant file βœ…
      • do it only in the GptSearchComponent βœ…
      • when clicking on GptSearchComponent should toggle name from GptSearch to homepage βœ…
      • in homepage option for language change should not come βœ…
      • before moving ahead clean up all the componentnts βœ…
      • bug fixes regarding multilang feature βœ…
  • Starting GptSearch Feature βœ…

    • register on open ai βœ…
    • from platform.openai βœ…
    • get your api key βœ…
    • keep your key secret [paid api] βœ…
    • install open ai npm library, go through its docs, readme on github βœ…
    • make seprate util file to initialse open ai, export it βœ…
    • on click of search btn > submitHandler
      • preventDefault behaviour βœ…
      • import open ai βœ…
      • call the open ai function with the search term
      • dangerously allow error by openAi set it to allowed βœ…
      • be specific about passing the query, query , form one,βœ…
        • query : act as a movie recommendation system and recommend some movies to me for the specific query, query : {dynamic input} , give me comma separated values as result in an array format contains 5 movie titles only, such as for query : indian old is gold movies, result : [gadar, sholey, don, golmaal, kabhi khushi kabhi gam]
        • Flow βœ…
          • after query like this, openAI will give result for 5 movies βœ…
          • search these 5 titles using TMDB seach movie api's βœ…
          • movie details will comes to us, then simply display those movies to user in UI βœ…
    • in case open AI gpt does not give result, handle that error gracefully βœ…
    • create array of movies from resultβœ…
    • now for all 5 movie names, we must call TMDB's search api, 5 movies - 5 api calls, create a utility function for the same βœ…
    • using map call that utility funciton -> func will be called 5 times -> won't give result -> async code, will return unresolved promises array βœ…
    • use promise.all to resolve promise and get the results βœ…
    • multiple movies will come as result βœ…
    • store those movies in redux store, in gpt slice itself βœ…
    • search results which are coming from open ai, after entering query store those also in redux store βœ…
    • movies extraction logic can be extracted into hooks βœ…
  • Chat GPT Search result UI βœ…

    • GetMoviesSuggestions βœ…
      • in this compoennt, get movies name, and movies from redux store βœ…
      • use the same already used > movieList component for display movie cards βœ…
      • map over movie names and multiple movieList components with movies βœ…
  • Securing API Keys βœ…

    • create .env file in root βœ…
    • append REACT_APP_API_KEY_NAME to keys to append it, no strings directly content βœ…
    • when need to use it use process.env.REACT_APP_API_KEY_NAME βœ…
    • add .env file to gitIgnore βœ…
    • store all firebase config also in env βœ…
  • Memoization βœ…

    • for avoiding unnecessry api calls we can memoize, hooks fetching ones βœ…
    • if redux store has data for example moveis, then don't make api call for fetching moveis βœ…
    • do the same for all fetching logics βœ…
    • no need to use useMemo βœ…
    • simply check if store has it, don't call fetch function in useEffect βœ…
  • Make the site mobile responsive βœ…

    • using tailwind βœ…
      • default sm:(tablet min-width:640px) md:(desktop min-width:768px) βœ…
      • mobile first approch, βœ…
        • sm : for tablets βœ…
        • md/lg : for desktop βœ…
        • by default : whatever styling is there would be for mobile βœ…
  • Bug fixes + making the project stable as much as possible βœ…

    • plan once the above points are done ...
    • whever calling tmdb api(s) store hardcode that data, as TMDB is not working βœ…
    • work on the stability of site, without using TMDB make everything working, use hardcoded data whever possible βœ…
    • hero movie text if more then 2 lines, append it with ... βœ…
    • when not connected to vpn taking a lot of time if takes more then 3 seconds display harcoded data βœ…
    • find an alternative for suggested video tmdb issue ❌
      • api issue, gave alter and warning for the same βœ…
    • fix reload issue on firebase live βœ…
  • additional features

    • on click on movie cards take them to movie trailer on youtube βœ…

      • for bgVideo βœ…
      • for other movies cards βœ…
        • plan βœ…
          • give 2 options (btns) βœ…
            • view details βœ…
              • whatever we have in redux store, title, overview etc etc, make use of it and make a opo up card βœ…
            • watch trailer βœ…
              • query youtube with title and sent them to trailer search page, on youtube
          • make all things mobile responsive βœ…
    • add footer in site βœ…

    • bug fix, after clicking on search only, if can't fetch gptsearch then only show then JIO network issue βœ…

    • show hide password option on login form

    • fix login page styling βœ…

    • validation on chatGPT search bar βœ…

    • add buttons for scroll, impplement scroll feature βœ…

    • add google auth also βœ…

    • make google sign in looking good + make feature mobile responsive βœ…

  • Self-branding ❌ -- write a linkedin Post Appreaciating sir Akshay Saini, your own efforts, Additional features, Job fetching post

Features

  • NetFlix Home Page

    • Login / SignUp Form
    • Once logged in redirects to Broswe page
  • Browse Page (After Authentication)

    • Header
    • Hero Movie
      • Trailer in backgorund
      • Title & descirption
      • Movie suggestions
        • Movie list carousel * n
          • Movie * n
  • Netflix GPT

    • Search bar
    • Movie suggestion via AI on search