How vfarcic/youtube-automation works
Purpose and Entry Points
YouTube Automation is a Go service and embedded React SPA for managing a YouTube video lifecycle from planning through publishing and post-publish work. The executable starts the HTTP server from cmd/youtube-automation/main.go; API contract is defined in openapi.yaml. The production server serves the built frontend embedded through internal/frontend/embed.go.
HTTP/API Boundary
internal/api/server.go composes routing, middleware, services, SPA fallback, and health handling. Resource handlers expose video CRUD, lifecycle phases, aspect metadata, AI actions, Drive operations, publishing, and social actions under authenticated /api/* paths. internal/api/middleware_auth.go applies optional Bearer-token authentication while health remains public. API handlers are the boundary between browser clients and domain/integration services.
Video Workflow and Persistence
Videos are represented as YAML-backed workflow records, with lifecycle phases and typed aspects driving progress and editing. internal/video/manager.go owns video-level management; internal/storage/yaml.go reads and writes persisted manifests; internal/workflow/types.go and internal/workflow/constants.go define workflow state. The service layer in internal/service/video_service.go and internal/data/video_service.go coordinates API-facing operations over this local data store, rooted at DATA_DIR.
Metadata-Driven UI and Forms
The aspect subsystem describes editable fields, mapping, setters, and completion calculations rather than hard-coding each video form. internal/aspect/service.go, internal/aspect/types.go, and internal/aspect/completion.go supply metadata and progress to API consumers. The React client renders that contract dynamically through web/src/pages/VideoDetail.tsx, web/src/components/forms/DynamicForm.tsx, and web/src/api/client.ts; the backend’s embedded build lives in internal/frontend/dist/index.html.
AI Content and Thumbnail Pipeline
AI adapters generate and analyze titles, descriptions, tags, tweets, shorts, AMA material, timing, and thumbnail prompts. internal/ai/provider.go establishes the provider boundary, while feature-specific operations include internal/ai/titles.go and internal/ai/analyze_timing.go. Thumbnail generation is a separate orchestration pipeline: internal/thumbnail/orchestrator.go coordinates prompts, generation providers, resolution, and image storage via internal/thumbnail/service.go and internal/thumbnail/image_store.go. AI credentials are externally configured (AI_KEY); Gemini/GPT image implementations are isolated in this layer.
Publishing and External Integrations
Publishing adapters turn video metadata and assets into external side effects. internal/publishing/youtube.go handles YouTube uploads, updates, captions, playlists, and analytics support; internal/publishing/hugo.go produces Hugo content/assets; internal/publishing/scheduler.go supports publish timing. Google OAuth and Drive are encapsulated by internal/auth/oauth.go and internal/gdrive/service.go. Social distribution is separated into platform adapters such as internal/platform/bluesky/bluesky.go, internal/platform/linkedin.go, and internal/platform/hackernews.go; Slack and email notifications use internal/slack/service.go and internal/notification/email.go.
Scheduled and Operational Runtime
AMA automation and notifications execute through an internal scheduler, centered on internal/scheduler/scheduler.go and internal/scheduler/ama_job.go. Runtime configuration comes from settings.yaml and internal/configuration/settings.go. Deployment supports a containerized Go binary (Dockerfile) and Kubernetes/Helm (helm/youtube-automation/templates/deployment.yaml), with the SPA built separately from the Vite React project under web/.
Main entry points: server.go API server · VideoDetail.tsx React video UI · manager.go Video manager · orchestrator.go Thumbnail pipeline
Components 21
Runtime
- Go executable · Starts the HTTP server.
cmd/youtube-automation/main.go - API server · Routes API requests, middleware, health, and SPA fallback.
internal/api/server.go - Bearer auth · Protects API routes while leaving health public.
internal/api/middleware_auth.go - OpenAPI contract
openapi.yaml - Embedded SPA · Production frontend served by the Go server.
internal/frontend/embed.go - React video UI · Dynamically renders video details and editable aspect forms.
web/src/pages/VideoDetail.tsx - AMA scheduler · Runs AMA automation and scheduled notifications.
internal/scheduler/scheduler.go - Runtime settings · Supplies runtime configuration and external credentials.
internal/configuration/settings.go
Workflow & Data
- Video service · Coordinates API-facing video operations.
internal/service/video_service.go - Video manager · Owns video-level workflow management.
internal/video/manager.go - Workflow model · Phases and typed aspects define video progress.
internal/workflow/types.go - YAML manifests · Workflow records persisted under DATA_DIR.
internal/storage/yaml.go - Aspect metadata · Provides fields, setters, mappings, and completion.
internal/aspect/service.go
Content Generation
- AI provider boundary · Externally credentialed AI generation and analysis.
internal/ai/provider.go - Thumbnail pipeline · Coordinates prompts, image generation, resolution, and storage.
internal/thumbnail/orchestrator.go - Thumbnail images
internal/thumbnail/image_store.go
External Delivery
- Google OAuth
internal/auth/oauth.go - Google Drive
internal/gdrive/service.go - YouTube publishing · Uploads, updates, captions, playlists, and analytics.
internal/publishing/youtube.go - Social platforms · Bluesky, LinkedIn, and Hacker News distribution.
internal/platform/bluesky/bluesky.go - Notifications · Slack and email delivery.
internal/slack/service.go
Connections 26
- Go executable → API server: starts
- API server → Bearer auth: applies
- API server → OpenAPI contract: implements
- API server → Embedded SPA: serves
- React video UI → API server: calls /api
- Embedded SPA → React video UI: contains build
- API server → Video service: video API operations
- API server → Aspect metadata: aspect metadata API
- Video service → Video manager: manages
- Video manager → Workflow model: uses lifecycle
- Video manager → YAML manifests: reads and writes
- Aspect metadata → Workflow model: describes aspects
- React video UI → Aspect metadata: renders metadata-driven forms
- API server → AI provider boundary: AI actions
- API server → Thumbnail pipeline: thumbnail actions
- Thumbnail pipeline → AI provider boundary: generates prompts and images
- Thumbnail pipeline → Thumbnail images: stores images
- API server → Google OAuth: authorizes Google operations
- Google OAuth → Google Drive: authenticates
- API server → Google Drive: Drive operations
- API server → YouTube publishing: publishing actions
- API server → Social platforms: social actions
- AMA scheduler → Social platforms: scheduled distribution
- AMA scheduler → Notifications: sends alerts
- Runtime settings → API server: configures
- Runtime settings → AMA scheduler: configures