# damon248/disney-clone-new architecture

> Architecture diagram of the GitHub repository damon248/disney-clone-new, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/damon248/disney-clone-new
- Repository: https://github.com/damon248/disney-clone-new

## Overview

##### Project Type and Purpose
- This is a full-stack, server-side-rendered (SSR) Next.js application with built-in React components and serverless functions.
- Purpose: Browse movie data (by genre or search term) and get AI-generated suggestions.

##### Main Components
a. Frontend (Next.js “app” directory)
- app/layout.tsx, app/page.tsx: Root layout and home page
- app/genre/[id]/page.tsx & app/search/[term]/page.tsx: Dynamic genre/search pages
- Global styles (app/globals.css) & Tailwind configuration
- React components in /components (UI primitives under /components/ui)
- ThemeProvider and ThemeToggler for theming
b. Backend / Serverless Functions (functions directory)
- getAiSuggestions.ts: Azure-style (host.json) function that calls OpenAI or another LLM
c. Utilities / Libraries (lib directory)
- getMovies.tsx, getImagePath.tsx, utils.ts: Shared helpers for fetching and formatting TMDB data
d. External Services
- TMDB API (movie data, images)
- OpenAI or AI service (for “AI suggestions”)
e. Configuration & Deployment
- next.config.js, tsconfig.json, tailwind.config.js, package.json — define build, linting, and deployment settings
- .funcignore, host.json — Azure Functions configuration

##### Relationships & Data Flows
- Browser <–> Next.js Frontend: SSR/SSG pages request data at build time or on demand
- Frontend → Serverless Function: e.g., user clicks “Get AI Suggestions” → fetch to /api/suggestions
- Serverless Function → AI Service: Function calls LLM, returns suggestions JSON
- Frontend / Utility Libraries → TMDB API: getMovies, getImagePath call TMDB to fetch movie lists/images
- Static Assets served from public folder

##### Architectural Patterns & Principles
- Component-based UI (atomic UI primitives under /components/ui)
- App Router (Next.js v13+) for file-based routing and layout nesting
- Serverless API layer (“functions” folder) separated from frontend code
- Shared utils to avoid duplication (lib folder)
- Theming via React Context (ThemeProvider)

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Client"
        Browser["Browser"]:::client
    end

    subgraph "Frontend (Next.js SSR)"
        Layout["Root Layout\napp/layout.tsx"]:::frontend
        Home["Home Page\napp/page.tsx"]:::frontend
        subgraph "Dynamic Pages"
            Genre["Genre Page\napp/genre/[id]/page.tsx"]:::frontend
            Search["Search Page\napp/search/[term]/page.tsx"]:::frontend
        end
        subgraph "UI Components"
            ThemeProvider["ThemeProvider\ncomponents/ThemeProvider.tsx"]:::frontend
            ThemeToggler["ThemeToggler\ncomponents/ThemeToggler.tsx"]:::frontend
            AiSuggestionUI["AI Suggestion UI\ncomponents/AiSuggestion.tsx"]:::frontend
            Carousel["Carousel Banner Wrapper\ncomponents/CarouselBannerWrapper.tsx"]:::frontend
            MovieCard["Movie Card\ncomponents/MovieCard.tsx"]:::frontend
            MoviesCarousel["Movies Carousel\ncomponents/MoviesCarousel.tsx"]:::frontend
            GenreDropdown["Genre Dropdown\ncomponents/GenreDropdown.tsx"]:::frontend
            SearchInput["Search Input\ncomponents/SearchInput.tsx"]:::frontend
            Header["Header\ncomponents/Header.tsx"]:::frontend
        end
        subgraph "UI Primitives"
            UIButton["UI Button\ncomponents/ui/button.tsx"]:::frontend
            UIDropdown["UI Dropdown Menu\ncomponents/ui/dropdown-menu.tsx"]:::frontend
            UIForm["UI Form\ncomponents/ui/form.tsx"]:::frontend
            UIInput["UI Input\ncomponents/ui/input.tsx"]:::frontend
            UILabel["UI Label\ncomponents/ui/label.tsx"]:::frontend
        end
        subgraph "Styles & Config"
            Globals["Global Stylesheet\napp/globals.css"]:::config
            TailwindCfg["Tailwind Config\ntailwind.config.js"]:::config
            NextCfg["Next.js Config\nnext.config.js"]:::config
        end
    end

    subgraph "Utilities (lib)"
        MoviesUtil["getMovies Helper\nlib/getMovies.tsx"]:::util
        ImageUtil["getImagePath Helper\nlib/getImagePath.tsx"]:::util
        SharedUtil["Shared Utils\nlib/utils.ts"]:::util
    end

    subgraph "Serverless Functions"
        APIRoute["API Route\napp/api/suggestions/route.ts"]:::functions
        subgraph "Azure Functions"
            HostCfg["host.json\nfunctions/host.json"]:::config
            FuncIgnore[".funcignore\nfunctions/.funcignore"]:::config
            FuncPkg["package.json\nfunctions/package.json"]:::config
            FuncSrc["Source Dir\nfunctions/src/functions"]:::functions
            GetAiFunc["getAiSuggestions\nfunctions/src/functions/getAiSuggestions.ts"]:::functions
        end
    end

    subgraph "External Services"
        TMDB["TMDB API"]:::external
        AIService["AI Service\nOpenAI"]:::external
    end

    Browser -->|"HTTP SSR/SSG"| Layout
    Layout --> Home
    Layout --> Genre
    Layout --> Search

    Home --> Header
    Home --> Carousel
    Home --> MoviesCarousel

    Genre --> MovieCard
    Genre --> GenreDropdown

    Search --> SearchInput
    Search --> MovieCard

    Home --> MoviesUtil
    Genre --> MoviesUtil
    Search --> MoviesUtil
    MoviesUtil -->|REST JSON| TMDB

    Home --> ImageUtil
    Genre --> ImageUtil
    Search --> ImageUtil
    ImageUtil --> TMDB

    MovieCard --> SharedUtil

    Browser -->|"Click Get AI Suggestions"| AiSuggestionUI
    AiSuggestionUI -->|"POST /api/suggestions"| APIRoute
    APIRoute --> GetAiFunc
    GetAiFunc -->|"Calls LLM"| AIService
    APIRoute --> SharedUtil
    APIRoute --> MoviesUtil

    NextCfg --> Layout
    HostCfg --> GetAiFunc

    click Layout "https://github.com/damon248/disney-clone-new/blob/master/app/layout.tsx"
    click Home "https://github.com/damon248/disney-clone-new/blob/master/app/page.tsx"
    click Genre "https://github.com/damon248/disney-clone-new/blob/master/app/genre/[id]/page.tsx"
    click Search "https://github.com/damon248/disney-clone-new/blob/master/app/search/[term]/page.tsx"
    click Globals "https://github.com/damon248/disney-clone-new/blob/master/app/globals.css"
    click TailwindCfg "https://github.com/damon248/disney-clone-new/blob/master/tailwind.config.js"
    click NextCfg "https://github.com/damon248/disney-clone-new/blob/master/next.config.js"
    click ThemeProvider "https://github.com/damon248/disney-clone-new/blob/master/components/ThemeProvider.tsx"
    click ThemeToggler "https://github.com/damon248/disney-clone-new/blob/master/components/ThemeToggler.tsx"
    click AiSuggestionUI "https://github.com/damon248/disney-clone-new/blob/master/components/AiSuggestion.tsx"
    click Carousel "https://github.com/damon248/disney-clone-new/blob/master/components/CarouselBannerWrapper.tsx"
    click MovieCard "https://github.com/damon248/disney-clone-new/blob/master/components/MovieCard.tsx"
    click MoviesCarousel "https://github.com/damon248/disney-clone-new/blob/master/components/MoviesCarousel.tsx"
    click GenreDropdown "https://github.com/damon248/disney-clone-new/blob/master/components/GenreDropdown.tsx"
    click SearchInput "https://github.com/damon248/disney-clone-new/blob/master/components/SearchInput.tsx"
    click Header "https://github.com/damon248/disney-clone-new/blob/master/components/Header.tsx"
    click UIButton "https://github.com/damon248/disney-clone-new/blob/master/components/ui/button.tsx"
    click UIDropdown "https://github.com/damon248/disney-clone-new/blob/master/components/ui/dropdown-menu.tsx"
    click UIForm "https://github.com/damon248/disney-clone-new/blob/master/components/ui/form.tsx"
    click UIInput "https://github.com/damon248/disney-clone-new/blob/master/components/ui/input.tsx"
    click UILabel "https://github.com/damon248/disney-clone-new/blob/master/components/ui/label.tsx"
    click APIRoute "https://github.com/damon248/disney-clone-new/blob/master/app/api/suggestions/route.ts"
    click HostCfg "https://github.com/damon248/disney-clone-new/blob/master/functions/host.json"
    click FuncIgnore "https://github.com/damon248/disney-clone-new/blob/master/functions/.funcignore"
    click FuncPkg "https://github.com/damon248/disney-clone-new/blob/master/functions/package.json"
    click FuncSrc "https://github.com/damon248/disney-clone-new/tree/master/functions/src/functions"
    click GetAiFunc "https://github.com/damon248/disney-clone-new/blob/master/functions/src/functions/getAiSuggestions.ts"
    click MoviesUtil "https://github.com/damon248/disney-clone-new/blob/master/lib/getMovies.tsx"
    click ImageUtil "https://github.com/damon248/disney-clone-new/blob/master/lib/getImagePath.tsx"
    click SharedUtil "https://github.com/damon248/disney-clone-new/blob/master/lib/utils.ts"
    classDef client fill:#E3F2FD,stroke:#90CAF9
    classDef frontend fill:#BBDEFB,stroke:#2196F3
    classDef functions fill:#C8E6C9,stroke:#4CAF50
    classDef external fill:#FFE0B2,stroke:#FB8C00
    classDef util fill:#E0E0E0,stroke:#9E9E9E
    classDef config fill:#FFF9C4,stroke:#FBC02D
```
