# Contributing to Website Monitoring ## Branch Strategy ``` main ← production-ready, protected └─ develop ← integration branch └─ feature/xxx ← your work └─ fix/xxx ← bug fixes └─ chore/xxx ← maintenance ``` ### Rules - **Never push directly to `main`** — always open a PR - Branch from `develop` for features, from `main` for hotfixes - Delete branches after merge ## Development Setup ```bash # Clone & install git clone cd website-monitoring npm install # Install project dependencies cd website-monitoring-backend && npm install && cd .. cd website-monitoring-frontend && npm install && cd .. # Start everything npm run dev ``` ## Workflow 1. **Create a branch**: `git checkout -b feature/my-feature develop` 2. **Make changes**: Write code, add tests 3. **Verify locally**: ```bash npm run lint # No errors npm run test # All pass npm run build # Compiles clean ``` 4. **Commit**: Use [Conventional Commits](https://www.conventionalcommits.org/) ``` feat: add uptime monitoring endpoint fix: resolve SSE connection leak chore: update lighthouse dependency docs: add API endpoint documentation test: add lighthouse service unit tests ``` 5. **Push & open PR**: Target `develop` (or `main` for hotfixes) ## Code Review Checklist - [ ] Code compiles and all tests pass - [ ] New code has tests - [ ] No `console.log` left in production code (use proper logger) - [ ] TypeScript types are explicit (minimize `any`) - [ ] API changes are documented - [ ] Environment variables documented in `.env.example` - [ ] No secrets committed ## Code Style - **TypeScript** everywhere (no plain JS) - **ESLint** for linting — `npm run lint` - **Prettier** for formatting — auto-runs on commit via Husky - Use `async/await` over `.then()` chains - Prefer named exports over default exports ## Testing - **Backend**: Jest + Supertest — `cd website-monitoring-backend && npm test` - **Frontend**: Jest + Testing Library — `cd website-monitoring-frontend && npm test` - Aim for tests on all API endpoints and critical business logic - Use meaningful test names: `it("should return 400 when URL is missing")` ## Docker ```bash # Full stack with Docker Compose npm run docker:up # Tear down npm run docker:down ```