2.5 KiB
2.5 KiB
Repository Guidelines
Project Structure & Module Organization
This repository is split into two apps:
mengyaping-frontend/: React + Vite UI. Main code is insrc/(components/,pages/,hooks/,services/), with static assets inpublic/.mengyaping-backend/: Go + Gin API and monitor service. Core folders arehandlers/,services/,router/,models/,storage/,config/, andutils/.
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 indist/.npm run lint: run ESLint checks.
Backend (run inside mengyaping-backend/):
go mod tidy: sync Go modules.go run main.go: start API server (default0.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 inuseXxx.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.gonext to implementation; focus on handlers and service logic. - Frontend: if introducing test tooling, prefer Vitest + Testing Library with
*.test.jsxnaming.
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 filterfix(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/apiinmengyaping-frontend/src/services/api.js. - Commit only sanitized sample data in
mengyaping-backend/data/.