Lovable (Vibe Coding) TutorialIntermediate120 min read
Build an AI-Powered FAQ with Lovable
Build a searchable FAQ with Lovable Cloud, a protected administrator backend, AI-generated questions and answers, review and publishing controls, categories, and realtime public updates.
Tutorial ForgeUpdated Aug 25, 2026
In this tutorial, you'll build **Answers Hub**, a searchable FAQ website with an administrator-only AI workflow.
Visitors can search, filter, and expand published questions. Administrators provide business information, ask AI to generate one question or a complete FAQ set, review the generated questions and answers, and approve or publish them.
The completed project includes:
- Searchable public FAQ accordions
- Category filters and deep links
- Lovable Cloud database storage
- Published and Draft FAQ states
- One-time administrator setup
- Protected administrator routes
- AI generation for one FAQ or a complete FAQ set
- Generated question and answer review
- Approve, publish, reject, restore, edit, unpublish, and delete controls
- Category management
- Realtime public synchronization
- Accessible responsive layouts
- A Lovable account
- Access to Lovable Cloud
- Lovable AI credits for generation testing
- A modern browser
- Information about a sample business or website
- About two hours
Build and test one layer at a time. Do not add Cloud, authentication, AI, and administrator tools in the first prompt.
AI Never Publishes Automatically
Every AI-generated question and answer begins as a private Pending suggestion. An administrator must review it before creating a Draft or Published FAQ record.
Part 1 — Build the Public FAQ
Begin with temporary sample data so the public experience can be tested independently.
Step 1 — Create the Lovable Project
Create a new Lovable project named **Answers Hub**.
Step 2 — Generate the Public FAQ
Build the Public FAQ
Build a polished responsive FAQ website named Answers Hub using temporary sample data. Create at least ten realistic questions across General, Accounts, Billing, Shipping, Technical Support, Privacy, and Security. Add a Help Center header, page title, description, search field, category filters, accessible accordion cards, Popular badges for featured questions, optional related links and CTA buttons, an empty search state, Reset Filters, and a Still Have Questions support card. Published sample questions should sort featured items first and then by sort order. Use a clean light design with white cards, a pale page background, deep-navy question text, dark-teal answer text, visible focus styles, comfortable mobile spacing, and no horizontal scrolling. Allow one accordion item to remain open at a time. Support mouse, touch, Enter, Space, Arrow Up, Arrow Down, Home, End, and Escape. Add aria-expanded, aria-controls, labelled answer regions, and URL hash deep links. Do not add Lovable Cloud, authentication, AI, or administrator pages yet.
Creates the complete public FAQ using temporary sample content.
Step 3 — Test the Public Experience
Verify:
In Part 2, you'll replace the temporary data with Lovable Cloud records.
Part 2 — Enable Lovable Cloud
Step 4 — Create the FAQ Database
Enable Cloud and Migrate the FAQs
Enable Lovable Cloud for Answers Hub while preserving the complete public FAQ design and behavior. Create `faq_categories` with UUID id, unique name, unique slug, optional description, integer sort_order, boolean active default true, created_at, and updated_at. Create `faqs` with UUID id, required question, required answer, required category_id foreign key, integer sort_order, boolean featured default false, boolean published default false, optional related_link_label, related_link_url, cta_label, cta_url, created_at, and updated_at. Migrate the existing sample categories and questions without changing their content, order, published state, featured state, links, or CTAs. Update the public page to read active categories and published FAQs from Cloud. Public visitors may read only published FAQs in active categories. Block anonymous inserts, updates, and deletes. Hide Draft records from the public page, search, categories, deep links, and structured data. Add loading, error, retry, and empty states. Remove hard-coded FAQ data after migration. Do not add administrator pages yet.
Creates the canonical FAQ database and preserves the tested public interface.
Step 5 — Verify Database Content
In Part 3, you'll create the first administrator and protect the backend.
Part 3 — Add Administrator Authentication
Step 6 — Create the One-Time Administrator Setup
Add Secure Administrator Authentication
Add secure email-and-password administrator authentication using Lovable Cloud. Preserve the public FAQ. Create `/admin/setup` as a one-time first-administrator page with email, password, confirmation, validation, loading, success, and safe error states. Allow setup only when no administrator exists, store the administrator role securely in the database, then permanently close setup and redirect future visits to `/admin/sign-in`. Create `/admin/sign-in` with generic errors, loading state, and redirect authenticated administrators to `/admin`. Add Sign Out. Protect every `/admin` route with a database-verified administrator role; signed-out users go to sign-in and signed-in nonadministrators are denied. Do not trust local storage, email addresses, hidden links, or client-only checks. Do not add public registration, additional roles, social login, or password recovery. Create a temporary protected FAQ Administration page showing the administrator email, Sign Out, and a View Public FAQ link.
Creates the first administrator and closes registration automatically.
Step 7 — Test Route Protection
In Part 4, you'll create a simplified administrator shell and Overview.
Part 4 — Build the Administrator Workspace
Step 8 — Create the Simplified Admin
Build the FAQ Administration Workspace
Replace the temporary administrator page with a responsive protected workspace. Keep navigation limited to Overview, AI FAQs, Categories, View Public FAQ, and Sign Out. Use a desktop sidebar and accessible mobile navigation. Make View Public FAQ link to the relative path `/`, open in a new tab, and use `rel="noopener noreferrer"` so it works in preview and on the published domain. On Overview, add database-computed cards for Total FAQs, Published, Drafts, and Active Categories. Below the cards, show every canonical FAQ record, most recently updated first, using accessible accordion cards. Display question, category, status, Featured badge, and updated date when collapsed; display the complete answer, metadata, related link, CTA, and actions when expanded. Add search across questions and answers, category/status/featured filters, Reset Filters, result count, and 20-record pagination. Allow only one accordion open at a time. Keep all administrator reads and mutations behind the database-verified role. Do not add AI generation yet.
Creates the unified administrator layout and full FAQ Overview.
Step 9 — Test the Overview
In Part 5, you'll add two administrator-only AI generation modes.
Part 5 — Generate FAQs with AI
Step 10 — Add the Business Information Profile
Add the AI FAQ Generator
Build `/admin/faqs` as an administrator-only AI FAQ Generator with two modes: Generate One FAQ and Generate Complete FAQ. Save a private Business Information profile containing business or website name, description, products or services, important policies or information, target audience, preferred tone, and default suggestion count. Generate One FAQ accepts a topic, optional context, optional active category, and tone; AI returns one complete customer-focused question, complete helpful answer, and suggested active category. Generate Complete FAQ uses the saved Business Information and creates 5, 10, or 15 balanced suggestions. Use only supplied information; never invent prices, guarantees, delivery times, refund rules, contact details, security claims, or legal claims. Skip unsupported topics instead of guessing. Call Lovable's AI gateway only from secure server-side code, verify the database-authorized administrator, validate input lengths and structured JSON output, and rate-limit generation. Save every result as a private Pending suggestion. AI must never create or publish a public FAQ automatically.
Creates single-question and complete-FAQ generation from administrator-supplied information.
Step 11 — Prevent Duplicate Suggestions
Add AI Duplicate Protection
Before saving AI FAQ suggestions, normalize and compare generated questions case-insensitively against every canonical FAQ, Pending suggestion, Approved suggestion, recent Rejected suggestion, and every other question in the same generated batch. Skip duplicates and report how many were skipped. Require each suggestion to contain a meaningful question, meaningful answer, and an existing active category. Keep generated content private and preserve the administrator's business information if generation fails.
Prevents repeated questions and incomplete AI output.
Step 12 — Verify Both Modes
In Part 6, you'll review suggestions and promote them safely.
Part 6 — Review, Approve, and Publish AI Suggestions
Step 13 — Build the Suggestion Review Queue
Add the AI Review Workflow
On AI FAQs, show Pending and Rejected suggestions as accessible accordion cards. The collapsed row displays generated question, category, status, and generated date. Expanding it displays the complete generated answer directly under the question. Add Pending actions: Edit, Approve as Draft, Publish, Regenerate, and Reject. Edit must allow changes to question, answer, category, sort order, Featured, related-link fields, and CTA fields. Reject requires confirmation and moves the item to Rejected. Rejected actions are Restore to Pending and Delete. Keep Approved Draft and Published canonical FAQs off this page; manage them on Overview. After approval or publishing, link to the created Overview record. Preserve keyboard accordion behavior, clear focus states, mobile wrapping, and administrator authorization.
Creates the private review-and-approval queue for generated content.
Step 14 — Make Promotion Atomic
Secure AI Approval and Publishing
Create a protected transactional database function that promotes one Pending AI suggestion to either Draft or Published. Verify the authenticated database administrator, lock the suggestion, require Pending status and no existing FAQ link, require an active category, and reject a case-insensitive duplicate canonical question. In one transaction, create the FAQ with the complete question, answer, category, sort order, Featured state, related link, and CTA; set published false for Approve as Draft or true for Publish; update the suggestion to Approved or Published; and save the new FAQ id. Roll everything back on failure. Revoke public and anonymous execution, grant only authenticated execution, and verify the administrator role inside the function. Update the UI server action to call this function instead of separate insert and update operations.
Prevents duplicate promotions, partial writes, and orphaned FAQs.
Step 15 — Test Suggestion Lifecycles
In Part 7, you'll edit and control every canonical FAQ from Overview.
Part 7 — Manage All Questions and Answers
Step 16 — Add Inline Editing and Status Actions
Complete FAQ Management on Overview
Make the Overview `faqs` table the single source of truth for all Draft and Published FAQ records. Allow editing directly inside the expanded accordion card without a separate page. Include question, answer, active category, sort order, Featured, Published, related-link label and URL, and CTA label and URL. Add Save, Cancel, field and URL validation, loading and safe error states, success feedback, and an unsaved-change warning. Add Publish, Unpublish, and Delete actions. Unpublish requires confirmation, sets published false, moves the FAQ to Drafts, and removes it publicly. Delete requires confirmation showing the complete question, deletes the canonical record, updates counts and pagination, and safely clears a linked suggestion's faq_id without recreating content. Preserve search, filters, current page, and open accordion when practical.
Adds full question-and-answer editing and publication controls to the complete Overview list.
Step 17 — Verify Canonical FAQ Management
In Part 8, you'll keep categories and public content synchronized.
Part 8 — Manage Categories and Realtime Updates
Step 18 — Add Simple Category Management
Complete Category Management
Keep Categories simple. Display each category as a responsive card with name, Active or Inactive badge, canonical FAQ count, and Edit. Allow an administrator to rename a category and activate or deactivate it inline. Validate nonempty unique names, update timestamps, and refresh Overview counts and filters. AI generation may use only active categories. Deactivating a category must remove it and its Published FAQs from public category filters and public results without deleting the canonical records. Keep every mutation restricted to database-authorized administrators.
Allows categories to be renamed or disabled without deleting FAQ records.
Step 19 — Add Realtime Public Synchronization
Synchronize Admin and Public FAQ Data
Subscribe the public FAQ query to insert, update, and delete changes for `faqs` and relevant changes for `faq_categories`. On change, refresh published FAQs and active categories while preserving search and the selected category when possible. Close an accordion if its FAQ was unpublished or deleted, remove invalid category filters safely, refresh again when the browser regains focus or reconnects, and clean up subscriptions on unmount. Do not create duplicate subscriptions. Realtime public access must still expose only Published FAQs in active categories. Administrator changes must refresh Overview accordions, filters, pagination, counts, and category counts. Remove hard-coded or duplicated local FAQ state.
Makes publish, edit, unpublish, and delete changes appear publicly without rebuilding the site.
Step 20 — Test in Two Tabs
Open public FAQ and admin in separate tabs.
In Part 9, you'll apply the final card, color, and spacing system.
Part 9 — Polish the Public and Administrator Design
Step 21 — Apply the FAQ Card System
Polish FAQ Cards and Containers
Polish public and administrator FAQ layouts using reusable semantic styles. Use a pale blue-gray page background, white cards, deep-navy question text, dark-teal answer text, soft blue-gray normal borders, medium-blue expanded borders, pale-blue expanded backgrounds, pale-cyan answer panels, teal answer accent borders, accessible blue focus rings, and short restrained transitions. Questions must look visually different from answers. Make every question an individual rounded card with spacing and subtle shadow. The open card receives a 2px inset primary ring and restrained glow without layout movement; only one card remains highlighted. Keep Published green, Draft neutral, Pending amber, Rejected red, Featured gold, and Category light blue. Apply matching card styling to Overview, AI suggestions, Categories, filters, loading, errors, and empty states. Preserve WCAG AA contrast, reduced motion, keyboard behavior, and mobile wrapping.
Creates a consistent accessible color and card system across the project.
Step 22 — Widen and Separate the Public Sections
Improve Public FAQ Width and Spacing
Widen the public FAQ page to a centered `max-w-6xl` shell with an approximately `max-w-5xl` FAQ list while keeping answer paragraphs near `max-w-3xl` or `max-w-prose`. Separate the page into three elevated areas: FAQ header with badge, title, description, search and categories; individual question cards; and the Still Have Questions support footer card. Add 32px mobile and 40–48px desktop separation between header and questions, and 48–64px above the support footer. Keep the pale page background visible between sections. Prevent horizontal scrolling, safely wrap long words and URLs, and preserve search, filters, accordions, deep links, loading states, and realtime behavior.
Gives questions more width and visually separates the header, list, and support footer.
Part 10 — Final Testing and Publishing
Step 23 — Run the Final Checklist
Public FAQ
Administrator
AI Workflow
Step 24 — Publish the Project
Publish through Lovable, then open the public URL in a new browser tab. Test search, a category, an accordion, a deep link, and mobile layout. Sign in as administrator in a separate tab, publish one reviewed suggestion, confirm it appears publicly, then unpublish it and confirm it disappears.
AI-Powered FAQ Complete
You built a database-backed FAQ where administrators can generate complete questions and answers with AI, review every suggestion, safely promote it to Draft or Published, manage canonical records, organize categories, and update the public experience in realtime.
Keep the Main Project Focused
Bulk actions, complex analytics, public accounts, automatic AI publishing, and large editorial workflows are intentionally omitted. Add them only when a real project requires them.