A modern, high-performance REST API template built with Rust using Axum framework and clean architecture principles.
- High Performance: Rust + Axum for speed and memory efficiency
- Clean Architecture: Domain, application, and infrastructure layers
- OpenAPI Documentation: Auto-generated docs with Swagger UI and Scalar
- Observability: Health checks, structured logging, and tracing
- Production Ready: CORS, compression, timeouts, Docker support
- Development Tools: Pre-configured linting, formatting, and testing
src/
├── domain/ # Business logic and entities
├── application/ # Use cases and business rules
├── infrastructure/ # External concerns (HTTP, DB, etc.)
├── lib.rs
└── main.rs
-
Clone and setup
git clone <repository-url> your-project-name cd your-project-name rm -rf .git && git init
-
Update project details in
Cargo.toml
-
Run the application
# Development cargo run # With Docker (includes Redis + PostgreSQL) docker-compose up -d
The API will be available at http://localhost:3000
- Swagger UI: http://localhost:3000/swagger-ui
- Scalar UI: http://localhost:3000/scalar
- OpenAPI JSON: http://localhost:3000/api-docs/openapi.json
- GET
/health
- Health check endpoint
# Testing
cargo test
# Formatting & Linting
cargo fmt
cargo clippy
# Coverage
cargo install cargo-tarpaulin
cargo tarpaulin --out html
The compose.yaml
includes:
- Redis: Port 6379 (UI: 8001)
- PostgreSQL: Port 5432 (postgres/postgres)
# Start services
docker-compose up -d
# View logs
docker-compose logs -f
# Stop and cleanup
docker-compose down -v
Variable | Description | Default |
---|---|---|
PORT |
Server port | 3000 |
RUST_LOG |
Logging level | info |
- Add domain models in
src/domain/
- Implement business logic in
src/application/
- Create HTTP handlers in
src/infrastructure/http/
- Add database repositories and integrations
- Extend OpenAPI documentation
- Configure authentication and authorization
Licensed under the Apache License 2.0 - see LICENSE file for details.