Agent-Driven Full-Stack Web Prototype Delivery: From Requirements to Acceptance

    Large-model-assisted programming has moved from completing single lines of code to generating complete pages from a requirements description. For booking systems, the key question is no longer whether an agent can generate a prototype, but whether the result can ship. This article presents a five-step agent workflow covering structured requirements, SVG frontend generation, server-side capacity constraints, persistence and concurrency, and an executable acceptance checklist.

    Large-model-assisted programming has evolved from completing single lines of code to generating complete pages from a requirements description. The question teams ask has changed from “Can it generate this?” to “Can the result go directly into production?” A deliverable booking website needs at least three layers: a visual and interaction frontend, a business-logic backend, and data persistence. Completing only one layer usually produces a demo, not a deliverable.

    The advantage of an agent is that it can connect multiple steps in one task. It can decompose requirements, write files, run checks, and fix errors, reducing the cost of humans switching between steps. It does not lower the bar for acceptance. The practical workflow can be summarized in five steps: requirements structuring, generation, run checks, correction, and human acceptance. The first four can be completed by the agent in a loop; the fifth cannot be skipped.

    The examples in this article are fictional. Seats, sessions, and numeric values do not correspond to any specific product.

    1. Structuring Requirements

    The more specific the requirements, the more stable the generated structure. If the prompt only says “build a timeline with a narrative feel,” the output often drifts in node count, layout, and data format. Use the following table to describe each feature:

    Field Description Example (fictional)
    Functional goal One thing the page or API must accomplish A visitor selects a seat for an experience session
    Data objects Entities and key fields involved Session, seat, reservation record
    State set All legal states, including how unknown states are handled available, held, booked; unknown states treated as unavailable
    Quantity rules Node counts, capacity limits, sorting rules Seat count per session is determined by session configuration; seat codes are sorted by row number
    Visual constraints Inspectable parameters such as color, font size, and animation duration Animation duration is specified as a range, and the value used during review is recorded
    Acceptance criteria Standards that can be judged by tests or manual checks When the same seat is submitted concurrently, only one request succeeds

    Every row in the table should be convertible into a test case. If you cannot write a test for a condition, the requirement is usually not specific enough.

    2. Frontend Generation: SVG Seat Map

    Cabin selection and seat maps are good candidates for SVG. Each seat is an independent element that can bind click events. The following code maps server state to style class names:

    1. const SEAT_CLASS = {
    2. available: "seat seat--available",
    3. held: "seat seat--taken",
    4. booked: "seat seat--taken",
    5. };
    6. const FALLBACK_CLASS = "seat seat--taken";
    7. // isPicked means the current user has selected this seat in the UI, which is local UI state
    8. function getSeatClass(status, isPicked) {
    9. if (isPicked && status === "available") return "seat seat--selected";
    10. return SEAT_CLASS[status] ?? FALLBACK_CLASS;
    11. }

    Unknown states fall back to the “unavailable” style. This is a fail-safe approach: when frontend state is abnormal, it is better to prevent the user from selecting a seat than to submit an invalid seat.

    This code only solves the display problem. Its boundaries need to be explained separately:

    • Scale: Each seat in SVG is a DOM node. As seat count grows, rendering and event binding overhead increase. Suitability should be determined by measured results on target devices; this article does not provide a specific threshold.
    • State source: Seat state is returned by the server query API. The frontend only displays it; it does not decide whether a seat has been taken by someone else.
    • Server wins on inconsistency: After the user submits a seat selection, the frontend must wait for the server response. If an occupied failure is returned, it should immediately refresh the seat state for that session and prompt the user to select again.
    • Frontend disabling cannot prevent overselling: Requests can bypass the UI and be sent directly. Capacity control must live in the server and data layers.

    3. Server-Side Capacity Constraints

    The most common error in booking systems is overselling. Capacity checks and seat uniqueness must be completed server-side and guaranteed by conditional database updates. The following statement merges “check availability” and “occupy” into one step:

    1. UPDATE seats
    2. SET status = 'held',
    3. reserved_by = ?,
    4. reserved_at = NOW(3),
    5. version = version + 1,
    6. updated_at = NOW(3)
    7. WHERE session_id = ?
    8. AND seat_code = ?
    9. AND status = 'available';

    After execution, check the affected row count. A return of 1 means the hold succeeded. A return of 0 means the seat is already occupied or does not exist, and the server should return 409 Conflict. InnoDB locks rows matched by the UPDATE and evaluates the WHERE condition on the latest committed version. Therefore, when two concurrent requests try to occupy the same seat, only one can get an affected row count of 1.

    If capacity is counted by quota rather than by seat, the same approach can be used for an inventory table:

    1. UPDATE inventory
    2. SET remaining = remaining - ?
    3. WHERE id = ? AND remaining >= ?;

    Idempotency is another issue that must be handled. After a network timeout, the client usually retries, and the same seat selection must not create two reservations. The client carries an Idempotency-Key in the request header, and the server uses it together with the user ID as a unique key. Replaying the same request returns the first result. If the same key is used with a different request body, the server returns 422, indicating a request conflict.

    Recommended server response rules are as follows:

    • First successful hold: return 200 with the seat code and status.
    • Replay of the same key: return the first result without duplicate writes.
    • Seat unavailable: return 409.
    • Parameter error or request body conflict: return 400 and 422 respectively.
    • Server exception: return 500; write error details only to logs, not to the client response.

    Multi-seat orders need deadlock awareness. All seat codes should be sorted first, then locked in order. If any seat update fails, the entire transaction must roll back.

    4. Persistence and Concurrency

    The seat table structure is shown below. The version field is used for auditing and optimistic concurrency checks, and status allows only three values:

    1. CREATE TABLE seats (
    2. id BIGINT PRIMARY KEY AUTO_INCREMENT,
    3. session_id BIGINT NOT NULL,
    4. seat_code VARCHAR(16) NOT NULL,
    5. status VARCHAR(16) NOT NULL DEFAULT 'available',
    6. reserved_by BIGINT NULL,
    7. reserved_at DATETIME(3) NULL,
    8. version INT NOT NULL DEFAULT 0,
    9. updated_at DATETIME(3) NOT NULL,
    10. UNIQUE KEY uk_session_seat (session_id, seat_code),
    11. KEY idx_status_reserved (status, reserved_at),
    12. CONSTRAINT chk_seat_status CHECK (status IN ('available', 'held', 'booked'))
    13. ) ENGINE=InnoDB;

    uk_session_seat ensures that a seat code appears only once within the same session. This is the final defense at the database layer; even if application code has defects, duplicate seats cannot be created. The CHECK constraint requires MySQL 8.0.16 or later.

    The reservations table records each request and handles idempotency control:

    1. CREATE TABLE reservations (
    2. id BIGINT PRIMARY KEY AUTO_INCREMENT,
    3. user_id BIGINT NOT NULL,
    4. idempotency_key VARCHAR(64) NOT NULL,
    5. session_id BIGINT NOT NULL,
    6. seat_code VARCHAR(16) NOT NULL,
    7. status VARCHAR(16) NOT NULL,
    8. request_hash CHAR(64) NOT NULL,
    9. created_at DATETIME(3) NOT NULL,
    10. UNIQUE KEY uk_user_idem (user_id, idempotency_key),
    11. KEY idx_session_seat (session_id, seat_code)
    12. ) ENGINE=InnoDB;

    request_hash stores the hash of the request body. When the same key corresponds to a different hash, the server treats it as a request conflict.

    State changes need to be traceable, so add an event table:

    1. CREATE TABLE seat_events (
    2. id BIGINT PRIMARY KEY AUTO_INCREMENT,
    3. seat_id BIGINT NOT NULL,
    4. from_status VARCHAR(16) NOT NULL,
    5. to_status VARCHAR(16) NOT NULL,
    6. actor_id BIGINT NOT NULL,
    7. request_id VARCHAR(64) NOT NULL,
    8. created_at DATETIME(3) NOT NULL,
    9. KEY idx_seat_time (seat_id, created_at)
    10. ) ENGINE=InnoDB;

    The following function places all steps of holding a seat in one transaction. The example uses a single-seat request; a multi-seat order can process sorted seat codes one by one within the same transaction:

    1. def hold_seat(db, user_id, idem_key, req_hash, session_id, seat_code):
    2. with db.transaction(): # any exception inside the function rolls back the entire transaction
    3. try:
    4. db.execute(
    5. "INSERT INTO reservations (user_id, idempotency_key, session_id, "
    6. "seat_code, status, request_hash, created_at) "
    7. "VALUES (%s, %s, %s, %s, 'held', %s, NOW(3))",
    8. (user_id, idem_key, session_id, seat_code, req_hash),
    9. )
    10. except DuplicateKeyError:
    11. # Same user replays the request: return the first result; reject if the body differs
    12. return replay_or_reject(db, user_id, idem_key, req_hash)
    13. updated = db.execute(
    14. "UPDATE seats SET status = 'held', reserved_by = %s, reserved_at = NOW(3), "
    15. "version = version + 1, updated_at = NOW(3) "
    16. "WHERE session_id = %s AND seat_code = %s AND status = 'available'",
    17. (user_id, session_id, seat_code),
    18. ).rowcount
    19. if updated != 1:
    20. # After the exception is raised, the newly inserted reservations record is also rolled back
    21. raise SeatUnavailable(seat_code)
    22. write_seat_event(db, session_id, seat_code, "available", "held", user_id)
    23. return {"status": "held", "seat_code": seat_code}

    There is a design tradeoff to make explicit. When a hold fails, the reservation record rolls back with the transaction, so the same idempotency key can be used to retry. If you want failure results to be cached as well, failure records need to be written in a separate transaction, and the business side must decide this first.

    Expiration release is a required step. A user may hold a seat and not pay, leaving the seat in held state for a long time. A scheduled task should release timed-out holds. The timeout duration is determined by the business and should not be hard-coded in the code:

    1. UPDATE seats
    2. SET status = 'available',
    3. reserved_by = NULL,
    4. reserved_at = NULL,
    5. version = version + 1,
    6. updated_at = NOW(3)
    7. WHERE status = 'held'
    8. AND reserved_at < NOW(3) - INTERVAL ? MINUTE;

    Payment callbacks must use conditional updates: a seat can change from held to booked only when it is still held by that user. If the callback arrives after the seat has been released by expiration and taken by someone else, the system needs to enter a compensation flow, such as a refund or reschedule. This race cannot be handled by the frontend.

    5. Acceptance Checklist

    Agent-generated code needs item-by-item verification. The following table lists executable checks:

    Check item Verification method Pass criteria
    Frontend state mapping Pass valid states and unknown states Unknown state renders as unavailable and does not trigger submission
    Concurrent hold Multiple requests hold the same seat simultaneously Only one request succeeds; the rest return 409
    Overselling test Fixed quota with concurrent requests exceeding the quota Success count does not exceed the quota; remaining count is not negative
    Idempotent replay Send the same request twice with the same key Only one reservation record is created; results are identical
    Request conflict Send different request bodies with the same key Returns 422; no new database record is created
    Rollback Inject an exception after the hold update No residual changes in reservations or seats
    Expiration release Create a timed-out held record and run the task Seat returns to available and an event is written
    Payment race Make the payment callback arrive after expiration release Compensation flow is entered; seat status is not incorrectly overwritten
    Log audit Complete one hold and one release Every state change has an event record and request ID
    Error messages Trigger a server exception Response contains no stack trace or SQL statements
    Backup recovery Restore a backup in the test environment Restored seat and reservation data matches the backup

    The following items cannot be completed automatically by an agent and require human confirmation:

    • Whether business rules are correct, such as refund rules and the maximum number of seats a user can reserve.
    • Whether payment and personal information processing comply with applicable regulations and internal policies.
    • Performance metrics under real load. Load-test targets should be set by the business side and must not be inherited from defaults in generated code.
    • Permission policies, key management, and release approval.

    An agent can move a prototype to a testable state, but pre-release judgment still requires experienced engineers. The purpose of the acceptance checklist is to give that judgment a clear basis.