# feige996/unibest architecture

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

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

## Overview

##### Project type and purpose
- This is an opinionated **frontend application framework/template** (“unibest”) for building uni-app projects using Vue 3 + TypeScript + Vite + UnoCSS + wot-ui + z-paging.
- It provides a **CLI/boilerplate generator**, **dev-time server**, **build pipelines** for multiple targets (H5, mini-programs, App), plus conventions: pages-based routing, layouts, request handling, i18n, styling, code snippets, etc.

##### File-structure analysis
- Top-level:
- Configuration & metadata (`package.json`, `.eslintrc.*`, `.prettierrc.*`, `vite.config.ts`, `manifest.config.ts`, `openapi-ts-request.config.ts`, `pages.config.ts`)
- `.github` + CI/CD workflows (release, deploy, auto-merge)
- `docs/`: VitePress site for documentation
- `env/`: environment variables per target
- `scripts/`: post-upgrade scripts
- `src/`: application template code
- `screenshots/`, `CHANGELOG.md`, `LICENSE`
- Inside `src/`:
- `main.ts` & `App.vue` bootstrap the Vue app via Vite & uni-app runtime
- `layouts/`: layout components (Default, Demo)
- `pages/` & `pages-sub/`: file-based routes → pages
- `components/`: reusable UI pieces
- `service/`: API service layer with VueQuery hooks, type definitions, and store integration
- `store/`: Pinia (or similar) stores `index.ts`, `user.ts`
- `hooks/`: composables (useRequest, useUpload)
- `interceptors/`: request/response, prototype, route
- `utils/`: http client, platform detection, generic helpers
- `style/`: global CSS/SCSS
- `types/`/`typings.*`: TS declarations
- Build & dev:
- `vite.config.ts` + `uno.config.ts` configure Vite and UnoCSS
- Plugins in `vite-plugins/` (e.g., copyNativeRes)
- Targets configured in `package.json` scripts (`dev:h5`, `dev:mp-weixin`, `dev:app`, `build:h5`, etc.)

##### Key architecture insights from README
- **Multi-target build**: one codebase ⇒ H5, various mini-programs, native App
- **Convention-based routing** & **layout system**
- **Unified request+intercept** pipeline with built-in login guard
- **Pluggable plugin system** via Vite, UnoCSS, openapi-ts-request, pages.config.ts

a. Main components to represent:
1. Developer environment (VSCode/CLI)
2. **CLI/Boilerplate Generator** (`pnpm create unibest`)
3. **Configuration layer**:
- Vite (`vite.config.ts`, `vite-plugins/`)
- Pages config (`pages.config.ts`)
- Manifest config (`manifest.config.ts`)
- OpenAPI client config (`openapi-ts-request.config.ts`)
4. **Dev-time servers**:
- Vite Dev Server (H5)
- Uni-app CLI for mini-programs & App (HBuilderX)
5. **Source code layers** (inside `src/`):
- Bootstrapping (`main.ts`, `App.vue`)
- Routing & layouts (`pages/`, `layouts/`)
- UI components (`components/`)
- State management (`store/`)
- Data fetching & API layer (`service/`, `hooks/useRequest`, `interceptors/`)
- Utilities (`utils/`)
- Static assets (`static/`)
6. **Output bundles** (in `dist/`) per target
7. **Documentation site** (VitePress in `docs/`)
8. **External dependencies/services**:
- Backend APIs
- Uni-app runtime on each platform
- HBuilderX or Developer Tools for mini-programs & App packaging

b. Relationships & data flows:
- Developer invokes CLI → generates project → config files feed into Vite & uni-app CLI
- ViteDev reads `src/` + configs → serves H5 at localhost:9000
- Uni-app CLI reads same code & configs → produces mini-program/App artifacts
- `main.ts` mounts Vue app → router reads `pages/` → renders layouts + pages → UI components consume `store/` & `service/`
- `service/` uses `interceptors/` → generic `http.ts` to call external APIs → results stored in `store/` or returned to hooks
- Documentation site built separately by VitePress, pulling `.vitepress` config in `docs/`

c. Architectural patterns & principles:
- **Convention over configuration**: file-based routing, default layout
- **Separation of concerns**: layers for routing, layout, UI, data, state, and utilities
- **Composable & declarative**: Vue hooks (`useRequest`, `useUpload`), Pinia stores
- **Plugin-driven**: Vite plugins, UnoCSS, openapi-ts-request
- **Multi-target build abstraction**: single code → multiple deployment targets

d. Technologies & frameworks to annotate:
- Vue 3 + TypeScript + uni-app runtime
- Vite 5 (with custom plugins)
- UnoCSS
- wot-ui, z-paging
- VitePress (docs)
- Pinia or VueQuery (service layer)

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Developer Environment"
        DevEnv["VSCode/Terminal"]:::external
        CLI["CLI/Boilerplate Generator<br/>(pnpm create unibest)"]:::build
    end

    subgraph "Configuration Layer"
        ViteCfg["vite.config.ts"]:::config
        UnoCfg["uno.config.ts"]:::config
        VitePlugins["vite-plugins/"]:::config
        PagesCfg["pages.config.ts"]:::config
        ManifestCfg["manifest.config.ts"]:::config
        OpenAPICfg["openapi-ts-request.config.ts"]:::config
        Env["env/"]:::config
        Meta["package.json & Lint Configs"]:::config
    end

    subgraph "Dev Servers"
        ViteDev["Vite Dev Server<br/>(H5)"]:::build
        UniCLI["uni-app CLI<br/>(HBuilderX)"]:::build
    end

    subgraph "Source Code (src/)"
        Entry["src/main.ts"]:::code
        RootComp["src/App.vue"]:::code
        Pages["src/pages/"]:::code
        PagesSub["src/pages-sub/"]:::code
        PagesManifest["src/pages.json"]:::code
        Layouts["src/layouts/"]:::code
        Components["src/components/"]:::code
        Store["src/store/"]:::code
        Service["src/service/"]:::code
        Hooks["src/hooks/"]:::code
        Interceptors["src/interceptors/"]:::code
        Utils["src/utils/"]:::code
        Static["src/static/"]:::code
        Style["src/style/"]:::code
        Types["src/types/"]:::code
        HTML["index.html"]:::code
    end

    subgraph "Build Outputs"
        DistH5["dist/h5"]:::build
        DistMP["dist/mp"]:::build
        DistApp["dist/app"]:::build
    end

    subgraph "Documentation"
        Docs["docs/ (VitePress)"]:::docs
    end

    subgraph "External Services"
        APIs["Backend APIs"]:::external
        UniRuntime["uni-app Runtime"]:::external
        HBuilder["HBuilderX/DevTools"]:::external
    end

    DevEnv --> CLI
    CLI --> ViteCfg
    CLI --> UnoCfg
    CLI --> VitePlugins
    CLI --> PagesCfg
    CLI --> ManifestCfg
    CLI --> OpenAPICfg
    CLI --> Env
    CLI --> Meta

    ViteCfg --> ViteDev
    UnoCfg --> ViteDev
    VitePlugins --> ViteDev
    PagesCfg --> ViteDev
    ManifestCfg --> ViteDev
    OpenAPICfg --> ViteDev
    Env --> ViteDev
    Meta --> ViteDev

    ViteCfg --> UniCLI
    UnoCfg --> UniCLI
    VitePlugins --> UniCLI
    PagesCfg --> UniCLI
    ManifestCfg --> UniCLI
    OpenAPICfg --> UniCLI
    Env --> UniCLI
    Meta --> UniCLI

    ViteDev --> Entry
    UniCLI --> Entry

    Entry --> RootComp
    Entry --> Router["Router"]:::code
    Entry --> Pages
    Entry --> PagesSub
    Entry --> PagesManifest
    Entry --> Layouts
    Entry --> Components
    Entry --> Store
    Entry --> Service
    Entry --> Hooks
    Entry --> Interceptors
    Entry --> Utils
    Entry --> Static
    Entry --> Style
    Entry --> Types
    Entry --> HTML

    Service --> APIs
    UniRuntime --> UniCLI
    HBuilder --> UniCLI

    ViteDev --> DistH5
    UniCLI --> DistMP
    UniCLI --> DistApp

    Docs -->|"built by VitePress"|Docs

    click ViteCfg "https://github.com/feige996/unibest/blob/main/vite.config.ts"
    click UnoCfg "https://github.com/feige996/unibest/blob/main/uno.config.ts"
    click VitePlugins "https://github.com/feige996/unibest/tree/main/vite-plugins/"
    click PagesCfg "https://github.com/feige996/unibest/blob/main/pages.config.ts"
    click ManifestCfg "https://github.com/feige996/unibest/blob/main/manifest.config.ts"
    click OpenAPICfg "https://github.com/feige996/unibest/blob/main/openapi-ts-request.config.ts"
    click Env "https://github.com/feige996/unibest/tree/main/env/"
    click Meta "https://github.com/feige996/unibest/blob/main/package.json"
    click Entry "https://github.com/feige996/unibest/blob/main/src/main.ts"
    click RootComp "https://github.com/feige996/unibest/blob/main/src/App.vue"
    click Pages "https://github.com/feige996/unibest/tree/main/src/pages/"
    click PagesSub "https://github.com/feige996/unibest/tree/main/src/pages-sub/"
    click PagesManifest "https://github.com/feige996/unibest/blob/main/src/pages.json"
    click Layouts "https://github.com/feige996/unibest/tree/main/src/layouts/"
    click Components "https://github.com/feige996/unibest/tree/main/src/components/"
    click Store "https://github.com/feige996/unibest/blob/main/src/store/index.ts"
    click Service "https://github.com/feige996/unibest/tree/main/src/service/"
    click Hooks "https://github.com/feige996/unibest/blob/main/src/hooks/useRequest.ts"
    click Interceptors "https://github.com/feige996/unibest/tree/main/src/interceptors/"
    click Utils "https://github.com/feige996/unibest/tree/main/src/utils/"
    click Static "https://github.com/feige996/unibest/tree/main/src/static/"
    click Style "https://github.com/feige996/unibest/blob/main/src/style/index.scss"
    click Types "https://github.com/feige996/unibest/tree/main/src/types/"
    click HTML "https://github.com/feige996/unibest/blob/main/index.html"
    click Docs "https://github.com/feige996/unibest/tree/main/docs/"
    
    classDef config fill:#9f6,stroke:#396,stroke-width:1px
    classDef code fill:#6bf,stroke:#039,stroke-width:1px
    classDef build fill:#f90,stroke:#a60,stroke-width:1px
    classDef docs fill:#fc3,stroke:#c90,stroke-width:1px
    classDef external fill:#b7b,stroke:#84b,stroke-width:1px
```
