Skip to content
/ rustapi Public template

A modern, high-performance REST API template built with Rust using Axum framework and clean architecture principles.

License

Notifications You must be signed in to change notification settings

uuhnaut69/rustapi

RustAPI

A modern, high-performance REST API template built with Rust using Axum framework and clean architecture principles.

🚀 Features

  • 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

🏗️ Architecture

src/
├── domain/           # Business logic and entities
├── application/      # Use cases and business rules  
├── infrastructure/   # External concerns (HTTP, DB, etc.)
├── lib.rs
└── main.rs

🛠️ Quick Start

  1. Clone and setup

    git clone <repository-url> your-project-name
    cd your-project-name
    rm -rf .git && git init
  2. Update project details in Cargo.toml

  3. Run the application

    # Development
    cargo run
    
    # With Docker (includes Redis + PostgreSQL)
    docker-compose up -d

The API will be available at http://localhost:3000

📖 API Documentation

Endpoints

  • GET /health - Health check endpoint

🔧 Development

# Testing
cargo test

# Formatting & Linting
cargo fmt
cargo clippy

# Coverage
cargo install cargo-tarpaulin
cargo tarpaulin --out html

🐳 Docker Services

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

⚙️ Configuration

Variable Description Default
PORT Server port 3000
RUST_LOG Logging level info

🎯 Next Steps

  1. Add domain models in src/domain/
  2. Implement business logic in src/application/
  3. Create HTTP handlers in src/infrastructure/http/
  4. Add database repositories and integrations
  5. Extend OpenAPI documentation
  6. Configure authentication and authorization

📝 License

Licensed under the Apache License 2.0 - see LICENSE file for details.

About

A modern, high-performance REST API template built with Rust using Axum framework and clean architecture principles.

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages