# nasrokamora/app6 architecture

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

- Interactive diagram: https://gitdiagram.com/nasrokamora/app6
- Repository: https://github.com/nasrokamora/app6

## Overview

##### Project type and purpose
- This is a full-stack Next.js web application for browsing, streaming, and interacting with Movies & TV Shows data.
- The front-end is implemented with Next.js (App Router, SSR/ISR/SSG), Tailwind CSS, ShadcnUI, Magic UI, Framer Motion and Zod for validation.
- The back-end is built into Next.js via API routes (serverless functions) that proxy to external services (TMDB API, KindeAuth, Upstash Redis).

##### File structure
- Top-level “app” directory: main Next.js App Router folder containing pages, UI components, layouts, global styles, parallel routes for `/movies`, `/tv`, `/person`.
- “app/api”: Next.js serverless functions (e.g., fetchGenres, getMoviesById, auth routes, streaming route).
- “app/libs”: utility modules for data-fetching, Redis caching, error handling, URL construction, Zod schemas.
- “app/Components”, “app/(movies)”, “app/(tv)”, “app/(person)”: UI component hierarchies for each domain (movies, TV, person)—modular, nested by route.
- “components/ui”: shared ShadcnUI-based primitives (buttons, dialogs, cards, etc.).
- Configuration files: next.config.mjs, tailwind.config.js, jsconfig.json, postcss.config.js.

##### README for additional insights
- Key external dependencies: TMDB API, KindeAuth (authentication), Upstash Redis (caching), Vercel (hosting/CDN).
- Feature list: dynamic routing for movies, TV shows, person details, TV seasons/episodes; movie streaming endpoint; SSR/ISR/SSG; brand-new streaming feature.

a. Frontend Layer:
- Next.js App (App Router)
- ShadcnUI/Magic UI components, Tailwind CSS styling
- Framer Motion animations, React Context & custom hooks
- Browser/Device

b. Backend Layer (Next.js Serverless Functions):
- API Routes under `app/api/*`
- `/fetch*`, `/get*` routes (TMDB proxies)
- `/auth/*` routes (KindeAuth integration, session fetch)
- `/Streaming/route.js` (movie streaming endpoint)
- Utility libs (`app/libs`) for data-fetch, Redis cache, error handling, Zod schemas

c. External Services:
- TMDB REST API (movies & TV data)
- KindeAuth (OAuth-style user authentication)
- Upstash Redis (serverless caching layer)
- Vercel CDN & Edge (hosting, SSR, ISR, static assets)

##### Relationships & interactions
- Browser → Vercel CDN (static assets, SSR pages)
- Browser → Next.js client code (React components, client-side data fetch via SWR/hooks)
- Next.js server (SSR/ISR) → internal API routes →
- First checks Redis cache →
– If cached, returns data
– Else calls TMDB API → stores in Redis → returns data
- Auth flows: Browser ↔ KindeAuth via Next.js `/api/auth` routes for login/logout/session.
- Streaming: Browser → Next.js `/api/Streaming` → streams movie content (could be proxied or signed URLs).

##### Architectural patterns & design principles
- SSR/ISR/SSG hybrid via Next.js App Router
- Parallel routes for domain separation (`(movies)`, `(tv)`, `(person)`)
- Modular component hierarchy (domain-specific + shared UI primitives)
- Serverless micro-endpoints (each route encapsulates one responsibility)
- Cache-aside pattern with Upstash Redis
- Separation of concerns: UI vs data-fetch libs vs API routes vs external services

## Diagram (Mermaid)

```mermaid
graph TD
  subgraph "Client (Browser)" 
    Browser["Browser/Device"]:::client
  end

  subgraph "Next.js Frontend (Client-Side)" 
    AppRouter["Next.js App Router"]:::frontend
    TailwindConfig["Tailwind CSS Config"]:::frontend
    GlobalsCSS["Global Styles (globals.css)"]:::frontend
    ShadcnUI["Shared UI Component Library"]:::frontend
    FramerAnim["Framer Motion Animations"]:::frontend
    ContextHooks["React Context & Custom Hooks"]:::frontend
    DomainMovies["Movies UI Components"]:::frontend
    DomainTV["TV Shows UI Components"]:::frontend
    DomainPerson["Person Details UI Components"]:::frontend
  end

  subgraph "Next.js Backend (Serverless API)" 
    APIRoutes["Next.js API Routes"]:::backend
    UtilsLibs["Utility Libraries"]:::backend
  end

  subgraph "External Services" 
    TMDB["TMDB REST API"]:::external
    KindeAuth["KindeAuth"]:::external
    UpstashRedis["Upstash Redis"]:::external
    VercelCDN["Vercel CDN & Edge"]:::external
  end

  Browser -->|Requests Pages| VercelCDN
  Browser -->|Loads App Router| AppRouter
  AppRouter -->|Uses Styles| TailwindConfig
  AppRouter -->|Imports| GlobalsCSS
  AppRouter -->|Renders Components| ShadcnUI
  AppRouter -->|Plays Animations| FramerAnim
  AppRouter -->|Uses Context/Hooks| ContextHooks
  AppRouter -->|Renders Domain UI| DomainMovies
  AppRouter -->|Renders Domain UI| DomainTV
  AppRouter -->|Renders Domain UI| DomainPerson

  AppRouter -->|API Calls| APIRoutes
  APIRoutes -->|Cache-Aside| UpstashRedis
  APIRoutes -->|Fetch Data| TMDB
  APIRoutes -->|Auth Flow| KindeAuth
  Browser -->|Auth Requests| APIRoutes
  Browser -->|Stream Requests| APIRoutes

  APIRoutes -->|Helper Functions| UtilsLibs

  classDef client fill:#D0E8FF,stroke:#0366D6;
  classDef frontend fill:#E6FFDC,stroke:#237804;
  classDef backend fill:#FFF7E6,stroke:#D48806;
  classDef external fill:#FFE6E6,stroke:#CF1322;

  click AppRouter "https://github.com/nasrokamora/app6/blob/main/app/layout.js"
  click TailwindConfig "https://github.com/nasrokamora/app6/blob/main/tailwind.config.js"
  click GlobalsCSS "https://github.com/nasrokamora/app6/blob/main/app/globals.css"
  click ShadcnUI "https://github.com/nasrokamora/app6/tree/main/components/ui/"
  click FramerAnim "https://github.com/nasrokamora/app6/tree/main/app/Animations/"
  click ContextHooks "https://github.com/nasrokamora/app6/blob/main/app/Context/MediaContext.js"
  click DomainMovies "https://github.com/nasrokamora/app6/tree/main/app/(movies)/Components/"
  click DomainTV "https://github.com/nasrokamora/app6/tree/main/app/(tv)/Components/"
  click DomainPerson "https://github.com/nasrokamora/app6/tree/main/app/(person)/Components/"
  click APIRoutes "https://github.com/nasrokamora/app6/tree/main/app/api/"
  click UtilsLibs "https://github.com/nasrokamora/app6/tree/main/app/libs/"
```
