The Shift from Writing Code to Designing Architecture with LLMs

    This guide explores how to move beyond treating large language models as snippet generators and start using them as software architects for full-stack application development. It walks through key technical decisions for frontend architecture, cloud service combinations, and layered AI integration, then details modular code generation practices for browsing, uploading, and AI-powered image creation modules. The goal is to help developers build complex applications faster by establishing clear architectural constraints before writing code.

    1. From Writing Code to Designing Architecture: The Fundamental Role Shift

    In traditional AI-assisted programming, developers often interact with models at the level of “implement this component for me.” The model outputs a usable code snippet, and the developer then manually stitches it together, debugs it, and fills in the missing context. This approach is essentially an “advanced code snippet generator,” and the model lacks understanding of the overall engineering structure.

    When task complexity rises to a complete application with multiple pages, modules, and role-based permissions, the drawbacks of snippet-based collaboration quickly amplify: inconsistent API contracts, duplicate data model definitions, and inconsistent error handling styles. The truly valuable shift is to let the model first take on the role of “architect” and then take on the role of “implementer.”

    Consider a representative scenario: building a photo asset mini-program that includes three major sections—waterfall-style asset browsing, user uploads and content management, and AI image generation and editing. If you directly ask the model to “write a waterfall layout,” you often get isolated code. However, if you first ask the model to output a complete technical plan, the output quality improves dramatically.

    A reusable prompt skeleton is as follows:

    1. Role: Senior Full-Stack Architect
    2. Task: Output a technical plan for a "Photo Asset Mini-Program"; do not write code yet
    3. Must include:
    4. 1. Frontend technology selection and page structure (including navigation hierarchy)
    5. 2. Backend and data storage solution (including draft database schema)
    6. 3. Integration boundaries and call sequence for third-party AI capabilities
    7. 4. Cloud function responsibility division and file upload/compression strategy
    8. 5. Risk points and fallback plans
    9. Output format: Section headings + bullet point lists

    The value of this plan lies in making “implicit decisions” explicit. Developers can reach a consensus on the tech stack, data models, and module boundaries before writing the first line of code. Every subsequent round of code generation then has a clear constraint baseline.

    2. Key Decision Points in the Architecture Planning Phase

    1. Frontend Selection and Page Information Architecture

    Mini-program applications typically benefit from native development frameworks for more stable base component support and smaller package sizes. In terms of information architecture, three to four primary entries are a restrained choice, such as “Asset Home / AI Creation / User Center,” to avoid overly deep hierarchies that cause user churn. The waterfall layout requires additional consideration for pagination loading, image placeholders, scroll reuse, and memory usage control.

    2. Backend and Cloud Service Combination

    For small- to medium-scale projects with rapid iteration, adopting a cloud-native integrated solution (cloud database + cloud functions + object storage) can significantly reduce operations costs. Common capabilities can be summarized as:

    • Object storage: Hosts unstructured data like images, with temporary credentials enabling direct client uploads;
    • Cloud database: Stores asset metadata, category tags, and user-works association relationships;
    • Cloud functions: Handle authentication, paginated queries, aggregated statistics, and AI request forwarding;
    • Logging services and monitoring alerts: Used to track AI call failure rates and API latency.

    3. Layered AI Capability Integration

    AI image-related features can typically be broken down into three layers: visual understanding layer (analyzing image subject, style, composition), text optimization layer (rewriting vague user descriptions into structured prompts), and generation layer (text-to-image or image-to-image). The benefit of decoupling these three layers is that any layer can be independently replaced or degraded, avoiding a single point of failure that renders the entire feature unusable.

    An illustrative call sequence is as follows:

    1. Client compresses image → Cloud function issues temporary upload credentials → Client uploads directly to object storage
    2. → Cloud function calls visual understanding model → Returns structured tags
    3. → User edits prompts → Cloud function calls text optimization → Calls generation model
    4. → Results written back to database → Client displays and saves

    3. Practical Points in the Modular Code Generation Phase

    1. Asset Browsing Module

    Ask the model to first implement the data model and query interfaces before building the UI. Cloud functions must support pagination cursors and category filtering to avoid pulling the entire dataset at once. The waterfall component should encapsulate lazy loading and height estimation logic to prevent layout shifts caused by asynchronous image loading.

    2. Upload and Management Module

    The core difficulty lies not in the UI but in the pipeline: client-side compression (reducing bandwidth and storage costs), temporary credential exchange (avoiding hardcoding keys in the client), upload progress tracking and failure retries, and content moderation and deduplication. These aspects should be listed one by one in the prompt with clear acceptance criteria.

    3. AI Creation Module

    After upload, automatically analyze and output multi-dimensional tags (subject, style details, background atmosphere) and highlight key elements. Generation results should support three follow-up actions: save, regenerate, and continue editing. From an engineering standpoint, timeout handling, rate limiting, and result caching must be implemented, otherwise costs and latency will spiral out of control during peak periods.

    4. Real-World Experience and Engineering Insights

    Overall, the most commendable aspect is the model’s performance in “long-context consistency”: in a single task generating over thirty files, it still maintained consistent naming conventions, directory structures, and error handling styles, running directly without blocking defects. This marks a shift in the collaboration mode from “conversational Q&A” to “task-based delivery.”

    However, three boundaries must be soberly recognized: First, the model cannot replace developers’ judgment on business rules; the more vague the requirements, the more rework occurs. Second, parts involving keys, permissions, and billing must be reviewed by humans. Third, it is essential to insist on small-step commits and module-by-module acceptance rather than accepting all output at once.

    In summary, the correct positioning of LLMs in intelligent programming is to handle architecture draft generation, boilerplate code laying, and cross-module consistency maintenance, while developers focus on requirement clarification, boundary constraints, and quality control. Drawing this division of labor clearly is the key prerequisite for domestic large models to enter real production workflows.