CLAUDE.md
frontend/CLAUDE.mdCLAUDE.md
Quality
83/100
Scores the file, not the repository.Length
560 words
6 headings · 0 code blocksRepository
44k
— · pushed 1 days agoLast changed
3 days ago
First indexed 3 days ago.1# frontend/CLAUDE.md23Frontend agent guide. Full detail: `frontend/README.md` and the root4`CONTRIBUTING.md` ("Working on the frontend"). This is the short version.56## What this is7React 19 + Ant Design 6 + Vite 8 + TypeScript. The Vite config is8`vite.config.js` (plain JS). Three bundles, each emitted into9`internal/web/dist/` and embedded into the Go binary:10- `index.html` — admin panel SPA (entry `src/main.tsx`; react-router under11 `/panel`, lazy routes).12- `login.html` — login + 2FA (`src/entries/login.tsx`).13- `subpage.html` — public subscription viewer (`src/entries/subpage.tsx`).14The `@` import alias maps to `src/`.1516## Data flow17- Server state via TanStack Query (`src/api/`, keys in `src/api/queryKeys.ts`);18 invalidate on mutation. WebSocket pushes feed the cache19 (`src/api/websocketBridge.ts`).20- Local UI state in the page (`useState`); shared concerns via `src/hooks/`.21 Extend an existing hook before adding a global.22- Zod (`src/schemas/`) is the single source of truth for the xray config model.23 Infer types with `z.infer`. Go-side types are mirrored into `src/generated/`24 by `npm run gen:zod` (`go run ./tools/openapigen`) — do not hand-edit that25 folder (every file is marked `DO NOT EDIT`).26- xray domain logic (links, defaults, form<->wire adapters) is pure functions in27 `src/lib/xray/`. HTTP goes through `HttpUtil` in `src/utils/index.ts`.2829## Rules30- Ant Design 6 for components; no Tailwind/shadcn (a migration was rolled back).31 Form *state* runs on React Hook Form (`src/components/form/rhf/`), not Ant32 Design's `Form` store.33- Function components + hooks only; no class components.34- No `//` line comments in committed TS/TSX. HTML comments are fine.35- TS strict; `no-explicit-any` is an error. Build forms with `useZodForm` +36 `FormField` from `@/components/form/rhf` (wrap the tree in `FormProvider`);37 validate through the `zodResolver` or per-field38 `rules={{ validate: rhfZodValidate(Schema.shape.field) }}` — messages are Zod39 issue keys resolved via `t()`, never inline `z.string()`. AntD `<Form>` stays40 only as a layout wrapper. Complex shared config editors (FinalMask / Sniffing /41 Sockopt) remain AntD-`Form` islands wrapped as value/onChange adapters in42 `src/lib/xray/forms/fields/`, bound via a `Controller`.43- New `g.POST`/`g.GET` route => add it to `src/pages/api-docs/endpoints.ts`,44 then `npm run gen`.45- i18n strings live in `internal/web/translation/<locale>.json`, NOT under46 `frontend/`, and are shared with the Go backend. A new English key must be47 added to every locale. Interpolation here uses single braces `{var}`, not the48 i18next default `{{var}}`.49- Persian/Arabic (RTL) users are first-class — isolate code identifiers on their50 own line when writing Persian text in labels/toasts.51- Vite is pinned to an exact version (no `^`) — bump deliberately, then verify52 `npm run dev` AND `npm run build`.5354## Adding a panel route551. `src/pages/<page>/<Page>.tsx` (kebab folder, PascalCase component).562. Register in `src/routes.tsx` under `/panel` (lazy import).573. Add a sidebar link in `src/layouts/AppSidebar.tsx` if it needs nav.58Only standalone bundles (login/subpage) need a new `.html` + `src/entries/*` +59`rollupOptions.input` (in `vite.config.js`) + a Go controller route.6061## Commands62- `npm run dev` (HMR on :5173, proxies to the Go panel on :2053 — start Go first).63- `npm run typecheck` / `npm run lint` / `npm run test` / `npm run build`.64- `npm run gen` = `gen:zod` (Go → `src/generated/`) + `gen:api`65 (`build-openapi.mjs` → `public/openapi.json`).66- `npm run storybook` (workbench on :6006) / `npm run build-storybook` (CI67 compile-checks every story). Reusable `src/components/` get a co-located68 `<Component>.stories.tsx` with `tags: ['autodocs']`; document props via69 `argTypes` / `parameters.docs` string metadata, never JSDoc.70- After `npm run build`, RESTART `go run .` (see the XUI_DEBUG gotcha in root71 CLAUDE.md) before checking the panel.72
Also in MHSanaei/3x-ui
Diff this repo’s formatsOne repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| MHSanaei/3x-uiCLAUDE.md · 44k | CLAUDE.md | buildtestlint-formatstyle+4 | 82/100 | 2 days ago |
Similar configs
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| bagisto/bagistoCLAUDE.md · 28k | CLAUDE.md | setupbuildteststyle+5 | 100/100 | 3 days ago | |
| filamentphp/filamentCLAUDE.md · 32k | CLAUDE.md | buildtestlint-formatstyle+7 | 100/100 | 3 days ago | |
| stacklok/toolhiveCLAUDE.md · 2.0k | CLAUDE.md | buildteststylearch+4 | 100/100 | 3 days ago | |
| dotCMS/corecore-web/CLAUDE.md · 949 | CLAUDE.md | teststylearchtesting-strategy+3 | 100/100 | 3 days ago | |
| nimbalyst/nimbalystpackages/android/CLAUDE.md · 1.4k | CLAUDE.md | setupbuildstylearch+2 | 100/100 | 3 days ago | |
| microsoft/playwrightCLAUDE.md · 94k | CLAUDE.md | buildtestlint-formatstyle+7 | 100/100 | 3 days ago | |
| Adit-Jain-srm/NightmareNetCLAUDE.md · 45 | CLAUDE.md | buildtestlint-formatstyle+6 | 100/100 | 3 days ago | |
| dotCMS/coreCLAUDE.md · 949 | CLAUDE.md | setupbuildteststyle+7 | 99/100 | today |
