# nyumat/nyumatflix architecture

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

- Interactive diagram: https://gitdiagram.com/nyumat/nyumatflix
- Repository: https://github.com/nyumat/nyumatflix

## Overview

##### Project type and purpose
- NyumatFlix is a full-stack, server-side-rendered (SSR) streaming-aggregator web application built on Next.js (App Router).
- Its purpose is to fetch and surface movies, TV shows, anime, etc., with filtering, search, pagination, and content-row carousels, sourcing metadata from external APIs (TMDb, FMHY VPS).

##### File structure
- Top-level “app/” directory: Next.js App Router.
- app/page.tsx, app/layout.tsx, plus nested folders for routes (home, movies, tvshows, search, country, genre, watch, etc.).
- app/api/: each folder under app/api/ is a serverless function route that implements data-fetching endpoints (e.g., /api/movies/[id]/route.ts).
- “components/”: UI component library, organized by feature (content, hero, ui primitives, search, tvshow, etc.).
- “lib/”: shared business logic – constants, fetchers, Zustand stores.
- “hooks/”: React hooks to encapsulate client-side state & data fetching.
- “utils/” and “utils/filters.json”: pure utilities and filter definitions.
- “public/”: static assets (preview.png, favicon, etc.).
- Config files: next.config.mjs, tailwind.config.ts, jest/vitest configs, ESLint, Prettier, Husky, Vercel.

##### README for additional insights
- Confirms SSR, Next.js, TypeScript, Tailwind.
- Mentions TMDb + FMHY VPS environment variables.
- Outlines dev scripts and dependencies.

##### Essential elements, but avoid over-fragmentation
- Critical paths: page load, search, filtering, detail page fetch flow.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client Layer"
        direction TB
        Components["UI Component Library"]:::ui
        Hooks["React Hooks"]:::clientdash
        Stores["Zustand Stores"]:::clientdash
    end

    %% CDN / Static Assets
    subgraph "CDN / Static Assets"
        direction TB
        Public["Static Assets"]:::cdn
        Vercel["Vercel Hosting"]:::cdn
    end

    %% Next.js Server (SSR + API)
    subgraph "Next.js Server (SSR + API)" 
        direction TB
        Layout["app/layout.tsx"]:::ssr
        Page["app/page.tsx"]:::ssr
        subgraph "API Routes"
            direction TB
            API_Movies["app/api/movies/route.ts"]:::ssr
            API_MovieId["app/api/movies/[id]/route.ts"]:::ssr
            API_TVSeason["app/api/tv/[id]/season/[seasonNumber]/route.ts"]:::ssr
            API_ContentRows["app/api/content-rows/route.ts"]:::ssr
        end
        subgraph "Business Logic & Utils"
            direction TB
            LibConstants["lib/constants.ts"]:::ssr
            LibRowConfig["lib/content-row-config.ts"]:::ssr
            LibRowFetcher["lib/content-row-fetcher.ts"]:::ssr
            Utils["Utilities & Filters"]:::ssr
        end
    end

    %% External Services
    subgraph "External Services"
        direction TB
        TMDb["TMDb API"]:::external
        VPS["FMHY VPS"]:::external
        VPS2["FMHY VPS2"]:::external
    end

    %% Data Flows
    Public -->|Served via CDN| Vercel
    Vercel -->|Delivers Assets| Components
    Browser["Browser"]:::client -->|Requests Page| Layout
    Layout -->|Loads Root Page| Page
    Page -->|Calls API| API_ContentRows
    Page -->|Calls API| API_Movies
    Page -->|Calls API| API_MovieId
    Page -->|Calls API| API_TVSeason

    API_Movies -->|Uses| LibConstants
    API_Movies -->|Uses| LibRowFetcher
    API_ContentRows -->|Uses| LibRowConfig
    API_MovieId -->|Uses| Utils
    API_TVSeason -->|Uses| Utils

    API_Movies -->|Fetch Metadata| TMDb
    API_MovieId -->|Fetch Details| TMDb
    API_ContentRows -->|Fetch Rows| TMDb
    API_ContentRows -->|Fetch Rows| VPS
    API_TVSeason -->|Fetch Season Data| VPS2

    Components -->|Hydrates| Hooks
    Hooks -->|Client Fetch| API_ContentRows
    Hooks -->|Client Fetch| API_Movies
    Hooks -->|Client Fetch| API_MovieId
    Hooks -->|Client Fetch| API_TVSeason
    Hooks -->|Read/Write| Stores

    %% Click Events
    click Layout "https://github.com/nyumat/nyumatflix/blob/main/app/layout.tsx"
    click Page "https://github.com/nyumat/nyumatflix/blob/main/app/page.tsx"
    click API_Movies "https://github.com/nyumat/nyumatflix/blob/main/app/api/movies/route.ts"
    click API_MovieId "https://github.com/nyumat/nyumatflix/blob/main/app/api/movies/[id]/route.ts"
    click API_TVSeason "https://github.com/nyumat/nyumatflix/blob/main/app/api/tv/[id]/season/[seasonNumber]/route.ts"
    click API_ContentRows "https://github.com/nyumat/nyumatflix/blob/main/app/api/content-rows/route.ts"
    click Components "https://github.com/nyumat/nyumatflix/tree/main/components/"
    click Hooks "https://github.com/nyumat/nyumatflix/tree/main/hooks/"
    click Stores "https://github.com/nyumat/nyumatflix/tree/main/lib/stores/"
    click LibConstants "https://github.com/nyumat/nyumatflix/blob/main/lib/constants.ts"
    click LibRowConfig "https://github.com/nyumat/nyumatflix/blob/main/lib/content-row-config.ts"
    click LibRowFetcher "https://github.com/nyumat/nyumatflix/blob/main/lib/content-row-fetcher.ts"
    click Utils "https://github.com/nyumat/nyumatflix/tree/main/utils/"
    click Public "https://github.com/nyumat/nyumatflix/tree/main/public/"

    %% Styles
    classDef ui fill:#cce5ff,stroke:#000,stroke-width:1px
    classDef ssr fill:#d4edda,stroke:#000,stroke-width:1px
    classDef external fill:#fff3cd,stroke:#000,stroke-width:1px
    classDef cdn fill:#e2e3e5,stroke:#000,stroke-width:1px
    classDef clientdash fill:#f8d7da,stroke:#000,stroke-width:1px,stroke-dasharray: 5 5
    class Browser clientdash
```
