Frontend Architecture & Component Hierarchy
This document outlines the architecture of the Run, Veo, Run frontend application.
Tech Stack
Section titled “Tech Stack”- Framework: Lit (Web Components)
- Language: TypeScript
- Build Tool: Vite
- Styling: CSS Variables + Material Design 3 (via
@material/web) - State Management: Reactive properties within Lit components (local state).
Component Hierarchy
Section titled “Component Hierarchy”The application is structured as a single-page application (SPA) encapsulated within a main custom element.
1. Root Component: <run-veo-run>
Section titled “1. Root Component: <run-veo-run>”- File:
src/run-veo-run.ts - Role: The main application container and state manager.
- Responsibilities:
- State: Manages global app state:
genMode: Current generation mode (Text, Image, Storyboard, Ingredients, Upload).videoUri: URI of the currently displayed video.sourceUri: GCS URI of the source video (used for extension).prompt: User’s text prompt.isRunning: Loading state.config: Settings like Model and Aspect Ratio.
- Layout: Renders the header, video player, tabs, controls, and footer.
- Logic:
- Handles API calls (via
api/layer). - Manages the “Continuity Loop” (Gemini analysis + Veo extension).
- Enforces business logic (e.g., locking Aspect Ratio in Ingredients mode).
- Handles API calls (via
- State: Manages global app state:
2. Child Components
Section titled “2. Child Components”<image-upload>
Section titled “<image-upload>”- File:
src/components/image-upload.ts - Role: Handles image file selection, preview, and upload.
- Usage:
- Start Frame: In Image-to-Video and Storyboard modes.
- End Frame: In Storyboard mode.
- Ingredients: For uploading style/character references.
- Events: Dispatches
upload-completewith the GCS URI upon success.
<video-upload>
Section titled “<video-upload>”- File:
src/components/video-upload.ts - Role: Handles video file selection, validation, preview, and upload.
- Responsibilities:
- Validation: Enforces strict constraints before upload:
- MIME:
video/mp4only. - Duration: 1s to 30s.
- Resolution: 720p or 1080p (16:9 or 9:16).
- MIME:
- Preview: Uses an HTML
<video>element for playback validation.
- Validation: Enforces strict constraints before upload:
- Usage: In “Upload” mode to provide a base for extension.
3. API Layer
Section titled “3. API Layer”The application logic is decoupled from UI components via the api/ directory.
src/api/veo.ts:generateVideo(options): Calls/api/veo/generate.extendVideo(uri, prompt, model): Calls/api/veo/extend.- Type definitions for
GenerateOptionsandVeoResponse.
src/api/gemini.ts:analyzeVideo(uri): Calls/api/gemini/analyzeto get visual context description.
Data Flow
Section titled “Data Flow”- User Input: User interacts with UI (Tabs, Uploads, Text Field).
- State Update:
<run-veo-run>updates its@stateproperties. - Action: User clicks “Run Simulation” / “Extend Timeline”.
- API Call:
- Continuity (Optional): Frontend calls
analyzeVideo-> Backend (Gemini) -> Returns context string. - Generation: Frontend combines prompt + context -> calls
generateVideoorextendVideo-> Backend (Veo) -> Returns Signed URL.
- Continuity (Optional): Frontend calls
- Render:
<run-veo-run>updatesvideoUri, triggering the<video>element to play the new clip.