# rengarjs/rengar-admin architecture

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

- Interactive diagram: https://gitdiagram.com/rengarjs/rengar-admin
- Repository: https://github.com/rengarjs/rengar-admin

## Overview

##### Project Type and Purpose
- A front-end single-page application (SPA) admin template built with Vue 3 and Vite.
- Targets rapid admin-UI development, with built-in routing, state management, theming, and code generators.

##### File Structure
Top-level:
- config files (.env, tsconfig, .editorconfig, eslint.config.ts, vite.config.ts)
- /build: custom Vite plugin implementations
- /public: static assets (version.json, 404.html)
- /src: Vue application code
– /api: HTTP client & endpoint modules
– /components: reusable Vue components (AppLoading, SvgIcon, AppProvider)
– /layouts: layout shells + shared UI elements (header, footer, sidebar, breadcrumbs, drawers)
– /router: route definitions, guards, utils
– /stores: Pinia modules (app state, auth, menu, tabs, keepAlive)
– /hooks: composition-API utilities (auth, loading, router, update)
– /views: pages grouped by domain (home, login, setting, docs, examples)
– /plugins: Vue plugin initializers (global registration)
- /build/plugins: TypeScript files producing Vite plugin pipeline
- Monorepo workspace config: pnpm-workspace.yaml, pnpm-lock.yaml

##### Key Architectural Patterns
- MVVM via Vue 3 + Composition API
- Modular architecture: feature-based directories and domain-driven views
- Pinia for store (state management)
- Vue Router for navigation (with code-gen in build pipeline)
- Plugin pipeline pattern in Vite
- Monorepo pattern enabling local package development and tight integration

##### Main Components and Their Relationships
[Developer Machine] → (pnpm dev / Vite)
→ [Vite Dev Server]
- Applies custom plugins (import auto-resolver, version injector, router code-gen, UnoCSS, name injector)
→ Serves → [Vue SPA in Browser]
– Root (App.vue)
– RouterView → dynamic views
– Pinia Store → application state
– API Layer (axios wrapper) → External Backend API
Build/Production:
[Vite Build]
- same plugin pipeline → outputs /dist => Deployed Static Site

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Tooling & Dev
    subgraph "Tooling & Development"
        direction TB
        Dev["Developer Machine"]:::tooling
        IDE["IDE (Volar)"]:::tooling
        PNPM["pnpm CLI"]:::tooling
        ViteCLI["Vite CLI"]:::tooling
    end

    Dev -->|uses| PNPM
    IDE -->|integrates| PNPM
    PNPM -->|runs dev/build| ViteServer

    %% Monorepo Packages
    subgraph "Monorepo Packages"
        direction TB
        AXS["axios wrapper"]:::monorepo
        CLR["color/theme"]:::monorepo
        UOC["unocss integration"]:::monorepo
        VPV["vite-plugin-version"]:::monorepo
        VPN["vite-plugin-vue-inject-name"]:::monorepo
        VPR["vite-plugin-vue-routes"]:::monorepo
    end

    AXS -->|local pkg| ViteServer
    CLR -->|local pkg| ViteServer
    UOC -->|local pkg| ViteServer
    VPV -->|local pkg| ViteServer
    VPN -->|local pkg| ViteServer
    VPR -->|local pkg| ViteServer

    %% Vite Dev Server & Build Pipeline
    subgraph "Vite Dev Server / Build Pipeline"
        direction TB
        ViteServer["Vite Dev Server"]:::pipeline
        subgraph "Plugin Pipeline"
            direction TB
            ImportP["Import Auto-Resolver"]:::pipeline
            RouterP["Router CodeGen"]:::pipeline
            UnoP["UnoCSS"]:::pipeline
            InjectP["Name Injector"]:::pipeline
            VersionP["Version Injector"]:::pipeline
        end
    end

    ViteServer -->|applies| ImportP
    ImportP --> RouterP
    RouterP --> UnoP
    UnoP --> InjectP
    InjectP --> VersionP
    VersionP -->|serves| Browser

    %% Vue SPA in Browser
    subgraph "Vue SPA (Browser)" 
        direction TB
        Browser["Browser"]:::external
        subgraph "Application Entry"
            direction TB
            Main["main.ts"]:::frontend
            AppV["App.vue"]:::frontend
            IndexHTML["index.html"]:::frontend
        end
        subgraph "Routing & Views"
            direction TB
            Router["Vue Router"]:::frontend
            Views["Views"]:::frontend
        end
        subgraph "State Management"
            direction TB
            Store["Pinia Store"]:::state
        end
        subgraph "API Layer"
            direction TB
            Request["request.ts"]:::network
            AuthAPI["auth.ts"]:::network
            MenuAPI["menu.ts"]:::network
        end
        subgraph "UI Components & Layouts"
            direction TB
            Components["Components"]:::frontend
            Layouts["Layouts"]:::frontend
        end
    end

    VersionP -->|serves| Browser
    Browser -->|loads| Main
    Main --> AppV
    AppV --> Router
    Router --> Views
    Views -->|reads/writes| Store
    Views -->|calls| Request
    Request -->|calls| AuthAPI
    Request -->|calls| MenuAPI
    Request -->|HTTP| ExternalAPI
    ExternalAPI -->|response| Request
    Request -->|updates| Store
    Store -->|updates| Views

    %% External Backend
    ExternalAPI["External Backend API"]:::external

    %% Click Events
    click AXS "https://github.com/rengarjs/rengar-admin/blob/main/packages/axios/index.ts"
    click CLR "https://github.com/rengarjs/rengar-admin/blob/main/packages/color/index.ts"
    click UOC "https://github.com/rengarjs/rengar-admin/blob/main/packages/unocss/index.ts"
    click VPV "https://github.com/rengarjs/rengar-admin/blob/main/packages/vite-plugin-version/index.ts"
    click VPN "https://github.com/rengarjs/rengar-admin/blob/main/packages/vite-plugin-vue-inject-name/index.ts"
    click VPR "https://github.com/rengarjs/rengar-admin/blob/main/packages/vite-plugin-vue-routes/index.ts"
    click ImportP "https://github.com/rengarjs/rengar-admin/blob/main/build/plugins/import.ts"
    click RouterP "https://github.com/rengarjs/rengar-admin/blob/main/build/plugins/router.ts"
    click UnoP "https://github.com/rengarjs/rengar-admin/blob/main/build/plugins/unocss.ts"
    click InjectP "https://github.com/rengarjs/rengar-admin/blob/main/build/plugins/inject.ts"
    click VersionP "https://github.com/rengarjs/rengar-admin/blob/main/build/plugins/version.ts"
    click ViteServer "https://github.com/rengarjs/rengar-admin/blob/main/vite.config.ts"
    click Main "https://github.com/rengarjs/rengar-admin/blob/main/src/main.ts"
    click AppV "https://github.com/rengarjs/rengar-admin/blob/main/src/App.vue"
    click IndexHTML "https://github.com/rengarjs/rengar-admin/blob/main/index.html"
    click Request "https://github.com/rengarjs/rengar-admin/blob/main/src/api/request.ts"
    click AuthAPI "https://github.com/rengarjs/rengar-admin/blob/main/src/api/common/auth.ts"
    click MenuAPI "https://github.com/rengarjs/rengar-admin/blob/main/src/api/setting/menu.ts"

    %% Styles
    classDef tooling fill:#DDDDDD,stroke:#888,stroke-width:1px
    classDef monorepo fill:#D0E8FF,stroke:#005B96,stroke-width:1px
    classDef pipeline fill:#CCE5FF,stroke:#3399FF,stroke-width:1px
    classDef frontend fill:#DFFFD6,stroke:#2E8B57,stroke-width:1px
    classDef state fill:#FFEFD6,stroke:#FF8C00,stroke-width:1px
    classDef network fill:#F3E5FF,stroke:#800080,stroke-width:1px
    classDef external fill:#FFD6D6,stroke:#FF0000,stroke-width:1px
```
