Skip to content
mentoor

Topic 5 of 5 · 5 min read

When a prototype becomes production code

Goal: Decide whether an AI-built prototype can be kept, refactored or rebuilt, using a checklist of security, data and maintainability risks.

Decide keep, refactor or rebuild with a written checklist before a prototype takes real users or real data. The decision is easy to postpone and expensive to make late.

Check yourself · 1 of 3

An API key was found in a prototype's front-end code. What is the correct fix?

Choose one answer

Why it matters

Prototypes get promoted by accident. The demo went well, a customer asks for access, and the prompt-built app is now production. Tools that generate full apps optimise for something that runs, not for something safe. The usual gaps are the ones attackers look for.

The checklist

  1. Secrets. Search the code and its history for API keys, database URLs and tokens. A key in front-end code is public to every visitor. Rotate any key that was ever exposed; deleting it from a file does not unexpose it.
  2. Authentication and authorisation. Is there a login? Does every server route check who is calling and whether they may see that record? Generated apps often check only in the interface, so a direct request to the API bypasses the check. Broken access control is the top item on the OWASP Top Ten.
  3. Data. Where is it stored, who can read it, and is it backed up? Is personal data stored without a plan for deletion?
  4. Dependencies. List every package. Does it exist, is it maintained, is it the name you expect? Models sometimes suggest packages that do not exist or are look-alikes.
  5. Structure. Can a new developer find where things live? Are there tests? Is the same logic copied in five places?
  6. Operations. Is there logging, error capture, a deploy process and a way to roll back?

Keep, refactor or rebuild

  • Keep when the checklist is clean and the app is small. Rare.
  • Refactor when the idea and data model are sound but individual items fail: move keys to server settings, add server-side checks, replace dependencies.
  • Rebuild when the structure, the data model or the security approach is wrong. Use the prototype as a specification, not as a foundation.

Before and after

Before: "It works in the demo, so we will launch it."

After: "Checklist done. Two keys rotated and moved to server settings, access checks added to all five API routes, three dependencies replaced. Verdict: refactor, 4 days."

What goes wrong

  • Reviewing only the screens, which are the part that looks fine.
  • Assuming the generator also secured the backend.
  • Fixing the visible problem and skipping the history.

Examples

An exposed key in front-end code

// src/lib/payments.ts
const stripe = new Stripe("sk_live_...redacted");

This file ships to every browser. Fix: move the call to a server route, read the key from a server-side environment variable, and rotate the key because it was exposed.

A verdict written down

Verdict: refactor.

  • Keys: two found, rotated, moved server-side.
  • Auth: login exists; three of five routes lack ownership checks, add them.
  • Dependencies: one unmaintained package, replace.
  • Structure: acceptable; add tests for payment and sign-up.

Key points

  • Prototypes are promoted by accident, so run the checklist before real users or data arrive.
  • A secret in front-end code is public, and a leaked key must be rotated, not just deleted.
  • Check authorisation on the server for every route; hiding a button is not access control.
  • Verify every dependency exists, is maintained and is the package you meant.
  • Rebuild when the structure or data model is wrong, and use the prototype as the specification.

Common mistakes

  • Launching because the demo worked, without a security and data checklist.
  • Reviewing the screens but not the server routes and dependencies.
  • Deleting an exposed key from the code without rotating it.
  • Refactoring code whose data model is wrong, instead of rebuilding.

Check yourself · 2 of 3

A generated app hides the Delete button from non-admins, but the delete API route has no check. What is the risk?

Choose one answer

Check yourself · 3 of 3

A prototype has a sound data model, but keys are in the front end and two routes lack access checks. What is the best verdict?

Choose one answer

Practice items, not counted towards your mastery.

Start here

More for this topic