Thank you for taking the time to contribute! The following guidelines will help you get the project running locally and understand the workflow for submitting changes.
- Code of Conduct
- Getting Started
- Development Workflow
- Coding Guidelines
- Adding a New Endpoint
- Database Migrations
- Testing
- Commit Messages
- Pull Request Process
- Reporting Bugs
- Suggesting Features
Please be respectful and constructive in all interactions. We follow the Contributor Covenant.
-
Fork the repository and clone your fork locally.
-
Make sure you have Rust (edition 2021) and PostgreSQL 12+ installed.
-
Copy the example environment file and configure it:
cp .env.example .env # Edit .env with your local PostgreSQL credentials and Stellar network settings -
Build the project to confirm everything compiles:
cargo build
-
Run the server:
cargo run
The server applies pending migrations automatically on startup and listens on
0.0.0.0:8000by default.
-
Create a feature branch from
main:git checkout -b feat/my-feature
-
Make your changes (see the guidelines below).
-
Run the test suite to make sure nothing is broken:
cargo test -
Run
cargo clippyto catch common mistakes:cargo clippy -- -D warnings
-
Format your code with
rustfmt:cargo fmt
-
Commit your changes (see Commit Messages) and open a pull request.
- Follow standard Rust idioms and the Rust API Guidelines.
- Keep functions small and focused; delegate database work to the
controllers/layer. - Use
anyhow::Resultfor fallible functions that call external services or the database. - Use
thiserrorfor domain-specific error types. - Log with the
tracingmacros (tracing::info!,tracing::error!, etc.) rather thanprintln!. - Do not commit secrets or
.envfiles. The.gitignorealready excludes.env.
The project follows a layered architecture:
Routes → Controllers → Services → Database
- Model – Add any new structs (request body, response body, DB row) to
src/models/. - Controller – Add the database query or business logic function to
src/controllers/. - Route – Wire the handler to an HTTP path in
src/routes/and call the controller. - Register – Mount the new router in
src/main.rsif you created a new route file. - Migration – If the feature requires a schema change, add a migration (see below).
- Tests – Add at least one test that exercises the happy path.
Migrations are plain SQL files in the migrations/ directory and run automatically on server startup.
Install the SQLx CLI if you need to manage them manually:
cargo install sqlx-cliCommon commands:
# Create a new migration pair (up + down)
sqlx migrate add -r <migration_name>
# Apply pending migrations
sqlx migrate run
# Revert the most recent migration
sqlx migrate revertName migrations sequentially (e.g. 0003_add_index_to_tips) so they apply in the correct order.
Tests use axum-test to exercise handlers in-process.
# Run all tests
cargo test
# Include stdout/stderr output
cargo test -- --nocapture
# Run a specific test by name
cargo test <test_name>Every new feature or bug fix should be accompanied by a test that demonstrates the expected behaviour.
Use the Conventional Commits format:
<type>(<optional scope>): <short description>
[optional body]
[optional footer]
Common types: feat, fix, docs, refactor, test, chore.
Examples:
feat(tips): add pagination to GET /creators/:username/tips
fix(stellar): handle timeout errors from Horizon API
docs: update API reference in README
- Ensure
cargo test,cargo clippy, andcargo fmt --checkall pass. - Give your PR a descriptive title following the Conventional Commits format.
- Fill in the PR description with a summary of what changed and why.
- Link any related issues (e.g.
Closes #42). - Request a review from a maintainer.
- Address review comments and push additional commits to the same branch.
A maintainer will merge the PR once it is approved.
Open a GitHub issue and include:
- A clear, descriptive title.
- Steps to reproduce the problem.
- Expected behaviour vs. actual behaviour.
- Relevant logs, error messages, or screenshots.
- Your environment (OS, Rust version, PostgreSQL version).
Open a GitHub issue with the label enhancement and describe:
- The problem you want to solve.
- Your proposed solution or API changes.
- Any alternatives you considered.