AI Agent-Driven Full-Stack Delivery: From Requirements to a Running System
AI agents can generate attractive interfaces quickly, but a production-ready system also requires reliable persistence, consistent business rules, validation, testing, and deployment considerations. This article explains how to turn natural-language requirements into verifiable engineering tasks, using a flight-style booking experience and a brand landing page as examples. It covers structured prompts, visual implementation, seat-state management, concurrency control, idempotency, input validation, privacy, and testing. The numbers and rules are illustrative examples rather than specifications for a real product.
1. The Difference Between Generating a Page and Delivering a System
When teams first use an AI agent to generate a website, they often focus on visual quality: whether the page looks attractive, whether animations feel smooth, and whether the copy is appropriate. These are visible and useful metrics, but they cover only part of the deliverable.
A system that can actually go live must satisfy at least three additional requirements:
- The interface must support a complete business workflow.
- Data must be persisted reliably.
- Business rules must remain correct under concurrency and failure conditions.
When evaluating an agent’s output, it is therefore important to distinguish between a page and a system.
A page is primarily a presentation layer. It focuses on information architecture, visual hierarchy, and interaction feedback. A system also includes frontend state management, API design, data models, persistence, authorization, input validation, deployment, and monitoring.
The connection between these layers is where many problems occur. For example, the frontend may show a seat as available while another user has already booked it on the backend. Such inconsistencies are easy to miss in a demo but can cause real losses under production traffic.
This article uses two typical requirements—a flight-style booking website and a brand presentation page—to explain how natural-language descriptions can be broken down into verifiable engineering tasks. All values and rules in the examples are illustrative and do not represent parameters for an actual product.
2. Structuring Requirements for AI Agents
2.1 Why Free-Form Prompts Are Not Stable Enough
Natural-language requirements often combine design preferences, functionality, data, and constraints without clearly defining their boundaries. When an AI agent encounters ambiguity, it fills in the gaps. The result may differ from what the team intended.
For example, a requirement that says “support seat selection” does not specify whether seat availability must be synchronized in real time or how the system should handle two users selecting the same seat concurrently.
A more reliable approach is to divide the requirements into fixed fields, with each field answering a specific question. Common fields include:
- Target users
- Page scope
- Feature list
- Data entities
- Business rules
- Non-functional requirements
- Acceptance criteria
2.2 A Reusable Requirements Template
The following template can be used for page generation, API design, or backend development:
[Role]You are a senior engineer responsible for frontend and backend delivery.[Goal]Build a flight booking page for general users, including cabin selection and the booking workflow.[Page Scope]1. Hero section: brand presentation and real-time status indicator2. Flight narrative: key stages displayed on a timeline3. Booking: date selection, seat selection, passenger information, and order submission[Data Entities]- Flight(id, departure_time, capacity, seats_left)- Booking(id, flight_id, seat_no, passenger_name, created_at)[Business Rules]- Each flight has a maximum capacity of 6 seats.- A seat becomes unavailable immediately after it is booked.- Once the flight is full, the booking entry point is disabled and a message is displayed.[Non-Functional Requirements]- Booking data must be persisted.- Inputs must be validated on the server.- The page must remain usable on mobile devices.[Acceptance Criteria]- When multiple requests submit the same seat concurrently, only one booking succeeds.- A full flight cannot accept a new booking.- After the page is refreshed, the booked-seat state remains consistent.
The value of this template is that it makes business rules and acceptance criteria explicit. An AI agent can use them to generate code, while the team can use the same information to write tests.
Acceptance criteria should be written as statements that can be automatically evaluated whenever possible. Avoid vague requirements such as “the experience should be good” or “the style should be consistent,” because they are difficult to verify objectively.
2.3 How to Express Visual Requirements
Visual requirements also benefit from structure. Instead of asking for a “premium” or “high-end” appearance, specify concrete design decisions:
- Whether the background uses full-screen video or a static image
- Primary and secondary colors
- Font hierarchy
- Animation triggers and durations
- Whether the system’s reduced-motion preference must be supported
A practical method is to divide visual requirements into three layers:
- Structure: Which sections exist and in what order.
- Style: Values for colors, fonts, spacing, border radii, and other design tokens.
- Motion: Which elements animate, how animations are triggered, and how long they last.
The more precise the visual constraints, the more consistent the generated result will be. If the prompt contains only subjective adjectives, outputs may vary significantly between generations.
3. Engineering the Visual and Narrative Layers
3.1 The Hero Section and Brand Expression
The hero section is often where visitors decide whether a page appears credible. A professional brand page usually includes three elements:
- A clear primary visual
- A concise headline
- A distinct call to action
Technically, a full-screen background can use video, a compressed image sequence, or a static image with lightweight motion. The right choice depends on the bandwidth and performance budget of the target devices.
Background video requires particular care:
- Compress the video and provide multiple resolutions. Mobile devices should receive a lower-resolution version.
- Set the video to muted autoplay and allow users to pause it to support accessibility.
- Ensure sufficient contrast between overlaid text and the background. Text and background luminance should meet commonly accepted readability requirements.
3.2 Organizing Narrative Content with a Timeline
A vertical timeline works well for processes with a clear sequence, such as launch, acceleration, microgravity, and landing during a flight.
Each stage should be represented as a data record containing:
- A time label
- A title
- A description
- An image
- A key metric
The frontend should render the timeline from data rather than hard-coding each stage as an independent page fragment.
const phases = [{ t: "T-60:00", title: "Suiting and Security Check", metric: "Cabin pressure 101.3 kPa", image: "phase-01.webp" },{ t: "T+03:00", title: "Propulsion Phase", metric: "Acceleration 3.0 g", image: "phase-02.webp" },{ t: "T+08:00", title: "Entering Orbit", metric: "Velocity 7.8 km/s", image: "phase-03.webp" },];function renderTimeline(items, container) {container.innerHTML = items.map((p) => `<article class="phase"><span class="phase-time">${escapeHtml(p.t)}</span><h3>${escapeHtml(p.title)}</h3><p class="metric">${escapeHtml(p.metric)}</p><img src="${escapeHtml(p.image)}" alt="" loading="lazy"></article>`).join("");}
Every data field is escaped before being inserted into the page, reducing injection risks. Images use lazy loading to reduce the number of requests required for the initial viewport. Metrics use a monospaced font to improve alignment and readability.
3.3 Data Panels and Status Indicators
Data panels are useful for real-time or near-real-time parameters such as remaining seats, flight status, and countdowns.
The design should distinguish between status and value:
- A status should be communicated through both color and text. For example, use a green dot together with “Operational” rather than relying on color alone.
- Numerical values should use a monospaced font and maintain a stable layout when updated.
Breathing animations for status indicators are easy to overuse. Multiple continuous animations can distract users and increase rendering costs on lower-end devices. Animation should be reserved for states that genuinely require attention. It should also stop when the user’s operating system requests reduced motion.
@media (prefers-reduced-motion: reduce) {.status-dot {animation: none;}}
3.4 Typography and Layout
Brand pages often use serif typefaces to create a premium impression. From an engineering perspective, font loading must be handled carefully.
Recommended practices include:
- Load only the weights and character sets actually used.
- Provide sensible fallback fonts.
- Avoid flashes of unstyled text and layout shifts during font loading.
For pages that combine Chinese and English text, additional attention is required for letter spacing and line height. In an English-localized implementation, the same principle applies to mixed scripts and fallback font behavior.
4. Seat Data Models and Interaction
4.1 The Seat State Machine
Seat selection is one of the most common sources of inconsistency in this type of application. A seat passes through several states during the booking process. Clearly defining those states and their transitions is the foundation for reliable behavior.
Typical states include:
- Available: The seat is not occupied and can be selected.
- Held: The user has selected the seat but has not yet paid or submitted the booking. A hold usually has an expiration time.
- Booked: The booking has been successfully created.
- Blocked: The seat is temporarily unavailable for maintenance or another reason.
State transitions should follow explicit paths. For example, a booked seat can normally return to the available state only through an order cancellation flow. The frontend should not modify that state directly.
4.2 Generating an SVG Seat Map
A cabin or seat map can be drawn with SVG. Seat elements should be generated dynamically from data instead of being positioned manually. This means that changes to seat counts or layouts can be handled by modifying the data rather than rewriting the page structure.
function renderSeatMap(seats, svg) {const cell = 36;const gap = 8;svg.innerHTML = seats.map((s, i) => {const x = (i % 3) * (cell + gap);const y = Math.floor(i / 3) * (cell + gap);const status = s.status; // "available" | "held" | "booked" | "blocked"return `<rect x="${x}" y="${y}" width="${cell}" height="${cell}"data-seat="${escapeHtml(s.no)}" data-status="${status}" />`;}).join("");}
The state rendered by the frontend is only a display copy. Whether a seat can actually be selected must always be determined by the server.
4.3 Synchronizing Frontend and Backend State
After a user selects a seat, the frontend should immediately request that the server hold or lock the seat. It should then update the interface based on the response.
If the request fails, the interface should clearly explain the reason and refresh the seat map.
There are three common synchronization approaches:
- Fetch a snapshot when the page loads, submit a request when the user acts, and refresh after a failure. This is the simplest option and works for low-concurrency scenarios.
- Poll seat status at regular intervals. This can reduce conflicts but increases request volume and still leaves a time window for inconsistencies.
- Use a persistent connection or event-based updates to push seat changes. This offers the best real-time behavior but is more complex to implement.
For most small and medium-sized booking scenarios, the first approach combined with strict server-side validation is sufficient. The choice should be based on expected concurrency and the business requirement for real-time updates.
5. Backend Consistency in Booking Workflows
5.1 How Overselling Happens
Overselling occurs when the same resource is assigned to multiple users.
For seat booking, a typical sequence is:
- Two requests arrive at nearly the same time.
- Both requests read the seat as available.
- Both requests write a booked state.
- Both bookings succeed.
Without protection between the read and write operations, duplicate allocation is possible.
This problem is uncommon in development environments because test requests are usually serialized. In production, concurrent access makes it a realistic failure mode.
5.2 Ensuring Atomicity with Conditional Updates
A common and reliable approach is to combine the check and the modification into a single conditional update. The database changes only rows that satisfy the condition and returns the number of affected rows. The application uses that value to determine whether the operation succeeded.
def book_seat(conn, flight_id, seat_no, passenger_name):cur = conn.cursor()cur.execute("""UPDATE seatsSET status = 'booked', passenger_name = %sWHERE flight_id = %s AND seat_no = %s AND status = 'available'""",(passenger_name, flight_id, seat_no),)if cur.rowcount != 1:conn.rollback()raise SeatUnavailableError(f"Seat {seat_no} is no longer available")cur.execute("UPDATE flights SET seats_left = seats_left - 1 WHERE id = %s AND seats_left > 0",(flight_id,),)if cur.rowcount != 1:conn.rollback()raise FlightFullError("The flight is full")conn.commit()
Several details are important:
- SQL parameters are passed through placeholders rather than string concatenation, reducing injection risks.
- The seat state and remaining-seat count are updated in the same transaction. If either step fails, the transaction is rolled back.
- Checking
rowcountis central to business correctness and must not be omitted.
A production implementation can also use database constraints. For example, a unique index on (flight_id, seat_no) ensures that the database rejects duplicate records even if an application-level defect occurs.
5.3 Handling Full Flights
When a flight becomes full, the system must perform three tasks:
- Prevent new bookings.
- Update the page presentation.
- Preserve existing bookings.
It is preferable to use seats_left as the single source of truth instead of maintaining separate “full” flags in multiple locations. Otherwise, one missed update can create inconsistent states.
The frontend can display a message based on the remaining-seat count, but the server must still validate every submission. This prevents stale frontend state from producing an invalid booking.
5.4 Idempotency and Duplicate Submissions
When the network is unstable, users may click the submit button multiple times, and clients may retry after a timeout. The booking endpoint should therefore support idempotency.
A common approach is to require the client to send a unique request identifier with every submission. The server stores the identifier and the processing result. If the same identifier is received again, the server returns the existing result instead of creating another booking.
6. Input Validation and Security Boundaries
6.1 The Trust Boundary
All data received from the browser should be treated as untrusted. Even if the frontend performs validation, the server must validate the data again.
Possible validation targets include:
- Whether the date is within a reasonable range
- Whether the seat number belongs to the selected flight
- The length and character set of the passenger name
- The format of identification information
6.2 Validation Example
import refrom datetime import dateNAME_PATTERN = re.compile(r"^[A-Za-z\s·]{1,40}$")def validate_booking(payload, today):errors = []flight_date = date.fromisoformat(payload["date"])if flight_date < today:errors.append("The flight date cannot be earlier than today")if not NAME_PATTERN.match(payload.get("passenger_name", "")):errors.append("The passenger name format is invalid")if not payload.get("seat_no"):errors.append("Please select a seat")return errors
When validation fails, the response should provide a useful error message without exposing database structure or internal exception traces.
6.3 Handling Personal Information
Passenger information is sensitive personal data. Development and production systems should follow the principle of data minimization:
- Collect only the fields required for the business process.
- Do not log complete names, identification numbers, or contact details.
- Encrypt sensitive fields in the database.
- Apply strict role-based access controls.
These requirements do not become less important simply because the page was generated by an AI agent.
7. Testing and Verification
7.1 Testing by Layer
AI-generated code requires testing just like manually written code. A practical testing strategy contains three layers:
- Unit tests: Validate input functions, state transitions, and pure calculations such as pricing or seat allocation.
- Integration tests: Verify interactions between APIs and the database, including transaction rollbacks and unique constraints.
- End-to-end tests: Simulate the complete user journey from date selection to order submission.
7.2 Concurrency Testing
Overselling can only be reliably discovered through concurrency testing. One simple approach is to start multiple threads or coroutines and submit booking requests for the same seat at the same time. The test should then verify that exactly one booking succeeds.
import concurrent.futuresdef test_concurrent_booking_same_seat(make_conn):def attempt(name):conn = make_conn()try:book_seat(conn,flight_id=1,seat_no="A1",passenger_name=name,)return "ok"except SeatUnavailableError:return "conflict"finally:conn.close()with concurrent.futures.ThreadPoolExecutor(max_workers=8) as executor:results = list(executor.map(attempt, [f"Passenger {i}" for i in range(8)]))assert results.count("ok") == 1
The essential assertion is that concurrent requests for the same seat produce one successful booking and conflicts for the remaining requests. In a complete implementation, other expected failures, such as a full flight or database error, should also be tested explicitly.
The central lesson is that an AI agent can accelerate full-stack delivery, but generated code is not automatically a production-ready system. Reliable delivery requires structured requirements, explicit state models, server-side consistency controls, secure validation, and tests that reproduce real failure and concurrency conditions.
