How thejohnpg/inspiration-viral-youtube-videos works
Project type and purpose
• This is a lightweight full-stack web application (“Viral Video Search”) built with Node.js and Express.js on the backend, and vanilla HTML/CSS/JavaScript on the frontend.
• Its sole business function is to let users enter a niche, hit “Search,” then display YouTube videos sorted by view count, using the Google YouTube Data API v3.
File structure
• Top-level files
• .env – stores the YouTube API key and other environment variables
• index.js – entry point and Express server setup
• package.json – lists dependencies (express, dotenv, etc.) and scripts
• Readme.md & .gitignore
• public/ directory
• index.html – the UI shell
• style.css – styling
• script.js – client-side logic (XHR/fetch to your Express endpoints)
• There is no database or caching layer yet (planned future features include Redis, CDN, cloud hosting).
README for additional insights
• Confirms tech stack: Node.js, Express.js, Google YouTube Data API, plain HTML/CSS/JS
• Future roadmap: mobile-first CSS, Webpack/production build, Redis cache, cloud + CDN, mobile app
• No existing microservices or database—pure server-as-API approach.
a. Main components
• Client Browser (UI)
• Express.js Server
• YouTube Data API (external service)
• Environment/config layer (.env holds API key)
• (Future) Redis Cache, CDN, Cloud Hosting nodes
b. Relationships & data flows
1. User interacts with Browser UI → enters niche → clicks “Search.”
2. Browser (script.js) sends an HTTP request to Express endpoint (/search?term=...).
3. Express server reads API key from .env, constructs a request to YouTube Data API.
4. YouTube Data API responds with video metadata.
5. Server optionally caches results (future Redis), then returns JSON to the client.
6. Browser renders the results.
c. Architectural patterns / design principles
• Single-page server-rendered approach with client-side fetch calls (separation of concerns).
• 3-tier logical separation: Presentation (HTML/CSS/JS), Application (Express), External API (YouTube).
• Env-driven configuration (12-factor principles).
d. Key technologies & libraries
• Node.js & Express.js for HTTP server and routing
• dotenv to load .env
• Fetch/XHR in script.js for AJAX
• Google YouTube Data API v3 as external dependency
• Static assets served from public/