Architecture-First Development with Large Language Models

    A practical guide to using AI coding tools as architecture collaborators rather than code generators. It explains how to define capability boundaries, design data and task flows, separate AI responsibilities, implement modules incrementally, and validate systems through explicit constraints, traceable states, and independent acceptance criteria.

    Why “Write the Code First” Often Fails

    Many teams treat AI coding tools as advanced snippet generators: give the model a prompt such as “build a masonry layout,” receive a set of components, and then manually connect the pages, add APIs, implement permissions, and handle edge cases. This may appear highly efficient at first, but three problems emerge as the project becomes more complex.

    First, the context becomes fragmented. The model sees only local instructions and does not know how pages should connect, which data must be persisted, or which calls require authentication. Second, technical decisions become hidden inside the code. Frontend frameworks, storage strategies, and asynchronous task boundaries are not discussed explicitly, making it difficult for new team members to understand why the system was designed that way. Third, generated output becomes difficult to evaluate. Without API contracts and data models, there is no reliable way to determine whether something “works” because the structure is sound or merely by accident.

    A more reliable approach is to treat the model as an architecture collaborator. First ask it to produce a proposal that people can review. Confirm the constraints, then implement the system module by module. This does not necessarily slow development down. Instead, it moves rework from integration and debugging back into the design phase.

    Turn Requirements into Implementable Capability Boundaries

    Consider a common lightweight application for content management and AI-assisted generation. Its requirements are more useful when expressed as business capabilities rather than a list of page names.

    • Content browsing: category lists, detail previews, pagination, and conditional filtering, with lazy loading to control initial load time and bandwidth.
    • User content management: upload, compression, moderation status, private visibility, and deletion. Files should not be stored in the business database; only metadata and object URLs should be retained.
    • AI image workflow: after an upload, analyze the image, extract an editable description, and use that description for text-to-image generation or local inpainting. Results should be saved, retried, or edited further.

    Prompts given to the model should include constraints, not just desired features. Specify the target users, client form factor—native lightweight application or cross-platform client—whether cloud functions and object storage are required, whether long-running tasks are allowed, the budget and latency limits, and which data is private. The clearer the constraints, the less likely the design is to drift toward connecting every possible service and generating unnecessary functionality.

    What an Architecture Proposal Should Make Checkable

    A useful first-round proposal is not a marketing-style feature list. It is a set of decisions that can be reviewed one by one. Ask the model to organize its response around the following areas.

    Client and navigation. Keep the main path to a small number of entry points, such as browsing, creation, and profile. Each entry point should handle one type of task. Avoid making a single page responsible for lists, uploads, generation, and settings at the same time.

    Service boundaries. Read-heavy lists should use query APIs. Uploads should use temporary credentials to send files directly to object storage instead of routing large files through the business server. Image understanding and generation are slow operations and should be asynchronous. Use task states rather than holding a synchronous request open until it times out.

    Data model. At minimum, distinguish between content, albums or categories, user assets, and generation tasks. A content record may contain dimensions, category, cover URL, and status. A task record should contain the input object, prompt version, model category, status, and failure reason. Define the schema before writing page code; otherwise, the frontend and backend may each invent their own field set.

    Separation of model responsibilities. Visual understanding, text rewriting, and image generation are different calls and should not be bundled into one “万能” interface. The understanding step should produce a structured description, the rewriting step should produce an editable prompt, and the generation step should create the image. If one step fails, it should be possible to retry only that step, making both cost control and troubleshooting clearer.

    Security and limits. The proposal should specify upload types and size limits, request frequency, the maximum number of concurrent generation tasks per user, and the visibility of generated results. Otherwise, the first production problems are likely to involve abuse and unexpected costs rather than the interface.

    At this stage, the human’s main responsibility is to reduce scope. Remove middleware, caching layers, and multi-model routing that are not needed for the current version. Keep only one complete path that can run end to end.

    Implement Modules Instead of Generating an Entire Repository

    Once the architecture is approved, ask the tool to produce code module by module. A consistent implementation order is helpful.

    1. Data and permissions. Create collections or tables, indexes, and access rules first. Then implement pagination and filtering. Without stable queries, there is no reliable way to validate a masonry or infinite-scroll component.
    2. File pipeline. Compress images on the client to an agreed dimension and quality level. Request temporary upload credentials, upload the file, and write only the object key to the business record after a successful upload. Client-side compression can significantly reduce storage usage and the input size sent to downstream vision services.
    3. Browsing experience. Use incremental loading for lists. Serve thumbnails for browsing and request larger images only for previews. Encapsulate lazy loading, but do not scatter network retries, empty states, and permission failures across every page.
    4. Generation pipeline. Create a task as soon as an upload completes. Use visual capabilities to extract a limited set of dimensions—such as subject, style, visual details, and background—instead of producing one long, uncontrolled paragraph. Mark important prompt fragments so users can edit a few words rather than rewrite the entire prompt. Write the generation result back to the task and support saving, retrying, and editing based on the current result.
    5. Management view. For the first version, provide only status filtering, takedown actions, and failed-task retries. Avoid building complex operational configuration too early.

    A task state machine can remain small:

    1. created -> analyzing -> prompt_ready -> generating -> succeeded
    2. \-> failed
    3. prompt_ready -> generating // User edits the prompt and generates again

    Each state should allow only defined transitions. APIs should return the task ID and current status. The client can poll for updates or subscribe to changes; it should not combine analysis and image generation into one request.

    Generating a large number of files at once is not the goal. A runnable baseline should meet these criteria: an empty dataset opens correctly, uploads are persisted, lists support pagination, failures expose their causes, and a task remains available after generation begins even if the user leaves the page and returns later. Once this baseline works, refine styling and animations.

    How to Evaluate the System Like a Colleague, Not a Code Completer

    Use four checks instead of relying on subjective impressions.

    • Does the architecture come before the code, and do the technology choices correspond to actual constraints rather than a list of fashionable components?
    • Can each module run independently? For example, if generation is disabled, can browsing and uploading still work?
    • Are naming conventions, error codes, and fields consistent across the project, or does every file use its own terminology?
    • Does the human still control deletion and modification? Can you explain the model’s proposed tables, cloud functions, and call chain on a single page?

    No matter how capable the tool becomes, people must define the boundaries. When requirements change, update the data flow and state model in the architecture documentation first, then ask the tool to modify the affected modules. Avoid continuously patching old code without revisiting the design.

    How Developers Can Keep Up with Changing Model Capabilities

    Anxiety often comes from interpreting “models change every day” as “we must change tools every day.” For engineering teams, three practices are more valuable.

    Standardize the collaboration process. For similar requirements, always follow the same five steps: constraints, architecture, data, primary path, and exceptions. Changing models should not require changing the process. As models improve, the benefit should be more complete proposals, not a constantly redesigned workflow.

    Treat prompts as design documents. Save the original constraints, rejected options, and acceptance examples. This makes later reviews possible: was the model deviating from the constraints, or were the constraints incomplete?

    Have people review architecture and tools fill in implementation. Humans remain responsible for trade-offs, permissions, costs, and external commitments. Tools are responsible for boilerplate, repetitive validation, and adding files according to established contracts. Stronger models do not eliminate this division; they make the implementation side more complete.

    Control verification costs. For every module, use a minimal dataset to test the primary path and one failure case—for example, an oversized upload, an analysis timeout, or a generation failure that can be retried. Do not expand the generation scope until these cases work.

    Conclusion

    The value of large language models in application development lies in turning implicit technical choices into an architecture that people can discuss, then translating that architecture into runnable modules covering data, files, browsing, and generation.

    Visual understanding, prompt editing, and image generation should be separated. Long-running tasks should be asynchronous. Files should use object storage, while the business database retains metadata. Developers do not need to preserve a particular model-specific trick. They need clear constraints, traceable states, and modules that can be accepted independently.

    When these principles are in place, AI coding tools become closer to colleagues who can help build the structure of an application—and less like code fountains that are difficult to maintain.