AI Coding in Practice: How LLMs Go from Writing Code to Designing Architecture
A practical guide to using large language models as architecture-level collaborators rather than one-off code generators. Through a mini app build that combines a waterfall image feed, user upload management, and AI image generation, it walks through a mature AI coding workflow: aligning on requirements first, planning the architecture (frontend, a serverless backend, multi-model AI integration, and data models with function boundaries), generating code module by module, and orchestrating multi-step business logic. It also lays out reusable collaboration principles and the risks worth watching — hallucination and correctness, credential security, cost and rate limiting, and privacy — showing why the key to keeping pace with fast-moving models is upgrading how you collaborate, not chasing every new release.
Introduction: AI Coding Is Moving from Autocomplete to Collaboration
For a long time, the most common way we interacted with AI coding tools was one request at a time: “write me a carousel,” “write a pagination endpoint.” The model would spit out a snippet, and we would then stitch it together, debug it, and fill in the gaps ourselves. At its core, this is an advanced snippet generator that solves isolated, point-sized problems.
But as large language models have matured, a more capable way of working has started to emerge: treating the model as a senior architect colleague — aligning on requirements and technology choices first, then implementing module by module. Built around a real-world mini app project, this article extracts the key stages and methods of this kind of architecture-level AI collaboration, and helps you decide which work you can confidently hand to the model and which you must own yourself.
1. The Paradigm Shift: Let the Model Be an Architect First, Then a Developer
Whether an AI coding tool is genuinely useful is not measured by whether it can write one snippet correctly in isolation. It is measured by whether, when handed a complete requirement, it can first produce an actionable overall plan.
Picture a business requirement: build a mini app with a waterfall image feed, user upload management, and AI image generation — supporting image analysis, prompt editing, one-tap outfit change, and image generation. Faced with a composite requirement that spans multiple platforms and services and involves several models, a mature workflow should not start by dumping code. It should first produce a complete technical architecture, and only then move into implementation.
The value of this step is that putting architecture first makes a large number of implicit decisions — technology selection, boundaries, data flow — explicit. It gives developers the chance to catch directional mistakes before writing any code, which dramatically lowers the cost of rework. At this stage the model plays the role of “technology selection plus solution review.”
2. Core Step 1: Technology Selection and Architecture Planning
A practical architecture plan usually covers at least four dimensions. Using this mini app as an example, here is how the model should produce a structured plan:
- Frontend selection: Build with the native mini-program framework, planning three main pages in a bottom navigation bar (Home/Library, AI Creation, Profile) to keep first-screen loading and interaction performance solid.
- Backend selection: Adopt a serverless cloud development model, backed by three common capabilities — cloud database, cloud functions, and object storage — which removes the operational burden of running your own servers.
- AI capability integration: Split responsibilities across different classes of models — a multimodal vision model handles image understanding and analysis, a text LLM handles understanding and optimizing prompts, and an image generation model handles the final image-to-image output.
- Data models and interface boundaries: Define the core tables (such as the resource table, user table, and generation task table) and split cloud functions along business boundaries (such as resource queries, upload signing, and AI orchestration).
When the architecture plan lands at the data-model level, it typically looks something like this (illustrative):
wallpaper // resource library_id, url, category, tags[], likes, createdAtai_task // generation task_id, uid, sourceImage, prompt, status, resultUrl, createdAtuser // user_id, nickname, avatar, createdAt
When the model can proactively lay out the database schema, the cloud-function split, and the file upload and compression logic all at once, it has made the leap from “code tool” to “architecture collaborator.” The developer’s main action at this point is to review and trim the plan — not to start thinking from scratch.
3. Core Step 2: Modular Coding and Layered Implementation
Once the architecture is settled, the right way to collaborate is to generate module by module, rather than requesting all the code at once. Modularity has three benefits: each round stays focused on a narrower context, errors are easier to localize, and every module can be verified independently.
Take the resource library module. The model should first build the cloud-database design and query logic, then add pagination and category filtering, and finally wrap the lazy loading of the waterfall feed component. The query skeleton of the cloud function looks roughly like this (illustrative):
// Cloud function: paginated resource query (illustrative)exports.main = async (event) => {const { page = 1, pageSize = 20, category } = event;const db = cloud.database();const skip = (page - 1) * pageSize;let query = db.collection('wallpaper');if (category) query = query.where({ category });const result = await query.orderBy('createdAt', 'desc').skip(skip).limit(pageSize).get();return {list: result.data,hasMore: result.data.length === pageSize, // whether there is a next page};};
The frontend waterfall component then triggers loading when the user scrolls to the bottom, based on hasMore, combined with image lazy loading to reduce first-screen requests. Modules like this — with a clear skeleton and well-defined boundaries — are exactly what LLMs handle best and are least likely to get wrong.
4. Core Step 3: Orchestrating Complex Business Logic
What really separates the field is a model’s ability to handle complex logic that is multi-step, stateful, and dependent on external capabilities. Take upload management: a robust implementation should include requesting temporary upload credentials from object storage, compressing the image on the frontend, and writing back metadata after a successful upload. The key here is not the code itself, but whether the model proactively accounts for engineering details like “compress first, upload second” and “least-privilege credentials.”
The AI creation module is where orchestration ability shows itself most clearly. Its flow can be abstracted into three stages: analyze → optimize → generate.
// AI image generation orchestration (illustrative; vendor SDK abstracted away)async function generateWallpaper(imageFile, userPrompt) {// 1. Visual understanding: extract structured info like subject, style, backgroundconst analysis = await visionModel.analyze(imageFile);// returns { subject, style, background }// 2. Prompt optimization: the text model combines the analysis with the user's intentconst optimized = await textModel.enhance(`Subject: ${analysis.subject}; Style: ${analysis.style}; ` +`Background: ${analysis.background}; User intent: ${userPrompt}`);// 3. Image generation: image-to-image, using the original as a referenceconst result = await imageModel.generate({ image: imageFile, prompt: optimized });return { analysis, optimized, imageUrl: result.url };}
What deserves attention is the completeness of the interaction design. After the analysis returns, key elements can be automatically highlighted in red to help the user edit; the generation result can support three follow-up actions — “save / regenerate / continue editing.” When a model proactively fills in these state transitions, what it delivers is not “code that runs” but “a usable product.”
5. A Methodology for Getting the Most out of LLMs
No matter how powerful a tool is, it needs to be used the right way. Drawing on the walkthrough above, here are a few reusable collaboration principles:
- Describe requirements in a structured way: Spelling out “what to build, who it’s for, which pages exist, and which capabilities it depends on” produces a higher-quality plan than a vague “make me a mini app.”
- Architecture first, generate in steps: Ask for the plan before the code, and proceed module by module. This avoids the context explosion and error accumulation that come from generating everything at once.
- Split into modules to reduce complexity: The more focused the context of a single module, the higher the model’s accuracy and the less rework.
- Human review is non-negotiable: Review critical paths (authentication, payments, data handling) line by line. A model’s output should be treated as a high-quality first draft, not a finished product.
6. Risks and Boundaries: A Clear-Eyed View of AI Collaboration
- Hallucination and correctness: Models can invent interfaces or parameters that don’t exist. For anything involving a specific SDK or configuration, always defer to the official documentation and verify through real testing.
- Credential and permission security: Always use temporary, least-privilege credentials for object storage, and never write long-lived keys into frontend code.
- Cost and rate limiting: Multi-model orchestration brings invocation costs. Design caching, rate limiting, and failure retries well, so generation tasks can’t be maliciously abused to inflate usage.
- Privacy and compliance: User-uploaded images involve personal information, so encryption and compliant handling must be in place across storage, transmission, and retention.
Conclusion: Keeping Pace Means Upgrading How You Collaborate
Back to the original anxiety — models change from one day to the next, so how can developers keep up? The answer isn’t chasing every new model. It’s upgrading your own role from “someone who writes code line by line” to “someone who defines the problem, reviews the solution, and controls quality.” When you learn to collaborate with LLMs by putting architecture first — handing selection and design to the model, and keeping judgment and verification for yourself — the faster the tools iterate, the greater your leverage becomes. That is the right way to turn AI into a dependable “architect colleague.”
