# koya-tech/primevideo-clone architecture

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

- Interactive diagram: https://gitdiagram.com/koya-tech/primevideo-clone
- Repository: https://github.com/koya-tech/primevideo-clone

## Overview

##### Project Type and Purpose
- This is a front-end only clone of a streaming platform built with React and Vite. It displays movie and TV show information by consuming data from the TMDB and Youtube APIs.
- The README confirms that it uses modern web technologies (React, Vite, Tailwind CSS, shadcn UI) and emphasizes features like dark mode and smooth UI animations.

##### Analyzing the File Structure
- The entire application lives under the “frontend” directory. This underscores a single-page application (SPA) approach without a separate backend.
- The “src” folder within “frontend” contains clearly defined subdirectories:
- “components” – organized further into sections like about, common, detail, home, and ui. This shows a modular, component-based architecture.
- “contexts” – includes a DarkModeContext, which is likely used to control theme switching across components.
- “hooks” – custom hooks such as useDarkMode indicate reusable logic for state management.
- “lib” – contains utility functions and data fetching modules (like fetchData, fetchMovieDetail, etc.) which abstract the interactions with external APIs (TMDB and Youtube).
- “providers” – holds providers for wrapping the application with context support (e.g., DarkProvider).
- Additionally, configuration files (e.g., vite.config.ts, tailwind.config.js, tsconfig files) are present to support the development and build process.

##### Key Components
a. Core UI Layer:
- React Components for pages and UI elements (organized in directories like “home”, “detail”, and “common” such as Header, Footer, ToggleButton).
- UI library elements from shadcn UI and styling using Tailwind CSS.

b. Data Layer:
- Utility modules in the “lib” directory that handle data fetching from the TMDB API and Youtube API.
- Data transformation logic to convert API responses into a format that UI components can use.

c. State Management:
- Contexts (e.g., DarkModeContext) and custom hooks (e.g., useDarkMode) to manage application state like theme preferences.
- Providers (e.g., DarkProvider) that wrap parts of the application to supply global state.

d. External Services:
- TMDB API for movie and TV show data.
- Youtube API for additional media information.
- Environment variables configured via a .env file to secure API keys.

##### Relationships and Interactions
- From the entry point, the App component renders the different pages (Home, Detail, About, etc.) under the components directory.
- UI components leverage the “contexts” and “hooks” to manage global state (for example, toggling dark mode).
- From the UI components → to the “lib” layer for data retrieval.
- From “lib” → to external APIs (TMDB and Youtube), with the data then flowing back to the UI.
- Configuration and build layers (Vite, Tailwind, ESLint, etc.) are shown as supporting elements in the background to indicate development and build orchestration.

##### Architectural Patterns and Design Principles
- Clearly separate concerns: UI rendering, state management, and data fetching.
- The use of contexts and providers signals dependency injection and shared global state patterns.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Entry Layer"
        A["main.tsx"]:::entry
        B["App.tsx"]:::entry
    end

    subgraph "Presentation Layer (UI Components)"
        C["UI Components (about, common, detail, home, ui)"]:::ui
    end

    subgraph "State Management Layer"
        D["DarkModeContext"]:::state
        E["useDarkMode"]:::state
        F["DarkProvider"]:::state
    end

    subgraph "Data Fetching Layer"
        G["Data Lib (fetchData, fetchMovieDetail, fetchYoutubeInfo)"]:::data
    end

    subgraph "External APIs"
        H["TMDB API"]:::external
        I["Youtube API"]:::external
    end

    A -->|"initializes"| B
    B -->|"renders"| C
    C -->|"uses"| D
    C -->|"uses"| E
    C -->|"wrappedBy"| F
    C -->|"calls"| G
    G -->|"fetchesFrom"| H
    G -->|"fetchesFrom"| I

    click A "https://github.com/koya-tech/primevideo-clone/blob/main/frontend/src/main.tsx"
    click B "https://github.com/koya-tech/primevideo-clone/blob/main/frontend/src/App.tsx"
    click C "https://github.com/koya-tech/primevideo-clone/tree/main/frontend/src/components"
    click G "https://github.com/koya-tech/primevideo-clone/tree/main/frontend/src/lib"
    click D "https://github.com/koya-tech/primevideo-clone/blob/main/frontend/src/contexts/DarkModeContext.tsx"
    click F "https://github.com/koya-tech/primevideo-clone/blob/main/frontend/src/providers/DarkProvider.tsx"
    click E "https://github.com/koya-tech/primevideo-clone/blob/main/frontend/src/hooks/useDarkMode.ts"

    classDef entry fill:#f0f4c3,stroke:#afb42b,stroke-width:2px,color:#000;
    classDef ui fill:#bbdefb,stroke:#0d47a1,stroke-width:2px,color:#000;
    classDef data fill:#c8e6c9,stroke:#2e7d32,stroke-width:2px,color:#000;
    classDef state fill:#e1bee7,stroke:#6a1b9a,stroke-width:2px,color:#000;
    classDef external fill:#ffe0b2,stroke:#ef6c00,stroke-width:2px,color:#000;
```
