How agricidaniel/youtubepro works
Purpose and runtime entry points
YouTube Pro is a local-first workspace that turns public YouTube metadata into evidence-grounded research, Gemini-assisted ideas and scripts, and generated thumbnail packages. The browser entry point is client/src/main.tsx; the Express server starts from server/index.ts and serves API routes plus the Vite/production client bundle.
Client workflow shell
client/src/App.tsx composes the application shell, navigation, and workflow-aware pages. The principal stages are Research, Script Writer, Thumbnail Creator, and Settings, implemented in client/src/pages/research.tsx, client/src/pages/script.tsx, client/src/pages/thumbnail.tsx, and client/src/pages/settings.tsx. The legacy ideas route is folded into Research rather than represented as a separate page.
Local workflow persistence and state boundary
The client owns project history and active workflow state; no server database or session store exists. client/src/lib/workflow-context.tsx provides shared workflow state, while client/src/lib/workflow-storage.ts persists up to eight recent workflows in browser IndexedDB. Stored state includes snapshots, ideas, scripts, briefs, and results, but intentionally excludes uploaded thumbnail reference files and all API keys.
Research ingestion and analytics
Research begins in the client and calls server routes defined in server/routes.ts. The YouTube provider in server/youtube.ts searches and enriches up to 50 public videos with statistics, durations, captions, tags, status, live details, and channel metadata. The resulting ordered snapshot, deterministic analytics, filters, coverage, warnings, and snapshot identity form the evidence boundary consumed by subsequent AI stages.
Evidence contracts and AI generation
Shared schemas/contracts enforce the handoff from research to Gemini: shared/schema.ts, shared/evidence-contracts.ts, and shared/research-contracts.test.ts. server/gemini.ts invokes Google Gemini through server-held credentials; server/gemini-models.ts controls permitted text/image models. Insights, ideas, scripts, and section/paragraph regeneration must use bounded context from the active snapshot rather than arbitrary client claims. Script regeneration contracts are centralized in server/script-regeneration-contract.ts.
Thumbnail generation pipeline
The thumbnail page gathers a selected promise/concept, controls, and at most three browser-prepared image references. server/thumbnail-contract.ts validates bounded request semantics; server/gemini.ts submits permitted references and prompts to Gemini image generation. Generated outputs return to the current local workflow; reference uploads are not retained after the request/session workflow restoration boundary.
Server security and infrastructure boundaries
Express middleware and route assembly reside in server/index.ts and server/routes.ts; static/Vite serving is separated into server/static.ts and server/vite.ts. Server-only settings in server/settings.ts update ignored .env values without returning secrets to the client. server/rate-limit.ts applies an in-memory, per-process limit to billable YouTube/Gemini endpoints. The intended deployment is a loopback-bound Node.js 22+ process (127.0.0.1:5000 by default), integrating only YouTube Data API v3 and Google Gemini; it is not designed as a publicly exposed multi-user service.
Main entry points: routes.ts API routes · App.tsx Workflow shell · gemini.ts Gemini generation · research.tsx Research
Components 18
Browser client
Local workflow UI and persistence.
- Client entry
client/src/main.tsx - Workflow shell · Navigation and stage composition.
client/src/App.tsx - Workflow state · Active workflow and project history boundary.
client/src/lib/workflow-context.tsx - Local workflow store · Retains up to eight workflows without keys or reference files.
client/src/lib/workflow-storage.ts - Research
client/src/pages/research.tsx - Script Writer
client/src/pages/script.tsx - Thumbnail Creator · Prepares up to three transient image references.
client/src/pages/thumbnail.tsx - Settings
client/src/pages/settings.tsx
Loopback Node server
Express API and provider boundary.
- Express server · Loopback server serving APIs and client bundle.
server/index.ts - API routes · Research and billable generation endpoints.
server/routes.ts - YouTube ingestion · Searches and enriches up to 50 public videos.
server/youtube.ts - Gemini generation · Creates grounded text and thumbnail outputs.
server/gemini.ts - Server controls · Rate limits, manages secrets, and serves static or Vite assets.
server/rate-limit.ts - Thumbnail request contract · Validates bounded concepts, controls, and references.
server/thumbnail-contract.ts
Shared contracts
Evidence and request contracts.
- Evidence contracts · Bounds research evidence passed into AI stages.
shared/evidence-contracts.ts - Script regeneration contract
server/script-regeneration-contract.ts
External APIs
- YouTube Data API v3
- Google Gemini
Connections 23
- Client entry → Workflow shell: mounts
- Workflow shell → Research: research stage
- Workflow shell → Script Writer: script stage
- Workflow shell → Thumbnail Creator: thumbnail stage
- Workflow shell → Settings: settings stage
- Workflow shell → Workflow state: uses
- Workflow state → Local workflow store: persists snapshots and outputs
- Research → API routes: research requests
- Script Writer → API routes: grounded generation
- Thumbnail Creator → API routes: generation request
- Settings → API routes: updates server settings
- Express server → API routes: mounts
- Express server → Server controls: applies middleware and serving
- API routes → Server controls: rate-limited endpoints
- API routes → YouTube ingestion: delegates ingestion
- YouTube ingestion → YouTube Data API v3: public metadata
- API routes → Gemini generation: delegates AI requests
- Gemini generation → Google Gemini: text and image generation
- Research → Evidence contracts: creates bounded snapshot
- Evidence contracts → Gemini generation: grounds insights and ideas
- Script regeneration contract → Gemini generation: bounds regeneration
- Thumbnail request contract → Gemini generation: validates image request
- Gemini generation → Workflow state: returns generated outputs