# akash-sharma8/youtube-transcript-chatbot architecture

> Architecture diagram of the GitHub repository akash-sharma8/youtube-transcript-chatbot, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/akash-sharma8/youtube-transcript-chatbot
- Repository: https://github.com/akash-sharma8/youtube-transcript-chatbot

## Overview

TubeMind AI is a YouTube-transcript RAG chatbot. Users submit a video URL to index its transcript, then ask questions scoped to that video; answers can include transcript timestamps. The graph follows the evidenced API routes and their runtime dependencies. The README documents the broader indexing and retrieval workflow; some supporting modules were not sampled, so uncertain connections are omitted.

Main entry points: [`app/api/index/route.ts`](https://github.com/akash-sharma8/youtube-transcript-chatbot/blob/main/app/api/index/route.ts) (Index endpoint), [`components/chat/Chat.tsx`](https://github.com/akash-sharma8/youtube-transcript-chatbot/blob/main/components/chat/Chat.tsx) (Chat interface), [`lib/chat/chat.ts`](https://github.com/akash-sharma8/youtube-transcript-chatbot/blob/main/lib/chat/chat.ts) (Chat service), [`app/page.tsx`](https://github.com/akash-sharma8/youtube-transcript-chatbot/blob/main/app/page.tsx) (Application page)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User experience"]
  node_page["Application page<br/>[page.tsx]"]
  node_video_input["Video input<br/>[VideoInput.tsx]"]
  node_chat_ui["Chat interface<br/>[Chat.tsx]"]
  node_chat_input["Question input<br/>[ChatInput.tsx]"]
  node_chat_state["Chat state<br/>[useChat.ts]"]
  node_chat_window["Message window<br/>[ChatWindow.tsx]"]
  node_chat_message["Message rendering<br/>[ChatMessage.tsx]"]
end

subgraph group_api["API routes"]
  node_index_route["Index endpoint<br/>[route.ts]"]
  node_chat_route["Chat endpoint<br/>[route.ts]"]
end

subgraph group_transcripts["Transcript indexing"]
  node_video_ids["Video ID parsing<br/>[video-id.ts]"]
  node_transcript_fetch["Transcript fetch<br/>[fetch.ts]"]
  node_transcript_merge["Transcript merging<br/>[merger.ts]"]
  node_documents["Document creation<br/>[document.ts]"]
  node_splitter["Chunk splitting<br/>[splitter.ts]"]
  node_indexer["Vector indexing<br/>[indexer.ts]"]
end

subgraph group_rag["Retrieval and answers"]
  node_chat_service["Chat service<br/>[chat.ts]"]
  node_chat_prompt["Chat prompt<br/>[prompt.ts]"]
  node_retriever["Similarity retrieval<br/>[retriever.ts]"]
end

subgraph group_integrations["AI and storage"]
  node_embedding["Hugging Face embeddings<br/>[huggingface.ts]"]
  node_collections["Video collections<br/>[collections.ts]"]
  node_chroma_client["Chroma client<br/>[client.ts]"]
end

node_user(("Video user"))
node_chroma[("ChromaDB")]
node_groq{{"Groq LLM"}}
node_transcript_service{{"Transcript API"}}

node_user -->|"opens"| node_page
node_page -->|"shows"| node_video_input
node_page -->|"shows"| node_chat_ui
node_video_input -->|"submits URL"| node_index_route
node_chat_ui -->|"uses"| node_chat_input
node_chat_ui -->|"uses"| node_chat_state
node_chat_ui -->|"uses"| node_chat_window
node_chat_window -->|"renders"| node_chat_message
node_chat_state -->|"posts question"| node_chat_route
node_index_route -->|"parses URL"| node_video_ids
node_index_route -->|"fetches transcript"| node_transcript_fetch
node_transcript_fetch -->|"requests transcript"| node_transcript_service
node_index_route -->|"merges segments"| node_transcript_merge
node_index_route -->|"creates documents"| node_documents
node_index_route -->|"splits documents"| node_splitter
node_index_route -->|"indexes chunks"| node_indexer
node_indexer -->|"embeds chunks"| node_embedding
node_indexer -->|"adds vectors"| node_collections
node_chat_route -->|"parses URL"| node_video_ids
node_chat_route -->|"asks question"| node_chat_service
node_chat_service -->|"retrieves context"| node_retriever
node_chat_service -->|"builds prompt"| node_chat_prompt
node_chat_service -->|"invokes model"| node_groq
node_retriever -->|"embeds query"| node_embedding
node_retriever -->|"queries collection"| node_collections
node_collections -->|"uses client"| node_chroma_client
node_chroma_client -.->|"connects"| node_chroma

click node_page "https://github.com/akash-sharma8/youtube-transcript-chatbot/blob/main/app/page.tsx"
click node_video_input "https://github.com/akash-sharma8/youtube-transcript-chatbot/blob/main/components/index/VideoInput.tsx"
click node_chat_ui "https://github.com/akash-sharma8/youtube-transcript-chatbot/blob/main/components/chat/Chat.tsx"
click node_chat_input "https://github.com/akash-sharma8/youtube-transcript-chatbot/blob/main/components/chat/ChatInput.tsx"
click node_chat_state "https://github.com/akash-sharma8/youtube-transcript-chatbot/blob/main/hooks/useChat.ts"
click node_chat_window "https://github.com/akash-sharma8/youtube-transcript-chatbot/blob/main/components/chat/ChatWindow.tsx"
click node_chat_message "https://github.com/akash-sharma8/youtube-transcript-chatbot/blob/main/components/chat/ChatMessage.tsx"
click node_index_route "https://github.com/akash-sharma8/youtube-transcript-chatbot/blob/main/app/api/index/route.ts"
click node_chat_route "https://github.com/akash-sharma8/youtube-transcript-chatbot/blob/main/app/api/chat/route.ts"
click node_video_ids "https://github.com/akash-sharma8/youtube-transcript-chatbot/blob/main/lib/youtube/video-id.ts"
click node_transcript_fetch "https://github.com/akash-sharma8/youtube-transcript-chatbot/blob/main/lib/transcript/fetch.ts"
click node_transcript_merge "https://github.com/akash-sharma8/youtube-transcript-chatbot/blob/main/lib/transcript/merger.ts"
click node_documents "https://github.com/akash-sharma8/youtube-transcript-chatbot/blob/main/lib/transcript/document.ts"
click node_splitter "https://github.com/akash-sharma8/youtube-transcript-chatbot/blob/main/lib/transcript/splitter.ts"
click node_indexer "https://github.com/akash-sharma8/youtube-transcript-chatbot/blob/main/lib/indexing/indexer.ts"
click node_chat_service "https://github.com/akash-sharma8/youtube-transcript-chatbot/blob/main/lib/chat/chat.ts"
click node_chat_prompt "https://github.com/akash-sharma8/youtube-transcript-chatbot/blob/main/lib/chat/prompt.ts"
click node_retriever "https://github.com/akash-sharma8/youtube-transcript-chatbot/blob/main/lib/retrieval/retriever.ts"
click node_embedding "https://github.com/akash-sharma8/youtube-transcript-chatbot/blob/main/lib/embeddings/huggingface.ts"
click node_collections "https://github.com/akash-sharma8/youtube-transcript-chatbot/blob/main/lib/chroma/collections.ts"
click node_chroma_client "https://github.com/akash-sharma8/youtube-transcript-chatbot/blob/main/lib/chroma/client.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_page,node_video_input,node_chat_ui,node_chat_input,node_chat_state,node_chat_window,node_chat_message,node_user toneBlue
class node_index_route,node_chat_route,node_chroma toneAmber
class node_video_ids,node_transcript_fetch,node_transcript_merge,node_documents,node_splitter,node_indexer,node_transcript_service toneMint
class node_chat_service,node_chat_prompt,node_retriever toneRose
class node_embedding,node_collections,node_chroma_client,node_groq toneIndigo
```

## Components

### User experience

- [Application page](https://github.com/akash-sharma8/youtube-transcript-chatbot/blob/main/app/page.tsx): `app/page.tsx`
- [Video input](https://github.com/akash-sharma8/youtube-transcript-chatbot/blob/main/components/index/VideoInput.tsx): `components/index/VideoInput.tsx`
- [Chat interface](https://github.com/akash-sharma8/youtube-transcript-chatbot/blob/main/components/chat/Chat.tsx): `components/chat/Chat.tsx`
- [Question input](https://github.com/akash-sharma8/youtube-transcript-chatbot/blob/main/components/chat/ChatInput.tsx): `components/chat/ChatInput.tsx`
- [Chat state](https://github.com/akash-sharma8/youtube-transcript-chatbot/blob/main/hooks/useChat.ts): `hooks/useChat.ts`
- [Message window](https://github.com/akash-sharma8/youtube-transcript-chatbot/blob/main/components/chat/ChatWindow.tsx): `components/chat/ChatWindow.tsx`
- [Message rendering](https://github.com/akash-sharma8/youtube-transcript-chatbot/blob/main/components/chat/ChatMessage.tsx): `components/chat/ChatMessage.tsx`

### API routes

- [Index endpoint](https://github.com/akash-sharma8/youtube-transcript-chatbot/blob/main/app/api/index/route.ts): `app/api/index/route.ts`
- [Chat endpoint](https://github.com/akash-sharma8/youtube-transcript-chatbot/blob/main/app/api/chat/route.ts): `app/api/chat/route.ts`

### Transcript indexing

- [Video ID parsing](https://github.com/akash-sharma8/youtube-transcript-chatbot/blob/main/lib/youtube/video-id.ts): `lib/youtube/video-id.ts`
- [Transcript fetch](https://github.com/akash-sharma8/youtube-transcript-chatbot/blob/main/lib/transcript/fetch.ts): `lib/transcript/fetch.ts`
- [Transcript merging](https://github.com/akash-sharma8/youtube-transcript-chatbot/blob/main/lib/transcript/merger.ts): `lib/transcript/merger.ts`
- [Document creation](https://github.com/akash-sharma8/youtube-transcript-chatbot/blob/main/lib/transcript/document.ts): `lib/transcript/document.ts`
- [Chunk splitting](https://github.com/akash-sharma8/youtube-transcript-chatbot/blob/main/lib/transcript/splitter.ts): `lib/transcript/splitter.ts`
- [Vector indexing](https://github.com/akash-sharma8/youtube-transcript-chatbot/blob/main/lib/indexing/indexer.ts): `lib/indexing/indexer.ts`

### Retrieval and answers

- [Chat service](https://github.com/akash-sharma8/youtube-transcript-chatbot/blob/main/lib/chat/chat.ts): `lib/chat/chat.ts`
- [Chat prompt](https://github.com/akash-sharma8/youtube-transcript-chatbot/blob/main/lib/chat/prompt.ts): `lib/chat/prompt.ts`
- [Similarity retrieval](https://github.com/akash-sharma8/youtube-transcript-chatbot/blob/main/lib/retrieval/retriever.ts): `lib/retrieval/retriever.ts`

### AI and storage

- [Hugging Face embeddings](https://github.com/akash-sharma8/youtube-transcript-chatbot/blob/main/lib/embeddings/huggingface.ts): `lib/embeddings/huggingface.ts`
- [Video collections](https://github.com/akash-sharma8/youtube-transcript-chatbot/blob/main/lib/chroma/collections.ts): `lib/chroma/collections.ts`
- [Chroma client](https://github.com/akash-sharma8/youtube-transcript-chatbot/blob/main/lib/chroma/client.ts): `lib/chroma/client.ts`

### Other components

- **Video user**
- **ChromaDB**
- **Groq LLM**
- **Transcript API**

## Connections

- Video user → Application page: opens (evidence: `README.md`)
- Application page → Video input: shows (evidence: `app/page.tsx`)
- Application page → Chat interface: shows (evidence: `app/page.tsx`)
- Video input → Index endpoint: submits URL (evidence: `README.md`)
- Chat interface → Question input: uses (evidence: `components/chat/Chat.tsx`)
- Chat interface → Chat state: uses (evidence: `components/chat/Chat.tsx`)
- Chat interface → Message window: uses (evidence: `components/chat/Chat.tsx`)
- Message window → Message rendering: renders (evidence: `components/chat/ChatWindow.tsx`)
- Chat state → Chat endpoint: posts question (evidence: `hooks/useChat.ts`)
- Index endpoint → Video ID parsing: parses URL (evidence: `app/api/index/route.ts`)
- Index endpoint → Transcript fetch: fetches transcript (evidence: `app/api/index/route.ts`)
- Transcript fetch → Transcript API: requests transcript (evidence: `lib/transcript/fetch.ts`)
- Index endpoint → Transcript merging: merges segments (evidence: `app/api/index/route.ts`)
- Index endpoint → Document creation: creates documents (evidence: `app/api/index/route.ts`)
- Index endpoint → Chunk splitting: splits documents (evidence: `app/api/index/route.ts`)
- Index endpoint → Vector indexing: indexes chunks (evidence: `app/api/index/route.ts`)
- Vector indexing → Hugging Face embeddings: embeds chunks (evidence: `lib/indexing/indexer.ts`)
- Vector indexing → Video collections: adds vectors (evidence: `lib/indexing/indexer.ts`)
- Chat endpoint → Video ID parsing: parses URL (evidence: `app/api/chat/route.ts`)
- Chat endpoint → Chat service: asks question (evidence: `app/api/chat/route.ts`)
- Chat service → Similarity retrieval: retrieves context (evidence: `lib/chat/chat.ts`)
- Chat service → Chat prompt: builds prompt (evidence: `lib/chat/chat.ts`)
- Chat service → Groq LLM: invokes model (evidence: `lib/chat/chat.ts`)
- Similarity retrieval → Hugging Face embeddings: embeds query (evidence: `lib/retrieval/retriever.ts`)
- Similarity retrieval → Video collections: queries collection (evidence: `lib/retrieval/retriever.ts`)
- Video collections → Chroma client: uses client (evidence: `lib/chroma/collections.ts`)
- Chroma client → ChromaDB: connects (evidence: `README.md`)
