By Shubham Maurya, co-founder of BuildKodiq · 2026-11-30
Before real users sign up, fix five things in an app you built with Lovable, Bolt.new, Replit, v0 or Cursor. Turn on row-level security for every table. Keep secret keys out of the browser. Update payments from Stripe webhooks, not from the success page. Put the database schema in migrations, with indexes and tested backups. Add error tracking, a few tests on sign-up, login and payments, and CI that runs them.
None of this means the tool did a bad job. AI app builders are very good at getting a working first version in front of people. They build what you ask for, and most prompts are about screens and features, not about who can read which row. These five checks are what we look at first when a founder asks us whether their app is ready for real users.
1. Can one user read another user's data?
Many apps built with these tools use Supabase. The browser talks to the database directly, using the project URL and the anon key (newer projects call it the publishable key). That key is meant to be public. Anyone can open the browser's developer tools and copy it.
That is safe only because of row-level security (RLS). RLS is a Postgres feature: each table has policies that decide which rows a request can read or change. If RLS is off on a table, anyone with the public key can read the whole table, and often change it too. If RLS is on but a policy says using (true), the effect is much the same.
What to look for:
- In the Supabase dashboard, any table marked as unrestricted, or a warning from the built-in security advisor.
- Policies with using (true) or with check (true) on tables that hold user data.
- Tables that link rows to users by a column nobody checks, such as user_id or org_id.
- Storage buckets that are public but hold private files such as invoices or ID documents.
How to fix it: turn RLS on for every table in the public schema, then add one policy per action, tied to the signed-in user. A minimal version for a table of projects owned by users:
alter table public.projects enable row level security; create policy "Users read their own projects" on public.projects for select to authenticated using ((select auth.uid()) = user_id); create policy "Users create their own projects" on public.projects for insert to authenticated with check ((select auth.uid()) = user_id); Add update and delete policies the same way, and only if users should be able to do those things. Then test it. Sign in as one user and try to read another user's rows, and try the API with only the public key and no sign-in. Both should return nothing. If your app has teams or organizations, the policies need to check membership, and that is worth writing carefully once rather than prompting several times.
2. Are secret keys shipped in the browser?
Anything your frontend code can read, a visitor can read. In a Vite app, which is what Lovable and Bolt.new usually generate, every environment variable that starts with VITE_ goes into the JavaScript bundle. In Next.js, the same is true of variables that start with NEXT_PUBLIC_. That is fine for the Supabase URL and anon key. It is not fine for anything else.
What to look for:
- The Supabase service_role key, or a newer secret key that starts with sb_secret_, anywhere in frontend code. This key skips RLS completely.
- A Stripe secret key (sk_live_ or sk_test_), an OpenAI or Anthropic API key, or email and SMS provider keys in the frontend.
- Keys committed to the Git history, even if a later commit removed them.
- Calls to paid APIs, such as AI models, made straight from the browser.
A quick check: build the app, then search the output folder for sk_live, sk_test, service_role and sb_secret. Also open the deployed site, view the JavaScript files in the browser's developer tools and search the same strings.
How to fix it: move every call that needs a secret to the server. That can be a Supabase Edge Function, a Next.js route handler, or a small backend in Node or Python. The browser calls your function; your function holds the key, checks who the user is, and calls the other service. Then rotate every key that was ever exposed, in each provider's dashboard. Deleting the key from the code is not enough, because the old key still works and may already be copied.
3. Does a payment really update your database?
A common first version works like this: the user pays on Stripe Checkout, Stripe sends them back to /success, and the success page marks them as paid. That breaks in ordinary ways. The user closes the tab before the redirect. The page is opened again later. Someone visits /success without paying. A renewal fails a month later and nothing in your database changes.
Stripe tells your server what happened through webhooks: signed messages sent to an endpoint you own. Your database should change when a verified webhook arrives, not when a page loads. Stripe's own docs recommend this for fulfilling orders.
What to look for:
- Paid status set from the browser or from the success page.
- A webhook endpoint that doesn't check the Stripe signature.
- No handling for failed payments, cancelled subscriptions or refunds.
- The same event processed twice. Stripe can deliver an event more than once, so a duplicate must be harmless.
How to fix it: add a webhook endpoint that verifies the signature, records each event ID so a repeat is skipped, and updates the subscription row. A minimal Next.js route handler with the official stripe package:
import Stripe from "stripe"; const stripe = new Stripe(process.env.STRIPE_SECRET_KEY); export async function POST(req) { const body = await req.text(); // the raw body, unparsed let event; try { event = stripe.webhooks.constructEvent( body, req.headers.get("stripe-signature"), process.env.STRIPE_WEBHOOK_SECRET, ); } catch { return new Response("Invalid signature", { status: 400 }); } if (await alreadyHandled(event.id)) return Response.json({ received: true }); switch (event.type) { case "checkout.session.completed": case "customer.subscription.updated": case "customer.subscription.deleted": case "invoice.payment_failed": await syncSubscription(event.data.object); break; } await markHandled(event.id); return Response.json({ received: true }); } alreadyHandled, markHandled and syncSubscription are your own functions; a table of processed event IDs with a unique constraint is enough for the first two. The signature check needs the raw request body, so don't parse it as JSON first. In a Supabase Edge Function, which runs on Deno, use the async version, constructEventAsync.
Two more details. When your server creates payments or subscriptions, pass an idempotency key, so a retried request doesn't charge twice. And decide what a failed renewal means in your app: a grace period, a banner, or locked features. Then test it with the Stripe CLI, which can forward events to your local endpoint and trigger test events.
4. Will your data model survive real data?
Prompt-driven apps often change the database by hand in the dashboard, one request at a time. After a few months nobody knows exactly what the schema is, and the staging and production databases don't match.
What to look for:
- No migrations folder, or one that doesn't match the live database.
- Important data stored in one big JSON column instead of real columns and tables.
- No foreign keys, so deleting a user leaves orphaned rows behind.
- No indexes beyond primary keys. Postgres doesn't index foreign key columns for you, and RLS policies filter on columns like user_id on every query.
- No tested backup. A backup you have never restored is a guess.
How to fix it: pull the current schema into migrations and make every change through them from now on. With the Supabase CLI, supabase db pull captures the live schema, supabase migration new starts a change, and supabase db push applies it. Move the fields you filter, sort or join on out of JSON and into columns. Add foreign keys and indexes for the columns your queries and policies use, for example:
create index projects_user_id_idx on public.projects (user_id); Then check what backups your database plan includes, and restore one into a separate project once to prove it works.
5. Can someone other than the AI maintain the code?
The last check is about the next six months. If every change is a new prompt, and every prompt breaks something that used to work, the code has stopped being something you control.
What to look for:
- Files with thousands of lines, where one component holds the UI, the data fetching and the business rules.
- No tests at all, so nobody knows a change broke sign-up until a user says so.
- No error tracking. Errors happen in users' browsers and you never see them.
- No staging environment: changes go straight to the live app.
- The code only lives in the builder tool, not in a GitHub repository you own.
How to fix it, in this order:
- Connect the project to a GitHub repository in your own account.
- Add error tracking such as Sentry to the frontend and backend, with alerts sent to a person.
- Write a few end-to-end tests, for example with Playwright, for the paths that make or lose money: sign-up, login, the main action, and payment.
- Run those tests in CI, such as GitHub Actions, on every pull request.
- Add a staging environment with its own database and Stripe test mode.
- Split the largest files as you touch them, not all at once.
You can keep using AI tools after this. The difference is that a change which breaks sign-up or payments is caught before it reaches users.
Should you fix the app or rebuild it?
Most of the time, fix it. Screens and flows that users already understand are worth keeping. The risk usually sits in four places: data access, secrets, payments and background jobs. Those can be fixed or rebuilt one at a time while the app stays live.
A larger rebuild makes sense when several of these are true:
- Business rules live only in the browser and would all need to move to a server.
- The data model is mostly JSON blobs and every feature depends on their shape.
- You are moving off a platform that doesn't export code, such as Bubble.
- Fixing each issue would cost more than building that part again, and you can say why.
Even then, rebuild in stages. Keep the old app running, move one part at a time, and switch over when each part is tested.
What does a production audit check?
When we audit an app built with an AI tool, we read the code, the database, the auth rules and the deploy setup, and test the five areas above. The result is a written list of what to keep, what to fix and what to rebuild, with a quote for each stage. The work then happens in your own GitHub, Supabase, Stripe and hosting accounts.
We do this as a fixed-scope service for founders who built a first version with these tools. See how we take an AI-built app to production.
Checklist before launch
| What to look for | How to fix it | |
|---|---|---|
| Database access | Tables with RLS off, or policies that allow everything | Turn on RLS and add a policy per action tied to auth.uid(); test as two users |
| Secrets | Service role, Stripe secret or AI keys in the frontend bundle or Git history | Move calls to server or edge functions; rotate every exposed key |
| Payments | Paid status set by the success page; unsigned or missing webhooks | Verify webhook signatures, skip repeated events, handle failures and cancellations |
| Data model | No migrations, JSON blobs, no indexes, untested backups | Migrations for every change, real columns, indexes, one test restore |
| Maintainability | Giant files, no tests, no error tracking, no staging | GitHub, Sentry, end-to-end tests in CI, a staging environment |
- Every table has RLS on, and one user can't read another's rows.
- Search the built site for sk_live, service_role and sb_secret, and find nothing.
- A paid, failed and cancelled subscription each show up correctly in your database.
- The schema is in migrations, and you have restored a backup once.
- Sign-up, login and payment have tests that run on every change, and errors reach a person.
Shubham Maurya led our Visneo and CareerCraft360 builds, and Rishabh Maurya led Aircreator. CareerCraft360 runs Stripe subscriptions with webhooks, Aircreator uses Supabase for auth, and Visneo runs production and staging environments with Sentry. The case studies are linked below, or email hello@buildkodiq.com.
Related projects
Originally published on buildkodiq.com. BuildKodiq is a two-engineer studio building AI agents, automation, dashboards, MVPs and websites. Questions: hello@buildkodiq.com.

