AI Agent–Driven Full-Stack Prototyping: Engineering Practices for Reliable Delivery
Learn how to turn AI-generated full-stack prototypes into verifiable deliverables through structured specifications, consistent frontend design, concurrency-safe booking logic, persistent storage, and systematic testing. This article also covers code review, sensitive data handling, and pre-launch checks for demonstration websites.
1. Why AI-Generated Prototypes Need a Redesigned Workflow
Building a user-facing showcase website has traditionally required collaboration among designers, frontend developers, and backend developers, with delivery timelines measured in weeks. Large language model agents can now generate page structures, styles, and basic service logic from a description. The bottleneck has shifted from whether code can be generated to whether it is correct, runnable, and maintainable.
Using a public-facing website prototype as an example, this article breaks the work into verifiable engineering steps. All scenarios are for demonstration purposes and involve no real business data or transactions.
2. Write the Specification Before Generating Code
The quality of an agent’s output depends heavily on its input specification. An actionable specification should include at least four categories of information:
- Page objectives: What visitors should do in the initial viewport, such as browse schedules or start a reservation.
- Information architecture: Which sections the page contains and how they are ordered.
- Data objects: The fields required for seats, scheduled departures, passengers, and orders, including which fields are mandatory.
- Constraints: Capacity limits, concurrency rules, and input validation requirements.
Use structured text rather than a free-form description. For example:
[Page] Home- Hero: Full-screen background visual, a slowly pulsing status indicatorin the upper-left corner, and a key metrics panel in the lower-right corner- Narrative: A vertical timeline; each entry includes a timestamp,a stage title, one key metric, and an image[Business logic] Reservations- Each departure has a maximum capacity of N seats; reject submissions when full- A seat can be reserved only once for a given departure- Validate the date, seat, passenger name, and identification fields before submission
A structured specification also serves as the acceptance criteria. Each rule can map to a test case, allowing reviewers to verify requirements individually.
3. Frontend Generation: Visual Consistency and Runtime Performance
3.1 Standardize the UI with Design Tokens
Agent-generated styles can easily drift into inconsistent colors, font sizes, and spacing. Define a set of design tokens first, then require components to reference them.
:root {--color-bg: #05070c;--color-accent: #7ff3e0;--color-text: #e6edf3;--font-mono: ui-monospace, monospace;--space-unit: 8px;--dur-slow: 1.2s;}.status-dot {width: calc(var(--space-unit) * 1.25);height: calc(var(--space-unit) * 1.25);border-radius: 50%;background: var(--color-accent);animation: breathe var(--dur-slow) ease-in-out infinite;}@keyframes breathe {50% { opacity: 0.35; }}@media (prefers-reduced-motion: reduce) {.status-dot { animation: none; }}
With shared tokens, changing the theme color requires editing only one value. The prefers-reduced-motion media query disables the animation for users who have requested reduced motion.
3.2 Build a Scroll-Driven Narrative Timeline
A vertical timeline works well for presenting a process in stages. Avoid reading layout information directly inside scroll event handlers, which can cause dropped frames. A more robust approach is to use the Intersection Observer API to apply an active style when an entry enters the viewport.
Key implementation points:
- Each entry manages its own display state rather than depending on a global scroll position.
- Images sit inside fixed-aspect-ratio containers to prevent layout shifts when they load.
- Key metrics use a monospace font to make values easier to compare across stages.
3.3 Keep Interactive Graphics State-Driven
Seat maps are often implemented with SVG. Each seat can be represented by an element with a data-seat-id attribute and one of three states: available, selected, or sold.
Store these states in a single data structure and let a rendering function apply the corresponding styles. Avoid scattering direct DOM updates across event handlers. This keeps the visual interface consistent with the underlying data.
4. Backend Booking Logic: Concurrency Correctness Comes First
4.1 The Common Failure: Check, Then Write
Many prototypes handle a reservation by checking remaining capacity and then creating an order. If two requests arrive almost simultaneously, both may read the same available capacity and proceed, resulting in overbooking.
This is a classic race condition.
4.2 Use a Conditional Update for Atomic Capacity Checks
A more reliable approach combines the capacity check and counter update in a single conditional statement, allowing the database to perform them atomically.
The following example uses a conditional SQL update within a transaction:
class SoldOutError(Exception):passdef reserve_seat(conn, flight_id, seat_no, passenger_name):# Use the connection context manager to roll back on exceptions.with conn:cur = conn.execute("UPDATE flights SET booked = booked + 1 ""WHERE id = ? AND booked < capacity",(flight_id,),)# A rowcount of 0 means the update condition was not met.if cur.rowcount != 1:raise SoldOutError(f"flight {flight_id} is full")# A composite unique constraint on (flight_id, seat_no)# prevents the same seat from being reserved twice.conn.execute("INSERT INTO reservations (flight_id, seat_no, passenger_name) ""VALUES (?, ?, ?)",(flight_id, seat_no, passenger_name),)return "confirmed"
Three design choices matter here:
- Conditional update: The
booked < capacitycheck is part of the update statement, so the database evaluates the condition and performs the write together. - Transaction rollback: If inserting the reservation fails, the counter increment is rolled back as well, keeping the count consistent with the reservation records.
- Unique constraint: The database enforces seat uniqueness instead of relying solely on application-level checks.
4.3 Handle Retries with Idempotency
Network timeouts can trigger client retries, causing the same logical request to be submitted more than once. Generate an idempotency key for each submission and have the server record processed keys. A repeated request should return the original result rather than create another reservation.
5. Data Persistence and Migrations
Prototypes still need persistent storage. A relational database is suitable for structured data such as departures, seats, and orders. Define primary keys, foreign keys, and unique constraints in the first version of the schema.
Persistence also requires attention to three practices:
- Migration scripts: Save every schema change as a script that can be run repeatedly without unintended effects.
- Backups: Back up the database before migrations or bulk changes, and verify that the backup can be restored.
- Seed data: Import reference data, such as departures and seats, through seed scripts rather than hardcoding it in application code.
6. Testing and Validation
Agent-generated code is not ready for delivery until it has been systematically validated. Cover at least these four test categories:
- Boundary tests: With a capacity of N, the Nth reservation should succeed and the N+1th should fail.
- Concurrency tests: Submit substantially more simultaneous requests than the available capacity. The number of successful reservations must not exceed the limit.
- Input validation tests: Test empty values, excessively long strings, invalid dates, and special characters. Confirm that invalid input is rejected or safely escaped, as appropriate.
- UI regression tests: Check layout, contrast, and keyboard navigation at both desktop and mobile viewport sizes.
Concurrency testing is easy to overlook, but it is one of the most effective ways to uncover overbooking defects.
7. What to Review in Agent-Generated Code
Common issues include:
- Hardcoded data with no working path for reading or writing persistent records.
- Error handling that covers the happy path but overlooks failure scenarios.
- Dependencies missing from the dependency manifest, or references to versions that do not exist.
- External resource URLs embedded in styles or scripts without checking availability or licensing.
Review the code file by file rather than judging it only by the rendered page. For images, fonts, videos, and other assets, verify copyright status and usage permissions.
8. Risk Controls and Pre-Launch Checks
Passenger names, identification numbers, and similar fields require careful handling as personal data. Even in a prototype, follow these principles:
- Collect only the minimum fields needed for the demonstration.
- Use encrypted transport and encrypt or mask sensitive stored fields.
- Clearly label the site as a demonstration environment and do not connect it to real payment processing.
- Store secrets and tokens only in environment variables or a dedicated secrets management service, never in frontend code or logs.
Before launch, verify the following:
- Every business rule in the specification has a corresponding test case.
- Successful reservations never exceed capacity during concurrency testing.
- Database migrations can be rerun safely, and backup restoration has been verified.
- The sources and licenses of dependencies, assets, and fonts have been checked.
- Animations can be disabled, and primary content remains readable without JavaScript.
- Sensitive information does not appear in frontend code, logs, or error messages.
AI agents can significantly shorten the path from an idea to a working prototype. Delivery quality still depends on clear specifications, reliable concurrency control, and thorough verification.
