# vigiapriliansyah/yt-converter-nextjs architecture

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

- Interactive diagram: https://gitdiagram.com/vigiapriliansyah/yt-converter-nextjs
- Repository: https://github.com/vigiapriliansyah/yt-converter-nextjs

## Overview

##### Project type and purpose
- This is a full‑stack Next.js application built with the App Router.
- Purpose: A simple UI for downloading media (e.g., video/audio) via an internal API that leverages yt‑dlp and ffmpeg.

##### File structure
- Top‑level config files: package.json, next.config.mjs, ESLint, PostCSS, etc.
- /public: static assets.
- /src/app: Next.js “app” directory containing
- layout.js (root layout)
- globals.css (global styles)
- page.js (homepage UI)
- /api/download/route.js (serverless API endpoint)
- /src/components: reusable React components (theme-provider, UI primitives).
- /src/lib: shared utilities (utils.js).

##### README for additional insights
- Instructs installation of yt‑dlp and ffmpeg (external CLIs).
- Uses Next.js built‑in font optimization.
- Deployed to Vercel as serverless functions.

##### Main components to model
a. Frontend (Browser)
- Page.js + UI components (button, input, theme‑switcher)
- CSS (globals.css)
b. Next.js Server (Node.js)
- SSR/rendering engine
- App router handling layouts, pages
- API Route (download)
c. External CLIs
- yt‑dlp (media retrieval)
- ffmpeg (transcoding)
d. Deployment Platform
- Vercel serverless functions (implied)

##### Relationships and interactions
- User → Browser renders React UI → submits download request
- Browser → HTTP POST to /api/download → Next.js serverless handler
- Handler invokes yt‑dlp → pipes to ffmpeg → processes output
- Serverless returns final media stream/download link → Browser

##### Architectural patterns & design principles
- App Router (file‑based routing)
- Component‑based UI library (theme provider + primitives)
- Separation of concerns: UI vs. server logic vs. external tools
- Serverless functions for API endpoints (scalable, zero‑ops)

##### Technologies, frameworks, libraries
- Next.js (React, SSR, App Router)
- React components (JSX, hooks)
- Node.js runtime (serverless)
- yt‑dlp, ffmpeg (external binaries)
- CSS via globals.css + PostCSS
- Vercel (deployment)

- Callouts for important config (e.g., next.config.mjs, environment variables)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend (Browser)"
        direction TB
        Browser["Browser"]:::frontend
        Layout["Root Layout\n(layout.js)"]:::frontend
        Page["Home Page\n(page.js)"]:::frontend
        Styles["Global Styles\n(globals.css)"]:::frontend
        ThemeProv["Theme Provider\n(theme-provider.js)"]:::frontend
        Button["Button Component\n(button.jsx)"]:::frontend
        Input["Input Component\n(input.jsx)"]:::frontend
        Switcher["Theme Switcher\n(theme-switcher.js)"]:::frontend
    end

    %% Server Layer
    subgraph "Next.js Server (Serverless)"
        direction TB
        Config["Next.js Config\n(next.config.mjs)"]:::server
        SSR["SSR Engine & App Router"]:::server
        API["API Route: /api/download\n(route.js)"]:::server
        Utils["Shared Utilities\n(utils.js)"]:::server
    end

    %% External Tools
    subgraph "External Tools"
        direction TB
        YTDLP["yt-dlp"]:::external
        FFMPEG["ffmpeg"]:::external
    end

    %% Deployment
    Vercel["Vercel (Deployment)"]:::deployment

    %% Connections
    Browser -->|"GET /"| SSR
    SSR --> Page
    SSR --> Layout
    SSR --> Styles
    SSR --> ThemeProv

    Page --> Button
    Page --> Input
    Page --> Switcher

    Browser -->|"HTTP POST /api/download"| API
    API -->|"exec yt-dlp"| YTDLP
    YTDLP -->|"pipe STDOUT"| FFMPEG
    FFMPEG -->|"processed media"| API
    API -->|"response with download link"| Browser

    %% Deployment Connections
    Vercel --> SSR
    Vercel --> API

    %% Click Events
    click Page "https://github.com/vigiapriliansyah/yt-converter-nextjs/blob/main/src/app/page.js"
    click Layout "https://github.com/vigiapriliansyah/yt-converter-nextjs/blob/main/src/app/layout.js"
    click Styles "https://github.com/vigiapriliansyah/yt-converter-nextjs/blob/main/src/app/globals.css"
    click API "https://github.com/vigiapriliansyah/yt-converter-nextjs/blob/main/src/app/api/download/route.js"
    click ThemeProv "https://github.com/vigiapriliansyah/yt-converter-nextjs/blob/main/src/components/theme-provider.js"
    click Button "https://github.com/vigiapriliansyah/yt-converter-nextjs/blob/main/src/components/ui/button.jsx"
    click Input "https://github.com/vigiapriliansyah/yt-converter-nextjs/blob/main/src/components/ui/input.jsx"
    click Switcher "https://github.com/vigiapriliansyah/yt-converter-nextjs/blob/main/src/components/ui/theme-switcher.js"
    click Utils "https://github.com/vigiapriliansyah/yt-converter-nextjs/blob/main/src/lib/utils.js"
    click Config "https://github.com/vigiapriliansyah/yt-converter-nextjs/blob/main/next.config.mjs"
    click Browser "https://github.com/vigiapriliansyah/yt-converter-nextjs/tree/main/public/"

    %% Styles
    classDef frontend fill:#E3F2FD,stroke:#2196F3,color:#0D47A1;
    classDef server fill:#E8F5E9,stroke:#4CAF50,color:#1B5E20;
    classDef external fill:#FFF3E0,stroke:#FF9800,color:#E65100;
    classDef deployment fill:#F3E5F5,stroke:#9C27B0,color:#4A148C;
```
