# eryajf/xirang-ui architecture

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

- Interactive diagram: https://gitdiagram.com/eryajf/xirang-ui
- Repository: https://github.com/eryajf/xirang-ui

## Overview

##### Project type and purpose
- This repository is the **frontend** for the XiRang full-stack application. The backend lives in a separate Go/Gin+Gorm project; this is a Vue.js SPA (single-page application) that consumes those REST APIs, implements pages (login, dashboard, user/role management, etc.), and ships in a Docker container behind an HTTP server.

##### File structure
- Top-level config and build scripts:
- Dockerfile, default.conf (nginx-style config)
- babel.config.js, postcss.config.js, vue.config.js, build/* (custom Webpack/Vue CLI build)
- .env.* files for dev/staging/prod
- Public assets and HTML template: `public/index.html`
- Source code (`src/`):
- `App.vue`, `main.js`, `router/`, `store/` (Vue Router + Vuex modules), `permission.js` (route guards)
- `api/` directory: HTTP client wrappers and modules per domain (dashboards, system, example)
- `components/`, `layout/`, `views/`: component-based MVVM structure
- `utils/`, `directive/`, `filters/`: cross-cutting utilities, custom directives, and filters
- Tests: unit tests for components and utils under `tests/unit/`

##### README for additional insights
- The overall XiRang system is a simple web framework built with Gin (HTTP server) + Gorm (ORM) and MySQL.
- The frontend (this repo) is intended to be cloned alongside the backend and run via `yarn dev` on port 8090, forwarding API calls to the Go server.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% External Client
    Browser["Browser"]:::external

    %% Infrastructure
    subgraph "Infrastructure"
        Nginx["Nginx Reverse Proxy"]:::infra
        Dockerfile["Dockerfile"]:::infra
        NginxConf["default.conf"]:::infra
    end

    %% Server-side
    subgraph "Server-side"
        Backend["Go/Gin API Server"]:::backend
        MySQL["MySQL Database"]:::db
    end

    %% Client-side SPA
    subgraph "Client-side"
        subgraph "Frontend SPA (Vue.js)"
            subgraph "UI Layer"
                Views["src/views/"]:::frontend
                Comps["src/components/"]:::frontend
                Layout["src/layout/"]:::frontend
            end
            subgraph "Router Layer"
                Router["src/router/index.js"]:::frontend
                Permission["src/permission.js"]:::frontend
            end
            subgraph "State Layer"
                StoreIndex["src/store/index.js"]:::frontend
                StoreModules["Vuex Modules (app, user, etc.)"]:::frontend
            end
            subgraph "API Layer"
                APIDir["src/api/"]:::frontend
            end
            subgraph "Utilities & Helpers"
                Utils["src/utils/"]:::frontend
                Directive["src/directive/"]:::frontend
                Filters["src/filters/index.js"]:::frontend
            end
            subgraph "Assets & Styles"
                Assets["src/assets/"]:::frontend
                Styles["src/styles/"]:::frontend
            end
            subgraph "Entry & Configuration"
                Main["src/main.js"]:::frontend
                AppVue["src/App.vue"]:::frontend
                Babel["babel.config.js"]:::frontend
                VueConfig["vue.config.js"]:::frontend
                PostCSS["postcss.config.js"]:::frontend
            end
            subgraph "Public Template"
                IndexHTML["public/index.html"]:::frontend
            end
            subgraph "Environment Configs"
                EnvDev[".env.development"]:::frontend
                EnvStag[".env.staging"]:::frontend
                EnvProd[".env.production"]:::frontend
            end
            subgraph "Build & DevOps Scripts"
                BuildScript["build/index.js"]:::frontend
            end
            subgraph "Tests"
                TestsComp["tests/unit/components/"]:::test
                TestsUtil["tests/unit/utils/"]:::test
                JestConfig["jest.config.js"]:::test
            end
        end
    end

    %% Flows
    Browser -->|"HTTP" | Nginx
    Nginx -->|"serves SPA" | Main
    Main -->|"bootstraps"| Router
    Router -->|"guards"| Permission
    Router -->|"renders"| Views
    Views -->|"updates state"| StoreIndex
    StoreIndex -->|"dispatches"| APIDir
    APIDir -->|"HTTP (Axios)"| Backend
    Backend -->|"GORM Queries"| MySQL
    APIDir -->|"receives JSON"| StoreIndex
    StoreIndex -->|"updates UI"| Views

    %% Click Events
    click Views "https://github.com/eryajf/xirang-ui/tree/main/src/views/"
    click Comps "https://github.com/eryajf/xirang-ui/tree/main/src/components/"
    click Layout "https://github.com/eryajf/xirang-ui/tree/main/src/layout/"
    click Router "https://github.com/eryajf/xirang-ui/blob/main/src/router/index.js"
    click Permission "https://github.com/eryajf/xirang-ui/blob/main/src/permission.js"
    click StoreIndex "https://github.com/eryajf/xirang-ui/blob/main/src/store/index.js"
    click APIDir "https://github.com/eryajf/xirang-ui/tree/main/src/api/"
    click Utils "https://github.com/eryajf/xirang-ui/tree/main/src/utils/"
    click Directive "https://github.com/eryajf/xirang-ui/tree/main/src/directive/"
    click Filters "https://github.com/eryajf/xirang-ui/blob/main/src/filters/index.js"
    click Assets "https://github.com/eryajf/xirang-ui/tree/main/src/assets/"
    click Styles "https://github.com/eryajf/xirang-ui/tree/main/src/styles/"
    click Main "https://github.com/eryajf/xirang-ui/blob/main/src/main.js"
    click AppVue "https://github.com/eryajf/xirang-ui/blob/main/src/App.vue"
    click Babel "https://github.com/eryajf/xirang-ui/blob/main/babel.config.js"
    click VueConfig "https://github.com/eryajf/xirang-ui/blob/main/vue.config.js"
    click PostCSS "https://github.com/eryajf/xirang-ui/blob/main/postcss.config.js"
    click IndexHTML "https://github.com/eryajf/xirang-ui/blob/main/public/index.html"
    click EnvDev "https://github.com/eryajf/xirang-ui/blob/main/.env.development"
    click EnvStag "https://github.com/eryajf/xirang-ui/blob/main/.env.staging"
    click EnvProd "https://github.com/eryajf/xirang-ui/blob/main/.env.production"
    click Dockerfile "https://github.com/eryajf/xirang-ui/tree/main/Dockerfile"
    click NginxConf "https://github.com/eryajf/xirang-ui/blob/main/default.conf"
    click BuildScript "https://github.com/eryajf/xirang-ui/blob/main/build/index.js"
    click TestsComp "https://github.com/eryajf/xirang-ui/tree/main/tests/unit/components/"
    click TestsUtil "https://github.com/eryajf/xirang-ui/tree/main/tests/unit/utils/"
    click JestConfig "https://github.com/eryajf/xirang-ui/blob/main/jest.config.js"

    %% Styles
    classDef frontend fill:#D6EAF8,stroke:#3498DB,color:#154360
    classDef backend fill:#F9E79F,stroke:#F1C40F,color:#B9770E
    classDef db fill:#D5F5E3,stroke:#27AE60,color:#145A32
    classDef infra fill:#E5E7E9,stroke:#95A5A6,color:#1B2631
    classDef test fill:#FADBD8,stroke:#E74C3C,color:#641E16
    classDef external fill:#FFFFFF,stroke:#000000,color:#000000
```
