# ashishyadav85270/netflix-gpt architecture

> Architecture diagram of the GitHub repository ashishyadav85270/netflix-gpt, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ashishyadav85270/netflix-gpt
- Repository: https://github.com/ashishyadav85270/netflix-gpt

## Overview

##### Project type and purpose
- This is a single‐page application (SPA) built with React (Create React App) and Tailwind CSS.
- It uses Firebase for user authentication and hosting, Redux (via Redux Toolkit slices) for state management, and external APIs (TMDB for movie data and an OpenAI/GPT endpoint for “Netflix GPT” movie suggestions).
- The end goal is a Netflix‐style browsing interface where users log in, browse trailers and movie cards, and use a GPT‐powered search page.

##### File structure
- Top‐level files:
- package.json / package-lock.json → dependencies & scripts
- firebase.json / .firebaserc → Firebase hosting & config
- tailwind.config.js → Tailwind CSS setup
- public/ → static assets & index.html
- src/
- App.js, index.js, App.css → entry points
- components/ → UI components (Header, Body, Browse, MovieCard, VideoBackground, GptSearchBar, etc.)
- hooks/ → custom React hooks to fetch TMDB data (now playing, trending, etc.)
- utils/ → Redux slices (moviesSlice, userSlice, gptSlice, configSlice), Firebase wrapper (firebase.js), common constants, language files, store setup

##### README
- Confirms React + Tailwind + Firebase Auth + Redux + Formik
- Describes core features: login/signup → Browse page with trailers, movie lists → GPT‐powered search/suggestions
- Notes use of TMDB API and custom hooks; multi‐language support on GPT search

##### Main components
a. Client (Browser)
- React SPA runs in user’s browser after being served as static files (via Firebase Hosting).
- UI components (Header, Browse page, GptSearch page)
- State management: Redux store with slices (userSlice, moviesSlice, gptSlice, configSlice)
- Custom hooks connect UI to external APIs.
b. Firebase Hosting & Auth
- Hosts the static React build
- Provides Authentication (onAuthStateChanged)
c. External APIs
- TMDB API → movie data (now playing, trending, top rated, etc.)
- OpenAI/GPT API → dynamic suggestions based on user query
d. (Optional) Cloud Functions / Proxy

##### Relationships and data flow
1. User → Browser loads index.html from Firebase Hosting
2. React SPA initializes → Redux store bootstraps
3. User attempts SignUp / Login → Firebase Auth SDK call → Firebase Auth service → SDK callback updates userSlice
4. Authenticated user redirected to Browse route → React triggers custom hooks → fetch calls to TMDB API → responses stored in moviesSlice
5. Browse page components read from Redux store → display video background, movie cards, lists
6. On GPT Search page: user enters query → dispatch action in gptSlice → fetch to OpenAI/GPT endpoint → response stored in gptSlice → UI renders suggestions

##### Architectural patterns & design principles
- Component‐based UI (React)
- Unidirectional data flow (Redux)
- Separation of concerns:
- UI in components/
- Data fetching in hooks/
- State logic in utils/*.slice.js
- Configuration in constants.js & configSlice
- Static hosting + client‐side rendering with third‐party API calls

##### Elements
- Clear, descriptive labels (component names, file paths, service names)
- A note on hosting: “Firebase Hosting serves the React build from public/”

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Firebase Services
    subgraph "Firebase Services"
        Hosting["Firebase Hosting"]:::firebase
        AuthService["Firebase Auth"]:::firebase
    end

    %% External APIs
    subgraph "External APIs"
        TMDB["TMDB API"]:::external
        GPTAPI["OpenAI/GPT API"]:::external
    end

    %% Client Browser
    subgraph "Client Browser"
        ReactEntry["index.js"]:::client
        RootApp["App.js"]:::client
        ReduxStore["Redux Store\n(src/utils/appStore.js)"]:::client

        subgraph "Redux Slices"
            UserSlice["userSlice"]:::client
            MoviesSlice["moviesSlice"]:::client
            GPTSlice["gptSlice"]:::client
            ConfigSlice["configSlice"]:::client
        end

        subgraph "Custom Hooks"
            NowPlaying["useNowPlayingMovies"]:::client
            Trending["useGetTrendingMovies"]:::client
            TopRated["useGetTopRatedMovies"]:::client
            Upcoming["useGetUpcomingMovies"]:::client
            Popular["usePopularMovies"]:::client
            MovieVideos["useGetMoviesVideos"]:::client
        end

        subgraph "UI Components"
            subgraph "Browse Page Components"
                Header["Header"]:::client
                Body["Body"]:::client
                MainContainer["MainContainer"]:::client
                SecondaryContainer["SecondaryContainer"]:::client
                BrowsePage["Browse"]:::client
                VideoBackground["VideoBackground"]:::client
                VideoTitle["VideoTitle"]:::client
                MovieList["MovieList"]:::client
                MovieCard["MovieCard"]:::client
            end
            subgraph "Authentication Components"
                Login["Login/Signup"]:::client
                UserDropdown["UserDropdown"]:::client
            end
            subgraph "GPT Search Components"
                GPTSearchPage["GptSearch"]:::client
                GPTSearchBar["GptSearchBar"]:::client
                GPTSuggestions["GptMovieSuggestions"]:::client
            end
        end
    end

    %% Static & Config Files
    StaticHTML["public/index.html"]:::client
    PackageJSON["package.json"]:::client
    PackageLock["package-lock.json"]:::client
    Tailwind["tailwind.config.js"]:::client
    FirebaseJson["firebase.json"]:::client
    Firebaserc[".firebaserc"]:::client
    FirebaseWrapper["firebase.js"]:::client
    Constants["constants.js"]:::client
    Languages["languages.js"]:::client

    %% Data Flows
    Hosting -->|"serves public/index.html"| StaticHTML
    StaticHTML -->|"loads bundle"| ReactEntry
    ReactEntry -->|"renders"| RootApp
    RootApp -->|"bootstraps"| ReduxStore
    ReduxStore --> UserSlice
    ReduxStore --> MoviesSlice
    ReduxStore --> GPTSlice
    ReduxStore --> ConfigSlice

    %% Auth Flow
    RootApp -->|"init auth"| AuthService
    AuthService -->|"onAuthStateChanged"| UserSlice
    Header -->|"dispatch signOut"| AuthService

    %% Movie Data Flow
    BrowsePage --> NowPlaying
    BrowsePage --> Trending
    BrowsePage --> TopRated
    BrowsePage --> Upcoming
    BrowsePage --> Popular
    BrowsePage --> MovieVideos

    NowPlaying -->|"GET"| TMDB
    Trending -->|"GET"| TMDB
    TopRated -->|"GET"| TMDB
    Upcoming -->|"GET"| TMDB
    Popular -->|"GET"| TMDB
    MovieVideos -->|"GET"| TMDB

    NowPlaying --> MoviesSlice
    Trending --> MoviesSlice
    TopRated --> MoviesSlice
    Upcoming --> MoviesSlice
    Popular --> MoviesSlice
    MovieVideos --> MoviesSlice

    MoviesSlice --> MovieList
    MovieList --> MovieCard
    VideoBackground --> BrowsePage
    VideoTitle --> BrowsePage

    %% GPT Search Flow
    GPTSearchPage --> GPTSearchBar
    GPTSearchBar -->|"dispatch gptRequest"| GPTAPI
    GPTAPI -->|"response"| GPTSlice
    GPTSlice --> GPTSuggestions

    %% Click Events
    click ReactEntry "https://github.com/ashishyadav85270/netflix-gpt/blob/master/src/index.js"
    click RootApp "https://github.com/ashishyadav85270/netflix-gpt/blob/master/src/App.js"
    click StaticHTML "https://github.com/ashishyadav85270/netflix-gpt/blob/master/public/index.html"
    click PackageJSON "https://github.com/ashishyadav85270/netflix-gpt/blob/master/package.json"
    click PackageLock "https://github.com/ashishyadav85270/netflix-gpt/blob/master/package-lock.json"
    click Tailwind "https://github.com/ashishyadav85270/netflix-gpt/blob/master/tailwind.config.js"
    click FirebaseJson "https://github.com/ashishyadav85270/netflix-gpt/blob/master/firebase.json"
    click Firebaserc "https://github.com/ashishyadav85270/netflix-gpt/blob/master/.firebaserc"
    click ReduxStore "https://github.com/ashishyadav85270/netflix-gpt/blob/master/src/utils/appStore.js"
    click UserSlice "https://github.com/ashishyadav85270/netflix-gpt/blob/master/src/utils/userSlice.js"
    click MoviesSlice "https://github.com/ashishyadav85270/netflix-gpt/blob/master/src/utils/moviesSlice.js"
    click GPTSlice "https://github.com/ashishyadav85270/netflix-gpt/blob/master/src/utils/gptSlice.js"
    click ConfigSlice "https://github.com/ashishyadav85270/netflix-gpt/blob/master/src/utils/configSlice.js"
    click FirebaseWrapper "https://github.com/ashishyadav85270/netflix-gpt/blob/master/src/utils/firebase.js"
    click Constants "https://github.com/ashishyadav85270/netflix-gpt/blob/master/src/utils/constants.js"
    click Languages "https://github.com/ashishyadav85270/netflix-gpt/blob/master/src/utils/languages.js"
    click NowPlaying "https://github.com/ashishyadav85270/netflix-gpt/blob/master/src/hooks/useNowPlayingMovies.js"
    click Trending "https://github.com/ashishyadav85270/netflix-gpt/blob/master/src/hooks/useGetTrendingMovies.js"
    click TopRated "https://github.com/ashishyadav85270/netflix-gpt/blob/master/src/hooks/useGetTopRatedMovies.js"
    click Upcoming "https://github.com/ashishyadav85270/netflix-gpt/blob/master/src/hooks/useGetUpcomingMovies.js"
    click Popular "https://github.com/ashishyadav85270/netflix-gpt/blob/master/src/hooks/usePopularMovies.js"
    click MovieVideos "https://github.com/ashishyadav85270/netflix-gpt/blob/master/src/hooks/useGetMoviesVideos.js"
    click Header "https://github.com/ashishyadav85270/netflix-gpt/blob/master/src/components/Header.js"
    click Body "https://github.com/ashishyadav85270/netflix-gpt/blob/master/src/components/Body.js"
    click MainContainer "https://github.com/ashishyadav85270/netflix-gpt/blob/master/src/components/MainContainer.js"
    click SecondaryContainer "https://github.com/ashishyadav85270/netflix-gpt/blob/master/src/components/SecondaryContainer.js"
    click BrowsePage "https://github.com/ashishyadav85270/netflix-gpt/blob/master/src/components/Browse.js"
    click VideoBackground "https://github.com/ashishyadav85270/netflix-gpt/blob/master/src/components/VideoBackground.js"
    click VideoTitle "https://github.com/ashishyadav85270/netflix-gpt/blob/master/src/components/VideoTitle.js"
    click MovieList "https://github.com/ashishyadav85270/netflix-gpt/blob/master/src/components/MovieList.js"
    click MovieCard "https://github.com/ashishyadav85270/netflix-gpt/blob/master/src/components/MovieCard.js"
    click Login "https://github.com/ashishyadav85270/netflix-gpt/blob/master/src/components/Login.js"
    click UserDropdown "https://github.com/ashishyadav85270/netflix-gpt/blob/master/src/utils/UserDropdown.js"
    click GPTSearchPage "https://github.com/ashishyadav85270/netflix-gpt/blob/master/src/components/GptSearch.js"
    click GPTSearchBar "https://github.com/ashishyadav85270/netflix-gpt/blob/master/src/components/GptSearchBar.js"
    click GPTSuggestions "https://github.com/ashishyadav85270/netflix-gpt/blob/master/src/components/GptMovieSuggestions.js"

    %% Styles
    classDef client fill:#D6EFFF,stroke:#333,stroke-width:1px
    classDef firebase fill:#D5F5E3,stroke:#333,stroke-width:1px
    classDef external fill:#FDEBD0,stroke:#333,stroke-width:1px
```
