# devrico003/youtube_summarizer architecture

> Architecture diagram of the GitHub repository devrico003/youtube_summarizer, 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/devrico003/youtube_summarizer
- Repository: https://github.com/devrico003/youtube_summarizer

## Overview

##### Project Type & Overview
- The project is a full-stack web application built with Next.js (using the App Router) that provides AI-powered summarization of YouTube videos.
- It includes a modern frontend interface built with React and Tailwind CSS, API endpoints for both summarization and history management, a SQLite database managed via Prisma, and integrations with several external AI services (Google Gemini, Groq, and OpenAI).

##### Main Components
a. Frontend UI:
- Next.js “app” folder with pages for the home screen, summary view, history dashboard, and detailed history view.
- Components under the “components” directory that encapsulate UI elements like buttons, inputs, cards, and the sidebar.
- That the UI interacts with backend APIs via client-side calls (using fetch or similar).

b. Backend/API Routes:
- “app/api” directory, showing two primary endpoints:
– /api/summarize for processing YouTube video summarization requests.
– /api/history for retrieving and storing summarization history.
- These API routes handle HTTP requests coming from the frontend and return data or trigger processing (like streaming responses during generation).

c. Database & ORM:
- Prisma layer (from the “prisma” folder and “lib/prisma.ts”) that interfaces with a SQLite database.
- How the smart history system is created via Prisma models and migrations.

d. AI Models & Integration:
- External service integrations for the three AI models (Google Gemini 2.0 Flash, Groq with Llama 70B, and GPT-4o-mini).
- That API keys (configured via environment variables) determine access to these services.

e. Deployment & Environment:
- Optionally, note configuration files like next.config.ts, tailwind.config.ts, and Dockerfile that support deployment and build processes.

##### Architectural Patterns & Design Principles
- That the project is built on a modern full-stack framework with serverless-like API routes.
- Separation of concerns where the UI, API logic, database operations, and external service integrations are decoupled.
- A note on streaming responses and chunk processing for real-time progress, which is an important performance improvement.
- Migration from a Python/Streamlit backend to a Next.js frontend/backend monorepo architecture.

## Diagram (Mermaid)

```mermaid
flowchart TD

    %% Global User
    U["User"]

    %% Frontend UI Subgraph
    subgraph "Frontend UI"
        direction TB
        F1["Home (Next.js - app/page.tsx)"]:::frontend
        F2["Layout (Next.js - app/layout.tsx)"]:::frontend
        F3["History Dashboard (Next.js - app/history/page.tsx)"]:::frontend
        F4["History Detail (Next.js - app/history/[id]/page.tsx)"]:::frontend
        F5["Summary View (Next.js - app/summary/[videoUrl]/page.tsx)"]:::frontend
        F6["UI Components (React & Tailwind CSS)"]:::frontend
    end

    %% Backend / API Routes Subgraph
    subgraph "Backend/API Routes"
        direction TB
        B1["Summarization API"]:::backend
        B2["History API (List)"]:::backend
        B3["History API (Detail)"]:::backend
    end

    %% Database & ORM Subgraph
    subgraph "Database & ORM"
        direction TB
        D1["Prisma ORM (prisma/schema.prisma & migrations)"]:::database
        D2["SQLite Database"]:::database
    end

    %% External AI Services Subgraph
    subgraph "External AI Services"
        direction TB
        E1["Google Gemini 2.0 Flash"]:::external
        E2["Groq (Llama 70B)"]:::external
        E3["GPT-4o-mini"]:::external
    end

    %% Deployment & Environment Subgraph
    subgraph "Deployment & Environment"
        direction TB
        DEP1["Containerization (Docker)"]:::deployment
        DEP2["Build Config (next.config.ts)"]:::deployment
        DEP3["Tailwind Config (tailwind.config.ts)"]:::deployment
        DEP4["PostCSS Config (postcss.config.mjs)"]:::deployment
        DEP5["Env Variables (example.env)"]:::deployment
    end

    %% Relationships & Data Flow
    U -->|"initiates"| F1
    U --> F2
    U --> F3
    U --> F4
    U --> F5

    %% Frontend calls Backend API
    F5 -->|"APICall"| B1
    F3 -->|"APICall"| B2
    F4 -->|"APICall"| B3

    %% Backend interacts with Database
    B1 -->|"DataStorage"| D2
    B2 -->|"DataStorage"| D2
    B3 -->|"DataStorage"| D2

    %% Backend integrates with External AI Services (dashed lines)
    B1 ---|"ServiceRequest"| E1
    B1 ---|"ServiceRequest"| E2
    B1 ---|"ServiceRequest"| E3

    %% Database integration via ORM
    D1 --> D2

    %% Deployment & Environment configures Frontend & Backend
    DEP2 -->|"Configures"| F6
    DEP5 -->|"Configures"| B1
    DEP5 -->|"Configures"| B2
    DEP5 -->|"Configures"| B3

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef backend fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef database fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef external fill:#f8d7da,stroke:#721c24,stroke-width:2px;
    classDef deployment fill:#d1ecf1,stroke:#0c5460,stroke-width:2px;

    %% Click Events
    click F1 "https://github.com/devrico003/youtube_summarizer/blob/main/app/page.tsx"
    click F2 "https://github.com/devrico003/youtube_summarizer/blob/main/app/layout.tsx"
    click F3 "https://github.com/devrico003/youtube_summarizer/blob/main/app/history/page.tsx"
    click F4 "https://github.com/devrico003/youtube_summarizer/blob/main/app/history/[id]/page.tsx"
    click F5 "https://github.com/devrico003/youtube_summarizer/blob/main/app/summary/[videoUrl]/page.tsx"
    click F6 "https://github.com/devrico003/youtube_summarizer/tree/main/components"
    click B1 "https://github.com/devrico003/youtube_summarizer/blob/main/app/api/summarize/route.ts"
    click B2 "https://github.com/devrico003/youtube_summarizer/blob/main/app/api/history/route.ts"
    click B3 "https://github.com/devrico003/youtube_summarizer/blob/main/app/api/history/[id]/route.ts"
    click D1 "https://github.com/devrico003/youtube_summarizer/tree/main/prisma"
    click D2 "https://github.com/devrico003/youtube_summarizer/blob/main/lib/prisma.ts"
    click DEP1 "https://github.com/devrico003/youtube_summarizer/tree/main/Dockerfile"
    click DEP2 "https://github.com/devrico003/youtube_summarizer/blob/main/next.config.ts"
    click DEP3 "https://github.com/devrico003/youtube_summarizer/blob/main/tailwind.config.ts"
    click DEP4 "https://github.com/devrico003/youtube_summarizer/blob/main/postcss.config.mjs"
    click DEP5 "https://github.com/devrico003/youtube_summarizer/blob/main/example.env"
```
