# Repository Guidelines ## Project Structure & Module Organization This repository is split into two apps: - `mengyaping-frontend/`: React + Vite UI. Main code is in `src/` (`components/`, `pages/`, `hooks/`, `services/`), with static assets in `public/`. - `mengyaping-backend/`: Go + Gin API and monitor service. Core folders are `handlers/`, `services/`, `router/`, `models/`, `storage/`, `config/`, and `utils/`. Runtime data is persisted under `mengyaping-backend/data/` (`websites.json`, `records.json`, `groups.json`, `config.json`). Keep data format changes backward-compatible. ## Build, Test, and Development Commands Frontend (run inside `mengyaping-frontend/`): - `npm install`: install dependencies. - `npm run dev`: start Vite dev server. - `npm run build`: create production build in `dist/`. - `npm run lint`: run ESLint checks. Backend (run inside `mengyaping-backend/`): - `go mod tidy`: sync Go modules. - `go run main.go`: start API server (default `0.0.0.0:8080`). - `go test ./...`: run all backend tests. - `docker compose up -d --build`: build and run containerized backend. ## Coding Style & Naming Conventions - Frontend: 2-space indentation, ES module imports, React component files in PascalCase (for example `WebsiteCard.jsx`), hooks in `useXxx.js`, utility/service functions in camelCase. - Backend: format with `gofmt`; keep package names lowercase; exported identifiers in PascalCase, internal helpers in camelCase. - Keep handlers thin and place business logic in `services/`. ## Testing Guidelines There are currently no committed frontend tests and minimal backend test coverage. Add tests for every non-trivial change: - Backend: `*_test.go` next to implementation; focus on handlers and service logic. - Frontend: if introducing test tooling, prefer Vitest + Testing Library with `*.test.jsx` naming. ## Commit & Pull Request Guidelines Current history uses short, imperative commit text (for example `first commit`). Continue with concise, scoped messages such as: - `feat(frontend): add status filter` - `fix(backend): validate monitor interval` Each PR should include: - Clear summary and impacted area (`frontend`, `backend`, or both). - Validation steps and commands run. - Screenshots/GIFs for UI changes. - Linked issue/ticket when available. ## Security & Configuration Tips - Do not commit secrets, tokens, or private endpoints. - Frontend dev API target is `http://localhost:8080/api` in `mengyaping-frontend/src/services/api.js`. - Commit only sanitized sample data in `mengyaping-backend/data/`.