# Contributing to RustChat Thank you for contributing to RustChat. All contributions must be signed off per the [Developer Certificate of Origin (DCO)](DCO.md). Every commit must include a `Signed-off-by` line: ```bash git commit -s -m "feat: describe your change" ``` Pull requests will fail the required DCO check if any commit lacks this sign-off. AI agents and automated contributors should read [`AGENTS.md`](AGENTS.md) for the agent-specific workflow, allowed paths, scope boundaries, and validation commands before making any changes. For the detailed GitHub workflow (fork, branch, PR, reviews), see [docs/contributor-workflow.md](docs/contributor-workflow.md). ## Prerequisites - Rust `1.95+` (see `backend/Cargo.toml`) - Node.js `24+` (see `frontend/package.json` engines) - Docker + Docker Compose ## Development Setup 1. Clone your fork and enter the repository. 2. Copy environment defaults: ```bash cp .env.example .env ``` 3. Set required secrets in `.env`: - `RUSTCHAT_JWT_SECRET` - `RUSTCHAT_ENCRYPTION_KEY` - `RUSTCHAT_S3_ACCESS_KEY` - `RUSTCHAT_S3_SECRET_KEY` - `RUSTFS_ACCESS_KEY` - `RUSTFS_SECRET_KEY` 4. Start local dependencies: ```bash docker compose up -d postgres redis rustfs ``` 5. Run backend and frontend locally (separate terminals): ```bash cd backend && cargo run cd frontend && npm ci && npm run dev ``` Frontend package-management rules: - use `npm` only in `frontend/` - use `npm ci` for routine setup - keep `frontend/package-lock.json` committed - see [docs/frontend-dependency-policy.md](docs/frontend-dependency-policy.md) before adding or changing dependencies For full containerized startup, use: ```bash docker compose up -d --build ``` ## Project Structure | Path | Contents | |------|----------| | `backend/` | Rust API server (Axum 0.8 + Tokio) | | `frontend/` | Vue 3.5 + TypeScript SPA | | `push-proxy/` | Mobile push notification gateway | | `scripts/` | Smoke and utility scripts | | `tools/mm-compat/` | Python Mattermost compatibility tooling | | `docs/` | Project documentation | ## Code Quality Requirements Before opening a PR, run these checks. ### Backend Fast checks (run these before every PR): ```bash cd backend cargo fmt --all cargo clippy --all-targets --all-features -- -D warnings cargo check cargo test --lib --no-fail-fast -- --nocapture ``` Full integration tests (requires Docker infrastructure): ```bash # Start test services first: docker compose -f docker-compose.integration.yml up -d cd backend cargo test --no-fail-fast -- --nocapture # Then: docker compose -f docker-compose.integration.yml down -v ``` Run the full integration tests when your change touches auth, permissions, database migrations, API contracts, or compat-sensitive paths. ### Frontend ```bash cd frontend npm ci --ignore-scripts npm run check:dependency-policy npm run apply:dependency-patches npm run test:unit npm run build ``` ### Compatibility Smoke Tests Run these when touching v4 API/websocket/compatibility-sensitive behavior: ```bash ./scripts/mm_compat_smoke.sh ./scripts/mm_mobile_smoke.sh ``` ## Coding Guidelines - Keep code and documentation in English. - Keep functions focused and avoid unrelated refactors in the same PR. - Add or update tests for bug fixes and behavior changes whenever feasible. - Preserve API and websocket contract behavior unless the change explicitly targets it. ### Rust (Backend) - **Formatting:** `cargo fmt` — enforced in CI - **Linting:** `cargo clippy -- -D warnings` — enforced in CI - **Naming:** Follow Rust RFC 430 (`snake_case` for fns/vars, `CamelCase` for types) - **Error handling:** Use `thiserror` for error types, `Result` pattern - **Async:** Tokio runtime, prefer `async fn` for IO-bound work ### TypeScript/Vue (Frontend) - **Formatting:** Prettier with 2-space indent - **Linting:** ESLint with Vue 3 recommended rules - **Naming:** `camelCase` for functions/variables, `PascalCase` for components/types - **Components:** Composition API with `