How zczhao1992/react-manager works
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