Lovable (Vibe Coding) TutorialIntermediate120 min read
Build a YouTube Video Gallery with Lovable
Build a responsive YouTube gallery with a black-and-red theme, category filters, search, a popup video player, and a protected administrator backend.
Tutorial ForgeUpdated Aug 24, 2026
In this project, you'll use Lovable to build **Video Vault**, a responsive YouTube gallery with a dramatic black-and-red design.
Visitors will be able to:
- Browse published videos
- Search the gallery
- Filter videos by category
- Watch regular videos and YouTube Shorts
- View one administrator-selected featured video
The finished application will also include a protected administrator backend for adding, editing, publishing, deleting, categorizing, and featuring videos.
The completed application will include:
- A responsive public video gallery
- A featured-video hero
- Search and category filters
- Regular YouTube video support
- YouTube Shorts support
- A popup video player
- Lovable Cloud database storage
- Administrator authentication
- Add and Edit Video forms
- Publish and unpublish controls
- Safe video deletion
- Category management
- A secure featured-video selector
- Only one featured video at a time
Before You Begin
You'll need:
- A Lovable account
- A modern web browser
- Several public YouTube URLs for testing
- About two hours to complete the project
This tutorial builds and tests one part of the application at a time.
Do not add the database, authentication, and administrator backend during the first step. Establish and test the public interface before introducing those systems.
Build One Working Layer at a Time
Start with the public interface and temporary sample data.
Once the layout and interactions work correctly, replace the sample data with database records. This makes problems easier to identify and prevents interface, authentication, and database issues from becoming mixed together.
Part 1 — Build the Public Gallery
The first version of Video Vault will use temporary sample data.
In this part, you'll create:
- Header and navigation
- Featured-video hero
- Search
- Category filters
- Video-card grid
- Responsive mobile layout
The popup player, Lovable Cloud, authentication, and administrator backend will be added in later parts.
Step 1 — Create a New Lovable Project
01
Start the Video Vault Project
Sign in to Lovable and create a new project.
Use this project name:
Video Vault
Wait for the new project workspace to open before entering the first build prompt.
Keep the First Version Focused
The first prompt should establish the public interface without adding every planned feature.
Keeping temporary video data in the application allows you to test the design, search, and category filters before connecting the database.
Step 2 — Generate the Public Gallery
02
Build the Public Video Gallery
Copy the following prompt into Lovable.
Build the Public Video Gallery
Build a polished, responsive public YouTube video gallery named “Video Vault.” Use a dark entertainment-style theme with near-black page backgrounds, dark charcoal cards, deep red primary accents, white primary text, muted gray secondary text, and restrained red borders and glow effects. Create a responsive header with the Video Vault name, navigation links for Home, Videos, Categories, and About, a prominent search control, and a compact mobile navigation menu. Do not add Sign In, Sign Up, or Admin links yet. Add a large featured-video hero near the top of the homepage using a YouTube thumbnail as the background with a dark gradient overlay. Display the featured video’s title, short description, channel name, category, video type, and a red Watch Now button. Include exactly one featured video in the temporary sample data. Add category filter buttons for All Videos, Tutorials, Entertainment, Music, Technology, and Gaming. Do not use Featured as a category because featured status will be managed separately. Create a responsive gallery containing at least 12 realistic sample YouTube videos distributed across the categories. Each video card must display a YouTube thumbnail, video title, short description, channel name, category, a Regular Video or Short badge, and a red play icon over the thumbnail. Include restrained hover and keyboard-focus effects, consistent card heights, and appropriate thumbnail proportions for regular videos and Shorts. Add working search that filters the temporary videos by title, description, channel name, and category. Make search work together with the category filters. Include a single accessible clear-search control, a Reset Filters control, a visible matching-results count, and a helpful empty state when nothing matches. Create reusable components for the header, featured hero, search field, category filters, video cards, gallery grid, empty states, and footer. Keep all temporary sample video records in one clearly organized local data file. Each video record must contain id, title, description, channel name, YouTube URL, YouTube video ID, thumbnail URL, category, video type, featured status, published status, and sort order. Display only sample records marked as published. Include polished loading, no-videos, no-search-results, and missing-featured-video states. Add a footer containing the Video Vault name, a short description, navigation links, and copyright text. Make the entire public interface responsive for desktop, tablet, and mobile. Preserve accessible contrast, visible keyboard-focus indicators, useful accessible labels, semantic interactive controls, and touch-friendly sizing. Do not add Lovable Cloud, authentication, a database, an administrator dashboard, or a popup video player yet.
Creates the first public version of Video Vault using temporary sample data.
Wait for Lovable to finish generating the complete application before entering another prompt.
Step 3 — Inspect the Generated Gallery
03
Review the Public Interface
Inspect the generated application before requesting changes.
Confirm that the homepage includes:
- Video Vault header
- Public navigation
- Search field
- Featured-video hero
- Watch Now button
- Category filters
- At least 12 video cards
- Regular Video and Short badges
- Footer
Check both desktop and mobile previews.
Do not continue until the primary layout appears correctly.
Step 4 — Test Search and Category Filters
04
Test Gallery Filtering
Enter part of a video title into the search field.
Confirm that:
- Matching videos remain visible
- Nonmatching videos disappear
- The result count updates
- Clearing search restores the gallery
Next, select several category filters.
Confirm that:
- Only videos in the selected category appear
- Search continues working inside the selected category
- Reset Filters restores all published videos
- A helpful empty state appears when nothing matches
Watch for Two Search Clear Buttons
Some browsers provide a native clear button for inputs using `type="search"`.
If Lovable also adds a custom clear button, two “X” controls may appear after typing. Keep the accessible custom button and hide the browser-native search cancel decoration.
Optional Fix — Remove a Duplicate Search Clear Button
Use this prompt only if two clear controls appear inside the search field.
Fix Duplicate Search Clear Buttons
Fix the duplicate clear X appearing inside the Video Vault search field after text is entered. The field should display exactly one clear control. Keep the existing custom accessible clear button and hide the browser-native search cancel button and search decoration using the appropriate CSS selectors for search inputs, including the WebKit search cancel and search decoration pseudo-elements. Confirm that selecting the remaining clear button empties the search, restores the complete gallery, retains keyboard access, and does not change category filtering, styling, or other functionality.
Removes the browser-provided search clear control while preserving the custom accessible button.
Step 5 — Test the Responsive Layout
05
Review Desktop and Mobile Layouts
Use Lovable's responsive preview controls to inspect the gallery at several screen sizes.
Check:
- Desktop
- Tablet
- Mobile
Confirm that:
- Navigation remains usable
- The mobile menu opens and closes
- Hero text remains readable
- Video cards do not overflow
- Category controls wrap or scroll safely
- Search remains accessible
- Buttons remain large enough to select
- No horizontal page scrolling appears
Part 1 Verification
Before continuing, confirm:
Public Gallery Complete
You now have the public foundation for Video Vault.
The interface includes a featured hero, searchable video grid, category filters, temporary sample data, and responsive black-and-red styling.
In Part 2, you'll add the popup YouTube player and create separate layouts for regular videos and YouTube Shorts.
Part 2 — Add the Popup Player
The gallery currently displays video information, but the video cards and featured hero do not open a complete player.
In this part, you'll add a reusable popup player with separate layouts for regular YouTube videos and YouTube Shorts.
The completed modal will include:
- Large responsive playback for regular videos
- Vertical playback for YouTube Shorts
- Video information below the player
- Transparent surrounding space
- Thick red border and layered glow
- Keyboard and touch support
- Reliable playback cleanup
Regular Videos and Shorts Need Different Layouts
Regular YouTube videos normally use a horizontal 16:9 aspect ratio.
YouTube Shorts use a vertical 9:16 aspect ratio.
Forcing both types into the same dimensions can create large empty areas, distorted layouts, or videos that extend beyond the screen. Video Vault will select the correct modal layout from each video's stored `video_type`.
Step 1 — Add the Reusable Video Modal
01
Build the Popup Video Player
Copy the following prompt into Lovable.
Add the Popup Video Player
Add a reusable popup YouTube video-player modal to the existing Video Vault application. Preserve the current black-and-red design, featured hero, sample videos, category filters, search behavior, responsive layout, and single search clear button. Open the same modal when a visitor selects a video card or the featured hero’s Watch Now button. Load the selected video dynamically using its existing validated YouTube video ID and video type. Never hardcode one video into the modal and never inject the complete stored YouTube URL directly into the iframe. Construct the embed URL from the validated video ID using the privacy-enhanced format https://www.youtube-nocookie.com/embed/VIDEO_ID. Allow fullscreen playback and normal YouTube controls. For regular videos, create a responsive 16:9 player and make the desktop modal approximately 75vw wide with a sensible maximum width around 1400px. Keep the complete modal within approximately 88vh. For YouTube Shorts, use a centered vertical 9:16 player sized primarily by height, using approximately 70vh to 75vh on desktop. Do not stretch Shorts to 75vw. Keep the empty space beside a vertical Short transparent. Place the selected video’s title, channel name, category, and video-type badge inside a compact information section directly underneath the player. Do not place descriptive text beside the player. Do not give the overall modal a large solid background extending beyond the player. Give only the player and information section their own dark surfaces. Make the information section exactly the same width as the player. Add an approximately 3px deep-red border around the connected player and information section. Add a layered red glow consisting of a small bright glow near the border, a medium soft glow, and a larger faint dark-red glow. Keep the surrounding page visible through a dark blurred backdrop. Position one accessible close button near the upper-right corner of the actual player. Close the modal when the visitor selects the close button, presses Escape, or selects the backdrop outside the modal. Do not close it when someone interacts with the player or information section. Completely remove or reset the iframe when the modal closes so playback and audio stop immediately. Prevent the page behind the modal from scrolling while it is open and restore scrolling after it closes. Use an accessible dialog structure with role dialog, aria-modal true, and an accessible name based on the selected video title. Move focus into the modal when it opens, trap focus inside it, and return focus to the exact card or Watch Now button that opened it after closing. Support mouse, touch, Enter, and Space activation. Preserve visible keyboard-focus indicators. Keep the modal within the viewport on desktop, tablet, and mobile. On mobile, use nearly the full available width with safe margins. Allow the information section to scroll vertically if necessary. Respect prefers-reduced-motion for any opening animation. If the selected video ID is missing or invalid, do not render a broken iframe. Display a helpful message and allow the visitor to close the modal normally. Do not add Lovable Cloud, authentication, a database, or an administrator dashboard yet. Do not redesign unrelated parts of Video Vault.
Adds the responsive popup player for regular YouTube videos and YouTube Shorts.
Wait for Lovable to finish before testing the modal.
Step 2 — Test a Regular Video
02
Open a Regular YouTube Video
Select a video card labeled **Regular Video**.
Confirm that:
- The correct video opens
- The player uses a horizontal 16:9 layout
- The modal occupies approximately three-quarters of the desktop width
- The player is the dominant visual element
- The title and video information appear underneath
- The red border and layered glow are visible
- The surrounding sides remain transparent
- Only one close button appears
Close the modal and confirm that playback stops immediately.
Step 3 — Test a YouTube Short
03
Open a YouTube Short
Select a video card labeled **Short**.
Confirm that:
- The correct Short opens
- The player remains vertical
- The Short is not stretched across the screen
- The player uses approximately three-quarters of the desktop height
- The video information appears underneath
- The sides remain transparent
- No oversized charcoal panel appears around the video
- The complete modal remains within the viewport
Size Shorts by Height
A vertical player becomes too large if it uses the same width as a regular video.
For Shorts, calculate the layout primarily from the available viewport height while preserving the 9:16 aspect ratio.
Step 4 — Test Every Closing Method
04
Verify Modal Closing Behavior
Open a video and test each closing method separately:
1. Select the close button.
2. Open the modal again and press Escape.
3. Open it again and select the backdrop outside the modal.
Confirm that each method:
- Closes the modal
- Stops the video and audio
- Restores page scrolling
- Returns keyboard focus to the control that opened it
Next, select inside the player and information section.
Confirm that those interactions do not accidentally close the modal.
Hiding the Modal Does Not Stop Playback
If the iframe remains mounted after the modal closes, YouTube playback may continue invisibly.
The modal must remove or reset the iframe during closing. Always confirm that both the video and its audio stop.
Step 5 — Test Keyboard Accessibility
05
Navigate the Modal with a Keyboard
Use the Tab key to navigate the gallery.
Open a video card using Enter or Space.
Confirm that:
- Focus moves into the modal
- Focus remains inside the modal while it is open
- The close button has a visible focus indicator
- Escape closes the modal
- Focus returns to the original card
Repeat the test using the featured hero's **Watch Now** button.
Step 6 — Test Responsive Modal Sizes
06
Review the Player on Multiple Screens
Use Lovable's responsive preview controls to test:
- Large desktop
- Smaller desktop
- Tablet
- Mobile
For regular videos, confirm that:
- The player is large on desktop
- The player scales down safely
- The 16:9 aspect ratio remains correct
- The modal never extends beyond the viewport
For Shorts, confirm that:
- The vertical proportions remain correct
- The player fits within the available height
- The information section remains visible
- The sides remain transparent
- No horizontal page scrolling appears
Popup Player Verification
Before continuing, confirm:
Popup Player Complete
Video Vault now includes a responsive, accessible popup player.
Regular videos open in a large horizontal player, while YouTube Shorts retain their vertical proportions. Both layouts include transparent surrounding space, information beneath the player, and the black-and-red glow used throughout the application.
In Part 3, you'll enable Lovable Cloud and replace the temporary sample data with persistent video and category records.
Part 3 — Enable Lovable Cloud
Video Vault currently uses temporary sample data stored inside the application.
In this part, you'll enable Lovable Cloud, create persistent database tables, transfer the sample categories and videos into the database, and connect the public gallery to the new records.
The database will include:
- `categories`
- `videos`
- Published and unpublished statuses
- Featured-video status
- Regular video and Short types
- Category relationships
- One-featured-video enforcement
- Public read access for published content
- No public write access
Why Move the Videos into a Database?
Temporary data disappears when it is removed from the application code and cannot be managed through an administrator backend.
Lovable Cloud provides persistent storage so videos can later be added, edited, published, featured, and deleted without changing the application's source code.
Step 1 — Enable Lovable Cloud
01
Connect the Project to Lovable Cloud
Open the Cloud section of your Lovable project and enable Lovable Cloud.
Allow Lovable to finish preparing the project before requesting the database tables.
Do not add administrator pages or authentication forms during this step.
Preserve the Working Public Gallery
Enabling Cloud should not replace or redesign the public interface.
The black-and-red gallery, featured hero, search, filters, video cards, responsive layout, and popup player should remain visually unchanged.
Step 2 — Create the Database and Migrate the Sample Videos
02
Add Persistent Categories and Videos
Copy the following prompt into Lovable.
Connect Video Vault to Lovable Cloud
Connect the existing Video Vault gallery to Lovable Cloud and replace its temporary local sample-data dependency with persistent database records. Preserve the complete public interface, including the black-and-red theme, header, featured hero, search, category filters, responsive video grid, regular-video modal, vertical YouTube Shorts modal, transparent modal surroundings, thick red border, layered glow, accessibility behavior, loading states, empty states, and error states. Do not build administrator authentication or the administrator dashboard yet. Create a categories table with id as a UUID primary key, name as required text, slug as required unique text, description as optional text, sort_order as a required integer defaulting to 0, is_active as a required boolean defaulting to true, created_at, and updated_at. Create a videos table with id as a UUID primary key, title as required text, description as optional text, channel_name as required text, youtube_url as required text, youtube_video_id as required unique text, thumbnail_url as required text, category_id as a required foreign key referencing categories.id with restricted deletion, video_type as required text limited to regular or short and defaulting to regular, is_featured as a required boolean defaulting to false, is_published as a required boolean defaulting to false, sort_order as a required integer defaulting to 0, created_at, and updated_at. Add automatic updated_at behavior when category or video records change. Add useful indexes for published status, featured status, category, video sort order, category sort order, and active category status. Add a database-level partial unique index or equivalent constraint that permits no more than one videos record where is_featured is true. Do not rely only on the interface for the one-featured-video rule. Enable row-level security on both tables. Allow anonymous and authenticated public visitors to select only categories where is_active is true. Allow anonymous and authenticated public visitors to select only videos where is_published is true. Do not add public insert, update, or delete policies. Public visitors must not be able to create, edit, publish, feature, or delete records. Insert the existing Tutorials, Entertainment, Music, Technology, and Gaming categories into the categories table. Preserve their current display order. Move every existing temporary sample video into the videos table while preserving its title, description, channel name, YouTube URL, YouTube video ID, thumbnail URL, category, video type, featured status, published status, and sort order. Mark the existing public sample videos as published and keep exactly one sample video featured. Make the migration safe to run again by preventing duplicate categories and duplicate YouTube video IDs. After confirming the database records exist, update the public gallery to load active categories and published videos from Lovable Cloud. Order categories and videos by sort_order. Load the featured hero from the single record that is both published and featured. If no published featured record exists, display the existing missing-featured state. Keep search and category filtering working with the database records. Continue filtering only the small loaded public dataset in the browser for now. Show the existing loading state while records are loading. Show a helpful error state with a Retry button if loading fails. Keep a defensive application-level check that prevents an unpublished record from being displayed even if a query changes later. Organize database queries in a reusable data service or hooks instead of placing duplicate queries throughout components. Remove unused imports from the temporary sample-data file only after confirming the database-powered gallery works. Do not delete shared TypeScript types still used by the application. Do not add Sign In, Sign Up, Administrator, video-management, or category-management pages yet. Do not redesign or resize any working public component.
Creates the Video Vault database, migrates the sample content, and connects the public gallery to persistent records.
Wait for Lovable to finish creating the tables, policies, indexes, records, and application queries.
Database Structure
The finished `categories` table should contain these fields:
Field
Purpose
id
Unique category identifier
name
Public category name
slug
Unique URL-safe category value
description
Optional category description
sort_order
Category display position
is_active
Controls public category-filter visibility
created_at
Record creation time
updated_at
Last update time
The finished `videos` table should contain:
Field
Purpose
id
Unique video identifier
title
Public video title
description
Optional video description
channel_name
YouTube channel name
youtube_url
Original YouTube URL
youtube_video_id
Validated unique YouTube ID
thumbnail_url
Video card and hero image
category_id
Related category
video_type
regular or short
is_featured
Controls featured-hero selection
is_published
Controls public visibility
sort_order
Public display position
created_at
Record creation time
updated_at
Last update time
Featured Is Not a Category
A video's category describes its subject, such as Tutorials, Music, or Gaming.
Featured status is separate. It controls which published video appears in the homepage hero.
Keeping these values separate allows any published video from any category to become featured.
Step 3 — Confirm the Sample Data Was Migrated
03
Inspect the Cloud Records
Open the Lovable Cloud data interface.
Confirm that:
- The `categories` table exists
- The `videos` table exists
- All expected categories appear
- All temporary sample videos were transferred
- Every video has a category
- Every video has a YouTube video ID
- Every video has a thumbnail URL
- Regular videos use `regular`
- Shorts use `short`
- Public sample videos are published
- Exactly one video is featured
Do not manually create duplicate copies of the sample records.
Step 4 — Confirm the Gallery Uses Database Records
04
Refresh the Public Gallery
Refresh the Video Vault preview.
Confirm that:
- The featured hero still appears
- The same video cards still appear
- Categories remain in the correct order
- Search still works
- Category filters still work with search
- Regular videos still open correctly
- Shorts still open correctly
- Closing the modal stops playback
- Refreshing the browser does not remove the videos
The interface should look the same even though the data now comes from Lovable Cloud.
A Successful Data Migration Should Look Boring
Visitors should not notice that the data source changed.
The visible gallery should continue working exactly as before. The important difference is that videos and categories now persist in the database and can support the administrator backend added later.
Step 5 — Test Public Visibility Rules
05
Verify Published and Unpublished Content
In the Lovable Cloud data interface, choose a sample video that is not currently featured.
Temporarily change its `is_published` value to false.
Refresh the public gallery and confirm that the video no longer appears.
Change `is_published` back to true and confirm that it returns.
Next, temporarily deactivate a category by changing its `is_active` value to false.
Confirm that:
- The category disappears from the public filter controls
- Its videos are not deleted
- No database records are lost
Restore the category to active after testing.
Do Not Unpublish the Featured Video Yet
Later, Video Vault will automatically clear featured status when a featured video is unpublished.
That protection has not been added during this part. Use a nonfeatured video when testing published visibility.
Step 6 — Verify the Featured-Video Constraint
06
Confirm Only One Video Can Be Featured
Inspect the database migration or schema created by Lovable.
Confirm that the database includes a unique safeguard allowing no more than one record where `is_featured` is true.
This protection must exist in the database rather than only in the public interface.
Do not remove the currently featured value or attempt to force a second featured record if Lovable reports that the database constraint is active.
Protect Important Rules in More Than One Place
The administrator interface will later hide or disable invalid featured actions.
The database constraint provides a second layer of protection. Even if a future interface contains a bug, the database will still reject multiple featured records.
Part 3 Verification
Before continuing, confirm:
Cloud Database Connected
Video Vault now loads its public categories and published videos from Lovable Cloud.
The database supports regular videos, YouTube Shorts, publishing status, category relationships, sorting, and one featured video. Public visitors can view approved content but cannot modify it.
In Part 4, you'll create the first administrator account and protect the administrator backend.
Part 4 — Add Administrator Authentication
Video Vault now has a persistent database, but there is no secure way to manage its records.
In this part, you'll add administrator-only authentication using Lovable Cloud.
The authentication flow will:
1. Enable email-and-password authentication
2. Create the first administrator through a one-time setup page
3. Close registration automatically
4. Add Administrator Sign In and Sign Out
5. Protect every `/admin` route with an administrator-role check
Public visitors will continue using the video gallery without signing in.
Administrator Accounts Only
Video Vault does not need public visitor accounts.
Authentication is used only to protect the management area. The homepage, published videos, category filters, search, and popup player remain publicly accessible.
Step 1 — Add the Administrator Authentication System
01
Create Secure Administrator Access
Copy the following prompt into Lovable.
Add Administrator Authentication
Add secure administrator-only authentication to the existing Video Vault application using Lovable Cloud email-and-password authentication. Preserve the complete public gallery, Lovable Cloud video and category data, featured hero, search, category filters, responsive layout, popup video player, and black-and-red theme. The public gallery must remain accessible without signing in. Do not add visitor accounts, public registration, social login, or a second authentication system. Do not store passwords or authentication sessions in custom database tables. Create an app_role database enum limited to admin. Create a user_roles table containing id as a UUID primary key, user_id as a required foreign key referencing the authenticated user with cascade deletion, role as the admin enum, and created_at. Add a unique constraint preventing duplicate user and role combinations. Enable row-level security on user_roles. Do not give anonymous or normal authenticated browser users direct read or write access to user_roles. Users must not be able to view the administrator list, assign themselves a role, edit their role, or delete their role. Create secure backend role-checking helpers that can determine whether the current authenticated user has the admin role. Use a fixed safe database search path for security-definer functions. Create an atomic, backend-only first-administrator operation. It must check whether an administrator already exists, serialize simultaneous requests, create the first administrator role only when no administrator exists, and permanently reject future attempts after the first administrator is created. Do not trust a user ID supplied by the public browser when assigning administrator access. Create a one-time route at /admin/setup named Initial Administrator Setup. Before rendering it, securely check whether an administrator already exists. If setup is complete, redirect immediately to /admin/sign-in. Do not briefly display the registration form before redirecting. The setup form must contain Email Address, Password, and Confirm Password fields. Require the passwords to match and use a reasonable minimum such as at least 10 characters containing a letter and number. Include visible labels, show-and-hide password controls, validation, loading state, success feedback, and helpful errors without exposing sensitive technical details. The form must create the authentication account and assign its administrator role through secure backend logic. If role assignment fails, do not leave behind an ordinary account that can never administer the application. After successful setup, redirect to /admin/sign-in. Once an administrator exists, the setup route and backend operation must remain closed permanently. Do not add a reusable public Sign Up route. Create /admin/sign-in with Email Address and Password fields, visible labels, show-and-hide password control, validation, loading feedback, and a generic Incorrect email or password message that does not reveal whether the email exists. If sign-in succeeds, verify the administrator role before entering /admin. If the authenticated account does not have the administrator role, sign it out and deny access. Redirect an already authenticated administrator away from the Sign In page and into /admin. Create a protected /admin layout that requires both a valid authenticated session and the verified admin role before rendering protected information. While checking access, display a neutral Verifying administrator access loading state. Do not flash protected content. Redirect missing, expired, or unauthorized sessions to /admin/sign-in. Add a temporary protected administrator landing page displaying Video Vault Administration, the administrator email, and a working Sign Out button. Sign Out must clear the authentication session and return to /admin/sign-in. Do not add a prominent Admin or Sign In link to the public header. Administrators may visit /admin directly. Add noindex and nofollow metadata to setup, sign-in, and protected administrator pages. Match the existing black-and-red design, use a compact centered authentication panel, preserve accessible labels and visible focus indicators, and keep the pages responsive. Do not build video or category management yet. Do not add password recovery during this step.
Creates the one-time first-administrator setup, administrator sign-in, sign-out, role storage, and protected admin routes.
Wait for Lovable to finish creating the authentication flow and database security.
How the First-Administrator Setup Works
The setup page is available only while the application has no administrator.
The secure setup operation should:
1. Check whether an administrator already exists.
2. Lock the operation against simultaneous setup attempts.
3. Create the authentication account.
4. Assign the `admin` role through backend-only logic.
5. Close setup permanently.
6. Redirect later setup visits to Administrator Sign In.
Complete Setup Before Sharing the Project
Visit the setup page and create your administrator before publicly sharing the application.
The setup operation is designed to allow only the first successful administrator claim, but you should still complete this step as soon as it becomes available.
Enter the email address and password you want to use for Video Vault administration.
Use an email address you control and can continue accessing.
Select **Create Administrator**.
After the account is created, the application should redirect you to:
texttext
/admin/sign-in
Use a Dedicated Administrator Password
Use a unique password that you do not reuse on another website.
Do not place the password inside Lovable prompts, source files, screenshots, database tables, or tutorial notes.
Step 3 — Confirm Registration Closed
03
Revisit the Setup Route
Return to:
texttext
/admin/setup
Confirm that the application redirects to:
texttext
/admin/sign-in
The setup form must not appear again.
Also confirm:
- No public Sign Up page exists
- No Sign Up link appears in public navigation
- A second visitor cannot claim the administrator role
- The backend setup operation rejects later attempts
Removing the Form Is Not Enough
Registration must be closed in the backend as well as the interface.
A hidden or deleted setup page does not provide security if its administrator-creation operation remains publicly callable.
Step 4 — Sign In to Administration
04
Test Administrator Sign In
Open:
texttext
/admin/sign-in
Enter the email address and password created during setup.
Select **Sign In**.
Confirm that:
- A loading state appears while signing in
- Successful authentication redirects to `/admin`
- The page displays Video Vault Administration
- Your administrator email appears
- The protected page does not display before verification finishes
Step 5 — Test Incorrect Credentials
05
Verify Sign-In Errors
Sign out, then enter an incorrect email or password.
Confirm that the page displays a general message such as:
Incorrect email or password.
The error should not reveal:
- Whether the email address exists
- Whether the password alone was incorrect
- Authentication tokens
- Database errors
- Stack traces
- Internal security details
Step 6 — Test Protected Routes
06
Confirm Administrator Protection
Sign out of Video Vault.
Attempt to visit:
texttext
/admin
Confirm that the application redirects to:
texttext
/admin/sign-in
Sign in again and return to `/admin`.
Confirm that the administrator page becomes available only after both checks pass:
- Valid authenticated session
- Verified administrator role
Authentication and Authorization Are Different
Authentication confirms who signed in.
Authorization confirms that the signed-in account is permitted to access administration.
Video Vault must perform both checks. A valid account without the `admin` role must not enter `/admin`.
Step 7 — Test Sign Out
07
End the Administrator Session
From the protected administrator page, select **Sign Out**.
Confirm that:
- The session ends
- The application returns to Administrator Sign In
- Returning to `/admin` redirects back to Sign In
- The public gallery remains available
Part 4 Verification
Before continuing, confirm:
Administrator Access Secured
Video Vault now has a one-time administrator setup and a protected authentication flow.
Public visitors can continue browsing the gallery without an account, while `/admin` requires both a valid session and a securely verified administrator role.
In Part 5, you'll replace the temporary administrator landing page with the Video Vault dashboard and management navigation.
Optional Improvement — Password Recovery
Password recovery is useful for a production administrator account, but it is not required to continue building the gallery.
Add it after the primary administrator workflow is complete and tested.
Add Administrator Password Recovery
Add secure password recovery to the existing Video Vault administrator authentication flow without changing registration, administrator roles, public gallery access, or protected-route behavior. Add a Forgot Password link to /admin/sign-in and create /admin/forgot-password with one visible Email Address field. Send password-reset instructions through the existing Lovable Cloud authentication system. Always display the same response whether or not the email exists, such as “If an administrator account exists for that email, password reset instructions have been sent.” Create /admin/reset-password to handle the valid recovery session, collect New Password and Confirm New Password, validate matching passwords, update the existing authentication password, and return the administrator to /admin/sign-in after success. Include loading, success, expired-link, and invalid-link states. Do not expose account existence, tokens, raw errors, or technical details. Configure the reset redirect using the stable production domain when available rather than a temporary preview URL. Preserve the closed setup flow and do not add public registration.
Adds optional password recovery for the existing administrator account.
Part 5 — Build the Admin Dashboard
The protected `/admin` route currently contains only a temporary administrator landing page.
In this part, you'll build the Video Vault management interface.
The administrator backend will include:
- Dashboard summary cards
- Featured-video summary
- Recent videos
- Video management
- Category overview
- Search and status filters
- Responsive administrator navigation
- Two-row video records without horizontal scrolling
The Add Video, Edit Video, Delete, Publish, and Featured controls will be implemented in later parts.
Build the Management Interface Before the Forms
This part focuses on displaying and organizing the database records.
Building the dashboard and management lists first gives the Add and Edit forms clear destinations and makes it easier to verify later database changes.
Step 1 — Create the Administrator Dashboard
01
Build the Dashboard and Management Lists
Copy the following prompt into Lovable.
Build the Administrator Dashboard
Replace the temporary protected Video Vault administrator landing page with a complete responsive dashboard and management interface. Preserve the public gallery, Lovable Cloud database, one-time setup closure, administrator authentication, administrator role checks, Sign In, Sign Out, featured hero, search, category filters, popup player, and black-and-red theme. Do not rebuild authentication or create duplicate database tables. Create a reusable protected administrator layout for all routes under /admin. Include Video Vault Administration branding, navigation for Dashboard, Videos, and Categories, a View Public Gallery link, the signed-in administrator email, and a working Sign Out button. Use a desktop sidebar and compact mobile navigation. Clearly indicate the active section. Every administrator route must require both a valid authenticated session and the verified admin role. Do not render protected information until both checks finish. On /admin, create summary cards for Total Videos, Published Videos, Drafts, and Categories. Load the values from Lovable Cloud. Add a separate Featured Video panel displaying its thumbnail, title, channel, category, video type, published status, and featured status. If no featured video exists, display “No featured video selected.” Add a Recent Videos section showing the five most recently created or updated videos with title, category, last updated date, published status, and featured status. Include a View All link to /admin/videos. Add loading, empty, error, and Retry states. Create /admin/videos and load every video for verified administrators, including published and unpublished records. Add an Add Video button that routes to /admin/videos/new. For now, that route may display a clearly labeled “Video form coming next” state. Add search across title, channel name, description, and YouTube video ID. Add filters for category, video type, published status, and featured status. Add sorting for newest, oldest, title, and sort order. Include a Reset Filters button and result count. Store the current search, filters, and sorting in URL query parameters so they survive a refresh. Display desktop and tablet videos using one compact two-row record per video instead of a wide table. Do not use horizontal scrolling. In the first row, display the thumbnail, title, YouTube video ID, channel, category, and an Edit action aligned safely within the record. Allow long titles to use up to two lines and expose the full title in a title attribute or accessible tooltip. The Edit action may route to /admin/videos/VIDEO_ID/edit and display a clearly labeled temporary “Video form coming next” state. In the second connected row, display labeled values for video type, published status, featured status, sort order, and last updated date. Use a subtle border between the rows and stronger separation between video records. Use stacked management cards on mobile. Do not create fake buttons that appear to save, delete, publish, or feature content but do nothing. Create /admin/categories as a read-only overview for now. Display every category, including inactive categories, with name, slug, description, assigned-video count, active status, sort order, and last updated date. Add category search, active-status filtering, sorting, Reset Filters, result count, loading, empty, error, and Retry states. Use a responsive table or list that does not cause the entire page to scroll horizontally. Clearly explain that creating and editing categories will be added later. Add database read policies allowing only verified administrators to read every video, including unpublished videos, and every category, including inactive categories. Do not grant this access to all authenticated users. Preserve public policies so visitors still read only published videos and active categories. Keep the administrator interface practical and readable, with restrained red accents and glow. Use text plus badges for status rather than color alone. Add accessible labels to icon-only controls, visible keyboard-focus indicators, semantic record grouping, and noindex and nofollow metadata on administrator pages. Do not add working video creation, editing, deletion, publishing, featuring, bulk operations, pagination, or category editing during this step.
Creates the protected administrator dashboard, video-management list, filters, and category overview.
Wait for Lovable to finish before testing the administrator interface.
Step 2 — Review the Administrator Navigation
02
Test the Admin Layout
Sign in and open:
texttext
/admin
Confirm that the administrator layout includes:
- Video Vault Administration branding
- Dashboard
- Videos
- Categories
- View Public Gallery
- Administrator email
- Sign Out
Test the layout on desktop and mobile.
Confirm that:
- The active section is clearly indicated
- Desktop navigation uses the available space correctly
- Mobile navigation opens and closes
- View Public Gallery returns to the public site
- Sign Out still works
Step 3 — Verify the Dashboard Totals
03
Review the Summary Cards
Compare the dashboard totals with the records stored in Lovable Cloud.
Confirm that the dashboard accurately displays:
- Total Videos
- Published
- Drafts
- Categories
The total number of videos should equal:
texttext
Published Videos + Draft Videos
Also confirm that the Featured Video panel displays the current featured record.
Featured Status Is Display-Only for Now
The dashboard can identify the current featured video, but the control for changing it will be added later.
Do not manually edit featured status from the dashboard during this part.
Step 4 — Review Recent Videos
04
Inspect the Recent Videos List
Review the Recent Videos section.
Confirm that:
- No more than five videos appear
- The newest or most recently updated videos appear first
- Each entry displays its title
- Category appears
- Last updated information appears
- Published or Unpublished status appears
- Featured or Not Featured status appears
- View All opens `/admin/videos`
Step 5 — Test Video Search and Filters
05
Filter the Video Library
Open:
texttext
/admin/videos
Test the video search with:
- Part of a title
- A channel name
- Part of a description
- A YouTube video ID
Next, test these filters:
- Category
- Regular Video or Short
- Published or Unpublished
- Featured or Not Featured
Test each sorting option:
- Newest first
- Oldest first
- Title
- Sort order
Confirm that the result count updates and Reset Filters restores the complete list.
Refresh the page while filters are active and confirm that the URL parameters preserve them.
The Two-Row Video Layout
Each desktop video record should use two connected rows.
Primary row
The first row contains:
- Thumbnail
- Video title
- YouTube video ID
- Channel
- Category
- Edit action
Metadata row
The second row contains:
- Type
- Published status
- Featured status
- Sort order
- Last updated
Avoid Overloading a Wide Table
A traditional video-management table can become too wide when it includes thumbnails, titles, channels, categories, statuses, dates, and actions.
Using two connected rows keeps the information readable and prevents the Actions area from being cut off.
Step 6 — Test the Two-Row Records
06
Confirm Nothing Is Cut Off
Review `/admin/videos` on desktop and tablet.
Confirm that:
- Each video uses two connected rows
- The title has enough space
- Long titles wrap or truncate safely
- The complete title remains available through a tooltip or title attribute
- The YouTube ID appears beneath the title
- Status values appear in the second row
- The Edit action remains visible
- The page does not scroll horizontally
- No action area is cut off
On mobile, confirm that the records change to stacked cards.
Avoid Horizontal Table Scrolling
If Lovable creates one wide table row, ask it to replace the table with the two-row record structure.
Do not solve the problem by shrinking the text or allowing action buttons to extend outside the dashboard.
Optional Fix — Replace a Wide Video Table
Use this prompt only if Lovable creates a wide table that is cut off or requires horizontal scrolling.
Convert Videos to Two-Row Records
Replace the administrator video page’s wide single-row table with a compact two-row record layout for each video. Do not use horizontal scrolling. Preserve all data, search, filters, sorting, navigation, and black-and-red styling. In the first row display the thumbnail, video title, YouTube video ID beneath the title, channel name, category, and Edit action at the far right. In the second connected row display labeled values for video type, published status, featured status, sort order, and last updated date. Use a subtle divider between the rows and stronger spacing between separate video records. Give the second row a subtly different dark background. Allow long titles to use up to two lines and provide the complete title through an accessible tooltip or title attribute. Keep actions visible without clipping. Let fields wrap gracefully on narrower screens. Use semantic list or article markup so screen readers understand where each record begins and ends. Keep stacked management cards on mobile. Remove the wide table, sticky columns, minimum table width, and horizontal scrollbar. Do not change database queries, authentication, filters, or unrelated components.
Replaces an oversized table with the tested two-row video-management layout.
Step 7 — Review the Category Overview
07
Inspect Categories
Open:
texttext
/admin/categories
Confirm that each category displays:
- Name
- Slug
- Description
- Number of assigned videos
- Active or Inactive status
- Sort order
- Last updated date
The page should remain read-only during this part.
Step 8 — Test Loading and Error States
08
Verify Dashboard Feedback
Confirm that the administrator pages provide:
- Loading feedback while data is retrieved
- An empty state when no records exist
- A no-results state when filters match nothing
- A helpful error state when loading fails
- A Retry button
Video Vault now has a protected dashboard with accurate summary cards, recent videos, searchable video management, a category overview, and responsive two-row records.
In Part 6, you'll replace the Add Video placeholder with a complete form that validates YouTube URLs, extracts video IDs, detects Shorts, and generates thumbnail previews.
Part 6 — Add Videos
The administrator dashboard can display the video library, but the **Add Video** route still contains a temporary placeholder.
In this part, you'll replace that placeholder with a complete form that accepts common YouTube URLs, validates them, extracts the video ID, detects Shorts, generates a thumbnail, rejects duplicates, and saves the video as either published or unpublished.
No YouTube API Key Required
Video Vault does not use the YouTube API during this step.
The application extracts the video ID from the pasted URL and generates a standard thumbnail URL. The administrator enters the title, channel name, and description manually.
Supported YouTube URLs
The Add Video form will support:
texttext
https://www.youtube.com/watch?v=VIDEO_ID
texttext
https://youtu.be/VIDEO_ID
texttext
https://www.youtube.com/shorts/VIDEO_ID
It will also accept normal safe query parameters attached to supported YouTube URLs.
The form must reject unrelated and lookalike domains.
Step 1 — Build the Add Video Form
01
Replace the Add Video Placeholder
Copy the following prompt into Lovable.
Build the Add Video Form
Replace the temporary placeholder at /admin/videos/new with a complete Add Video form for Video Vault. Preserve the public gallery, Lovable Cloud database, administrator authentication, administrator role protection, dashboard, two-row video-management records, category overview, search, filters, popup player, and black-and-red theme. Do not rebuild authentication or create duplicate database tables. Ensure the static /admin/videos/new route opens the Add Video form and is not mistakenly handled as a dynamic video ID route. Require a valid authenticated administrator and verified admin role before rendering or saving. Add an administrator-only INSERT policy to the videos table using the existing secure admin-role helper. Do not allow anonymous visitors or every authenticated user to create videos. Build a reusable Video Form component that can later support editing. Organize the form into YouTube Information, Video Details, Organization, and Publishing Settings sections. Include required fields for YouTube URL, Thumbnail URL, Title, Channel Name, Category, Video Type, and Sort Order. Include an optional Description field limited to approximately 1000 characters. Include a Published switch defaulting to off. Do not include Featured in the Add Video form. Featured selection will be implemented later as a separate secure action. Accept only URLs from the exact hosts youtube.com, www.youtube.com, m.youtube.com, and youtu.be. Reject lookalike domains such as youtube.com.example.com or notyoutube.com. Accept standard watch links using youtube.com/watch?v=VIDEO_ID, shortened links using youtu.be/VIDEO_ID, and Shorts links using youtube.com/shorts/VIDEO_ID. Require an http or https URL and provide a helpful error when https:// is missing. Trim accidental whitespace. Extract only the YouTube video ID. Validate it as exactly 11 characters containing only letters, numbers, hyphens, or underscores. Never save the complete URL as the video ID and never inject the pasted URL directly into an iframe. Automatically detect /shorts/ links as Short. Treat watch and youtu.be links as Regular Video. Display the detected video ID clearly. Allow the administrator to change the Regular Video or Short selection manually after detection. Generate the default thumbnail as https://i.ytimg.com/vi/VIDEO_ID/hqdefault.jpg. Display a thumbnail preview and a helpful placeholder if the image cannot load. Allow the administrator to replace the thumbnail URL manually. Do not claim to retrieve the title, channel name, description, duration, or other metadata from YouTube without an API. Load active categories into the Category field. Require a category selection. Suggest the highest existing sort order plus one for new videos. Require a whole-number sort order of zero or greater. Allow repeated sort-order values without overwriting another video. Before saving, check whether the extracted YouTube video ID already belongs to another record. Display “That YouTube video is already in the library” when a duplicate is found. Keep the database uniqueness constraint on youtube_video_id as the final safeguard. Default new videos to unpublished. Explain that unpublished videos remain drafts hidden from the public gallery. If Published is enabled, allow the new video to appear publicly after saving. Disable Save Video while submitting, display Saving while the request is active, and prevent duplicate submissions. Preserve entered values after recoverable errors. Include a Cancel button returning to /admin/videos. Warn before leaving only when the administrator has unsaved changes. Do not warn after a successful save. After success, show “Video saved,” refresh the administrator video data, and return to /admin/videos without requiring a hard refresh. Display friendly errors for invalid URLs, duplicate videos, database failures, and expired administrator sessions. Redirect expired sessions to /admin/sign-in. Never display raw provider errors, database policies, stack traces, tokens, or internal security details. Use visible labels, required-field indicators, accessible error associations, keyboard controls, visible focus indicators, and a responsive form width. Do not add editing, deleting, bulk actions, category editing, or featured-video selection during this step.
Replaces the Add Video placeholder with the complete YouTube URL and publishing form.
Wait for Lovable to finish before testing the form.
Add Video Fields
The completed form should contain:
Section
Field
Required
YouTube Information
YouTube URL
Yes
YouTube Information
Detected Video ID
Automatic
YouTube Information
Thumbnail URL
Yes
YouTube Information
Thumbnail Preview
Automatic
Video Details
Title
Yes
Video Details
Channel Name
Yes
Video Details
Description
No
Organization
Category
Yes
Organization
Video Type
Yes
Organization
Sort Order
Yes
Publishing Settings
Published
No
Do Not Add Featured to This Form
A normal Featured checkbox could allow multiple browser operations to conflict.
Later, Video Vault will use a separate secure action that replaces the current featured video in one controlled database operation.
Step 2 — Test a Standard Watch Link
02
Add a Regular YouTube Video
Open:
texttext
/admin/videos/new
Paste a standard YouTube watch URL:
texttext
https://www.youtube.com/watch?v=VIDEO_ID
Confirm that:
- The URL is accepted
- The 11-character video ID appears
- Video Type selects Regular Video
- A thumbnail URL is generated
- A thumbnail preview appears
Complete the remaining required fields.
Leave **Published** off and save the video.
Step 3 — Confirm the Draft Is Private
03
Verify Unpublished Behavior
After saving, confirm that:
- The new video appears in `/admin/videos`
- Its status is Unpublished
- It does not appear in the public gallery
- Refreshing both pages preserves the result
This confirms that the public database policy is hiding draft records.
Step 4 — Test a Shortened Link
04
Add a youtu.be Video
Return to:
texttext
/admin/videos/new
Paste a shortened URL:
texttext
https://youtu.be/VIDEO_ID
Confirm that:
- The exact `youtu.be` domain is accepted
- The ID is extracted from the URL path
- The form selects Regular Video
- The thumbnail is generated
- The record saves successfully
Use a different video from the one added previously.
Step 5 — Test a YouTube Short
05
Add a YouTube Short
Paste a Shorts URL:
texttext
https://www.youtube.com/shorts/VIDEO_ID
Confirm that:
- The ID is extracted
- Video Type automatically selects Short
- A thumbnail preview appears
- The administrator can review or change the detected type
- The record saves successfully
If you publish the Short, open it from the public gallery and confirm that the vertical popup-player layout is used.
Shortened Links Are Not Automatically Shorts
A `youtu.be` link does not identify whether the destination is a Short.
Video Vault treats shortened links as Regular Video by default. The administrator can change the Video Type field manually when necessary.
Step 6 — Test URL Validation
06
Reject Unsafe or Unsupported URLs
Try several invalid values without saving them:
texttext
youtube.com/watch?v=VIDEO_ID
This should request a complete URL including `https://`.
texttext
https://example.com/watch?v=VIDEO_ID
This should be rejected because the domain is not YouTube.
texttext
https://youtube.com.example.com/watch?v=VIDEO_ID
This should be rejected as a lookalike domain.
texttext
https://www.youtube.com/watch
This should report that the `v=VIDEO_ID` value is missing.
Try a URL containing an incorrectly sized or invalid video ID.
Confirm that the form reports that a YouTube ID must contain exactly 11 letters, numbers, hyphens, or underscores.
Validate the Hostname Exactly
Do not validate a YouTube URL by checking whether its text merely contains the word `youtube`.
A malicious lookalike domain could include that word. Parse the URL and compare its hostname against an exact list of approved YouTube hosts.
Step 7 — Test Duplicate Protection
07
Reject an Existing Video
Return to the Add Video form and paste the URL of a video already stored in Video Vault.
Attempt to save it.
Confirm that:
- The duplicate is rejected
- A helpful message appears near the URL field
- A second record is not created
- The entered form details remain available
- The existing video remains unchanged
Two Layers of Duplicate Protection
Video Vault performs a friendly duplicate check before submitting.
The database also keeps `youtube_video_id` unique. This protects the library if two requests occur close together or the browser check is bypassed.
Step 8 — Publish a Video
08
Save a Public Video
Add another valid video and enable **Published** before saving.
After saving, confirm that:
- The video appears in `/admin/videos`
- Its status is Published
- It appears in the public gallery
- Search can find it
- Its category filter includes it
- Selecting the card opens the correct player
- Refreshing preserves the video
Step 9 — Test Cancel and Unsaved Changes
09
Leave the Form Safely
Open the Add Video form and change one or more fields.
Select **Cancel** or navigate away.
Confirm that the application warns about unsaved changes.
Return to the form without changing anything and select Cancel again.
Confirm that no warning appears when there are no unsaved changes.
After successfully saving a video, confirm that no unnecessary leave-page warning appears.
Troubleshooting — The Placeholder Still Appears
If selecting **Add Video** still displays “Video form coming next,” use this correction.
Connect the Add Video Route
The /admin/videos/new route still displays the temporary Video form coming next placeholder. Replace that placeholder with the completed Add Video form. Ensure the static /admin/videos/new route is defined or handled before dynamic video ID and Edit routes so new is not interpreted as a video ID. Do not create a duplicate form. Preserve the temporary placeholder on /admin/videos/VIDEO_ID/edit for now. Confirm that selecting Add Video, visiting /admin/videos/new directly, and refreshing that route all display the real form. Preserve all URL validation, duplicate checks, thumbnail generation, administrator permissions, publishing behavior, styling, and existing functionality.
Connects the completed Add Video form to the correct administrator route.
Part 6 Verification
Before continuing, confirm:
Add Video Complete
Administrators can now add standard YouTube videos, shortened YouTube links, and YouTube Shorts.
Video Vault validates every URL, extracts a safe video ID, detects Shorts, generates a thumbnail, rejects duplicates, and controls whether the saved video appears publicly.
In Part 7, you'll replace the Edit placeholder and add publishing changes and safe video deletion.
Part 7 — Edit and Delete Videos
Administrators can now add videos, but the Edit action still leads to a temporary placeholder.
In this part, you'll create the reusable Edit Video form and add safe deletion.
Administrators will be able to:
- Load an existing video
- Edit its information
- Publish or unpublish it
- Change its category or video type
- Receive an unsaved-change warning
- Delete it through a confirmation dialog
- Remove unpublished or deleted videos from the public gallery
- Automatically clear featured status when necessary
Reuse the Add Video Form
The Add and Edit pages use nearly identical fields and validation.
Instead of maintaining two separate forms, create one reusable Video Form component with Create and Edit modes. This prevents the two workflows from drifting apart later.
Step 1 — Add Editing and Safe Deletion
01
Replace the Edit Video Placeholder
Copy the following prompt into Lovable.
Add Video Editing and Deletion
Replace the temporary Edit Video placeholder in Video Vault with a complete editing interface and add safe administrator-only video deletion. Preserve the working Add Video form, strict YouTube URL parsing, duplicate checks, thumbnail generation, administrator authentication, administrator role checks, dashboard, two-row video-management layout, categories, public gallery, featured hero, search, filters, popup player, and black-and-red theme. Use the route /admin/videos/VIDEO_ID/edit. Require a valid authenticated administrator and verified admin role before loading or modifying the record. Add administrator-only UPDATE and DELETE policies to the videos table using the existing secure admin-role helper. Do not give update or delete access to anonymous visitors or every authenticated user. Load the selected video by its database ID. Display a loading state while retrieving it, a Retry state for loading errors, and a Video Not Found state when the record does not exist. Do not briefly display an empty form before loading completes. Reuse the existing Video Form component with separate Create and Edit modes rather than maintaining two unrelated forms. Prepopulate YouTube URL, detected YouTube video ID, thumbnail URL and preview, title, channel name, description, category, Regular Video or Short type, sort order, and published status. Display the current Published or Unpublished and Featured or Not Featured statuses above the form. Change the primary submit label to Save Changes. Disable it and display Saving while an update is active. After success, display Changes Saved, refresh administrator and public video data, and return to /admin/videos without requiring a hard refresh. Preserve entered values after recoverable errors. If the YouTube URL changes, run the same strict domain and video-ID validation used by Add Video. Extract the new ID, detect Shorts, and generate a new default thumbnail. Do not overwrite a manually customized thumbnail without warning. Check whether the new YouTube ID belongs to a different video. Allow the current record to keep its own ID but reject duplicates belonging to another record. Allow the Published switch to publish or unpublish the video. Publishing must make the video available to the public gallery after saving. Unpublishing must remove it from the public gallery. Add a database trigger or equivalent database-level safeguard that always sets is_featured to false whenever is_published becomes false. Also clear featured status in the application update operation when unpublishing, but keep the database safeguard as the final authority for every write path. Do not automatically select a replacement featured video. If no featured video remains, use the existing missing-featured hero state. Track whether form values changed. Warn before navigating away or selecting Cancel only when unsaved changes exist. Do not warn when nothing changed, while the initial data is loading, or after a successful save. Add a Delete action to the Edit Video page and each administrator video record. Selecting Delete must open an accessible confirmation dialog that displays the video title and explains that deletion permanently removes it and cannot be undone. Include separate Cancel and Delete Video buttons. Do not delete anything until Delete Video is deliberately confirmed. Disable the dialog and display Deleting while the request is active. Prevent repeated deletion requests. If Cancel is selected or Escape is pressed, close the dialog without changing the record and return focus to the Delete control. After successful deletion, remove the video from administrator and public data, display Video Deleted, and return to /admin/videos when deletion began on the Edit page. If the deleted video was featured, its featured record disappears with it. Do not automatically choose a replacement. Display the missing-featured public state until an administrator chooses another video later. Never remove the record from the interface unless deletion succeeds. Handle expired administrator sessions, missing records, duplicate IDs, update failures, and delete failures with helpful messages. Redirect expired sessions to /admin/sign-in. Never display raw database errors, row-level security details, stack traces, tokens, or internal configuration. Give every icon-only Delete control an accessible label containing the video title. Give the confirmation dialog an accessible name, trap focus inside it, support Escape to cancel, restore focus after cancellation, and preserve visible keyboard-focus indicators. Do not add featured-selection controls, bulk actions, pagination, or category editing during this step.
Adds the prepopulated Edit Video form, publishing changes, unsaved-change protection, and safe deletion.
Wait for Lovable to complete the form, policies, and database safeguard.
Step 2 — Open an Existing Video
02
Load the Edit Video Form
Open:
texttext
/admin/videos
Select **Edit** on one of the videos.
Confirm that the Edit page displays:
- Current publishing status
- Current featured status
- Last updated information
- YouTube URL
- Detected YouTube video ID
- Thumbnail URL and preview
- Title
- Channel name
- Description
- Category
- Video type
- Sort order
- Published switch
- Save Changes
- Cancel
- Delete
Every saved value should be prepopulated.
Step 3 — Edit Video Details
03
Save a Simple Change
Change a safe field such as:
- Title
- Description
- Channel name
- Category
- Sort order
Select **Save Changes**.
Confirm that:
- Saving appears while the request is active
- The button cannot be submitted repeatedly
- Changes Saved appears
- The administrator list updates
- The correct record changed
- The page does not require a hard refresh
If the video is published, confirm that the public gallery also displays the updated information.
Step 4 — Test YouTube URL Changes
04
Replace a Video URL
Edit a nonfeatured test video and paste a different valid YouTube URL.
Confirm that:
- The new video ID is extracted
- A Shorts link changes the type to Short
- A watch link changes the type to Regular Video
- A new default thumbnail is generated
- A manually customized thumbnail is not overwritten silently
- An ID belonging to another video is rejected
- The current record may retain its original ID
Cancel this test if you do not want to replace the saved video.
Step 5 — Test Unpublished Videos
05
Unpublish a Video
Choose a published video that is not currently featured.
Turn **Published** off and save the changes.
Confirm that:
- The administrator list displays Unpublished
- The video remains in the administrator backend
- The video disappears from the public gallery
- Search cannot reveal it publicly
- Its direct public card is no longer available
- Refreshing both pages preserves the state
Step 6 — Publish a Draft
06
Publish an Unpublished Video
Edit an unpublished video.
Turn **Published** on and save.
Confirm that:
- The administrator list displays Published
- The video appears in the public gallery
- Search can find it
- Its category filter includes it
- Its popup player works
Step 7 — Test the Unsaved-Change Warning
07
Leave an Edited Form
Open an existing video and change one field without saving.
Select **Cancel** or attempt to navigate away.
Confirm that the application warns about unsaved changes.
Cancel the navigation and return to the form.
Save the changes, then leave again.
Confirm that no warning appears after a successful save.
Also open another video without changing anything and select Cancel.
No warning should appear when the form is unchanged.
Do Not Warn During Initial Loading
The form must establish its original values after the video finishes loading.
If the form treats loading values as user edits, it may display an unsaved-change warning immediately. Only deliberate changes made after loading should mark the form as dirty.
Step 8 — Test Delete Cancellation
08
Open the Delete Confirmation
Choose a test video and select **Delete**.
Confirm that the dialog displays:
- Delete This Video?
- The video's title
- A permanent-deletion warning
- Cancel
- Delete Video
Select **Cancel**.
Confirm that:
- The dialog closes
- The video remains
- No database record changes
- Keyboard focus returns to the Delete control
Step 9 — Delete a Video
09
Confirm Permanent Deletion
Add a disposable test video if necessary.
Open its Delete confirmation and select **Delete Video**.
Confirm that:
- Deleting appears
- The action cannot be submitted repeatedly
- The dialog cannot be dismissed midway through deletion
- The video disappears from `/admin/videos`
- The video disappears from the public gallery
- The application returns to the video list
- Refreshing confirms that the record is gone
Deletion Cannot Be Undone
Use a disposable test video when verifying deletion.
The confirmation dialog protects against accidental selection, but confirmed deletion permanently removes the database record.
Step 10 — Test Featured-Status Cleanup
10
Protect the Featured Hero
Inspect the database logic created during this part.
Confirm that changing any video to unpublished automatically clears its featured status at the database level.
If you test this with the current featured video, expect:
- The video to become unpublished
- Its featured status to become false
- The public hero to display the missing-featured state
- No random replacement to be selected
If a featured video is deleted, the record and its featured status disappear together.
The next part will provide a safe yellow-star control for choosing a new featured video.
Enforce Publishing Rules in the Database
The Edit form clears featured status when unpublishing a video.
The database trigger provides a second layer of protection, ensuring that an unpublished video cannot remain featured even if a future update comes from another interface.
Part 7 Verification
Before continuing, confirm:
Video Management Complete
Administrators can now edit video details, publish or unpublish records, leave forms safely, and permanently delete videos through an accessible confirmation dialog.
The database also prevents unpublished videos from remaining featured.
In Part 8, you'll complete category management by adding secure creation, editing, ordering, activation, deactivation, and safe deletion.
Part 8 — Manage Categories
Video Vault already organizes videos into categories, but the Categories page was initially read-only.
In this part, you'll allow administrators to:
- Create categories
- Edit existing categories
- Generate and change category slugs
- Control category order
- Activate or deactivate categories
- Safely delete empty categories
- Protect every category operation with administrator permissions
Categories Organize the Public Gallery
Active categories appear as filters in the public gallery.
Inactive categories remain available in administration, but they disappear from the public filter controls. Deactivating a category does not delete its videos.
Step 1 — Add Category Management
01
Replace the Read-Only Categories Page
Copy the following prompt into Lovable.
Add Category Management
Replace the read-only Video Vault Categories page and its Category editing coming later placeholder with complete administrator category management. Preserve category search, status filtering, sorting, result count, Reset Filters, public gallery, video management, Add and Edit Video forms, authentication, administrator protection, publishing, featured-video behavior, responsive layout, and black-and-red styling. Do not create a duplicate categories table. Add administrator-only INSERT, UPDATE, and DELETE policies for categories using the existing secure admin-role helper. Do not grant category write access to anonymous visitors or ordinary authenticated users. Keep public read access limited to active categories. Add an Add Category button connected to /admin/categories/new. Build one reusable Category Form component with Create and Edit modes. Include required Name and Slug fields, optional Description, Sort Order as a whole number of zero or greater, and an Active control defaulting to on. Generate a suggested lowercase hyphenated slug from the category name. Remove unsupported punctuation, repeated hyphens, and leading or trailing hyphens. Allow the administrator to edit the slug manually and stop replacing it automatically after manual editing begins. Reject duplicate slugs with a helpful field message while preserving the database unique constraint as the final safeguard. Disable repeated submission, display Saving during submission, preserve values after recoverable errors, and return to /admin/categories after success. Add a visible Actions area to each desktop category record and mobile category card. Make the category name a link to its Edit page and add a clearly labeled Edit button. Use /admin/categories/CATEGORY_ID/edit. Load and prepopulate Name, Slug, Description, Sort Order, and Active status. Display Loading, Error with Retry, and Category Not Found states. Keep the category database ID unchanged during editing so assigned videos remain connected. Explain that changing a slug may affect saved category-filter links and require confirmation before saving a changed slug. Warn before leaving only when unsaved changes exist. Allow administrators to activate or deactivate a category. Inactive categories must disappear from public filter controls without deleting the category or its videos. Published videos assigned to an inactive category may remain visible under All Videos. Keep inactive categories visible in administration. Add a Delete action with an accessible confirmation dialog. If a category has no assigned videos, allow deletion after confirmation. If one or more videos use it, block deletion and display the assigned-video count with a link to /admin/videos filtered to that category. Never cascade-delete or automatically reassign videos. Keep the category foreign key configured to restrict deletion while videos reference it. Refresh administrator categories, administrator videos, public category filters, public gallery data, dashboard totals, and video-form category options after successful changes without requiring a hard refresh. Keep desktop Actions visible without horizontal page scrolling and preserve stacked mobile category cards. Use accessible labels containing the category name, focus trapping in dialogs, Escape to cancel, restored focus, visible keyboard-focus indicators, and text labels in addition to status colors. Handle duplicate slugs, missing records, expired sessions, restricted deletion, and database failures without exposing raw errors, policies, stack traces, tokens, or internal configuration. Remove the old Category editing coming later placeholder after the working controls are installed. Do not add bulk category operations, drag-and-drop sorting, pagination, or unrelated features.
Adds secure category creation, editing, activation, ordering, and safe deletion.
Wait for Lovable to finish before testing the category forms.
Step 2 — Add a Category
02
Create a New Category
Open:
texttext
/admin/categories
Select **Add Category**.
Enter:
- Name
- Slug
- Description
- Sort order
- Active status
Confirm that entering the name generates a suggested slug.
For example:
texttext
Web Development
should generate:
texttext
web-development
Save the category.
Confirm that:
- The category appears in administration
- Its values are correct
- Its video count begins at zero
- An active category appears in public filters
- Refreshing preserves it
Step 3 — Test Duplicate Slugs
03
Protect Unique Category Slugs
Attempt to create another category using an existing slug.
Confirm that:
- The form rejects the duplicate
- A helpful message appears near the Slug field
- The entered values remain available
- No duplicate database record is created
Two Duplicate Safeguards
The form checks whether a slug already exists before saving.
The database unique constraint provides a second safeguard if two requests occur close together or the form check is bypassed.
Step 4 — Edit a Category
04
Open the Edit Category Form
Return to `/admin/categories`.
Select either:
- The category name
- Its Edit button
Confirm that the Edit page loads the correct category and prepopulates:
- Name
- Slug
- Description
- Sort order
- Active status
Change its description and save.
Confirm that the category list displays the updated description.
Step 5 — Change a Category Slug
05
Confirm Slug Changes
Edit a test category and change its slug.
Confirm that:
- A warning explains that saved filter links may be affected
- Canceling the warning prevents the change
- Confirming allows the change
- The category ID remains unchanged
- Assigned videos remain connected
- The public filter uses the new slug
Slugs May Appear in Saved Links
Changing a category slug does not disconnect its videos because relationships use the category ID.
However, bookmarks or shared links containing the old slug may no longer select that category.
Step 6 — Test Category Order
06
Change Filter Position
Edit the category's Sort Order.
Use a lower number to move it earlier or a higher number to move it later.
Save and confirm that:
- The administrator list reflects the new order
- The public category filters reflect the new order
- No videos are changed
Step 7 — Deactivate a Category
07
Hide a Public Category Filter
Edit a category and turn **Active** off.
Save the change.
Confirm that:
- The category remains visible in administration
- Its status displays Inactive
- It disappears from public category filters
- Its assigned videos are not deleted
- Published videos remain available under All Videos
Turn Active back on and confirm that the filter returns.
Step 8 — Delete an Empty Category
08
Remove an Unused Category
Create a disposable category with no assigned videos.
Select Delete on a category containing one or more videos.
Confirm that:
- Deletion is blocked
- The assigned-video count appears
- No Delete Category confirmation is available
- A View These Videos link appears
- The link opens the video list filtered to that category
- No videos are deleted or reassigned
Never Cascade-Delete Category Videos
Deleting a category should never silently delete every video assigned to it.
Video Vault restricts category deletion at both the interface and database levels while video records still reference it.
Part 8 Verification
Before continuing, confirm:
Category Management Complete
Administrators can now create, edit, order, activate, deactivate, and safely delete Video Vault categories.
Categories containing videos remain protected, and inactive categories can be hidden from public filters without losing any content.
In Part 9, you'll use the yellow-star control to choose the featured video.
Part 9 — Choose the Featured Video
Video Vault can identify a featured video, but administrators still need a safe way to change the homepage hero.
In this part, you'll add a clearly labeled yellow-star control that:
- Features only published videos
- Replaces the current featured video
- Prevents multiple featured videos
- Updates the public hero
- Allows featured status to be removed
- Never selects a random replacement
At Most One Featured Video
Video Vault allows either:
- One featured video
- No featured video
It must never allow two featured videos.
If the current featured video is unpublished, deleted, or deliberately removed from the hero, Video Vault displays its existing missing-featured state until an administrator chooses another one.
Why Featured Replacement Needs a Secure Operation
A browser could attempt to replace the featured video using two updates:
1. Remove featured status from the current video.
2. Add featured status to the new video.
This approach can fail between updates or conflict with another request.
Video Vault will instead use one protected database operation that performs both changes together.
Replace Featured Status Atomically
The secure database operation clears the previous featured record and assigns the new one inside one transaction.
Either the complete replacement succeeds or nothing changes.
Step 1 — Add the Yellow-Star Featured Control
01
Build Secure Featured-Video Management
Copy the following prompt into Lovable.
Add the Featured Video Selector
Add secure featured-video management to the existing Video Vault administrator backend. Preserve the Add Video form, Edit Video form, publishing and unpublishing, safe deletion, two-row video-management records, dashboard, authentication, administrator role protection, public gallery, featured hero, search, category filters, popup player, database tables, and black-and-red theme. Only one video may be featured at a time. Preserve the existing partial unique database index or equivalent database constraint that allows no more than one videos record where is_featured is true. Add an administrator-only secure database function named set_featured_video or an equivalent protected backend operation. It must determine the current user from the authenticated session, verify the user has the admin role, confirm the requested video exists, confirm the video is published, serialize competing featured-video requests, clear featured status from the previous video, and mark the requested video as featured. Perform the removal and assignment within one database transaction. Do not have the browser run two separate updates. Use a fixed safe search path if the function uses security-definer privileges. Do not allow anonymous visitors or ordinary authenticated users to run the operation successfully. Grant execution only where necessary. Preserve the database unique-featured constraint as an additional safeguard. Optionally add a separate secure clear_featured_video operation that verifies administrator access and removes featured status from the current video without selecting a replacement. Add a reusable featured-video control to every administrator video record and the Edit Video page. For a published video that is not currently featured, display a yellow star icon with the visible label Set as Featured. Use a yellow or amber border, text, subtle background, and visible focus style so the action is distinct from red destructive controls. For the current featured video, display a filled yellow star with the visible label Featured. Also provide a clearly labeled Remove Featured action if the secure clear operation is implemented. For unpublished videos, do not offer Set as Featured. Display no featured action or explain “Publish this video before featuring it.” Do not automatically publish a draft when featuring is attempted. Selecting Set as Featured should immediately call the secure database replacement operation. Disable repeated selection and display Saving while the operation runs. After success, refresh the administrator video list, administrator dashboard, Edit Video record, and public gallery data without requiring a hard browser refresh. Display “This video is now featured.” The old video must lose its Featured badge and the new video must receive the filled yellow star. The public hero must display the new featured video. If Remove Featured is selected, clear the status securely, display “Featured status removed. No video is featured,” and show the public missing-featured state. Preserve the existing behavior that unpublishing a featured video clears its featured status. Deleting a featured video must also leave no featured video. Never automatically choose a random replacement after unpublishing, deletion, removal, or an error. Handle expired administrator sessions, missing videos, unpublished-video attempts, database conflicts, and failed replacements. If replacement fails, preserve the previous featured video and display “The featured video could not be changed right now. Nothing was changed.” Redirect expired sessions to /admin/sign-in. Never expose raw database errors, row-level security details, stack traces, tokens, or internal function details. Give star controls accessible labels containing the video title, such as Set VIDEO_TITLE as featured. Use visible text with the icon rather than relying on the star or yellow color alone. Preserve keyboard access and visible focus indicators. Do not add bulk featured actions, random replacement logic, pagination, or unrelated features.
Adds the yellow-star control and secure one-featured-video replacement operation.
Wait for Lovable to finish creating the database operation and administrator controls.
Featured-Control States
The administrator video list should display one of these states:
Video state
Administrator control
Published and not featured
Yellow star + Set as Featured
Published and featured
Filled yellow star + Featured
Unpublished
No featured action or a publish-first explanation
Featured with removal available
Remove Featured action
Do Not Use a Normal Form Checkbox
Featured replacement should not be submitted as an ordinary field in the Add or Edit Video form.
Use the separate secure featured operation so the previous record and new record are updated safely.
Step 2 — Feature a Published Video
02
Select a New Hero Video
Open:
texttext
/admin/videos
Find a published video that is not currently featured.
Select:
⭐ Set as Featured
Confirm that:
- Saving appears while the operation runs
- The button cannot be selected repeatedly
- The new video receives a filled yellow star
- The visible status changes to Featured
- The previous video loses its Featured badge
- A success message appears
- No page refresh is required
Step 3 — Verify the Public Hero
03
Confirm the Homepage Updated
Open the public Video Vault gallery.
Confirm that the featured hero now displays:
- The newly featured video's thumbnail
- Title
- Description
- Channel name
- Category
- Video type
- Watch Now button
Select **Watch Now** and confirm that the correct video opens in the popup player.
Refresh the page and confirm that the featured selection persists.
Step 4 — Confirm the Previous Video Was Replaced
04
Verify Only One Record Is Featured
Return to the administrator video list.
Confirm that:
- The new video displays Featured
- The old video displays Set as Featured
- No second filled yellow star appears
- Filtering by Featured returns only one video
Inspect the Lovable Cloud `videos` records.
Confirm that no more than one record has:
texttext
is_featured = true
Two Layers Protect the Rule
Video Vault now uses:
1. A secure replacement function that clears the old selection and assigns the new one.
2. A unique database constraint that rejects multiple featured records.
The interface communicates the rule, while the database enforces it.
Step 5 — Attempt to Feature a Draft
05
Protect Unpublished Videos
Find an unpublished video in the administrator list.
Confirm that:
- Set as Featured is unavailable
- The interface does not automatically publish the video
- The draft remains hidden from the public gallery
If you deliberately attempt the secure featured operation for an unpublished record during testing, the backend should reject it with a helpful message:
Only published videos can be featured. Publish this video first.
The current featured video must remain unchanged.
Step 6 — Unpublish the Featured Video
06
Clear the Hero Through Unpublishing
Open the current featured video's Edit page.
Turn **Published** off and save the changes.
Confirm that:
- The video becomes Unpublished
- Its featured status is cleared
- It disappears from the public gallery
- The homepage displays the missing-featured state
- No other video becomes featured automatically
Publish the video again if you want it available publicly.
Publishing it again must not automatically restore featured status. Use **Set as Featured** deliberately when needed.
Step 7 — Delete a Featured Test Video
07
Confirm Deletion Does Not Pick a Replacement
Use a disposable published test video for this test.
Set it as featured, then delete it through the existing confirmation dialog.
Confirm that:
- The record is deleted
- Its featured status disappears with it
- The public hero displays the missing-featured state
- Another video is not selected automatically
- The administrator must deliberately choose a replacement
Step 8 — Remove Featured Status
Complete this step only if the optional **Remove Featured** action was added.
08
Leave the Hero Empty
Select **Remove Featured** on the current featured video.
Confirm that:
- Featured status is removed
- The video remains published
- The public video card remains available
- The homepage uses the missing-featured state
- No replacement is selected
- The administrator can feature another video later
Step 9 — Test Failure Safety
09
Preserve the Current Selection After an Error
Confirm from the implementation and normal error handling that if featured replacement fails:
- The old featured video remains featured
- The requested video does not receive a false Featured badge
- The public hero remains unchanged
- A helpful error appears
- Retrying is possible
- No raw technical details are displayed
Part 9 Verification
Before continuing, confirm:
Featured Video Management Complete
Administrators can now choose the homepage hero using a clearly labeled yellow-star control.
Video Vault securely removes the previous selection and assigns the new featured video in one protected database operation. Unpublished videos cannot be featured, and deleting or unpublishing the current selection never chooses a random replacement.
In Part 10, you'll complete the final testing checklist and publish Video Vault.
Part 10 — Final Testing and Publishing
Video Vault is ready for its final review.
Test the main public and administrator workflows before publishing. Keep this review focused on the features built throughout the tutorial.
Step 1 — Test the Public Gallery
01
Review the Public Experience
Sign out and open the public homepage.
Confirm:
Step 2 — Test Search and Categories
02
Filter the Gallery
Confirm:
Step 3 — Test Regular Videos and Shorts
03
Review Popup Playback
Open at least one regular video and one Short.
Confirm:
Step 4 — Test Administrator Protection
04
Verify Protected Access
While signed out, visit:
texttext
/admin
Confirm:
Step 5 — Test Video Management
05
Complete an Administrator Workflow
Use a disposable YouTube video for this test.
1. Add it as unpublished.
2. Confirm it remains hidden publicly.
3. Edit its title or description.
4. Publish it.
5. Confirm it appears publicly.
6. Unpublish it.
7. Confirm it disappears publicly.
8. Delete it through the confirmation dialog.
Confirm:
Step 6 — Test Featured-Video Replacement
06
Confirm One Featured Video
Select **Set as Featured** on a published video.
Then select it on a second published video.
Confirm:
Two Featured-Video Safeguards
Video Vault replaces the featured video through a protected database function.
The function verifies administrator access, confirms the new video is published, removes the previous selection, and assigns the new one inside one transaction.
A unique database index provides a second safeguard by preventing more than one featured record.
The database permits **at most one** featured video. Before publishing, deliberately select one published video so the finished gallery has **exactly one** featured hero.
Step 7 — Test the Mobile Layout
07
Review Mobile Video Vault
Use Lovable's mobile preview or a real mobile device.
Confirm:
Step 8 — Publish Through Lovable
08
Publish Video Vault
Before publishing:
Use Lovable's publishing controls to publish the latest working version.
Open the published URL in a signed-out browser and repeat these checks:
You built and published a responsive YouTube gallery with search, categories, regular videos, Shorts, a popup player, Lovable Cloud data, protected administrator access, video management, and secure featured-video replacement.
Optional Improvement — Password Recovery
Use this optional extension if the administrator needs a self-service password-reset workflow.
Add Optional Password Recovery
Add secure administrator password recovery to Video Vault without reopening registration. Add Forgot Password to /admin/sign-in, create an email-request page, and always display the same response whether or not the account exists. Create a reset-password page that handles a valid recovery session, collects and confirms the new password, updates the existing account, and returns to Administrator Sign In. Use the stable published domain for reset redirects. Do not expose account existence, reset tokens, raw errors, or technical details.
Adds optional password recovery while keeping public registration closed.
Part 11 — Optional Gallery Add-ons
The completed Video Vault already supports public browsing, search, categories, regular videos, Shorts, administrator management, publishing, and a single featured hero video.
This optional lesson adds two improvements for a growing gallery: progressive video loading and automatic playback after a visitor intentionally opens the popup player.
Complete either add-on independently or add both.
What You’ll Add
- A database-backed Load More experience
- Accurate visible and total video counts
- Search and category filters that reset pagination
- Automatic modal playback after a visitor selects a video
- Reliable playback cleanup when the modal closes
Step 1 — Add Load More Pagination
01
Load Published Videos in Batches
As the gallery grows, loading every video during the first page visit becomes unnecessary. Add a Load More control so the first group appears quickly and visitors can request additional videos without losing the footer.
Copy this prompt into Lovable.
Add Load More Pagination
Add database-backed Load More pagination to the public Video Vault gallery while preserving the existing black-and-red design, featured hero, search, category filters, video cards, popup player, administrator backend, publishing controls, featured-video enforcement, and responsive layout. Initially request and display 12 published videos using the gallery's existing stable sort order. Add a centered Load More button underneath the video grid whenever additional matching videos are available. Each selection should request and append the next 12 published videos without replacing the cards already displayed. Show an accurate “Showing X of Y videos” count. Hide the button after all matching videos are loaded. Perform pagination, search, category filtering, published filtering, and ordering in the database query instead of downloading every video and hiding results in the browser. Reset the results to the first batch whenever the search query or selected category changes. Prevent duplicate cards across batches and use a deterministic secondary sort value when needed. Disable the button during a request, show accessible loading feedback, and provide a clear retry action if a request fails. Preserve the visitor's scroll position when results are appended. Keep the footer reachable and do not add automatic infinite scrolling. Query only published public content and do not expose drafts or unpublished records through public requests. Verify desktop, tablet, mobile, empty-result, final-page, loading, and failure states. Run the build and type check when finished.
Loads published gallery videos in manageable database-backed batches.
After Lovable finishes, test the gallery with enough published videos to create more than one batch.
Confirm:
Why Use Load More Instead of Automatic Infinite Scroll?
Load More keeps navigation predictable, leaves the footer accessible, and gives visitors control over additional database requests. It provides most of the convenience of infinite scrolling without making the page feel endless.
Step 2 — Autoplay the Selected Modal Video
02
Start Playback When the Modal Opens
The visitor has already selected a video, so the modal can request autoplay as it creates the YouTube player. The player must also be removed completely when the modal closes so audio never continues in the background.
Copy this prompt into Lovable.
Autoplay Modal Videos
Update the existing Video Vault popup player so a selected YouTube video requests autoplay when its modal opens after an intentional visitor click. Preserve the large 16:9 regular-video player, vertical Shorts layout, text underneath the player, transparent surrounding area, thick red border, layered glow, approximately 75-percent desktop modal size, responsive mobile behavior, Escape handling, backdrop close, focus management, and scroll locking. Add autoplay=1 and playsinline=1 to the YouTube embed created for the selected video, and ensure the iframe allow attribute permits autoplay. Support both regular YouTube videos and Shorts. Create only one active player at a time and do not preload or autoplay videos while their cards or featured hero remain on the gallery page. When another video is selected, stop and remove the previous player before creating the new one. When the modal closes through its close button, Escape key, backdrop click, browser navigation, or component unmount, stop playback immediately by unmounting the iframe or clearing its source. Return keyboard focus to the card or hero control that opened the modal. If a browser blocks autoplay, keep the normal YouTube player visible and ready for the visitor to press Play; do not show a false error. Do not autoplay the featured hero until the visitor opens it. Do not create custom controls that cover YouTube's required player controls. Verify that only one player exists, no audio continues after closing, regular videos and Shorts retain their correct aspect ratios, and the build and type check pass.
Starts the selected video automatically and cleans up playback when the modal closes.
Test regular videos and Shorts separately.
Confirm:
Browsers Can Still Block Autoplay
Autoplay with sound is most likely to work when a visitor clicks a card or hero button to open the modal. A browser may block playback when a modal opens automatically from a shared URL or without a recent user interaction. Keep the standard YouTube Play button available as the fallback.
Optional Add-ons Checklist
Optional Gallery Add-ons Complete!
Video Vault can now grow without loading every published video at once, and selected videos begin playing as soon as the browser allows. The existing public gallery, administrator workflow, featured-video rule, categories, regular-video layout, and Shorts layout remain intact.
Additional Optional Add-ons
The following optional steps can be appended after the existing pagination and autoplay lessons. They do not require replacing the blocks already added to the tutorial.
Step 3 — Hide the Lovable Badge (Optional Paid Feature)
03
Turn Off the Published-Site Badge
Lovable allows eligible paying users to hide the Lovable badge from a published project through Project settings. This is a platform setting, so you do not need to ask Lovable to remove the badge through application code.
In the Lovable editor:
1. Select the project name in the upper-left corner.
2. Open **Settings** or **Project settings**.
3. Find the Lovable badge setting.
4. Turn off the option that displays the badge on the published website.
5. Save the setting.
6. Select **Publish**, then **Update** so the latest settings are reflected on the live site.
7. Open the published gallery in a new tab and confirm the badge is no longer visible.
If the badge toggle is unavailable, confirm that the project belongs to an eligible paid workspace and that your project role permits editing project settings. Do not hide the badge by covering it with CSS, deleting unrelated elements, or adding a visual overlay.
Confirm:
The Badge Setting Depends on Your Plan
Lovable currently documents badge removal as a paid-plan capability. If the setting is not available, leave the badge in place and continue with the tutorial. Do not use unsupported CSS workarounds.
Step 4 — Rebrand the Site Name and Logo
04
Replace the Starter Branding
Choose a new gallery name and prepare a logo you have permission to use. A transparent PNG or SVG works well for the application header, while a simple square version works best as a favicon.
Copy this prompt into Lovable after replacing the bracketed values.
Rebrand the Video Gallery
Rebrand the existing Video Vault application as “[NEW SITE NAME]” using the supplied [LOGO FILE OR MEDIA ASSET]. Replace the visible Video Vault name and logo consistently across the public header, featured hero branding, footer, administrator navigation, authentication screens, empty states, loading states, and any other user-facing location where the old brand appears. Preserve the current black-and-red visual theme, public gallery, search, categories, regular-video and Shorts modal layouts, Load More behavior, administrator authentication, video and category management, publishing controls, and single-featured-video enforcement. Use the new logo responsively without stretching or cropping it, preserve its transparent background when provided, add accurate alt text, and maintain readable spacing on desktop and mobile. Search the project for remaining user-facing references to “Video Vault” and replace only brand-name references; do not rename database tables, routes, environment variables, internal identifiers, or working code unless a change is genuinely required. Update application-level page titles, accessible labels, and descriptive text to use the new brand. Run the build and type check when finished, then report any old-brand references intentionally retained for technical compatibility.
Replaces the visible starter name and logo without rebuilding the gallery.
After the application branding is updated, configure the published website identity:
1. Select **Publish** in Lovable.
2. Open the website information or publishing settings.
3. Select the current icon and upload the square favicon version of the new logo.
4. Select the current site title and enter the new site name.
5. Replace the site description with a concise description of the gallery.
6. Upload a branded 16:9 social sharing image when one is available.
7. Review the published URL. Changing the project name does not automatically change the `lovable.app` subdomain.
8. If desired, edit the URL subdomain through the publishing or Project settings, or connect a custom domain when the current plan supports it.
9. Publish or update the project.
10. Open the live website and verify the browser tab, public page, administrator pages, favicon, and shared-link preview.
Confirm:
Branding Add-ons Checklist
Gallery Branding Complete!
The gallery now presents a consistent custom identity across the public site, administrator area, browser metadata, and shared links. Existing gallery and administrator features remain intact.