Thank you for your interest in contributing to SOAR! This guide will help you get started with development.
- Prerequisites
- Development Setup
- Project Structure
- Development Workflow
- Code Style and Standards
- Testing
- Database Development
- Troubleshooting
Before you start, ensure you have the following installed:
-
Rust (latest stable)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh source ~/.cargo/env
-
Bun (version 1.0 or higher)
curl -fsSL https://bun.sh/install | bash -
PostgreSQL (version 15 or higher) with PostGIS
# Ubuntu/Debian sudo apt-get install postgresql postgresql-contrib postgis # macOS (with Homebrew) brew install postgresql postgis # Start PostgreSQL service sudo systemctl start postgresql # Linux brew services start postgresql # macOS
-
Git (for version control)
- Docker (for isolated database testing)
- pgAdmin or psql (for database management)
git clone <repository-url>
cd soarRun our automated setup script:
# This installs Diesel CLI, cargo-audit, cargo-outdated, and web dependencies
./scripts/install-dev-tools.sh# This installs pre-commit and configures hooks that match our CI pipeline
./scripts/setup-precommit.sh# Copy the example environment file
cp .env.example .env
# Edit .env with your settings
# Key variables to configure:
# - DATABASE_URL: Your PostgreSQL connection string
# - NATS_URL: NATS server URL (default: nats://localhost:4222)
# - GOOGLE_MAPS_API_KEY: For geocoding features# Create the main development database
createdb soar_dev
psql -d soar_dev -c "CREATE EXTENSION IF NOT EXISTS postgis;"
psql -d soar_dev -c "CREATE EXTENSION IF NOT EXISTS pg_trgm;"
# Set DATABASE_URL for development
export DATABASE_URL="postgres://username:password@localhost:5432/soar_dev"
# Run migrations
diesel migration run# Create the test database
createdb soar_test
psql -d soar_test -c "CREATE EXTENSION IF NOT EXISTS postgis;"
psql -d soar_test -c "CREATE EXTENSION IF NOT EXISTS pg_trgm;"
# Test database URL (used by tests and pre-commit hooks)
export DATABASE_URL="postgres://username:password@localhost:5432/soar_test"
diesel migration run# Download and install NATS server
wget https://github.com/nats-io/nats-server/releases/download/v2.11.8/nats-server-v2.11.8-amd64.deb
sudo dpkg -i nats-server-*.deb
rm nats-server-*.deb
# Start NATS server
nats-server &# Test Rust build
cargo build
# Test web build
cd web && bun run build && cd ..
# Run all pre-commit checks
pre-commit run --all-files
# Run tests
cargo test
cd web && bun run test && cd ..soar/
├── src/ # Rust source code
│ ├── actions/ # HTTP route handlers
│ ├── aprs_client/ # APRS-IS client implementation
│ ├── web.rs # Web server setup
│ └── main.rs # Application entry point
├── web/ # SvelteKit frontend
│ ├── src/
│ │ ├── routes/ # SvelteKit pages
│ │ ├── lib/ # Shared components and utilities
│ │ └── app.html # HTML template
│ └── package.json
├── migrations/ # Database migrations (Diesel)
├── scripts/ # Development and deployment scripts
├── .github/workflows/ # CI/CD configuration
├── .pre-commit-config.yaml # Pre-commit hook configuration
└── README.md
# Create a new branch for your feature/fix
git checkout -b feature/your-feature-name
# Make sure your environment is up to date
git pull origin main
./scripts/install-dev-tools.sh # If dependencies changed- Write your code following the established patterns
- Add tests for new functionality
- Update documentation as needed
- Run pre-commit hooks:
pre-commit run --all-files
# Format code
cargo fmt
cd web && bun run format && cd ..
# Run all checks locally (same as CI)
cargo clippy --all-targets --all-features -- -D warnings
cargo test
cd web && bun run lint && bun run check && bun run test && cd ..
# Or let pre-commit handle it
pre-commit run --all-files# Stage your changes
git add .
# Commit (pre-commit hooks will run automatically)
git commit -m "feat: add your feature description"
# Push to your branch
git push origin feature/your-feature-name- Use
cargo fmtfor formatting (enforced by CI) - Follow Rust naming conventions
- Use
clippyfor linting (enforced by CI) - Write documentation for public APIs
- Use
anyhow::Resultfor error handling - Prefer
tracingoverprintln!for logging
- Use Prettier for formatting (enforced by CI)
- Follow TypeScript best practices
- Use oxlint configuration (enforced by CI)
- Write type-safe code with proper TypeScript types
- Use Svelte 5 syntax and patterns
- Use descriptive table and column names
- Include proper indexes for queries
- Write both
up.sqlanddown.sqlfor migrations - Use UUID primary keys for new tables
- Include proper foreign key constraints
Follow conventional commit format:
type(scope): description
feat: add new feature
fix: correct bug
docs: update documentation
style: formatting changes
refactor: code restructuring
test: add or update tests
chore: maintenance tasks
# Run all Rust tests
cargo test
# Run tests with output
cargo test -- --nocapture
# Run specific test
cargo test test_name
# Run tests with coverage (requires cargo-tarpaulin)
cargo tarpaulin --out htmlcd web
# Run E2E tests with Playwright
bun run test
# Run tests in headed mode (see browser)
bun run test:headed
# Run specific test file
bunx playwright test tests/example.spec.ts- Tests automatically use the test database
- Database is reset between test runs
- Use transactions in tests to avoid side effects
# Create a new migration
diesel migration generate migration_name
# This creates two files:
# migrations/yyyy-mm-dd-hhmmss_migration_name/up.sql
# migrations/yyyy-mm-dd-hhmmss_migration_name/down.sql-
Always test both up and down migrations:
diesel migration run diesel migration revert diesel migration run
-
Use transactions for complex migrations:
-- up.sql BEGIN; -- Your migration commands here COMMIT;
-
Add indexes for performance:
CREATE INDEX CONCURRENTLY idx_table_column ON table_name (column_name);
- Use proper spatial indexes:
CREATE INDEX ON table_name USING GIST (geom_column); - Use appropriate SRID (4326 for WGS84 lat/lng)
- Test spatial queries thoroughly
-
Pre-commit hooks failing:
# Fix formatting issues cargo fmt cd web && bun run format && cd .. # Update hooks pre-commit autoupdate
-
Database connection errors:
# Check PostgreSQL is running sudo systemctl status postgresql # Check database exists psql -l # Verify DATABASE_URL in .env echo $DATABASE_URL
-
Rust compilation errors:
# Clean build cache cargo clean # Update dependencies cargo update # Check Rust version rustc --version
-
Web build errors:
cd web # Clear node_modules and reinstall rm -rf node_modules bun.lock bun install # Clear build cache rm -rf .svelte-kit build
-
NATS connection issues:
# Check NATS is running ps aux | grep nats-server # Start NATS server nats-server & # Check NATS_URL in .env
- Check existing GitHub Issues
- Review the GitHub Discussions
- Look at CI logs for similar failures
- Ask questions in the project chat/forum
-
Use cargo-watch for auto-rebuilding:
cargo install cargo-watch cargo watch -x run
-
Use browser dev tools for frontend debugging
-
Enable detailed logging:
export RUST_LOG=debug cargo run -
Use database GUI tools:
- pgAdmin for PostgreSQL management
- PostGIS extensions for spatial data
Thank you for contributing to SOAR! Your help makes this project better for everyone.