Full-Stack Code Generation with LLMs: A Practical Guide to Architecture-First Development
This article explains how large language models have shifted from generating isolated code snippets to delivering full-stack applications, using an integrated app with a wallpaper waterfall feed, user upload management, and AI image generation as the example. It covers writing requirements with clear business boundaries, prompting the model for an architecture before code, implementing modules such as content display, uploads, and model orchestration, and reusable engineering practices including staged confirmation, explicit interface contracts, post-generation validation, and security and quota awareness.
1. From Snippet Generation to Architecture Delivery
Earlier interactions with AI coding tools usually stayed at the local-task level: “write me a carousel component” or “implement a pagination API.” The model returned a runnable snippet, and developers still had to handle module decomposition, interface contracts, state management, and integration debugging themselves. In that mode, the model was essentially an advanced snippet generator with limited efficiency gains.
Once a model has strong long-context understanding and structured planning ability, the interaction moves up the stack: the developer describes the business goal, and the model first proposes technology choices and module boundaries, then generates implementation code layer by layer. This article uses an integrated application, a wallpaper waterfall feed plus user upload management plus AI image generation, to show how to use an LLM for end-to-end full-stack delivery.
2. Step One Is a Technical Plan, Not Code
2.1 Requirements Must Include Business Boundaries
High-quality output starts with a clear requirement statement. A reusable template:
Goal: a mobile mini program with three main pages (home, creation, profile)Capability A: wallpaper waterfall display with category filtering, pagination, image preview, and savingCapability B: user uploads and content management with compressed upload, my-works list, and deletionCapability C: AI image generation with image upload, scene analysis, prompt editing, style transfer, and result savingConstraints: use the cloud development stack (cloud database / cloud functions / object storage), no self-hosted servers
The key is to provide both the feature list and the non-functional constraints (storage approach, whether a custom backend is needed, expected concurrency). Only then can the model make reasonable choices instead of generic “suggestions.”
2.2 Ask for the Architecture Before the Code
Explicitly instructing the model to “give the plan first and wait for my confirmation before writing code” typically produces a structure like this:
- Frontend: the native mini program framework, three main pages plus several secondary pages, with components layered as pages, business components, and base components;
- Backend: the cloud development model, with a cloud database for metadata, cloud functions for business logic, and object storage for image files;
- Model orchestration: a vision model for scene analysis, a text model for prompt rewriting and expansion, and an image generation model for producing images;
- Data and API planning: collection partitioning, cloud function responsibility boundaries, and the file upload and compression path.
The value of this plan is making implicit decisions explicit. Before writing the first line of code, developers can surface easily overlooked questions such as whether images need multiple thumbnail sizes and whether analysis results need caching.
3. Module Implementation: Pair Programming with a Full-Stack Colleague
3.1 Content Display Module
After the plan is confirmed, generate module by module. The display module usually has three parts:
- Data layer: define the content collection fields (title, category, image URL, dimensions, creation time, status);
- Logic layer: cloud functions provide pagination and category filtering to avoid fetching the entire dataset at once;
- View layer: the waterfall component encapsulates lazy loading and height estimation, requesting real resources only after images enter the viewport.
An illustrative cloud function input contract:
// Paginated content list queryexports.main = async (event) => {const { category = 'all', page = 1, pageSize = 20 } = event;const skip = (page - 1) * pageSize;// Build the query condition from category, then return the list and whether another page existsreturn { list, hasMore: list.length === pageSize };};
3.2 Upload and Management Module
The engineering focus of the upload path is not “getting the file up” but “uploading reliably and economically”:
- Compress on the frontend before uploading to reduce bandwidth and storage costs;
- Upload directly to object storage with temporary credentials so files do not pass through cloud functions and cause timeouts;
- Write metadata after a successful upload, and maintain the my-works list and deletion logic (deletion must clean up both metadata and files).
3.3 AI Image Generation Module
This is the path that best shows the value of model orchestration, and it breaks into four steps:
- Upload and preprocessing: compression, format normalization, and dimension validation;
- Scene analysis: the vision model outputs a structured description across dimensions such as subject, style, and background atmosphere;
- Prompt editing: the text model rewrites and enhances the description, key elements are highlighted in the UI, and users can adjust them manually;
- Generation and post-processing: the image model produces the image, with support for saving, regenerating, and further editing.
Structured analysis results are easy to render and edit again on the frontend:
{"subject": "half-body portrait, looking back over the shoulder","style": "low-saturation film texture","background": "city street at dusk, blurred neon","keywords": ["film", "dusk", "neon", "shallow depth of field"]}
4. Reusable Engineering Practices
- Confirm in stages: proceed in three stages (architecture, data model, single-module implementation), confirming each before continuing, which significantly reduces rework;
- Define interface contracts clearly: fix fields and return structures first, then generate implementations, so parallel module work does not conflict;
- Constrain the tech stack: fix the framework and cloud service categories in the prompt to avoid dependencies that cannot be deployed;
- Always validate after generation: generating dozens of files at once does not mean zero defects; cover exception branches, permission checks, and resource cleanup;
- Keep security and quotas in mind: upload endpoints should restrict type and size, and model calls should set timeouts, retries, and caching to avoid repeated billing and cascading failures.
5. Conclusion: Shifting Focus as Tools Evolve
When models can take on architecture design and cross-module implementation, the developer’s value lies more in requirement definition, trade-off decisions, and quality control. Rather than worrying about how fast tools iterate, invest energy in three more stable things: defining the business problem clearly, thinking through system boundaries and the data model, and establishing validation and operations practices. Baidu AI Cloud’s ongoing improvements in common capabilities such as cloud development, object storage, and model services also provide a fairly complete environment for this kind of full-stack generation practice.
