# zczhao1992/react-manager architecture

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

- Interactive diagram: https://gitdiagram.com/zczhao1992/react-manager
- Repository: https://github.com/zczhao1992/react-manager

## Overview

##### Project type and purpose
- This is a front‑end single‑page admin dashboard framework called “React‑Manager.”
- Built with React18 + React‑Router v6 for routing, Zustand for state, Ant Design for UI, Vite + TypeScript as the build system.
- It provides features like authentication, role/menu permissions, i18n, dark mode, CRUD pages (dashboard, orders, system management), and a drag‑and‑drop low‑code form editor.

##### File structure
- Entry & configuration:
- index.html → main.tsx → App.tsx
- vite.config.ts, tsconfig.json, .env.* for build/dev/test environment setup
- Core layers under src/:
- router/ → route definitions, lazy loading, auth guard
- layout/ & components/ → global UI (NavHeader, NavFooter, Menu, low‑code components, common buttons)
- views/ → page components grouped by feature (dashboard, editor, lowcode, order, system, login, 403/404)
- api/ → typed API client wrappers for backend endpoints (lowCodeApi, orderApi, roleApi, etc.)
- store/ → Zustand stores for user/session, low‑code editor state
- utils/ → axios wrapper, request interceptor, loading indicator, storage utils
- _mock/ → development mock data for all major endpoints
- assets/, styles/, types/ — static assets, global styles, TypeScript definitions

##### README for additional insights
- Technology stack (React18, Router v6, Hooks, TS, Vite, Antd, Zustand, DnD‑kit)
- Features (CRUD, permissions, i18n, dark mode, low‑code editor with drag‑and‑drop)
- Build & run scripts

a. Main components
1. Browser/Client (User’s browser)
2. UI Layer
- App.tsx (root) → Layout components (NavHeader, NavFooter, Menu)
- Views (Dashboard, Editor, Order, System, LowCode, Login)
- Shared Global Components (SearchForm, Tabs, LowCodeComponents library)
3. Routing Layer (React‑Router v6)
- Route definitions, lazy loading, AuthLoader guard for permissions
4. State Management (Zustand stores)
- UserStore (auth, roles, permissions)
- LowCodeStore (canvas state, component tree, undo/redo)
5. Data Layer
- Api clients (Axios wrappers in src/api)
- Utils/request (global interceptor, cancelation, loading)
6. Mock Server (dev only)
- _mock directory serving fake JSON data
7. External Backend Services (production REST API)
8. Build & Deployment (Vite Dev Server, Vite build outputs)

b. Relationships & interactions
- User interacts with UI → routed by React‑Router to specific view
- View dispatches actions to Zustand store or invokes API client
- API client hits mock endpoints (in dev) or real backend (prod) → responses update store or directly feed component props
- Store publishes state changes → components re‑render
- Low‑code editor view uses dnd‑kit for drag events → updates LowCodeStore → re‑renders canvas

c. Architectural patterns & design principles
- Layered architecture: Presentation (components/views), Application (routing, hooks), Domain (stores), Infrastructure (API clients, utils)
- Component‑based UI with container/presentational split in views and component libs
- Unidirectional data flow: view → store/API → store → view
- Separation of concerns: routing, state, API, UI each in distinct folders

d. Key technologies & frameworks
- React18, React‑Router v6, React Hooks
- Vite + TypeScript
- Zustand for state management
- Ant Design for UI components
- Axios with custom interceptors for API
- dnd‑kit for drag‑and‑drop in low‑code editor
- i18next (via custom language modules) for i18n

##### Detail key interactions
- Login flow: LoginView → AuthApi → UserStore → Router guard → Protected Views
- CRUD flow: View → OrderApi/RoleApi → backend → update Store → re‑render table/list
- Low‑code flow: DragToolbar → Canvas → LowCodeStore → Prop panel → Component library

## Diagram (Mermaid)

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

    %% Entry & App
    subgraph "Entry & Core App" 
        MainHTML["index.html"]:::presentation
        MainTS["src/main.tsx"]:::presentation
        App["src/App.tsx"]:::presentation
    end

    %% UI Layer
    subgraph "Presentation Layer" 
        UI["UI Layer"]:::presentation
        subgraph "Global Layout & Navigation"
            Layout["Layout\n(index.tsx)"]:::presentation
            NavH["NavHeader"]:::presentation
            NavF["NavFooter"]:::presentation
            MenuComp["Menu"]:::presentation
        end
        subgraph "Shared UI Components"
            AuthBtn["AuthButton"]:::presentation
            Search["SearchForm"]:::presentation
            TabsComp["Tabs"]:::presentation
        end
        subgraph "Views (Pages)"
            Dashboard["Dashboard View"]:::presentation
            Editor["Editor View"]:::presentation
            LowCodeList["LowCode List View"]:::presentation
            Orders["Order Views"]:::presentation
            SystemMgmt["System Management Views"]:::presentation
            LoginView["Login View"]:::presentation
            StatusPages["403/404 Views"]:::presentation
            Welcome["Welcome View"]:::presentation
        end
        subgraph "Low-Code Components"
            LowCodeLib["LowCodeComponents\n(directory)"]:::presentation
            subgraph "Drag & Drop Utils"
                SortContainer["SortableContainer.tsx"]:::presentation
                SortItem["SortableItem.tsx"]:::presentation
            end
        end
    end

    %% Routing Layer
    subgraph "Application Logic"
        Router["Router (React-Router v6)"]:::application
        AuthGuard["AuthLoader Guard"]:::application
        LazyLoad["LazyLoad Wrapper"]:::application
    end

    %% State Management
    subgraph "State Layer"
        UserStore["useUserStore"]:::state
        LowCodeStore["useLowCodeStore"]:::state
    end

    %% API & Infrastructure
    subgraph "Infrastructure Layer"
        subgraph "API Clients"
            APIIndex["api/index.ts"]:::infra
            LowCodeAPI["lowCodeApi.ts"]:::infra
            OrderAPI["orderApi.ts"]:::infra
            RoleAPI["roleApi.ts"]:::infra
            ProCompAPI["proComponentsApi.ts"]:::infra
        end
        subgraph "Utilities"
            Request["request.ts"]:::infra
            Loading["loading/index.tsx"]:::infra
            Storage["storage.ts"]:::infra
            AntdGlobal["AntdGlobal.tsx"]:::infra
        end
    end

    %% Mock & Backend
    subgraph "External Systems"
        MockServer["_mock Data Server"]:::external
        Backend["Production REST API"]:::external
    end

    %% Connections
    Browser --> MainHTML
    MainHTML --> MainTS
    MainTS --> App
    App --> UI
    App --> Router
    Router --> AuthGuard
    Router --> LazyLoad
    AuthGuard --> Dashboard
    AuthGuard --> Editor
    AuthGuard --> LowCodeList
    AuthGuard --> Orders
    AuthGuard --> SystemMgmt
    Router --> LoginView
    Router --> StatusPages
    Router --> Welcome

    %% UI interactions
    Dashboard --> UserStore
    Editor --> LowCodeStore
    LowCodeList --> LowCodeStore
    Orders --> UserStore
    SystemMgmt --> UserStore
    LoginView --> UserStore

    %% Data flows
    Dashboard --> OrderAPI
    SystemMgmt --> RoleAPI
    SystemMgmt --> APIIndex
    Editor --> LowCodeAPI
    LowCodeList --> LowCodeAPI
    any_store--> Request
    Request --> APIIndex
    APIIndex --> MockServer
    APIIndex --> Backend
    MockServer --> Request
    Backend --> Request
    Request -->|updates| UserStore
    Request -->|updates| LowCodeStore

    %% Click Events
    click MainTS "https://github.com/zczhao1992/react-manager/blob/master/src/main.tsx"
    click MainHTML "https://github.com/zczhao1992/react-manager/blob/master/index.html"
    click App "https://github.com/zczhao1992/react-manager/blob/master/src/App.tsx"
    click Router "https://github.com/zczhao1992/react-manager/blob/master/src/router/index.tsx"
    click AuthGuard "https://github.com/zczhao1992/react-manager/blob/master/src/router/AuthLoader.ts"
    click LazyLoad "https://github.com/zczhao1992/react-manager/blob/master/src/router/LazyLoad.tsx"
    click Layout "https://github.com/zczhao1992/react-manager/blob/master/src/layout/index.tsx"
    click NavH "https://github.com/zczhao1992/react-manager/blob/master/src/components/NavHeader/index.tsx"
    click NavF "https://github.com/zczhao1992/react-manager/blob/master/src/components/NavFooter/index.tsx"
    click MenuComp "https://github.com/zczhao1992/react-manager/blob/master/src/components/Menu/index.tsx"
    click AuthBtn "https://github.com/zczhao1992/react-manager/blob/master/src/components/AuthButton.tsx"
    click Search "https://github.com/zczhao1992/react-manager/blob/master/src/components/SearchForm.tsx"
    click TabsComp "https://github.com/zczhao1992/react-manager/blob/master/src/components/Tabs.tsx"
    click LowCodeLib "https://github.com/zczhao1992/react-manager/tree/master/src/components/LowCodeComponents"
    click SortContainer "https://github.com/zczhao1992/react-manager/blob/master/src/components/DragSortable/SortableContainer.tsx"
    click SortItem "https://github.com/zczhao1992/react-manager/blob/master/src/components/DragSortable/SortableItem.tsx"
    click Dashboard "https://github.com/zczhao1992/react-manager/blob/master/src/views/dashboard/index.tsx"
    click Editor "https://github.com/zczhao1992/react-manager/blob/master/src/views/editor/index.tsx"
    click LowCodeList "https://github.com/zczhao1992/react-manager/blob/master/src/views/lowcode/index.tsx"
    click Orders "https://github.com/zczhao1992/react-manager/blob/master/src/views/order/OrderList/index.tsx"
    click SystemMgmt "https://github.com/zczhao1992/react-manager/blob/master/src/views/system/user/index.tsx"
    click LoginView "https://github.com/zczhao1992/react-manager/blob/master/src/views/login/Login.tsx"
    click UserStore "https://github.com/zczhao1992/react-manager/blob/master/src/store/useUserStore.ts"
    click LowCodeStore "https://github.com/zczhao1992/react-manager/blob/master/src/store/useLowCodeStore.ts"
    click APIIndex "https://github.com/zczhao1992/react-manager/blob/master/src/api/index.ts"
    click LowCodeAPI "https://github.com/zczhao1992/react-manager/blob/master/src/api/lowCodeApi.ts"
    click OrderAPI "https://github.com/zczhao1992/react-manager/blob/master/src/api/orderApi.ts"
    click RoleAPI "https://github.com/zczhao1992/react-manager/blob/master/src/api/roleApi.ts"
    click ProCompAPI "https://github.com/zczhao1992/react-manager/blob/master/src/api/proComponentsApi.ts"
    click Request "https://github.com/zczhao1992/react-manager/blob/master/src/utils/request.ts"
    click Loading "https://github.com/zczhao1992/react-manager/blob/master/src/utils/loading/index.tsx"
    click Storage "https://github.com/zczhao1992/react-manager/blob/master/src/utils/storage.ts"
    click MockServer "https://github.com/zczhao1992/react-manager/blob/master/src/_mock/index.ts"

    %% Styles
    classDef presentation fill:#cfe2f3,stroke:#2a6592,color:#000;
    classDef application fill:#d9ead3,stroke:#6aa84f,color:#000;
    classDef state fill:#fce5cd,stroke:#e69138,color:#000;
    classDef infra fill:#ead1dc,stroke:#a64d79,color:#000;
    classDef external fill:#e7e6e6,stroke:#8e8d8d,color:#000;
```
