* refactor(api): introduce defineApi + axios request layer Replace ad-hoc fetch httpClient with api/request.ts (axios interceptors, envelope unwrap, auth refresh) and defineApi-based resource modules. Move session hydration into api/auth, sync both templates, and update docs. Co-authored-by: zuiidea <zuiiidea@gmail.com> * chore: unify Cursor rules, fix monorepo install hooks, refresh basic docs Add root preinstall to set githooks and disable parallel vp config git lock races; merge per-app Cursor thin rules into app.mdx; keep template READMEs free of monorepo-only paths and describe basic as default English rather than English-only. Co-authored-by: Cursor <cursoragent@cursor.com> * chore: add root turbo fmt and format app sources Expose fmt via turbo at the monorepo root, apply Oxfmt in basic/with-lingui, and run vp staged through pnpm exec in pre-commit so hooks work without a global vp. Co-authored-by: Cursor <cursoragent@cursor.com> * chore: drop root eslint/prettier and bump turbo to 2.11.9 Root formatting and lint stay on turbo fmt/lint via Vite+ in workspace apps. Co-authored-by: Cursor <cursoragent@cursor.com> * chore: consolidate agent guidance into AGENTS.md Merge scoped instructions into per-app AGENTS.md, add monorepo AGENTS.md and add-resource skill, and remove template .github Copilot files plus the Cursor app router rule. Co-authored-by: Cursor <cursoragent@cursor.com> * chore(basic): add add-resource skill and portable app-root paths Align basic with with-lingui for CRUD scaffolding via AGENTS.md and .agents/skills, and drop hardcoded monorepo paths in agent docs. Co-authored-by: Cursor <cursoragent@cursor.com> * refactor(api): split modules under shared/ with API_PREFIX Move auth and users into folder modules, centralize path constants, and align MSW with endpoint paths in both template apps. Co-authored-by: Cursor <cursoragent@cursor.com> * docs: document modular API layer in README files Expand template READMEs with src/api layout, fix CLI table and E2E script references. Co-authored-by: Cursor <cursoragent@cursor.com> * docs: align site with modular src/api layout Document API_PREFIX, folder structure, templates, and E2E script usage in en/zh. Co-authored-by: Cursor <cursoragent@cursor.com> --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: zuiidea <zuiidea@example.com>
Antd Admin
Admin scaffold: MSW mocks, minimal RBAC, full CRUD, and Playwright E2E — built with React 19, Ant Design 6, and Vite+. AI-friendly with clear patterns, shared abstractions, AGENTS.md agent rules, and type-safe contracts at every boundary. Default UI language is English; for Lingui i18n (en + zh) out of the box, see apps/with-lingui.
Tech Stack
| Category | Technology |
|---|---|
| Build Tool | Vite+ (VoidZero unified toolchain) |
| UI Framework | Ant Design 6.x |
| Routing | TanStack Router (file-based, type-safe) |
| Async State | TanStack Query v5 |
| Local State | Zustand (persisted auth & settings) |
| Validation | Zod v4 (schemas, API contracts, form validation) |
| UI copy | Plain strings in source (default English); no bundled i18n stack |
| Icons | lucide-react |
| API Mocking | MSW 2.x (Service Worker based) |
| E2E Testing | Playwright |
| Language | TypeScript (strict mode) |
Features
- JWT Authentication — Login with access/refresh token flow, persisted via Zustand
- Dynamic Menu & RBAC — Backend-driven sidebar menu with permission guards and 403 page
- URL-First State — Table search params (page, pageSize, keyword, sort) synced to URL
- Default locale — UI copy in plain strings (English by default); Ant Design
ConfigProviderusesen_US. - Dark Mode — One-click toggle with Ant Design theme algorithm
- Modular API layer —
defineApimodules undersrc/api/<domain>/, shared Zod helpers, singleAPI_PREFIX - Full Type Safety — Zod schemas validate API boundaries at runtime where used
- Zero-Config Mocking — MSW intercepts API calls in development, no backend needed
Getting Started
Prerequisites
Install & Run
pnpm install
pnpm run dev
Open http://localhost:5173 — you'll be redirected to the login page.
Default credentials: admin / admin
Build
pnpm run build
pnpm run preview
Project Setup
pnpm run prepare
Code Quality
pnpm run fmt
pnpm run lint
pnpm run check
Unit Tests
pnpm run test:unit
E2E Tests
pnpm run test:e2e
pnpm run test:e2e -- e2e/login.spec.ts e2e/users.spec.ts # core flows only
pnpm run test:e2e:ui # interactive UI mode
Project Structure
AGENTS.md # Agent rules (frontend/api/testing/refactor)
.agents/skills/add-resource/ # CRUD scaffold checklist (Skill)
src/
├── api/ # HTTP + contracts (see “API layer” below)
│ ├── request.ts # axios, defineApi, token refresh, envelope unwrap
│ ├── schemas.ts # deprecated barrel; prefer @/api/shared and module schemas
│ ├── shared/ # API_PREFIX, pagination, params, menu, envelope helpers
│ ├── auth/ # paths, schemas, login/register/hydrateSession
│ └── users/ # schemas, listUsers CRUD, userQueryKeys, path constants
├── components/ # Reusable UI primitives and layout shells
│ ├── Layout/ # MainLayout, Header, Sidebar, UserMenu, AppFooter
│ ├── DataTable/ # Shared table frame/skeleton/empty state
│ ├── FormModal/ # Generic modal form wrapper
│ ├── FilterToolbar/ # Reusable list page toolbar
│ ├── Auth/ # Permission gate component
│ ├── Aurora/ # Login page background effect
│ ├── Icon/ # Shared icons (GitHub, Theme, etc.)
│ ├── NotFound/ # Not-found visual component
│ └── RouteError.tsx # Route-level error boundary UI
├── hooks/ # Shared hooks (theme, CRUD, URL state, permissions)
│ ├── useAppTheme.ts
│ ├── usePermission.ts
│ ├── useResourceCRUD.ts
│ ├── useCrudToasts.ts
│ ├── useUrlSearchState.ts
│ ├── useTableFitHeight.ts
│ └── tokenBuilders.ts
├── mocks/ # MSW bootstrap, handlers, seed data, test helpers
│ ├── browser.ts
│ ├── createHandler.ts
│ ├── createHandler.test.ts
│ ├── data.ts
│ ├── utils.ts
│ └── handlers/
├── routes/ # TanStack Router file routes
│ ├── __root.tsx # QueryClient + ConfigProvider (en_US) wiring
│ ├── _auth.tsx # Protected route layout
│ ├── _auth/dashboard/index.tsx
│ ├── _auth/users/index.tsx
│ ├── _auth/users/-Toolbar.tsx
│ ├── _auth/users/-FormModal.tsx
│ ├── _auth/403/index.tsx
│ ├── login/index.tsx
│ ├── register/index.tsx
│ ├── 404/index.tsx
│ └── index.tsx
├── stores/ # Persisted auth/settings stores
├── utils/ # constants, app menu helpers
├── main.tsx # App bootstrap (MSW init + React render)
└── routeTree.gen.ts # Generated TanStack route tree
e2e/ # Playwright E2E suites
├── helpers.ts
├── login.spec.ts
├── users.spec.ts
├── auth-refresh.spec.ts
├── rbac.spec.ts
└── url-state.spec.ts
API layer
Data flow: Zod schemas → defineApi in src/api/<module>/index.ts → routes/components call resource functions (never axios or @/api/request directly).
| Piece | Role |
|---|---|
request.ts |
Shared HTTP client, { code, data, message } handling, 401 refresh |
shared/ |
API_PREFIX (/api), pagination/query helpers, shared menu types |
auth/, users/ |
Domain schemas + defineApi exports; MSW handlers import the same path constants |
schemas.ts |
Compatibility re-exports; new code should import from @/api/shared and @/api/<module>/schemas |
Change the REST prefix in one place: src/api/shared/prefix.ts (API_PREFIX).
Language
User-facing copy lives in components and routes as plain strings. Default language is English; Ant Design is wired to en_US in __root.tsx. This template does not include a locale switcher or translation catalogs—you can add your own i18n library or start from the with-lingui template for LinguiJS (en + zh).
Extending the template
- New CRUD resource: Follow
.agents/skills/add-resource/SKILL.md(mirrorusers), thenvp check --no-fmt. - Real backend: Point
VITE_API_BASE_URLin env and disable or remove MSW inmain.tsxwhen you no longer need mocks. - Add i18n: Integrate your preferred stack, or copy patterns from
apps/with-lingui.
AI guidance
Single source of truth: AGENTS.md in this app. New CRUD flows: @.agents/skills/add-resource/SKILL.md.
Developer Notes
- Prefer Vite+ commands for installs, checks, and scripts. This repo is configured around
vp. - Run
vp check --no-fmtfor type/lint validation. - Core regression coverage lives in the login and users E2E flows.
Pages
| Route | Description |
|---|---|
/login |
Login form with validation |
/dashboard |
Statistics overview cards |
/users |
User CRUD table with search, pagination, create/edit/delete |
/403 |
Forbidden error page |
/404 |
Not found error page |
License
MIT