A Next.js app that analyzes the bias of any YouTube video using Gemini 2.5 Flash — extracts the real transcript, classifies bias across 5 dimensions, and recommends videos from opposing and neutral perspectives.
- 🎬 YouTube Embed — watch the video right in the app
- 📝 Transcript Extraction — real captions via
youtube-transcript - 🤖 Gemini 2.5 Flash — AI bias classification (server-side, key stays private)
- 📊 5 Bias Dimensions — Political Leaning, Emotional Tone, Factual Density, Perspective Diversity, Source Credibility
- 🧭 Political Spectrum Needle — animated visual indicator
- ⚑ Bias Signals — specific detected patterns (loaded language, omission, etc.)
- 🔗 4 Alternative Searches — Left, Right, Neutral/Expert, International
Go to https://aistudio.google.com/app/apikey and create a free API key.
npm installCreate (or edit) .env.local in the project root:
GEMINI_API_KEY=your_actual_api_key_here
⚠️ Never commit this file. It's in.gitignoreby default.
npm run dev- Paste any YouTube URL into the input field
- Click ANALYZE
- Wait ~10-20 seconds for transcript extraction + Gemini analysis
- View the full bias breakdown and click the recommendation links to find balance
- Transcript availability: Videos must have captions enabled (auto-generated or manual). Age-restricted, private, or caption-disabled videos will fail with a clear error message.
- API costs: Gemini 2.5 Flash has a generous free tier. One analysis uses ~2,000–5,000 tokens depending on transcript length.
- Model: Uses
gemini-2.5-flash— Google's latest fast, capable model.
| Layer | Technology |
|---|---|
| Framework | Next.js 15 (App Router) |
| Language | TypeScript |
| Styling | Tailwind CSS |
| AI | Gemini 2.5 Flash via @google/generative-ai |
| Transcript | youtube-transcript |
| Fonts | Bebas Neue, DM Mono, Playfair Display |
perspective-lens/
├── app/
│ ├── api/
│ │ └── analyze/
│ │ └── route.ts ← API route (Gemini + transcript logic)
│ ├── globals.css
│ ├── layout.tsx
│ └── page.tsx
├── components/
│ ├── PerchspectiveApp.tsx ← Main client component
│ ├── Header.tsx
│ ├── VideoEmbed.tsx
│ └── BiasResults.tsx ← Full analysis display
├── .env.local ← Add your API key here
└── README.md