Thanks for your interest in contributing!
- Rust 1.85+ (
rustup update stable) - Docker and Docker Compose
- PostgreSQL 14+ (or use Docker)
- protobuf compiler (
protoc)
# Clone
git clone https://github.com/lance0/prefixd.git
cd prefixd
# Start dependencies
docker compose up -d postgres gobgp
# Build
cargo build
# Run tests
cargo test --features test-utils
# Run with example config
cargo run -- --config ./configsIntegration tests require Docker (testcontainers):
# All tests including integration
cargo test --features test-utils
# GoBGP integration tests (requires gobgp container)
docker compose up -d gobgp
cargo test --test integration_gobgp -- --ignoredfeature/description- New featuresfix/description- Bug fixesdocs/description- Documentationrefactor/description- Code refactoring
Follow Conventional Commits:
feat: add IPv6 FlowSpec support
fix: handle GoBGP reconnection correctly
docs: update deployment guide for GoBGP v4
refactor: extract guardrails into separate module
test: add integration tests for reconciliation
- Fork the repository
- Create a feature branch
- Make your changes
- Run tests and lints
- Submit PR against
main
PRs should:
- Pass CI (tests, clippy, fmt)
- Include tests for new functionality
- Update documentation if needed
- Have a clear description
# Format code
cargo fmt
# Check formatting
cargo fmt -- --check# Run clippy
cargo clippy --all-targets --all-features -- -D warningsOptional but recommended:
# Install pre-commit
pip install pre-commit
pre-commit install
# Hooks run automatically on commitsrc/
├── alerting/ # Webhook alerting (Slack, Discord, Teams, PagerDuty, etc.)
├── api/ # HTTP handlers and routes
├── bgp/ # GoBGP client, FlowSpec construction
├── config/ # YAML configuration parsing
├── db/ # PostgreSQL repository
├── domain/ # Core types (AttackEvent, Mitigation, etc.)
├── guardrails/ # Safety validation
├── observability/ # Metrics, logging
├── policy/ # Policy engine, playbooks
├── scheduler/ # Reconciliation loop
├── auth/ # Authentication (sessions, operators)
├── ws/ # WebSocket handler
├── error.rs # Error types
├── state.rs # Shared application state
├── lib.rs # Public module exports
└── main.rs # CLI and startup
tests/
├── integration_*.rs # Integration tests (testcontainers)
└── ...
frontend/ # Next.js dashboard
docs/ # Documentation
configs/ # Example configuration files
proto/ # GoBGP protobuf definitions
# Run unit tests
cargo test
# Run with output
cargo test -- --nocapture
# Run specific test
cargo test test_name# Requires Docker
cargo test --features test-utils
# GoBGP tests (slower, require container)
cargo test --test integration_gobgp -- --ignored# Install tarpaulin
cargo install cargo-tarpaulin
# Generate coverage
cargo tarpaulin --out Html- Document public APIs with
///doc comments - Explain "why" not "what" in inline comments
- Use
// TODO:for future work
- Keep docs in
docs/directory - Update README.md for user-facing changes
- Update CHANGELOG.md for releases
We document significant design decisions in docs/adr/. When making a change that affects the system's architecture (new dependency, new pattern, structural change), add an ADR following the existing format. See ADR README for the index and template.
Releases are tagged from main:
# Update version in Cargo.toml
# Update CHANGELOG.md
# Commit and tag
git tag v0.14.1
git push origin v0.14.1CI builds and publishes:
- GitHub Release with binaries
- Docker image to ghcr.io
- Open an issue for bugs or feature requests
- Check existing issues before creating new ones
- Be respectful and constructive
By contributing, you agree that your contributions will be licensed under the MIT License.