# ouyangsh/hello-unibest architecture

> Architecture diagram of the GitHub repository ouyangsh/hello-unibest, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-08-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ouyangsh/hello-unibest
- Repository: https://github.com/ouyangsh/hello-unibest

## Overview

##### Project Type and Purpose
- Unibest is a front-end framework/template for building multi-platform UniApp applications using Vue3, TypeScript, Vite, UnoCSS, Pinia, and related libraries.
- It provides a CLI-driven build pipeline to target H5 (web), Weixin Mini Program, and native App (via HBuilderX), complete with conventions for routing, layouts, request interceptors, i18n, and more.

##### File-Structure Analysis
- Top-Level Configurations and Scripts
- package.json, pnpm-lock.yaml, tsconfig.json, vite.config.ts, manifest.config.ts, pages.config.ts, uno.config.ts
- env/ (.env files for dev/test/prod), shell/ (post-install and rename scripts), mock/ (mock servers)
- Source Code (src/)
- src/main.ts & App.vue – application entry point
- src/pages.json, src/pages/… – convention-based routing definitions & page components
- src/layouts/ – layout wrappers (default.vue, demo.vue)
- src/components/ – reusable Vue components (fly-login, fly-navbar, qiun-data-charts, etc.)
- src/uni_modules/ – embedded third-party UniApp modules (lime-echart, sp-editor)
- src/hooks/, src/interceptors/ – cross-cutting logic for requests, uploads, navigation
- src/service/ – typed API definitions & mock data
- src/store/ – Pinia stores (user, count, etc.)
- src/locale/, src/i18n.d.ts – internationalization resources
- src/static/, src/assets/ – static assets for H5 and app platforms
- src/style/, src/uni.scss – global styles and UnoCSS configuration
- Distribution & Documentation
- dist/build/ – compiled outputs for each platform
- docs/ – generated documentation and demos

##### README Insights
- Describes supported platforms (web/H5, mp-weixin, app), commands (pnpm dev:h5, build:h5, etc.), and core features (layout, routing, interceptors, i18n).
- Shows technology stack: UniApp + Vue3 + TS + Vite + UnoCSS + wot-ui + z-paging.

##### Key Components
a. Developer & CLI Tools
- pnpm / Node.js / Vite / UniApp CLI
b. Build Pipeline
- Vite (dev server & bundler) → UniApp Plugin → Platform Bundles (H5, mp-weixin, app)
c. Core Application Modules
- Entry Point (main.ts + App.vue)
- Router & Pages (pages.json → src/pages/)
- Layouts (src/layouts/)
- UI Components (src/components/)
- Third-Party Uni Modules (src/uni_modules/)
- State Management (Pinia stores)
- Internationalization (i18n, locale files)
- Services & HTTP Layer (src/service/, src/interceptors/, src/hooks/useRequest.ts)
- Stylings (UnoCSS config, global SCSS)
d. External Services & Dependencies
- Backend APIs (real or mock via mock/_mockProdServer.ts)
- Third-party libraries (wot-ui, z-paging, echarts/uCharts)
- App runtime (HBuilderX, mobile OS runtime)

##### Component Relationships & Data Flow
- Developer invokes CLI → Vite Dev/Build → UniApp plugin processes Vue/TS → Outputs platform-specific bundles under dist/
- At runtime (H5): Browser loads index.html → JS bundle initializes Vue app → Router resolves pages → Components fetch data via HTTP hook → Interceptors handle auth & responses → Pinia stores hold app state → i18n provides translations
- At runtime (MiniProgram/App): Similar flow but under Weixin/App runtime, using manifest.config.ts and pages.config.ts for platform conventions

##### Architectural Patterns & Principles
- Convention-over-Configuration for routing (pages.json)
- Modular, feature-based organization: pages/, components/, uni_modules/
- Cross-cutting concerns isolated in interceptors/ and hooks/
- State encapsulated in Pinia stores
- Build-time plugin architecture (Vite + UniApp)

- Separation between:
- Build System (CLI & Vite)
- Core App Modules (entry, router, pages, layouts, components)
- Cross-cutting Services (interceptors, hooks, services, store)
- Platform Outputs (H5 bundle, MiniProgram bundle, App bundle)
- Configuration files (vite.config.ts, manifest.config.ts, pages.config.ts, env/*.env) feeding into the build pipeline
- Mock server as an optional external service

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Developer & CLI Tools
    subgraph "Developer & CLI Tools"
        pkg["package.json"]:::config
        lock["pnpm-lock.yaml"]:::config
        tscon["tsconfig.json"]:::config
        vitecfg["vite.config.ts"]:::config
        unocfg["uno.config.ts"]:::config
        manifest["manifest.config.ts"]:::config
        pagescfg["pages.config.ts"]:::config
    end

    %% Build Pipeline & Plugins
    subgraph "Build Pipeline"
        vite["Vite (Dev Server & Bundler)"]:::build
        uniPlugin["UniApp Plugin"]:::build
        imagemin["vite-plugins/"]:::build
        shell["shell/"]:::build
    end

    pkg --> vite
    lock --> vite
    tscon --> vite
    vitecfg --> vite
    unocfg --> vite
    manifest --> vite
    pagescfg --> vite
    imagemin --> vite
    shell --> vite
    vite --> uniPlugin

    %% Platform Bundles
    subgraph "Platform Bundles"
        h5Bundle["H5 Bundle"]:::output
        mpBundle["mp-weixin Bundle"]:::output
        appBundle["App Bundle"]:::output
    end
    uniPlugin --> h5Bundle
    uniPlugin --> mpBundle
    uniPlugin --> appBundle

    %% Runtime Environments
    Browser["Browser Runtime"]:::runtime
    Weixin["Weixin MiniProgram Runtime"]:::runtime
    AppRT["App Runtime (HBuilderX)"]:::runtime

    h5Bundle --> Browser
    mpBundle --> Weixin
    appBundle --> AppRT

    %% Core Application Modules
    subgraph "Core App Modules"
        html["index.html"]:::module
        main["src/main.ts"]:::module
        appvue["src/App.vue"]:::module
        pagesJson["src/pages.json"]:::module
        pages["src/pages/"]:::module
        pagesSub["src/pages-sub/"]:::module
        layouts["src/layouts/"]:::module
        comps["src/components/"]:::module
        uniMods["src/uni_modules/"]:::module
        store["src/store/"]:::module
        i18n["src/locale/ + i18n.d.ts"]:::module
        service["src/service/"]:::module
        interceptors["src/interceptors/"]:::module
        hooks["src/hooks/"]:::module
        styles["src/style/ + uni.scss"]:::module
        assets["src/static/ + src/assets/"]:::module
    end

    Browser --> html
    html --> main
    main --> appvue
    appvue --> pagesJson
    pagesJson --> pages
    pages --> pagesSub
    pages --> layouts
    layouts --> comps
    comps --> uniMods
    comps --> store
    comps --> i18n
    comps --> service
    service --> interceptors
    interceptors <--> hooks
    hooks --> service
    styles --> Browser
    assets --> Browser

    %% External Services & Mock
    externalAPI["Backend APIs"]:::external
    mock["mock/_mockProdServer.ts"]:::external
    service --> externalAPI
    hooks --> externalAPI
    mock --> service

    %% Documentation & Outputs
    docs["docs/"]:::output
    h5Bundle --> docs
    mpBundle --> docs
    appBundle --> docs

    %% Click Events
    click pkg "https://github.com/ouyangsh/hello-unibest/blob/manghe/package.json"
    click lock "https://github.com/ouyangsh/hello-unibest/blob/manghe/pnpm-lock.yaml"
    click tscon "https://github.com/ouyangsh/hello-unibest/blob/manghe/tsconfig.json"
    click vitecfg "https://github.com/ouyangsh/hello-unibest/blob/manghe/vite.config.ts"
    click unocfg "https://github.com/ouyangsh/hello-unibest/blob/manghe/uno.config.ts"
    click manifest "https://github.com/ouyangsh/hello-unibest/blob/manghe/manifest.config.ts"
    click pagescfg "https://github.com/ouyangsh/hello-unibest/blob/manghe/pages.config.ts"
    click imagemin "https://github.com/ouyangsh/hello-unibest/tree/manghe/vite-plugins/"
    click shell "https://github.com/ouyangsh/hello-unibest/tree/manghe/shell/"
    click html "https://github.com/ouyangsh/hello-unibest/blob/manghe/index.html"
    click main "https://github.com/ouyangsh/hello-unibest/blob/manghe/src/main.ts"
    click appvue "https://github.com/ouyangsh/hello-unibest/blob/manghe/src/App.vue"
    click pagesJson "https://github.com/ouyangsh/hello-unibest/blob/manghe/src/pages.json"
    click pages "https://github.com/ouyangsh/hello-unibest/tree/manghe/src/pages/"
    click pagesSub "https://github.com/ouyangsh/hello-unibest/tree/manghe/src/pages-sub/"
    click layouts "https://github.com/ouyangsh/hello-unibest/blob/manghe/src/layouts/default.vue"
    click layouts "https://github.com/ouyangsh/hello-unibest/blob/manghe/src/layouts/demo.vue"
    click comps "https://github.com/ouyangsh/hello-unibest/tree/manghe/src/components/"
    click uniMods "https://github.com/ouyangsh/hello-unibest/tree/manghe/src/uni_modules/lime-echart/"
    click uniMods "https://github.com/ouyangsh/hello-unibest/tree/manghe/src/uni_modules/sp-editor/"
    click store "https://github.com/ouyangsh/hello-unibest/blob/manghe/src/store/index.ts"
    click store "https://github.com/ouyangsh/hello-unibest/blob/manghe/src/store/user.ts"
    click store "https://github.com/ouyangsh/hello-unibest/blob/manghe/src/store/count.ts"
    click i18n "https://github.com/ouyangsh/hello-unibest/blob/manghe/src/locale/index.ts"
    click i18n "https://github.com/ouyangsh/hello-unibest/blob/manghe/src/locale/en.json"
    click i18n "https://github.com/ouyangsh/hello-unibest/blob/manghe/src/locale/zh-Hans.json"
    click i18n "https://github.com/ouyangsh/hello-unibest/blob/manghe/src/i18n.d.ts"
    click service "https://github.com/ouyangsh/hello-unibest/tree/manghe/src/service/"
    click interceptors "https://github.com/ouyangsh/hello-unibest/blob/manghe/src/interceptors/index.ts"
    click interceptors "https://github.com/ouyangsh/hello-unibest/blob/manghe/src/interceptors/request.ts"
    click interceptors "https://github.com/ouyangsh/hello-unibest/blob/manghe/src/interceptors/route.ts"
    click hooks "https://github.com/ouyangsh/hello-unibest/blob/manghe/src/hooks/useRequest.ts"
    click hooks "https://github.com/ouyangsh/hello-unibest/blob/manghe/src/hooks/useUpload.ts"
    click styles "https://github.com/ouyangsh/hello-unibest/blob/manghe/src/style/index.scss"
    click styles "https://github.com/ouyangsh/hello-unibest/tree/manghe/src/style/fonts/"
    click styles "https://github.com/ouyangsh/hello-unibest/blob/manghe/src/style/iconfont.css"
    click styles "https://github.com/ouyangsh/hello-unibest/blob/manghe/src/uni.scss"
    click assets "https://github.com/ouyangsh/hello-unibest/tree/manghe/src/static/"
    click assets "https://github.com/ouyangsh/hello-unibest/tree/manghe/src/assets/"
    click mock "https://github.com/ouyangsh/hello-unibest/blob/manghe/mock/_mockProdServer.ts"
    click mock "https://github.com/ouyangsh/hello-unibest/blob/manghe/mock/test.ts"
    click docs "https://github.com/ouyangsh/hello-unibest/tree/manghe/docs/"

    %% Styles
    classDef config fill:#D6EAF8,stroke:#21618C,color:#154360
    classDef build fill:#FADBD8,stroke:#C0392B,color:#7B241C
    classDef module fill:#D5F5E3,stroke:#196F3D,color:#145A32
    classDef output fill:#FCF3CF,stroke:#B7950B,color:#7D6608
    classDef runtime fill:#EBDEF0,stroke:#884EA0,color:#6C3483
    classDef external fill:#F2F4F4,stroke:#566573,color:#2C3E50
```
