A Practical Guide to LLM-Driven Intelligent Programming: From Code Snippets to System Architecture

    This article presents a reusable workflow for building applications with LLM-powered coding tools. Instead of treating the model as a snippet generator, it explains how to have the model act as an architect first: producing a reviewable technical plan, data models, and API contracts before generating code. Using a content-browsing mini program as an example, it covers vertical-slice module development, orchestration of image understanding and generation pipelines, and a three-layer acceptance and regression process to turn generated output into maintainable software.

    1. Background: From Writing Code to Setting Up the Structure

    After introducing large language models into intelligent programming tools, many teams first notice that “generation is faster.” But a new problem quickly appears: the usability rate of the generated output is low. A common early pattern is to give a narrow instruction, such as “help me implement a carousel component.” The model returns a piece of code, and the developer then stitches it together, debugs it, and fills in the edge cases. This is essentially a “code snippet generator.” It saves typing time, but it does not save time spent on architecture design and system integration.

    When the task grows to “a complete application with multiple pages, multiple roles, multiple data entities, and dependencies on external intelligent capabilities,” snippet-based collaboration breaks down quickly, for three reasons:

    1. Insufficient context: The model cannot see global constraints and can only guess at implementation details based on local requirements, leading to inconsistent directory structures, naming conventions, and state management approaches.
    2. Interface drift: Different modules make different assumptions about the same data structure. Field names, pagination styles, and error code formats are inconsistent, which amplifies integration costs.
    3. Missed implicit requirements: Cross-cutting concerns such as permission boundaries, failure retries, resource quotas, and content compliance do not appear in an instruction like “write a page,” yet they determine whether the project can go live.

    A more mature collaboration model is to let the model take on the role of “architect” first: output the technology choices, module breakdown, data models, and interface contracts, then implement code module by module. This article uses a mini program project as an example to present a reusable workflow.

    2. Step 1: Have the Model Produce a Technical Plan, Not Code

    A typical requirement might be described as: build a content-browsing mini program that includes an image waterfall feed, user uploads and content management, and integrates image understanding and image generation capabilities, supporting image analysis, prompt editing, style replacement, and one-click generation.

    Faced with such a requirement, the high-quality approach is not to ask for code immediately, but to first ask the model to output a “reviewable technical plan.” The plan should cover at least the following dimensions:

    • Frontend choices: Native mini program development or a cross-platform framework; how to divide the page structure (for example, three main entry points: home, creation, and profile); navigation, state management, and component reuse strategy.
    • Backend choices: Using integrated cloud development capabilities (cloud database, cloud functions, object storage) or self-hosted services; how to design the authentication system, data isolation, and quota strategy.
    • Intelligent capability integration: Image understanding is used to extract information such as the subject, style, and background; a text model is used for prompt rewriting and structuring; an image generation model is used for image-to-image or style transfer. At this stage, only describe the capability categories and call sequence, without binding to any specific vendor or model.
    • Feature breakdown: Content library (list, album details, preview, download), creation flow (upload, analysis, editing, generation, saving), and admin side (review, takedown, category maintenance).
    • Engineering details: Database table structures, cloud function responsibilities, image compression and upload strategy, error code and logging conventions.

    The value of this plan is that it makes implicit requirements explicit and turns them into a unified constraint for all subsequent code generation. In practice, you can ask the model to output using a fixed template to make review and version management easier, for example:

    1. [Technical Constraints]
    2. - Runtime: native mini program + cloud development
    3. - Data access: cloud functions only; direct database access from the frontend is prohibited
    4. - Pagination: unified page/pageSize, returning { list, total, hasMore }
    5. - Errors: { code, message, requestId }
    6. - Resource constraint: compress each image before upload so the long edge does not exceed 1600px

    3. Step 2: Define the Data Model and Interface Contracts First

    After the architecture plan, have the model produce the data model and interface list before page code. The data model is the “skeleton” of the system; once it is stable, the consistency of generated modules improves significantly.

    Taking the content library as an example, you can abstract three core tables: a content table, an album table, and a user action table. A sketch is shown below (the fields are a generic design, not specific to any platform):

    1. wallpaper(id, title, category_id, cover_url, width, height, tags, status, created_at)
    2. album(id, name, cover_url, sort, created_at)
    3. user_action(id, openid, wallpaper_id, action_type, created_at) // view/download/like

    The interface contract should be enumerated in a “resource + action” style, with idempotency and pagination made explicit:

    1. GET /wallpaper?page=1&pageSize=20&categoryId=xxx // paginated by category
    2. GET /wallpaper/:id // details
    3. POST /upload/sign // get temporary object storage credentials
    4. POST /analyze // image understanding, returns structured prompts
    5. POST /generate // image-to-image, returns a task or result
    6. POST /admin/wallpaper/:id/status // publish or take down

    With the contract in place, when the model generates cloud functions and the frontend request layer, it automatically aligns fields and error structures, reducing cases where “integration means rewriting.”

    4. Step 3: Generate by Module Using Vertical Slices

    Module generation should avoid “spreading horizontally” (writing all pages first and then the backend). The recommended approach is “vertical slicing”: get one complete flow working end to end at a time, for example “upload -> compress -> sign -> write to object storage -> persist to database -> visible in the list.”

    In the content library module, you can ask the model to produce the following in order:

    1. Cloud database collections and index recommendations (category + time sorting);
    2. A query cloud function that supports pagination and category filtering;
    3. A waterfall component that internally encapsulates lazy loading and placeholder height calculation;
    4. Image download and save interactions, including failure retries.

    The key to a waterfall layout is not the layout itself, but predictable heights and a stable loading rhythm. The sketch logic is as follows:

    1. // Pseudocode: waterfall lazy loading
    2. const state = { page: 1, hasMore: true, loading: false };
    3. async function loadMore(categoryId) {
    4. if (state.loading || !state.hasMore) return;
    5. state.loading = true;
    6. const res = await callFn('wallpaperList', {
    7. page: state.page, pageSize: 20, categoryId
    8. });
    9. appendToColumns(res.list); // assign columns by estimated height
    10. state.hasMore = res.hasMore;
    11. state.page += 1;
    12. state.loading = false;
    13. }

    In the upload and management modules, the key constraints include: client-side compression, temporary credential acquisition, failure retries, and the content state machine (pending review / published / taken down). Having the model output a state machine table effectively avoids the common problem of “the status field being assigned arbitrarily.”

    5. Step 4: Orchestrating the Intelligent Capability Pipeline and Its Timing

    Image understanding and generation are typical “multi-step orchestration” tasks, so the model should provide the sequence first and then write the code. The recommended flow is:

    Upload -> image understanding (returns structured information across three dimensions: subject, style, and background) -> prompt editing (text model rewriting, highlighting key elements) -> image generation (submit task, poll or callback) -> save the result and edit again.

    Structured output significantly reduces downstream parsing costs. You can agree on a unified return format:

    1. {
    2. "subject": "Side profile of a person, shallow depth of field",
    3. "style": "Low-saturation film look",
    4. "background": "Dusk street, warm light spots",
    5. "keywords": ["film", "warm tones", "shallow depth of field"]
    6. }

    Engineering-wise, three things must be considered: timeouts and retries (generation tasks vary widely in duration), idempotency keys (to avoid duplicate submissions causing multiple charges), and fallback strategies (when the main flow fails, preserve the editing state and allow the user to retry rather than losing input). These constraints should be written into the technical constraint list so the model includes them automatically during generation.

    6. Step 5: Acceptance and Regression, Turning “It Runs” into “It Is Maintainable”

    Generating dozens of files in one pass that “just run” is a sign of efficiency, but it is not the finish line. It is recommended to establish three layers of acceptance:

    1. Static consistency: Whether the directory structure, naming, error codes, and pagination structures are unified; use a unified template for manual spot checks.
    2. Flow acceptance: Each vertical slice should have a minimal verification path, such as uploading an image and completing one generation.
    3. Regression checklist: Solidify cross-cutting items such as permissions, quotas, failure retries, and content compliance into a checklist, and confirm each item after every change.

    At the same time, it is recommended to put the “technical constraints + interface contracts + acceptance checklist” under version control as a single source of truth for team collaboration. Model capabilities continue to evolve, but the stability of constraints and contracts determines the lower bound of output quality.

    7. Conclusion: Tools Keep Evolving, but Methods Can Be Accumulated

    After large models entered programming tools, what really sets teams apart is not “whose model is newer,” but “who is better at structuring requirements.” Have the model do technology selection and data modeling first, then implement module by module using vertical slices, and finally complete acceptance with contracts and checklists. This method applies to the rapid construction of most small and medium-sized applications. For developers, rather than chasing every new model, it is better to accumulate constraint expression, architecture review, and regression verification as team assets—this is the sustainable path to improved efficiency.