# ruslan-zhabskyi/moviesappassignment architecture

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

- Interactive diagram: https://gitdiagram.com/ruslan-zhabskyi/moviesappassignment
- Repository: https://github.com/ruslan-zhabskyi/moviesappassignment

## Overview

##### Main Components
- API Integration Layer: Include a component for the API calls (tmdb-api.ts) that connects to the external TMDB endpoints. Also show the use of the Supabase client and the LlamaAPI integration used in components like fantasyMovieForm and dialogButton.
- State/Context Management: A designated block representing React context providers (authContext, moviesContext, peopleContext, languageContext) that manage global state and authentication.
– TMDB API (for movie and actor data)
– Supabase (used for authentication via magic link)
– LlamaAPI (enhances fantasy movie creation with GenAI)

##### Relationships and Interactions
- Protected and public route flow: show how navigation flows into the ProtectedRoute component that makes decisions based on authentication state supplied by the authContext.

##### Architectural Patterns and Design Principles
- Component-Based Architecture: All UI pieces are modular, reusable, and reside under src/components; emphasize separation of concerns by segregating UI, state management, and API integration.
- Context API & Custom Hooks: Illustrate that shared state and logic are abstracted via React Contexts and custom hooks (such as useMovie, useFiltering).
- External Abstraction: The reliance on external APIs for data and authentication is crucial; list these as separate entities outside the core app with clearly defined interfaces.

##### Incorporate Relevant Technologies, Frameworks, and Libraries
- React (component and page structure)
- Storybook (for UI testing and development)
- Supabase (for authentication)
- LlamaAPI (for fantasy movie GenAI)
- Axios (or similar HTTP client used in the API layer)
- TMDB API as the primary data source for movie and actor information

##### Elements
- Annotations or labels that describe the purpose of each component (e.g., “UserAuth handles login using Supabase”, “FantasyMovieForm integrates with LlamaAPI”, etc.).

## Diagram (Mermaid)

```mermaid
graph TD
    %% Frontend UI Layer
    subgraph "Frontend UI Layer"
        subgraph "Pages/Views"
            HomePage["HomePage (src/pages/homePage.tsx)"]:::pages
            MovieDetailsPage["MovieDetailsPage (src/pages/movieDetailsPage.tsx)"]:::pages
            LoginPage["LoginPage (src/pages/loginPage.tsx)"]:::pages
            FantasyMoviePage["FantasyMoviePage (src/pages/fantasyMoviePage.tsx)"]:::pages
        end
        subgraph "React Components"
            Components["UI Components (src/components)"]:::components
            subgraph "Card Icons"
                AddToFavourites["AddToFavourites (src/components/cardIcons/addToFavourites.tsx)"]:::components
                AddToWatchList["AddToWatchList (src/components/cardIcons/addToWatchList.tsx)"]:::components
                RemoveFromFavourites["RemoveFromFavourites (src/components/cardIcons/removeFromFavourites.tsx)"]:::components
            end
            FantasyMovieForm["FantasyMovieForm (src/components/fantasyMovieForm/index.tsx)"]:::components
            ProtectedRoute["ProtectedRoute (src/components/protectedRoute/protectedRoute.tsx)"]:::routing
        end
    end

    %% State & Hooks
    subgraph "State & Hooks"
        subgraph "Context Providers"
            AuthContext["AuthContext (src/contexts/authContext.tsx)"]:::context
            MoviesContext["MoviesContext (src/contexts/moviesContext.tsx)"]:::context
            PeopleContext["PeopleContext (src/contexts/peopleContext.tsx)"]:::context
            LanguageContext["LanguageContext (src/contexts/languageContext.tsx)"]:::context
        end
        subgraph "Custom Hooks"
            UseMovie["useMovie (src/hooks/useMovie.ts)"]:::hooks
            UseFiltering["useFiltering (src/hooks/useFiltering.ts)"]:::hooks
        end
    end

    %% API Integration Layer
    subgraph "API Integration"
        TMDBAPI["TMDB API Service (src/api/tmdb-api.ts)"]:::api
    end

    %% External Services
    subgraph "External Services"
        ExternalTMDB["TMDB API"]:::external
        Supabase["Supabase Auth (src/supabaseClient.js)"]:::external
        LlamaAPI["LlamaAPI"]:::external
    end

    %% Development Tools
    subgraph "Development Tools"
        Storybook["Storybook Environment (.storybook & src/stories)"]:::storybook
    end

    %% Connections between Pages and Components
    HomePage -->|"renders"| Components
    MovieDetailsPage -->|"renders"| Components
    LoginPage -->|"renders"| Components
    FantasyMoviePage -->|"renders"| Components

    %% Components and Context Interaction
    Components -->|"consumes"| AuthContext
    Components -->|"consumes"| MoviesContext
    Components -->|"consumes"| PeopleContext
    Components -->|"consumes"| LanguageContext

    %% Components using API Integration
    Components -->|"calls"| TMDBAPI
    TMDBAPI -->|"fetches from"| ExternalTMDB

    %% Protected Routes and Authentication Flow
    Components -->|"uses"| ProtectedRoute
    ProtectedRoute -->|"checks"| AuthContext
    AuthContext -->|"authenticates via"| Supabase

    %% Fantasy Movie Integration
    FantasyMovieForm -->|"integrates with"| LlamaAPI

    %% Custom Hooks usage
    Components -->|"utilizes"| UseMovie
    Components -->|"utilizes"| UseFiltering
    AuthContext -->|"leverages"| UseMovie
    MoviesContext -->|"leverages"| UseFiltering

    %% Storybook for isolated development
    Storybook ---|"develops"| Components

    %% Click Events
    click HomePage "https://github.com/ruslan-zhabskyi/moviesappassignment/blob/master/src/pages/homePage.tsx"
    click MovieDetailsPage "https://github.com/ruslan-zhabskyi/moviesappassignment/blob/master/src/pages/movieDetailsPage.tsx"
    click LoginPage "https://github.com/ruslan-zhabskyi/moviesappassignment/blob/master/src/pages/loginPage.tsx"
    click FantasyMoviePage "https://github.com/ruslan-zhabskyi/moviesappassignment/blob/master/src/pages/fantasyMoviePage.tsx"
    click Components "https://github.com/ruslan-zhabskyi/moviesappassignment/tree/master/src/components"
    click AddToFavourites "https://github.com/ruslan-zhabskyi/moviesappassignment/tree/master/src/components/cardIcons"
    click AddToWatchList "https://github.com/ruslan-zhabskyi/moviesappassignment/tree/master/src/components/cardIcons"
    click RemoveFromFavourites "https://github.com/ruslan-zhabskyi/moviesappassignment/tree/master/src/components/cardIcons"
    click FantasyMovieForm "https://github.com/ruslan-zhabskyi/moviesappassignment/blob/master/src/components/fantasyMovieForm/index.tsx"
    click ProtectedRoute "https://github.com/ruslan-zhabskyi/moviesappassignment/blob/master/src/components/protectedRoute/protectedRoute.tsx"
    click TMDBAPI "https://github.com/ruslan-zhabskyi/moviesappassignment/blob/master/src/api/tmdb-api.ts"
    click AuthContext "https://github.com/ruslan-zhabskyi/moviesappassignment/blob/master/src/contexts/authContext.tsx"
    click MoviesContext "https://github.com/ruslan-zhabskyi/moviesappassignment/blob/master/src/contexts/moviesContext.tsx"
    click PeopleContext "https://github.com/ruslan-zhabskyi/moviesappassignment/blob/master/src/contexts/peopleContext.tsx"
    click LanguageContext "https://github.com/ruslan-zhabskyi/moviesappassignment/blob/master/src/contexts/languageContext.tsx"
    click UseMovie "https://github.com/ruslan-zhabskyi/moviesappassignment/blob/master/src/hooks/useMovie.ts"
    click UseFiltering "https://github.com/ruslan-zhabskyi/moviesappassignment/blob/master/src/hooks/useFiltering.ts"
    click Supabase "https://github.com/ruslan-zhabskyi/moviesappassignment/blob/master/src/supabaseClient.js"
    click Storybook "https://github.com/ruslan-zhabskyi/moviesappassignment/blob/master/.storybook"

    %% Styles
    classDef pages fill:#bbdefb,stroke:#0d47a1,stroke-width:2px;
    classDef components fill:#c8e6c9,stroke:#2e7d32,stroke-width:2px;
    classDef context fill:#fff9c4,stroke:#f9a825,stroke-width:2px;
    classDef routing fill:#ffe0b2,stroke:#ef6c00,stroke-width:2px;
    classDef api fill:#ffcdd2,stroke:#c62828,stroke-width:2px;
    classDef external fill:#d1c4e9,stroke:#512da8,stroke-width:2px;
    classDef hooks fill:#f0f4c3,stroke:#558b2f,stroke-width:2px;
    classDef storybook fill:#b2dfdb,stroke:#00796b,stroke-width:2px;
```
