A modern, scalable backend service built with Rust and Axum, following Domain-Driven Design (DDD) and Clean Architecture principles.
This project implements a layered architecture designed for maintainability and scalability.
- Domain Layer: Pure business logic, entities, and value objects. Zero external dependencies.
- Application Layer: Use cases, DTOs, and business orchestration.
- Infrastructure Layer: Database repositories (Diesel), email services (Lettre), configuration.
- Presentation Layer: HTTP REST API (Axum), routing, middleware, and documentation (Swagger).
📖 Read the Full Architecture Guide
- Rust: 1.75+ (
rustup update) - Docker: For running the database and local development environment.
- Cargo Make (Optional): For running workflows.
We provide a standalone script to bootstrap the entire environment (Database + App + Monitoring):
./docker/backend/run_container.shThis will:
- Start PostgreSQL (with
axumuser andaxum_backenddb). - Run
cargo checkandcargo fmt. - Build the release binary.
- Launch the application container on
hostnetwork.
Access Points:
- API:
http://localhost:3000 - Swagger UI:
http://localhost:3000/swagger-ui/ - Example Endpoint:
GET http://localhost:3000/api/health
We use distinct Cargo profiles for different stages:
| Profile | Command | Use Case |
|---|---|---|
| Dev | cargo run |
Fast compilation, full debug info. |
| Staging | cargo build --profile staging |
Optimized but with debug symbols for profiling. |
| Release | cargo build --release |
Max performance, LTO, stripped symbols. |
We have a robust testing suite covering unit, integration, and flow tests.
# Run all tests
./tests/run_tests.sh all
# Run specific category
./tests/run_tests.sh authentication
./tests/run_tests.sh usersaxum_backend/
├── src/
│ ├── domain/ # Entities, Value Objects, Repository Traits
│ ├── application/ # Use Cases, DTOs, Commands, Queries
│ ├── infrastructure/ # Database (Diesel), Email, Config
│ ├── presentation/ # Routes, Handlers, Middleware
│ └── shared/ # Errors, Utils, Telemetry
├── tests/ # Integration tests
├── migrations/ # Diesel SQL migrations
├── docker/ # Dockerfiles and scripts
│ ├── backend/ # App container setup
│ └── postgres-docker/ # DB container setup with init scripts
├── docs/ # Detailed documentation
└── Cargo.toml # Dependencies & Build Profiles
- Core: Rust, Tokio
- Web Framework: Axum 0.7
- Database: PostgreSQL 16, Diesel 2.1 (ORM & Migrations)
- Auth: JWT (Access + Refresh Tokens), Argon2 hashing
- Observability: Tracing, Prometheus Metrics
- Documentation: Utoipa (OpenAPI/Swagger)
- Email: Lettre (SMTP)
- Follow the Architecture: Keep logic in the correct layer.
- Run Tests: Ensure
./tests/run_tests.sh allpasses. - Format:
cargo fmtis enforced by the build pipeline.
MIT License. See LICENSE for details.