/how-to-build-lovable

How to build CRM system with Lovable?

Build a CRM with Lovable: step-by-step guide on setup, integrations and best practices to streamline sales and customer support

Book a free  consultation
4.9
Clutch rating 🌟
600+
Happy partners
17+
Countries served
190+
Team members
Matt Graham, CEO of Rapid Developers

Book a call with an Expert

Starting a new venture? Need to upgrade your web app? RapidDev builds application with your growth in mind.

Book a free No-Code consultation

How to build CRM system with Lovable?

Build a small production-ready CRM in Lovable: a Next.js React frontend (pages or app), Supabase for auth & Postgres, basic Contacts/Companies/Deals CRUD, and a simple import/export. Use Lovable Chat Mode edits, Preview to test, Secrets UI for keys, and Publish/GitHub export for production. No terminal required inside Lovable; use Supabase dashboard for SQL if you need to run migrations.

 

What we’re building / changing

 

Minimal CRM with sign-in (Supabase), Contacts list/detail, Companies, Deals CRUD, server API wrappers to Supabase, and a small UI. It’s a real app you can preview and publish from Lovable.

  • Frontend: Next.js pages or app routes (React).
  • Backend/data: Supabase Postgres and Auth.
  • Deployment: Lovable Publish or GitHub export to deploy where you like.

 

Lovable-native approach

 

  • Use Chat Mode to create/modify files (no CLI). Make changes via editable diffs and Preview to run the dev server Lovable provides.
  • Store SUPABASE_URL and SUPABASE_ANON\_KEY in Lovable Cloud Secrets UI; reference them in src/lib/supabaseClient.ts.
  • For DB schema, create supabase/init.sql in the repo and run it in the Supabase dashboard SQL editor (outside Lovable but GUI, no terminal).
  • When you need more control, use GitHub export/sync from Lovable to run advanced tasks locally or CI/CD.

 

Meta-prompts to paste into Lovable (use Chat Mode)

 

Prompt — Initialize project files & deps

 

Goal: Add Next.js scaffold and dependency entries.

Files to create/modify: create package.json, create next.config.js, create src/pages/\_app.tsx, create src/pages/index.tsx

Acceptance criteria: Done when Preview boots and the home page shows “CRM — Welcome”.

Secrets/Integration: none yet.

Instruction for Lovable (paste into Chat Mode):

// Create package.json with minimal scripts and dependencies (next, react, react-dom, @supabase/supabase-js)
// create src/pages/_app.tsx that renders children
// create src/pages/index.tsx with "CRM — Welcome"
// create next.config.js default

 

Prompt — Add Supabase client & auth

 

Goal: Add a reusable Supabase client and a sign-in page.

Files: create src/lib/supabaseClient.ts, create src/pages/signin.tsx, update src/pages/\_app.tsx to provide auth context.

Acceptance: Done when Preview shows /signin and can call supabase.auth.signIn (UI button will trigger a popup flow or email link depending on your Supabase settings).

Secrets: Add SUPABASE_URL and SUPABASE_ANON\_KEY in Lovable Cloud Secrets UI and mark them for use by the app.

Instruction for Lovable:

// Create src/lib/supabaseClient.ts that reads process.env.SUPABASE_URL and process.env.SUPABASE_ANON_KEY and exports supabase client using @supabase/supabase-js
// Create signin page with a form that calls supabase.auth.signInWithPassword or signInWithOAuth depending on env
// Update _app to pass client via React Context

 

Prompt — Add DB schema and API wrappers

 

Goal: Add SQL schema file and small server API wrappers to call Supabase from server components/pages.

Files: create supabase/init.sql, create src/lib/db.ts (wrappers: createContact, listContacts, getContact, updateContact, deleteContact), create src/pages/contacts/index.tsx and src/pages/contacts/[id].tsx

Acceptance: Done when Preview contacts list fetches from Supabase (empty list is acceptable) and single contact page loads.

Secrets/Integration: After creating supabase/init.sql, run its SQL in the Supabase dashboard SQL editor (this is outside Lovable but GUI — no terminal required).

Instruction for Lovable:

// Create supabase/init.sql with CREATE TABLE contacts (...), companies, deals
// Create src/lib/db.ts using the supabase client to implement CRUD functions
// Create contacts pages that call those wrappers (client or server fetch)

 

Prompt — CSV import and basic UI polish

 

Goal: Add CSV upload to create contacts and an export button.

Files: modify src/pages/contacts/index.tsx to add upload form and CSV parse handler, create src/components/ContactRow.tsx

Acceptance: Done when Preview lets you upload a CSV and shows newly added rows after import.

Secrets: none.

Instruction for Lovable:

// Add CSV input that reads file, parses CSV (simple split/comma), calls createContact for each row
// Add UI component ContactRow to list fields

 

How to verify in Lovable Preview

 

  • Open Preview, go to /signin, sign in using your Supabase project auth method.
  • Go to /contacts, confirm list and detail pages load and CRUD operations work against your Supabase DB.
  • Upload CSV and confirm rows appear.

 

How to Publish / re-publish

 

  • Use Lovable Publish to deploy the app. Ensure SUPABASE\_\* secrets are saved in Lovable Cloud Secrets UI before publishing.
  • If you need custom hosting or migrations, export/sync to GitHub from Lovable and run CI/CD or Supabase CLI outside Lovable.

 

Common pitfalls in Lovable (and how to avoid them)

 

  • Missing Secrets: Add SUPABASE_URL and SUPABASE_ANON\_KEY in Lovable Secrets UI — Preview will fail silently if missing.
  • DB migrations: You cannot run CLI migrations in Lovable — run supabase/init.sql in Supabase dashboard or export to GitHub and run CLI externally.
  • Assuming terminal: Don’t expect to run npm install inside Lovable; edits change files and Preview uses the project environment Lovable provides.

 

Validity bar

 

This plan uses Lovable Chat Mode edits, Preview, Publish, Secrets UI, and GitHub export/sync where needed. Any CLI-only step is routed via Supabase dashboard or GitHub export and explicitly labeled as outside Lovable.

Want to explore opportunities to work with us?

Connect with our team to unlock the full potential of no-code solutions with a no-commitment consultation!

Book a Free Consultation

How to add audit logging to a Lovable CRM

This prompt helps an AI assistant understand your setup and guide to build the feature

AI AI Prompt

How to import CSV contacts with dry-run, dedupe & fallback

This prompt helps an AI assistant understand your setup and guide to build the feature

AI AI Prompt

How to add a reliable webhook relay & preview queue to a Lovable CRM

This prompt helps an AI assistant understand your setup and guide to build the feature

AI AI Prompt

Want to explore opportunities to work with us?

Connect with our team to unlock the full potential of no-code solutions with a no-commitment consultation!

Book a Free Consultation
Matt Graham, CEO of Rapid Developers

Book a call with an Expert

Starting a new venture? Need to upgrade your web app? RapidDev builds application with your growth in mind.

Book a free No-Code consultation

Best Practices for Building a CRM system with AI Code Generators

The fastest, safest path: model your CRM as a small API-backed app (Supabase for data + authentication), keep AI generation as a separate, permissioned service layer (server-side only), store prompts and rate rules in DB, protect all keys with Lovable Secrets, iterate inside Lovable using Chat Mode + Previews, and export to GitHub to run full local/CI tests. Prioritize explicit user controls, audit logs, quotas, and human review for any customer-facing AI outputs.

 

Architecture & core patterns

 

Keep AI generation server-side — never embed keys or call LLMs directly from the browser. Use Supabase (or Postgres) for contacts, prompt templates, and usage logs. Your API layer does authentication checks, rate limiting, prompt assembly, and logs what was generated.

  • Data: contacts, activities, prompt_templates, generation_logs, audit\_trail.
  • Flow: UI → authenticated API → server-side AI call → save result + log → return to UI.
  • Reason: protects secrets, centralizes quota/cost controls, ensures auditability.

 

Lovable workflow & developer ergonomics

 

Use Lovable Chat Mode to edit code, create diffs/patches, and iterate. Use Preview to test UI behavior that runs in the cloud. Put secrets into Lovable Secrets UI for SUPABASE_URL, SUPABASE_KEY, OPENAI\_KEY, etc. When you need local commands or CI, export/sync to GitHub — that’s the moment you run migrations or local tests.

  • No terminal in Lovable: don’t ask reviewers to "run migrations" inside Lovable — instead include migration SQL files and document running them after GitHub sync.

 

Security, secrets, and compliance

 

Store all credentials with Lovable Secrets and reference them as environment variables in your server functions. Implement row-level security in Supabase and server-side checks for every AI call. Record user IDs and prompts in generation\_logs for audit and rollback.

  • Redaction: avoid sending full PII to LLMs unless necessary; mask or transform data when possible.
  • Consent & opt-out: let users opt out of AI-synthesized outreach.

 

Prompt architecture & human-in-the-loop

 

Store prompts as templates in DB with named placeholders, version them, and test them via a small "prompt playground" in your app so non-devs can tweak copy safely. Add a review state (draft, approved) and require human approval for templates used in bulk sends.

  • Sanity checks: enforce length, disallowed words, and required placeholders before sending to the LLM.
  • Rate & cost controls: set per-user/day token caps and soft warnings in generation\_logs.

 

Testing, monitoring & rollout

 

Preview in Lovable for UI flow checks, then export to GitHub to run integration tests and local load tests. Monitor generation\_logs for quality and costs, and capture user feedback on generated content for retraining prompt iterations.

  • Canary releases: enable feature flags in DB to roll AI features to a subset of users.
  • Metrics: cost per generation, CTR for outreach, number of human edits after generation.

 

Minimal server-side code examples

 

// supabase client for server functions
import { createClient } from '@supabase/supabase-js'

// Use Lovable Secrets to set these env vars in the cloud
const supabase = createClient(process.env.SUPABASE_URL, process.env.SUPABASE_SERVICE_KEY)

// fetch contacts for a user
export async function getContacts(userId) {
  // // server-side only
  return await supabase.from('contacts').select('*').eq('owner_id', userId)
}
// simple server-side OpenAI call (node fetch)
export async function generateEmail(prompt) {
  // // OPENAI_KEY stored via Lovable Secrets
  const res = await fetch('https://api.openai.com/v1/chat/completions', {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${process.env.OPENAI_KEY}`,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      model: 'gpt-4o-mini', // choose an appropriately capable model you have access to
      messages: [{ role: 'system', content: 'You are a helpful CRM assistant.' }, { role: 'user', content: prompt }]
    })
  })
  return res.json()
}

 

Common pitfalls and what breaks vs local dev

 

Expect differences: Lovable Preview simulates cloud functions but you can’t run migrations or cron jobs there. If developers assume they can run CLI migrations in Lovable, deployments will fail. Use GitHub export for DB migrations and CI.

  • Secrets leakage: never check in keys — use Lovable Secrets and CI secrets for GitHub actions.
  • Edge cases: rate/cost runaway if you don’t quota LLM calls server-side.


Recognized by the best

Trusted by 600+ businesses globally

From startups to enterprises and everything in between, see for yourself our incredible impact.

RapidDev was an exceptional project management organization and the best development collaborators I've had the pleasure of working with.

They do complex work on extremely fast timelines and effectively manage the testing and pre-launch process to deliver the best possible product. I'm extremely impressed with their execution ability.

Arkady
CPO, Praction
Working with Matt was comparable to having another co-founder on the team, but without the commitment or cost.

He has a strategic mindset and willing to change the scope of the project in real time based on the needs of the client. A true strategic thought partner!

Donald Muir
Co-Founder, Arc
RapidDev are 10/10, excellent communicators - the best I've ever encountered in the tech dev space.

They always go the extra mile, they genuinely care, they respond quickly, they're flexible, adaptable and their enthusiasm is amazing.

Mat Westergreen-Thorne
Co-CEO, Grantify
RapidDev is an excellent developer for custom-code solutions.

We’ve had great success since launching the platform in November 2023. In a few months, we’ve gained over 1,000 new active users. We’ve also secured several dozen bookings on the platform and seen about 70% new user month-over-month growth since the launch.

Emmanuel Brown
Co-Founder, Church Real Estate Marketplace
Matt’s dedication to executing our vision and his commitment to the project deadline were impressive. 

This was such a specific project, and Matt really delivered. We worked with a really fast turnaround, and he always delivered. The site was a perfect prop for us!

Samantha Fekete
Production Manager, Media Production Company
The pSEO strategy executed by RapidDev is clearly driving meaningful results.

Working with RapidDev has delivered measurable, year-over-year growth. Comparing the same period, clicks increased by 129%, impressions grew by 196%, and average position improved by 14.6%. Most importantly, qualified contact form submissions rose 350%, excluding spam.

Appreciation as well to Matt Graham for championing the collaboration!

Michael W. Hammond
Principal Owner, OCD Tech

We put the rapid in RapidDev

Need a dedicated strategic tech and growth partner? Discover what RapidDev can do for your business! Book a call with our team to schedule a free, no-obligation consultation. We’ll discuss your project and provide a custom quote at no cost.