Building a Mini Program with LLM Assistance: Architecture Decisions and Engineering Lessons

    A practical walkthrough of building a wallpaper mini program with an LLM as a coding partner, covering three key architecture decisions (native frontend, serverless cloud backend, layered AI integration), module-by-module implementation of the browsing, upload/management, and AI image-generation flows, and engineering lessons on credential security, cost control, structured prompts, graceful degradation, and where human judgment still matters.

    Recently I used a large language model to build a relatively complete mini program from scratch, and the overall experience is worth reviewing. The project itself was not complex: a mini program centered on an image waterfall layout, made up of three parts — a home page for browsing and downloading wallpapers, user uploads with content management, and AI image generation and editing. What turned out to be valuable was not “how many lines of code were written,” but observing how the LLM’s role shifted over the course of the project, and how to collaborate with it efficiently. Here is the full picture, from an empty project to a runnable preview.

    From Pasting Code to Asking for a Plan: A Shift in Collaboration

    When I used intelligent coding tools in the past, the interaction usually stayed at the level of atomic instructions: “write me a carousel,” “implement a list.” The model returned a snippet, and I stitched it together, debugged it, and patched the gaps myself. In essence, it was just a sophisticated code-snippet generator.

    Building an integrated mini program this time felt clearly different. I described the requirements in one pass: a wallpaper waterfall, user uploads with admin management, and AI capabilities wired in to support image analysis, prompt editing, one-tap restyling, and image generation. The model did not rush to pile up code. Instead, it first produced a complete technical architecture proposal. The value of that step is that it pushed implementation details back and answered the fundamental questions first — what to build with, and how to layer it. That is how a senior architect works.

    Three Core Architecture Decisions

    A responsible technical proposal should at least give clear choices at three levels.

    1. Frontend stack

    I went with the native mini program development framework, structuring the information architecture around three main pages: Home (wallpaper browsing), AI Image Generation, and Profile (personal center). The native approach has a small package size and stays closely aligned with platform-level capabilities, which suits this kind of browsing- and interaction-heavy application.

    2. Backend and data layer

    I chose a serverless cloud development model made up of three parts: a cloud database, cloud functions, and object storage. The appeal of this model is zero operational burden — no servers to manage, no manual scaling, and billing typically based on invocation volume. It fits small-to-medium applications or ones with spiky traffic well. It is worth noting that whether you use a mainstream cloud provider (such as Baidu AI Cloud) or one of the various serverless platforms, common capabilities such as cloud functions, document databases, object storage, and log monitoring are generally available, so you can weigh ecosystem and cost when making a choice.

    3. Layered AI integration

    I broke AI capability into three categories, each with a single responsibility:

    • Multimodal vision model: analyzes the content of uploaded images;
    • Text generation model (long context): turns the analysis into structured, optimized prompts;
    • Image generation model: handles text-to-image or image-to-image.

    Splitting “understand — rewrite — generate” into three stages instead of forcing one model to carry the whole load is the key design point for this kind of AI application. Each stage has a single responsibility, which makes swapping, tuning, and cost control easier.

    Below is a schematic view of the architecture layers:

    1. Mini program frontend (native)
    2. ├── Home: waterfall / category filter / image preview / download
    3. ├── AI generation: upload → analyze → edit → generate → save
    4. └── Profile: works management / settings
    5. │
    6. ▼
    7. Cloud development (serverless)
    8. ├── Cloud functions: wallpaper list (pagination/filtering), upload signature, AI orchestration
    9. ├── Cloud database: wallpapers table / albums table / users table
    10. └── Object storage: original images / generated images
    11. │
    12. ▼
    13. AI capability layer: vision model + text generation model + image generation model

    Module-by-Module Implementation: Pair Programming with a Full-Stack Colleague

    Once the architecture was settled, I moved into module-by-module coding. I recommend delivering and verifying one module at a time rather than generating all the code in a single pass.

    Wallpaper browsing module

    • Database design: model the relationship between wallpapers and albums, recording fields such as tags, dimensions, and source;
    • Cloud function layer: support pagination and category filtering, avoiding a full-table fetch in one request;
    • Frontend components: the waterfall component encapsulates lazy loading, triggering the next page request only when scrolling reaches the bottom, balancing UX against traffic cost.

    Upload and management module

    • Storage access: use temporary credentials (temporary keys) so the client can upload directly, avoiding exposing long-term keys in the frontend;
    • Image processing: compress on the client before upload to reduce storage and bandwidth cost;
    • Access control: the upload endpoint must verify user identity to prevent unauthorized writes.

    AI generation module
    The full flow is “upload → AI analysis → edit → generate”:

    1. The upload component compresses the image automatically and moves into the analysis stage;
    2. The vision model describes the image, outputting information across dimensions such as subject, style, detail, and mood;
    3. The text model uses that output to produce structured prompts and highlights the key elements so the user can edit them;
    4. The image generation model produces an image from the final prompt, with options to save, regenerate, or keep refining.

    Engineering Details Worth Attention

    • Key security: write access to object storage must be handed to the client through temporary credentials, while long-term keys should live only in server-side cloud functions. This is easy to overlook, yet it is the highest-priority red line.
    • Cost control: image compression, paginated loading, and on-demand AI calls (analyze first, then decide whether to generate) all cut waste significantly.
    • Structured prompts: having the AI return structured fields such as subject / style / detail / mood instead of free-form text makes frontend rendering, editing, and further processing much easier.
    • Error handling and graceful degradation: AI endpoints can time out or hit rate limits, so the analysis and generation stages need timeout-and-retry logic plus friendly fallback messaging, or the whole chain can stall.
    • Authentication and validation: every write operation and every AI orchestration cloud function should verify the caller’s identity. This is the baseline for production safety.

    Lessons Learned: Making the LLM a Reliable Collaborator

    Overall, this experience changed how I think about AI-assisted development. It does not replace the developer; it frees the developer from tedious boilerplate so they can focus on solution design, boundary judgment, and quality control.

    First, describe requirements in a structured way. Spelling out the features, constraints, and expected architecture in one go noticeably improves the quality of the proposed solution. Second, verify in stages. Run and test after each module and course-correct early, instead of debugging everything once it is all generated. Third, keep architecture and security under human control. The model can help enormously with technology choices and coding, but key decisions such as key management, permission boundaries, and cost strategy still have to be made by the developer. Fourth, keep a learning mindset. Tooling capabilities keep evolving, and rather than worrying about being replaced, it is more useful to treat the model as a capability amplifier — what really creates a gap is the ability to ask good questions and make sound engineering judgments.