|
| 1 | +# Repository Guidelines |
| 2 | + |
| 3 | +## Project Structure & Module Organization |
| 4 | +- Crate source lives in `src/` with one module per Supabase service (`auth.rs`, `postgrest.rs`, `storage.rs`, `functions.rs`, `graphql.rs`, `realtime.rs`, `analytics.rs`); `lib.rs` re-exports them. |
| 5 | +- Shared constants and errors sit in `consts.rs` and `error.rs`; add cross-cutting values there before duplicating literals. |
| 6 | +- Integration coverage is in `tests/auth_integration.rs` and spins up real containers via Testcontainers, so Docker must be running. |
| 7 | +- Reference docs live in `docs/`; `README.md` shows usage patterns. Build artifacts land in `target/` and stay untracked. |
| 8 | + |
| 9 | +## Build, Test, and Development Commands |
| 10 | +- `cargo build --all-features` — compile with every service flag to catch cfg gaps; narrow scope with `--features "<list>"` when iterating. |
| 11 | +- `cargo fmt --all` — format with rustfmt; run before pushing. |
| 12 | +- `cargo clippy --all-targets --all-features -D warnings` — lint everything; prefer fixes over `allow` unless unavoidable. |
| 13 | +- `cargo test --features auth,const --test auth_integration -- --nocapture` — integration tests against real containers; first run pulls images and may take minutes. |
| 14 | + |
| 15 | +## Coding Style & Naming Conventions |
| 16 | +- Rustfmt defaults (4-space indent); keep imports explicit and prefer early returns over deep nesting. |
| 17 | +- Modules/functions use `snake_case`; public structs/enums use `PascalCase`; constants use `SCREAMING_SNAKE_CASE`. |
| 18 | +- Keep feature gates tight and named after services (`auth`, `postgrest`, `storage`, etc.); document new flags in `Cargo.toml` and `README.md`. |
| 19 | +- Use `anyhow::Result` for setup paths and `thiserror` for user-facing error types; add short doc comments for public items. |
| 20 | + |
| 21 | +## Testing Guidelines |
| 22 | +- Docker is mandatory; tests start PostgreSQL and service containers. |
| 23 | +- Name new integration files `tests/<service>_integration.rs` and test functions `test_<behavior>` for clarity. |
| 24 | +- Include a health or behavior check per service (e.g., `/health` plus one request). |
| 25 | +- For parallel runs, generate unique networks/container names (see `unique_test_id()` in the Auth suite) to avoid port collisions. |
| 26 | + |
| 27 | +## Commit & Pull Request Guidelines |
| 28 | +- Follow Conventional Commits used here (`feat`, `docs`, `chore`, `fix`, optional scopes); keep messages imperative. |
| 29 | +- PRs should note behavior changes, enabled features (if not `--all-features`), and commands run (fmt, clippy, tests). |
| 30 | +- Link related issues and attach logs or screenshots for user-visible changes; keep diffs focused and split unrelated tweaks. |
| 31 | + |
| 32 | +## Security & Configuration Tips |
| 33 | +- Never commit real credentials; mirror the test pattern of generated passwords and isolated networks. |
| 34 | +- Pin explicit image tags instead of `latest`; match versions documented in `README.md`. |
| 35 | +- Prefer Testcontainers-managed dynamic ports; expose only what the test actually needs. |
0 commit comments