# yudaocode/yudao-mall-uniapp architecture

> Architecture diagram of the GitHub repository yudaocode/yudao-mall-uniapp, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/yudaocode/yudao-mall-uniapp
- Repository: https://github.com/yudaocode/yudao-mall-uniapp

## Overview

##### Project type and purpose
- This is a full-stack e-commerce “mall” system, but the repository you have is the mobile/front-end client built with uni-app + Vue3.
- It targets multiple front-end channels (WeChat Mini Program, H5, App, Official Accounts) and communicates with a Java/Spring Boot or Spring Cloud backend via REST API.

##### Key architectural layers
a. Presentation Layer (uni-app cross-platform UI)
- Entry files: main.js, App.vue, pages.json, manifest.json, uni.scss, vite.config.js.
- Pages folder: organizes feature modules (activity, chat, commission, coupon, goods, index, order, pay, public, user).
- uni_modules/: external uni-app component libraries.
b. Business Logic Layer (sheep)
- sheep/api: service functions wrapping HTTP calls to backend modules (member, pay, product, promotion, system, trade, migration).
- sheep/store: Vuex-style state management (app, user, cart, modal, sys).
- sheep/hooks: composition-api hooks for features (useApp, useGoods, useWebSocket, useModal).
- sheep/components / sheep/ui / sheep/helper / sheep/util / sheep/validate: common UI components, styling, helpers, validators.
- sheep/config / sheep/request / sheep/router / sheep/platform: request pipelines, routing utils, platform (WeChat/AppStore) integrations.
c. Build & Deployment
- Vite-based build (vite.config.js), uni-app CLI generates platform-specific code.
- Outputs multiple bundles for each target (mini-program, H5, native).
d. External Services
- Backend REST endpoints (exposed via sheep/api).
- Third-party providers: payment channels (WeChat Pay, Apple Pay), social login, push notifications (via sheep/platform/provider).

a. Components
- User Device (WeChat Mini Program, H5 browser, native App).
- Front-end Application:
- Presentation: pages & uni_modules
- Business Logic: sheep modules (api, store, hooks, components)
- Build toolchain: vite, uni-app CLI.
- Backend API Layer: Spring Boot / Spring Cloud microservices.
- External Services: Payment Gateways, Third-Party Auth, CDN for static assets.
b. Relationships & data flows
- State management interactions (components → store → components).
c. Architectural patterns & design principles
- Modular feature segregation (pages folder per business domain).
- DRY reusability via sheep shared library (common components, hooks, utils).
- Uni-app cross-platform abstraction.
- Flux-style state management.
d. Key technologies
- Vue3 + Composition API; uni-app framework; Vite; Sass (sheep/scss); Vuex-style store; Axios or uni.request abstraction; Spring Boot / Spring Cloud.

##### Detailed capture
- Call out the store modules (user.js, cart.js).
- Uni_modules as external dependencies.
- Build toolchain block (Vite + uni-app).
- Don’t overthink: more components = clearer understanding of how the codebase maps to runtime architecture.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% User Device
    UserDevice["User Device\n(WeChat Mini Program, H5 Browser, Native App)"]:::external

    %% Presentation Layer
    subgraph "Presentation Layer" 
        direction TB
        EntryMain["main.js"]:::frontend
        EntryApp["App.vue"]:::frontend
        PagesConfig["pages.json"]:::frontend
        Manifest["manifest.json"]:::frontend
        Styles["uni.scss"]:::frontend
        ViteConfig["vite.config.js"]:::frontend

        subgraph "Feature Pages"
            direction TB
            Activity["Activity Module"]:::frontend
            Chat["Chat Module"]:::frontend
            Commission["Commission Module"]:::frontend
            Coupon["Coupon Module"]:::frontend
            Goods["Goods Module"]:::frontend
            IndexPage["Index Module"]:::frontend
            Order["Order Module"]:::frontend
            PayPage["Pay Module"]:::frontend
            Public["Public Pages"]:::frontend
            UserPage["User Module"]:::frontend
        end

        subgraph "Static Assets"
            StaticImages["/static/images"]:::external
            GeneralImages["/.image"]:::external
        end

        UniModules["/uni_modules (External uni-app Components)"]:::external
    end

    %% Business Logic Layer
    subgraph "Business Logic (sheep)" 
        direction TB
        subgraph "API Services" 
            direction TB
            MemberAPI["Member APIs"]:::shared
            PayAPI["Payment APIs"]:::shared
            ProductAPI["Product APIs"]:::shared
            PromotionAPI["Promotion APIs"]:::shared
            SystemAPI["System APIs"]:::shared
            TradeAPI["Trade APIs"]:::shared
            MigrationAPI["Migration APIs"]:::shared
            InfraUtil["Infra Utils /file.js"]:::shared
        end

        subgraph "State Management (store)"
            direction TB
            AppStore["app.js"]:::shared
            CartStore["cart.js"]:::shared
            ModalStore["modal.js"]:::shared
            SysStore["sys.js"]:::shared
            UserStore["user.js"]:::shared
            StoreIndex["index.js"]:::shared
        end

        subgraph "Hooks"
            direction TB
            UseApp["useApp.js"]:::shared
            UseGoods["useGoods.js"]:::shared
            UseModal["useModal.js"]:::shared
            UseWebSocket["useWebSocket.js"]:::shared
        end

        subgraph "Components & UI"
            direction TB
            SheepComponents["/sheep/components"]:::shared
            SheepUI["/sheep/ui"]:::shared
        end

        subgraph "Helpers & Utils"
            direction TB
            Helpers["/sheep/helper"]:::shared
            Utils["/sheep/util"]:::shared
            Consts["const.js"]:::shared
            Validators["form.js"]:::shared
        end

        subgraph "Config & Infra"
            direction TB
            Configs["/sheep/config"]:::shared
            Request["request/index.js"]:::shared
            Router["router/index.js"]:::shared
            Platform["/sheep/platform"]:::shared
        end
    end

    %% Build & Deployment
    subgraph "Build & Deployment"
        direction TB
        Vite["vite.config.js"]:::frontend
        UniCLI["uni-app CLI"]:::frontend
        subgraph "Outputs"
            H5Bundle["H5 Bundle"]:::frontend
            MiniBundle["Mini-Program Bundle"]:::frontend
            NativeBundle["Native App Bundle"]:::frontend
        end
    end

    %% Backend API Layer
    BackendAPI["Backend REST API\n(Spring Boot / Spring Cloud)"]:::backend

    %% External Services
    subgraph "External Services"
        direction TB
        PaymentGateways["Payment Gateways\n(WeChat Pay, Apple Pay)"]:::external
        SocialLogin["Social Login Providers"]:::external
        PushNotify["Push Notifications"]:::external
        CDN["CDN for Static Assets"]:::external
    end

    %% Relationships
    UserDevice -->|"UI Events"| Activity
    UserDevice -->|"UI Events"| Chat
    UserDevice -->|"UI Events"| IndexPage

    Activity -->|"uses"| MemberAPI
    Chat -->|"uses"| TradeAPI
    Goods -->|"uses"| ProductAPI
    PromotionAPI -->|"HTTP/HTTPS"| BackendAPI
    MemberAPI -->|"HTTP/HTTPS"| BackendAPI
    PayAPI -->|"HTTP/HTTPS"| BackendAPI
    SystemAPI -->|"HTTP/HTTPS"| BackendAPI
    TradeAPI -->|"HTTP/HTTPS"| BackendAPI
    MigrationAPI -->|"HTTP/HTTPS"| BackendAPI

    Activity -->|"dispatch"| AppStore
    Chat -->|"commit"| CartStore
    Goods -->|"commit"| CartStore

    Activity --> UseApp
    Goods --> UseGoods

    UniModules --> Activity

    EntryMain --> EntryApp
    EntryApp --> PagesConfig
    PagesConfig --> Activity

    ViteConfig --> Vite
    Vite --> H5Bundle
    Vite --> MiniBundle
    Vite --> NativeBundle
    UniCLI --> H5Bundle
    UniCLI --> MiniBundle
    UniCLI --> NativeBundle

    CDN --> StaticImages
    CDN --> GeneralImages

    PaymentGateways --> PayAPI
    SocialLogin --> Platform
    PushNotify --> Platform

    %% Click Events
    click EntryMain "https://github.com/yudaocode/yudao-mall-uniapp/blob/master//main.js"
    click EntryApp "https://github.com/yudaocode/yudao-mall-uniapp/blob/master//App.vue"
    click PagesConfig "https://github.com/yudaocode/yudao-mall-uniapp/blob/master//pages.json"
    click Manifest "https://github.com/yudaocode/yudao-mall-uniapp/blob/master//manifest.json"
    click Styles "https://github.com/yudaocode/yudao-mall-uniapp/blob/master//uni.scss"
    click ViteConfig "https://github.com/yudaocode/yudao-mall-uniapp/blob/master//vite.config.js"
    click Activity "https://github.com/yudaocode/yudao-mall-uniapp/tree/master//pages/activity"
    click Chat "https://github.com/yudaocode/yudao-mall-uniapp/tree/master//pages/chat"
    click Commission "https://github.com/yudaocode/yudao-mall-uniapp/tree/master//pages/commission"
    click Coupon "https://github.com/yudaocode/yudao-mall-uniapp/tree/master//pages/coupon"
    click Goods "https://github.com/yudaocode/yudao-mall-uniapp/tree/master//pages/goods"
    click IndexPage "https://github.com/yudaocode/yudao-mall-uniapp/tree/master//pages/index"
    click Order "https://github.com/yudaocode/yudao-mall-uniapp/tree/master//pages/order"
    click PayPage "https://github.com/yudaocode/yudao-mall-uniapp/tree/master//pages/pay"
    click Public "https://github.com/yudaocode/yudao-mall-uniapp/tree/master//pages/public"
    click UserPage "https://github.com/yudaocode/yudao-mall-uniapp/tree/master//pages/user"
    click StaticImages "https://github.com/yudaocode/yudao-mall-uniapp/tree/master//static/images"
    click GeneralImages "https://github.com/yudaocode/yudao-mall-uniapp/blob/master//.image"
    click UniModules "https://github.com/yudaocode/yudao-mall-uniapp/tree/master//uni_modules"
    click MemberAPI "https://github.com/yudaocode/yudao-mall-uniapp/tree/master//sheep/api/member"
    click PayAPI "https://github.com/yudaocode/yudao-mall-uniapp/tree/master//sheep/api/pay"
    click ProductAPI "https://github.com/yudaocode/yudao-mall-uniapp/tree/master//sheep/api/product"
    click PromotionAPI "https://github.com/yudaocode/yudao-mall-uniapp/tree/master//sheep/api/promotion"
    click SystemAPI "https://github.com/yudaocode/yudao-mall-uniapp/tree/master//sheep/api/system"
    click TradeAPI "https://github.com/yudaocode/yudao-mall-uniapp/tree/master//sheep/api/trade"
    click MigrationAPI "https://github.com/yudaocode/yudao-mall-uniapp/tree/master//sheep/api/migration"
    click InfraUtil "https://github.com/yudaocode/yudao-mall-uniapp/blob/master//sheep/api/infra/file.js"
    click AppStore "https://github.com/yudaocode/yudao-mall-uniapp/blob/master//sheep/store/app.js"
    click CartStore "https://github.com/yudaocode/yudao-mall-uniapp/blob/master//sheep/store/cart.js"
    click ModalStore "https://github.com/yudaocode/yudao-mall-uniapp/blob/master//sheep/store/modal.js"
    click SysStore "https://github.com/yudaocode/yudao-mall-uniapp/blob/master//sheep/store/sys.js"
    click UserStore "https://github.com/yudaocode/yudao-mall-uniapp/blob/master//sheep/store/user.js"
    click StoreIndex "https://github.com/yudaocode/yudao-mall-uniapp/blob/master//sheep/store/index.js"
    click UseApp "https://github.com/yudaocode/yudao-mall-uniapp/blob/master//sheep/hooks/useApp.js"
    click UseGoods "https://github.com/yudaocode/yudao-mall-uniapp/blob/master//sheep/hooks/useGoods.js"
    click UseModal "https://github.com/yudaocode/yudao-mall-uniapp/blob/master//sheep/hooks/useModal.js"
    click UseWebSocket "https://github.com/yudaocode/yudao-mall-uniapp/blob/master//sheep/hooks/useWebSocket.js"
    click SheepComponents "https://github.com/yudaocode/yudao-mall-uniapp/tree/master//sheep/components"
    click SheepUI "https://github.com/yudaocode/yudao-mall-uniapp/tree/master//sheep/ui"
    click Helpers "https://github.com/yudaocode/yudao-mall-uniapp/tree/master//sheep/helper"
    click Utils "https://github.com/yudaocode/yudao-mall-uniapp/tree/master//sheep/util"
    click Consts "https://github.com/yudaocode/yudao-mall-uniapp/blob/master//sheep/util/const.js"
    click Validators "https://github.com/yudaocode/yudao-mall-uniapp/blob/master//sheep/validate/form.js"
    click Configs "https://github.com/yudaocode/yudao-mall-uniapp/tree/master//sheep/config"
    click Request "https://github.com/yudaocode/yudao-mall-uniapp/blob/master//sheep/request/index.js"
    click Router "https://github.com/yudaocode/yudao-mall-uniapp/blob/master//sheep/router/index.js"
    click Platform "https://github.com/yudaocode/yudao-mall-uniapp/tree/master//sheep/platform"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0288D1,color:#000
    classDef shared fill:#E0F8E0,stroke:#388E3C,color:#000
    classDef backend fill:#FFE0B2,stroke:#F57C00,color:#000
    classDef external fill:#F5F5F5,stroke:#9E9E9E,color:#000
```
