LLM-Driven Vibe Coding: A Practical Guide to Shipping Mini Programs
This article explores how to move from AI-generated code snippets to a deliverable full-stack project using large language models and AI coding tools. Using a wallpaper mini program as a sample, it covers architecture-first prompting, data models and API contracts, waterfall browsing, secure uploads, an engineered AI image generation pipeline, project-level constraints, and a pre-launch quality checklist. The key takeaway is that a model's value shifts from writing fragments to defining structure.
1. Why Code Generation Is Not Project Delivery
AI-assisted programming has entered a more demanding phase. Many developers now rely on large language models to complete functions and generate boilerplate. Yet in real projects—especially complete applications with a frontend UI, backend services, storage, and third-party capability orchestration—code generation alone is rarely ready to ship. Common symptoms include broken context, inconsistent interfaces between modules, missing data model constraints, absent exception branches, and results that are hard to reproduce.
This article uses a typical practice as its sample: a wallpaper mini program with waterfall browsing, album details, image preview and download, user upload management, and a complete AI image generation flow (upload, image understanding, prompt editing, style transfer, generation, and re-editing). The goal is not to discuss a specific tool, but to abstract a methodology for collaborative delivery with a large language model plus an AI coding tool.
2. Treat the Model as an Architect: Plan First, Code Second
The first step toward high-quality collaboration is to have the model produce a technical plan before any code. A usable plan should cover at least these dimensions:
- Frontend shape and page structure: three main bottom tabs (Home, Create, Profile); secondary pages include album details, image preview, and upload management.
- Backend shape: a cloud development model using three core capabilities—cloud database, cloud functions, and object storage—to avoid the operational burden of self-hosted servers.
- Capability orchestration: an image understanding model handles scene analysis, a text model handles prompt optimization, and an image generation model produces the image; all three are chained through cloud functions.
- Data and interface contracts: collection design, pagination protocol, error code conventions, and authentication.
- Engineering constraints: image compression strategy, temporary credential lifetime, retries, and idempotency.
A schematic skeleton of the plan can be expressed as:
Page layer: Home (waterfall) / Create (AI image generation) / Profile (upload management)Service layer: cloud functions - feed/list, asset/sign, ai/analyze, ai/generateData layer: collections wallpaper, album, task, user_assetStorage layer: object storage - separate directories for originals/thumbnails/generated imagesExternal capabilities: vision understanding / text optimization / image generation
Once the plan is written down explicitly, every module’s coding shares a common frame of reference, and the model’s output stops contradicting itself.
3. Define Data Models and Interface Contracts First
With a cloud database, favor a “small and stable” set of collections covering the core domains:
- wallpaper: image metadata, including width, height, category, tags, source, and status.
- album: albums, including cover, description, and sort weight.
- task: generation tasks recording input, parameters, and a state machine (queued/processing/succeeded/failed).
- user_asset: ownership mapping for user uploads and generated results.
Unify interface contracts around “pagination + filtering + stable error codes”:
{"code": 0,"data": { "list": [], "cursor": "opaque", "hasMore": true },"message": "ok"}
Keeping the cursor opaque and layering error codes (parameter, authentication, rate limit, downstream dependency) decouples the frontend from cloud functions and makes the model’s branch handling more predictable.
4. Module 1: Wallpaper Browsing and Waterfall Layout
The key to a waterfall is not layout but the pace of data supply. The recommended approach is “two-column height estimation + cursor pagination + lazy image loading”:
- The first screen requests only a small amount of data, with fixed aspect-ratio placeholders to avoid layout shift.
- When scrolling reaches the bottom, fetch more by cursor, with the server guaranteeing stable ordering.
- Separate thumbnails from preview images: the list uses thumbnails, and the detail page loads the high-resolution image.
- Failed items enter a retry queue to avoid a blank screen.
On the cloud function side, consolidate “category filtering, tag filtering, and pagination” into a single entry point distinguished by parameters, reducing the number of interfaces and frontend branches.
5. Module 2: Upload Management and Storage Security
User uploads are the most error-prone part. The core is three things: compression, authentication, and lifecycle.
- Compression: the client performs one round of size and quality compression; the server generates multiple thumbnail tiers on demand.
- Authentication: a cloud function issues a short-lived upload credential, and the frontend uploads directly to object storage, avoiding large files passing through the function.
- Lifecycle: manage originals and generated images in separate directories, with periodic cleanup policies to control cost.
A typical signing request can be abstracted as:
POST asset/sign { contentType, size, scene }-> { uploadUrl, fileKey, expireIn }
After a successful upload, write only the fileKey to the database; resolve the real access URL at read time, which makes it easier to migrate storage or append processing parameters later.
6. Module 3: Engineering the AI Image Generation Pipeline
AI image generation is not “a single call” but a pipeline. Split it into four steps and drive state with a task table:
- Upload and preprocessing: compression, format normalization, and dimension validation.
- Image understanding: output multi-dimensional descriptions of subject, style, details, and background atmosphere; the frontend visually emphasizes key elements.
- Prompt optimization: the text model rewrites the structured description into controllable generation prompts, with support for manual user editing.
- Generation and re-editing: submit the generation task, obtain results via polling or callback, and support saving, regenerating, and continued editing.
Pseudocode for task-driven flow:
def on_submit(event):task = create_task(event) # state: queuedenqueue(task.id)return ok(task.id)def worker(task_id):task = mark_running(task_id)try:analysis = vision_analyze(task.image)prompt = llm_refine(analysis)image = imagegen(prompt, task.params)finish(task_id, image) # state: succeededexcept Exception as e:fail(task_id, e) # state: failed, retryable
Engineering must add: an idempotency key (to avoid duplicate charges on repeated submissions), timeout and retry limits, user-readable failure reasons, and cache reuse of generated results.
7. Why Generating 30+ Files at Once Can Run: Constraints Beat Luck
“Generating many files at once that run directly” is not accidental. It usually comes from four constraints: the directory structure is fixed in advance, interface contracts are locked, naming and error-handling style are unified, and dependency versions are explicit. In practice, maintain a project-level “context brief” that the model follows on every generation, for example:
- Directories: pages/ components/ cloudfunctions/ shared/- Cloud function inputs are uniformly { action, payload }- All network calls go through shared/request with unified error codes- Never concatenate access URLs directly; always use resolveUrl(fileKey)
The value of such a constraints file is equivalent to a team’s coding standards and significantly reduces later rework.
8. Quality Checks and a Pre-Launch Checklist
- Interfaces: pagination boundaries, empty states, error codes, and rate-limit messages.
- Data: whether indexes cover common filters and whether orphan data exists.
- Storage: credential lifetime, directory conventions, and cleanup policies.
- AI pipeline: whether the task state machine is complete and failures are retryable without duplicate billing.
- Experience: first-screen time, image placeholders, and retry entry points for load failures.
- Observability: logs and monitoring alerts on key paths to locate downstream fluctuations.
9. Conclusion: Apply the Model to Structure
The most important conclusion is that the model’s value shifts from “writing fragments” to “defining structure.” When architecture, contracts, and constraints are expressed explicitly, AI can reliably produce a runnable multi-file project; otherwise, asking it to “just write a feature” still requires extensive manual stitching. For developers, the real skill to build is translating business problems into clear structures and constraints—the most durable fundamental in the era of human-AI collaboration.
