/how-to-build-lovable

How to build Fitness tracking with Lovable?

Build fitness tracking with Lovable: step counting, heart rate integration, data sync, analytics and customizable user insights to engage users.

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 Fitness tracking with Lovable?

The fastest path: add a Supabase-backed workouts API and simple React UI inside your Lovable project using Chat Mode edits. Use Lovable Secrets UI to add SUPABASE_URL and SUPABASE_ANON_KEY, create a supabase client file, add a WorkoutForm and Workouts page, and wire a route in src/App.tsx. You don't need a terminal — use Lovable Preview to test and Publish to push. If you need server-side functions or migrations, export to GitHub and run them locally or via Supabase CLI (outside Lovable).

 

What we’re building / changing

 

Build a simple fitness tracker: users can add workouts (date, type, duration, notes) and see a list and daily totals. Data is stored in Supabase. UI is React pages/components inside the Lovable project.

 

Lovable-native approach

 

Use Chat Mode file edits to create/update files, use Lovable Preview to run the app and test, add Supabase credentials in Lovable Cloud Secrets UI, then Publish. No terminal required. If you need DB migrations, export to GitHub and run migrations outside Lovable (explicitly labeled).

 

Meta-prompts to paste into Lovable

 

Use these prompts one-by-one in Lovable chat. Each prompt tells Lovable exactly which files to create/modify and acceptance criteria.

 

Prompt 1 — Goal: Add Supabase client and types

 

Files to create: src/lib/supabaseClient.ts, src/types/workout.ts

Instructions for Lovable: Create src/lib/supabaseClient.ts that reads from environment via process.env (SUPABASE_URL, SUPABASE_ANON_KEY) and exports a Supabase client using @supabase/supabase-js. Create src/types/workout.ts with a Workout type: id, user_id, date, type, duration\_minutes, notes.

Acceptance criteria: Preview builds without import errors; components can import { supabase } from 'src/lib/supabaseClient'.

Secrets: Tell the user to add SUPABASE_URL and SUPABASE_ANON\_KEY via Lovable Cloud Secrets UI before Preview.

 

// src/lib/supabaseClient.ts
// create supabase client using env variables
import { createClient } from '@supabase/supabase-js'

const url = process.env.SUPABASE_URL!
const key = process.env.SUPABASE_ANON_KEY!
export const supabase = createClient(url, key)

// src/types/workout.ts
export type Workout = {
  id: string
  user_id?: string
  date: string // ISO date
  type: string
  duration_minutes: number
  notes?: string
}

 

Prompt 2 — Goal: Add WorkoutForm component

 

Files to create: src/components/WorkoutForm.tsx

Instructions: Implement a form with date, type (text), duration (number), notes (textarea). On submit call supabase.from('workouts').insert(...) and then call an onSaved callback prop with the new record.

Acceptance criteria: Component compiles; form submits and returns inserted row to caller in Preview (assuming Supabase configured).

 

// src/components/WorkoutForm.tsx
import React, { useState } from 'react'
import { supabase } from 'src/lib/supabaseClient'
import type { Workout } from 'src/types/workout'

export default function WorkoutForm({ onSaved }: { onSaved: (w: Workout)=>void }) {
  const [date, setDate] = useState(new Date().toISOString().slice(0,10))
  const [type, setType] = useState('')
  const [duration, setDuration] = useState(30)
  const [notes, setNotes] = useState('')
  const [saving, setSaving] = useState(false)

  async function submit(e: React.FormEvent) {
    e.preventDefault()
    setSaving(true)
    const { data, error } = await supabase
      .from('workouts')
      .insert([{ date, type, duration_minutes: duration, notes }])
      .select()
    setSaving(false)
    if (error) { alert(error.message); return }
    if (data?.[0]) onSaved(data[0])
  }

  return (
    <form onSubmit={submit}>
      <label>Date<input value={date} onChange={e=>setDate(e.target.value)} type="date"/></label>
      <label>Type<input value={type} onChange={e=>setType(e.target.value)}/></label>
      <label>Duration (min)<input value={duration} onChange={e=>setDuration(Number(e.target.value))} type="number"/></label>
      <label>Notes<textarea value={notes} onChange={e=>setNotes(e.target.value)}/></label>
      <button disabled={saving} type="submit">Save workout</button>
    </form>
  )
}

 

Prompt 3 — Goal: Add Workouts page and route

 

Files to create/modify: create src/pages/Workouts.tsx, update src/App.tsx to add a /workouts route and link

Instructions: Workouts page loads recent workouts via supabase.from('workouts').select('\*').order('date', {ascending:false}). Show list and daily totals. Include WorkoutForm and refresh list after save.

Acceptance criteria: Preview shows /workouts route with form and list; adding a workout updates the list with the new row.

 

// src/pages/Workouts.tsx
import React, { useEffect, useState } from 'react'
import { supabase } from 'src/lib/supabaseClient'
import WorkoutForm from 'src/components/WorkoutForm'
import type { Workout } from 'src/types/workout'

export default function Workouts() {
  const [workouts, setWorkouts] = useState<Workout[]>([])
  async function load() {
    const { data } = await supabase.from('workouts').select('*').order('date', { ascending: false })
    setWorkouts(data || [])
  }
  useEffect(()=>{ load() },[])
  return (
    <div>
      <h2>Workouts</h2>
      <WorkoutForm onSaved={(w)=> setWorkouts(prev => [w, ...prev])} />
      <ul>{workouts.map(w=> <li key={w.id}>{w.date} {w.type} {w.duration_minutes}min</li>)}</ul>
    </div>
  )
}

// modify src/App.tsx — add import and Route for /workouts and a Nav link

 

Prompt 4 — Goal: Add package dependency and instruct Secrets setup

 

Files to modify: package.json (add @supabase/supabase-js)

Instructions: Update package.json dependencies to include "@supabase/supabase-js": "^2.x". In Lovable Preview the environment will install packages automatically.

Secrets: In Lovable Cloud go to Settings → Secrets and add SUPABASE_URL and SUPABASE_ANON\_KEY. Provide guidance to copy from Supabase project.

Acceptance criteria: Preview installs dependency and no import errors for supabase client.

 

How to verify in Lovable Preview

 

  • Ensure Secrets set in Lovable Cloud (SUPABASE_URL, SUPABASE_ANON\_KEY).
  • Open Preview, navigate to /workouts, add a workout, confirm list updates and row appears in Supabase table.

 

How to Publish / re-publish

 

  • Use Lovable Publish button to push changes. If you enabled GitHub sync, confirm commit appears in the repo.
  • If you need DB migrations, export to GitHub and run migrations with Supabase CLI outside Lovable (this is outside Lovable and requires terminal).

 

Common pitfalls in Lovable (and how to avoid them)

 

  • Missing Secrets: Preview will fail to connect. Add SUPABASE\_\* in Lovable Secrets UI before testing.
  • Dependency not installed: After editing package.json open Preview — Lovable’s build will install packages automatically.
  • DB schema not present: Create the workouts table in Supabase dashboard or run migrations outside Lovable; create table with columns matching types above.

 

Validity bar

 

This plan uses Lovable-native actions only (Chat Mode edits, Preview, Secrets, Publish, GitHub export for outside tasks). Any DB migrations or serverless functions requiring terminal are labeled "outside Lovable" and require running CLI after GitHub export.

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 implement idempotent workout ingestion

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

AI AI Prompt

How to add a secure, idempotent Fitbit webhook

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

AI AI Prompt

How to export a workout as GPX

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 Fitness tracking with AI Code Generators

Build it as an AI-assisted, privacy-first web app: use Lovable’s chat-first edits to iterate UI + API, store secrets (Supabase, OpenAI) in Lovable Cloud Secrets UI (never in code), use Preview to test endpoints and UI, Publish when stable, and export/sync to GitHub when you need local tooling or DB migrations. Architect with Supabase for auth + real-time data, server-side AI calls (via serverless endpoints) to generate personalized workouts, and client-side UI that only queries curated endpoints. Prioritize input validation, rate limits, opt-in health data consent, and clear data retention policies.

 

Architecture & core pieces

 

  • Auth & DB: Use Supabase for sign-up, auth, and a workouts table to store structured workout sessions.
  • AI generation: Make AI calls from server-side endpoints (not browser). Store the AI key in Lovable Secrets and call OpenAI from your server function.
  • Client: UI pages to request/generate workouts, show history, and sync device metrics.
  • Privacy: Ask consent, store minimal PII, allow export/delete, and rate-limit generation requests.

 

Lovable-specific workflow

 

  • Iterate in Chat Mode: Ask the assistant to create or modify files — you get diffs and can accept edits. No terminal needed.
  • Secrets UI: Put SUPABASE_URL, SUPABASE_KEY, OPENAI\_KEY in Lovable Cloud Secrets — your code references process.env variables.
  • Preview: Use Preview to simulate API requests and UI flows. Test auth flows tied to Supabase by using the Preview session.
  • Publish & GitHub sync: Publish to Lovable Cloud for hosting. Export/sync to GitHub if you need migrations or local debugging (then run migrations from your machine or CI).

 

Practical code pattern (server endpoint using Supabase + OpenAI)

 

// pages/api/generate-workout.js  (Next.js-style serverless API route)
// Fetch user profile, generate workout via OpenAI, store in Supabase

import { createClient } from '@supabase/supabase-js'

// Create Supabase client on server
const supabase = createClient(process.env.SUPABASE_URL, process.env.SUPABASE_KEY)

export default async function handler(req, res) {
  // Basic validation
  if (req.method !== 'POST') return res.status(405).end()
  const { user_id, goal, experience_level } = req.body
  if (!user_id || !goal) return res.status(400).json({ error: 'Missing params' })

  // Fetch user record for personalization
  const { data: user } = await supabase.from('users').select('age,weight').eq('id', user_id).single()

  // Build prompt
  const prompt = `Create a ${experience_level || 'beginner'} ${goal} workout plan for a ${user?.age || 'adult'} year-old weighing ${user?.weight || 'unknown'} kg. Provide 5 exercises with reps/time and brief notes.`

  // Call OpenAI from server (key stored in Lovable Secrets -> process.env.OPENAI_KEY)
  const r = await fetch('https://api.openai.com/v1/chat/completions', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'Authorization': `Bearer ${process.env.OPENAI_KEY}`,
    },
    body: JSON.stringify({
      model: 'gpt-4o-mini', // choose a model available to you
      messages: [{ role: 'user', content: prompt }],
      max_tokens: 500
    })
  })
  const ai = await r.json()
  const planText = ai.choices?.[0]?.message?.content || 'Could not generate'

  // Store structured record
  const { error } = await supabase.from('workouts').insert([
    { user_id, goal, plan: planText, generated_at: new Date().toISOString() }
  ])
  if (error) return res.status(500).json({ error: error.message })

  res.json({ plan: planText })
}

 

Operational & safety best practices

 

  • Server-side AI: Always call AI from server endpoints so you can audit, rate-limit, and mask prompts.
  • Secrets: Use Lovable Secrets UI for keys; never commit them. Rotate keys and set limited-scope Supabase keys.
  • Validation & limits: Validate inputs, enforce per-user rate limits, and cap prompt size to control costs.
  • Data policies: Clarify what’s stored vs transient. Allow users to delete their data and export histories.
  • Testing: Use Preview to exercise UI and endpoint flows. Export to GitHub only when you need to run local migrations or CI.
  • External integrations: Use Supabase dashboard for DB migrations (since no CLI in Lovable), or sync repo to GitHub and run migrations in CI/local.


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.