LLM-Assisted Full-Stack Development: Practices from Architecture to Code Generation

    This article explores how to effectively use Large Language Models (LLMs) in full-stack development. Using a client-side mini-program with a wallpaper waterfall flow, user uploads, and AI image generation as an example, it details which development stages are suitable for LLMs and which require developer oversight, covering requirement breakdown, architecture selection, implementation details, and security compliance.

    The key to LLM-assisted full-stack development is letting the model clarify the requirements before writing code. This article uses a client-side mini-program featuring a wallpaper waterfall flow, user uploads, and AI image generation to illustrate which stages suit the model and which require developer oversight. The conclusions are based on a specific project practice, not general performance or efficiency benchmarks.

    1. Requirement Breakdown Before Architecture

    Feeding multiple feature requests directly to a model usually yields inconsistent code fragments. A safer approach is to have the model output a requirement breakdown and architecture plan first, confirming it before coding. Follow these four steps:

    1. List the feature inventory, annotating inputs, outputs, and external service dependencies for each.
    2. Identify non-functional requirements, including initial loading time, max file size per upload, data retention periods, and privacy needs.
    3. Ask the model to provide two or three technical solutions and explain their applicable conditions.
    4. Developers confirm the solution and create a written architecture document. All subsequent code generation relies on this document.

    The value of these steps is providing a verifiable standard for the model’s output. If the solution fails to address a requirement from step two, it’s incomplete and needs further prompting.

    2. Framework and Backend Selection

    For client-side mini-programs, common choices are native and cross-platform frameworks. Native frameworks offer more direct platform capabilities and shorter debugging chains. Cross-platform frameworks cover multiple platforms with one codebase but require verifying platform-specific behaviors. Base your choice on the number of target platforms, the team’s tech stack, and required native capabilities.

    For the backend, Serverless cloud-native architectures are often recommended, typically comprising cloud databases, cloud functions, and object storage. This eliminates server maintenance and scales elastically based on requests. However, evaluate these boundaries early:

    • Cold start latency: Functions inactive for a while may be noticeably slower on the first call; reserve a waiting state in the UI design.
    • Permission scope: Cloud function execution identities should follow the principle of least privilege to prevent a single function from reading or writing all data.
    • Cost structure: Costs depend on invocation counts and storage; set usage alerts as costs rise with traffic spikes.
    • Platform lock-in: Databases and function APIs are tied to the cloud provider; factor migration costs into your selection phase.

    3. Heterogeneous Integration and Call Sequence of AI Capabilities

    The AI image generation in this example involves three types of models: a vision model for image analysis, a text model for prompt expansion, and an image generation model for image-to-image transformation. They have distinct responsibilities and should not share a single interface.

    The complete call flow is:

    1. The frontend compresses images locally to control upload size.
    2. A cloud function validates file type and size, then routes it to content safety checks.
    3. The vision model returns structured tags (subject, style, background), and the frontend highlights key elements accordingly.
    4. The user edits the prompt, and the text model offers expansion suggestions.
    5. The image generation model performs image-to-image generation, returning the result to the frontend. The user can save, regenerate, or edit again.

    Each step requires failure handling. Prompt retries on upload failures. Retain user input on model timeouts and allow resubmission. Provide clear reasons for content safety blocks without exposing internal moderation strategies to the user. Timeout thresholds, retry limits, and daily cost caps should be written into configuration files, not scattered in business logic.

    4. Implementation of Waterfall Flow and Upload Modules

    The waterfall flow is the primary performance bottleneck on the client side. In our implementation, the model generated the lazy loading logic. Developers should verify the following during review:

    • Pagination: Set a clear limit per page and use cursors or pagination parameters to avoid fetching all data at once.
    • Placeholders: Display fixed-size placeholders before images load to prevent list jumping.
    • Viewport detection: Determine whether to load images based on viewport position. Use the platform’s intersection observer interface or scroll listeners.
    • Request cancellation: Cancel pending old requests when users quickly switch categories to prevent result misalignment.
    • Memory recycling: Release the decoding cache of large images outside the viewport to reduce memory usage.

    Performance validation should occur on real devices, recording frame rates during scrolling, memory peaks, and initial load times, and comparing them with pre-change data. Code review alone cannot prove optimization effects.

    On the database side, pagination queries rely on indexes. Create composite indexes based on actual query conditions (e.g., category and publish time) and verify via execution plans that queries hit the index.

    The user upload pipeline typically has three steps: the client requests a temporary key from the server, the client uploads directly to object storage, and the server compresses or validates post-upload. This pipeline has two security requirements. First, temporary keys should have a short validity period and be restricted to specific paths and operation types. Second, permanent keys must never appear in client code or logs; store them in environment variables or a key management service.

    5. Reliability of Generating Multiple Correlated Files

    Models can generate many correlated files in a single session, which happened in our practice. Whether the output compiles and runs depends on multiple factors: model and tool versions, project scale, dependency versions, and the ratio of manual fixes. Since we provide no unified statistics, this article claims no fixed ratio or quantity.

    Treat the generated output as a first draft and perform the following checks:

    1. Run compilation and static checks, recording pass rates.
    2. Conduct boundary testing on cloud function inputs, including nulls, overly long strings, and illegal file types.
    3. Check for hardcoded keys, test addresses, or debug toggles.
    4. Verify database read/write permissions item by item.
    5. Perform end-to-end testing on critical flows, covering upload, image generation, and saving.

    6. Security and Compliance of AI-Generated Code

    AI-generated code is not guaranteed to be production-ready. Features involving user images require addressing these issues:

    • Data privacy: Uploaded photos may contain personal info; clarify data usage, retention periods, and deletion mechanisms.
    • Content safety: Image generation and analysis can produce non-compliant content; review both input and output ends.
    • Third-party model terms: Before calling external models, confirm if data will be used for training and state this honestly in the privacy policy.
    • Audit logging: Retain logs for key operations like upload, generation, and deletion. Do not write keys or full user image addresses into logs.

    7. Developer Pre-Launch Checklist

    With models handling much of the initial drafting, the developer’s role shifts to review and oversight. Confirm the following before launch:

    1. Does the architecture document match the actual code?
    2. Are timeouts, retries, and failure handling configured for every external dependency?
    3. Are permissions and keys configured with least privilege?
    4. Do core paths have automated tests verified on real devices?
    5. Are cost caps and usage alerts set?
    6. Is there a rollback plan to quickly revert to the previous version if issues arise?

    The key to human-AI collaboration is division of labor. Models are suitable for rapidly generating plans and drafts, while developers judge if the solution fits the current project and take responsibility for the final production code. Whether time is saved depends on requirement clarity, review thoroughness, and the team’s ability to validate results.