Full-Stack AI Agent Development: From Frontend to Backend in Practice
This article explores whether AI agents can deliver end-to-end full-stack applications in real business scenarios. It examines the engineering practices of generating frontend interfaces, backend logic, and data storage from abstract requirements, while highlighting critical areas that require human intervention, such as concurrency control and enterprise deployment checklists.
In recent years, the application of Large Language Models (LLMs) and AI agents in software engineering has grown rapidly. While open-source models have shown improvements on public software engineering benchmarks, these scores depend heavily on test sets, model versions, and evaluation conditions. For developers, a more practical question is: Can an AI agent deliver an end-to-end full-stack application in a real business context? Starting from engineering practice, this article explores how an agent generates frontend interfaces, backend logic, and data storage based on a requirement, and identifies the areas where human intervention is essential.
1. Frontend: From Visual Requirements to Interface Code
Modern web application frontends are not just about form submissions; they must also reflect brand tone, dynamic effects, and complex interactions. Take the official website of a near-earth orbit travel company as an example. The developer’s input might be a brief description, such as “the premium feel of commercial aerospace.” The AI agent needs to translate this abstract aesthetic intent into specific styles and structures.
In implementation, the agent typically adopts the following approaches:
- Perspective and 3D Transforms: Page cards can use CSS
perspectiveto set the perspective distance, and properties likerotateXandtranslateZto create a sense of depth. The smooth rotation of the Earth’s arc can be achieved usingtransformandtransition. These effects rely on the browser’s GPU compositing, which can cause frame drops when there are many animated elements. When generating code, the agent should include the appropriate use ofwill-changeand disable animations for users who prefer reduced motion via@media (prefers-reduced-motion: reduce). - Timeline Components: A flight narrative timeline usually contains multiple nodes, from the preparation phase to splashdown recovery, each bound to a timestamp (e.g., T-60:00 to T+92:00). The agent generally uses Flexbox or CSS Grid to build a vertical timeline and renders nodes in a data-driven manner, avoiding hardcoding timestamps and copy directly into the HTML. This makes it easier to modify task nodes later by simply updating the data file.
- Interactive SVG Seat Maps: Cabin selection can be implemented using SVG, where each seat is a graphical element with an
onclickevent that updates the seat status upon clicking. This approach scales easily, but when the number of seats is large, an excess of DOM nodes can slow down the page. Furthermore, relying solely on mouse operations is unfriendly to keyboard users. When generating the code, the agent should supplement it withtabindexand keyboard event handling. - WebGL and Canvas Effects: Liquid rotation, light caustics, and other effects commonly seen on websites for deep-sea exploration agencies or perfume brands can be implemented using WebGL or the Canvas API. This type of code depends on the browser and graphics card, requiring compatibility checks. If the check fails, it should fall back to a 2D Canvas or static image, and the supported browser versions should be clearly documented in the code comments.
Whether these effects can be deployed depends on the performance budget and device coverage. The generated frontend code should be tested for frame rate and first-screen loading time on both low-to-mid-range mobile phones and mainstream desktop browsers before deciding which effects to retain.
2. Backend: Data Models, Business Validation, and Persistence
The frontend determines what users see, while the backend determines whether the system runs correctly. A truly deliverable AI agent should output an application with complete backend logic, not just an interface.
Take flight booking as an example. Besides frontend interactions like selecting dates, choosing seats, and filling in passenger information, the backend also needs to establish clear data relationships and storage mechanisms.
- Data Models: The agent typically defines entities such as Flight, Seat, and Passenger, and sets up foreign key relationships between them. For the seat table, a unique constraint should be established at the database level for
(flight_id, seat_number)to prevent the same seat from being written into two records. - Business Validation: The rule given in the requirement is “maximum of 6 seats per flight, auto-lock when full.” Below is a schematic pseudocode showing the basic validation logic:
def book_seat(flight_id, seat_number, passenger_info):flight = db.query(Flight).get(flight_id)if not flight:raise NotFoundError("Flight not found")booked_seats = db.query(Seat).filter(Seat.flight_id == flight_id,Seat.status == 'BOOKED').count()if booked_seats >= 6:flight.is_locked = Truedb.commit()raise BusinessError("Flight seats are full, auto-locked")seat = db.query(Seat).filter(Seat.flight_id == flight_id,Seat.number == seat_number).first()if seat and seat.status == 'AVAILABLE':seat.status = 'BOOKED'seat.passenger = Passenger(**passenger_info)db.commit()return {"status": "success", "seat": seat_number}raise BusinessError("This seat is not available")
This code is merely a sketch of the validation logic. It first queries the number of booked seats and then modifies the seat status, with no lock between the two steps. If two users submit simultaneously, both might read the remaining seats, ultimately causing overselling. In a production environment, this needs to be changed to the following approach:
- Transactions and Row Locks: Use row lock statements like
SELECT ... FOR UPDATEwhen reading flight and seat data to ensure that booking requests for the same flight are processed serially. Here is the revised schematic:
def book_seat(flight_id, seat_number, passenger_info):with db.begin(): # Read and write are in the same transactionflight = (db.query(Flight).filter(Flight.id == flight_id).with_for_update().first())if not flight:raise NotFoundError("Flight not found")if flight.is_locked:raise BusinessError("Flight is locked")seat = (db.query(Seat).filter(Seat.flight_id == flight_id,Seat.number == seat_number).with_for_update().first())if not seat or seat.status != 'AVAILABLE':raise BusinessError("This seat is not available")booked = db.query(Seat).filter(Seat.flight_id == flight_id,Seat.status == 'BOOKED').count()if booked >= 6:raise BusinessError("Flight seats are full")seat.status = 'BOOKED'seat.passenger = Passenger(**passenger_info)if booked + 1 == 6:flight.is_locked = True # Lock flight after 6th seat is soldreturn {"status": "success", "seat": seat_number}
- Unique Constraints and Idempotency: When a user double-clicks or retries due to a network timeout, the same request might be submitted twice. An idempotency key should be generated for each booking and a unique index created for it in the database.
- Isolation Levels: Different databases have different default isolation levels. For example, MySQL InnoDB defaults to Repeatable Read, while PostgreSQL defaults to Read Committed. The choice depends on the locking strategy and concurrency test results.
- Boundary Rules: Rules not specified in the requirements must be confirmed separately, including whether the total number of seats is fixed, whether a locked flight can be unlocked, whether refunds are issued after cancellation, and how seats are released after payment failure. These rules should be documented first before being handed over to the agent for implementation.
- Audit Logs: Every change in seat status should record the operator, time, status before and after the change, and request ID for post-event troubleshooting.
- Persistent Storage: SQLite can be used for quick demonstrations during the development phase. For production, switch to a managed database service and configure regular backups. SQLite is suitable for single-machine validation but not for carrying a booking system with heavy concurrent writes.
3. Task Decomposition and Context Management
AI agents can use similar prompts to generate websites for different industries because they first decompose the task. The common workflow is: identify industry attributes, plan the visual system, design the database table structure, generate frontend components, and finally write backend routes. This workflow helps maintain consistency across parts, but it cannot replace human confirmation of requirements.
Two points need attention here:
- Limited Context Window: A long context window can accommodate more code and conversations, but it is not infinite. The longer the session, the more likely early agreed-upon field names, business rules, and security requirements will be forgotten or misunderstood. In practice, critical constraints should be written into project files, such as a
READMEor an independent specification document, so that each generation can re-read them. - Cross-file Consistency Requires Contracts and Testing: The API paths, request parameters called by the frontend, and the routes defined by the backend must match exactly. Relying solely on the model’s memory cannot guarantee this reliably. A more robust approach is to use an interface contract like OpenAPI as the single source of truth, and then use automated tests to check whether frontend calls match the contract.
4. Enterprise Deployment: Engineering Requirements and Checklist
The generated monolithic application usually cannot go live directly. In an enterprise environment, supporting work in containerization, observability, and security compliance is also required.
- Containerization and CI/CD: The application needs to be packaged into a container image and integrated into a CI/CD pipeline. The pipeline should automatically execute unit tests, concurrency tests, and static scanning. Any failure should block the release.
- Observability: Key nodes such as seat locking and payment callbacks should have unified format logging and alerts.
- Security and Compliance: The generated code needs to undergo static analysis to prevent injection vulnerabilities and unauthorized access. Data involving user privacy should be encrypted and stored using a cloud provider’s Key Management Service (KMS).
The following checklist can serve as the minimum requirement before going live:
- Static Application Security Testing (SAST) tools are integrated into the pipeline; zero high-severity issues are required for merging (e.g., Semgrep or SonarQube).
- Dependency scanning has been executed (e.g.,
pip-audit,npm audit, or OWASP Dependency-Check); known high-severity vulnerabilities are fixed or have a written waiver. - Credentials such as database passwords and API keys are not in the code repository; they are stored in a KMS with a set rotation period.
- Logs contain request ID, flight number, seat number, operation result code, and timestamp; personally identifiable information (PII) like phone numbers and ID numbers are masked or not recorded.
- Concurrency testing covers simultaneous booking of the same seat, duplicate submissions, and the 6th seat selling scenario, with results meeting expectations.
- A full database backup is completed before going live, and a restore has been rehearsed once in the test environment.
- Database migration scripts are reversible, and the application version can roll back to the previous stable version.
- The new version is first released as a small percentage of canary traffic, observing error rates and latency before a full switch.
- Code involving payments, seat locking, and refunds is manually reviewed line-by-line by engineers.
- Copyrights and open-source licenses for visual assets and third-party components have been verified.
5. Conclusion
AI agents can already transform a requirement into an application prototype with a complete interface and basic business logic. They are highly efficient in generating frontend visuals and interface structures, and can provide usable sketches for backend logic. However, concurrency control, boundary rules, and data security still require the oversight of engineers. For developers, treating the AI agent as a pair programming partner while constraining its output with interface contracts, automated testing, and a pre-launch checklist is the only way to increase delivery speed while controlling risk. This remains a phased progress; AI-generated code requires manual review and test validation before it can be used in a production environment.
