# narenderthakur86/youtube-trend-analyzer architecture

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

- Interactive diagram: https://gitdiagram.com/narenderthakur86/youtube-trend-analyzer
- Repository: https://github.com/narenderthakur86/youtube-trend-analyzer

## Overview

AI Niche Trend Analyzer is a Streamlit application for finding recent YouTube videos that outperform their channels and summarizing trends for creators. The user supplies API keys and search parameters, then the app fetches video and channel statistics, calculates and filters outlier scores, requests an AI report, and displays the report and video details. The graph separates UI, YouTube data retrieval and scoring, and AI analysis. Relationships are based on the shown app and service excerpts; no persistent store is present.

Main entry points: [`app.py`](https://github.com/narenderthakur86/youtube-trend-analyzer/blob/main/app.py) (Streamlit workflow), [`youtube_service.py`](https://github.com/narenderthakur86/youtube-trend-analyzer/blob/main/youtube_service.py) (Video discovery and scoring), [`openai_service.py`](https://github.com/narenderthakur86/youtube-trend-analyzer/blob/main/openai_service.py) (Trend report generation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Search and Results UI"]
  node_app["Streamlit workflow<br/>[app.py]"]
end

subgraph group_youtube["YouTube Discovery"]
  node_youtube_service["Video discovery and scoring<br/>[youtube_service.py]"]
  node_youtube_api["YouTube Data API"]
end

subgraph group_ai["AI Trend Analysis"]
  node_openai_service["Trend report generation<br/>[openai_service.py]"]
  node_openai_api["OpenAI API"]
end

node_creator(("Creator"))

node_creator -->|"sets search"| node_app
node_app -->|"requests videos"| node_youtube_service
node_youtube_service -->|"searches and fetches stats"| node_youtube_api
node_youtube_service -->|"returns scored data"| node_app
node_app -->|"requests analysis"| node_openai_service
node_openai_service -->|"requests completion"| node_openai_api
node_openai_service -->|"returns report"| node_app
node_app -->|"displays results"| node_creator

click node_app "https://github.com/narenderthakur86/youtube-trend-analyzer/blob/main/app.py"
click node_youtube_service "https://github.com/narenderthakur86/youtube-trend-analyzer/blob/main/youtube_service.py"
click node_openai_service "https://github.com/narenderthakur86/youtube-trend-analyzer/blob/main/openai_service.py"

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_app toneBlue
class node_youtube_service,node_youtube_api toneAmber
class node_openai_service,node_openai_api toneMint
class node_creator toneIndigo
```

## Components

### Search and Results UI

- [Streamlit workflow](https://github.com/narenderthakur86/youtube-trend-analyzer/blob/main/app.py): `app.py`

### YouTube Discovery

- [Video discovery and scoring](https://github.com/narenderthakur86/youtube-trend-analyzer/blob/main/youtube_service.py): `youtube_service.py`
- **YouTube Data API**

### AI Trend Analysis

- [Trend report generation](https://github.com/narenderthakur86/youtube-trend-analyzer/blob/main/openai_service.py): `openai_service.py`
- **OpenAI API**

### Other components

- **Creator**

## Connections

- Creator → Streamlit workflow: sets search (evidence: `app.py`)
- Streamlit workflow → Video discovery and scoring: requests videos (evidence: `app.py`)
- Video discovery and scoring → YouTube Data API: searches and fetches stats (evidence: `youtube_service.py`)
- Video discovery and scoring → Streamlit workflow: returns scored data (evidence: `app.py`)
- Streamlit workflow → Trend report generation: requests analysis (evidence: `app.py`)
- Trend report generation → OpenAI API: requests completion (evidence: `openai_service.py`)
- Trend report generation → Streamlit workflow: returns report (evidence: `app.py`)
- Streamlit workflow → Creator: displays results (evidence: `app.py`)
