๐ rapid-rs
Zero-config, batteries-included web framework for Rust
FastAPI meets Spring Boot, powered by Axum
๐ What's New in v0.3.0
Phase 2 Complete! ๐
- ๐๏ธ Database Migrations - Automatic migration management with sqlx
- ๐งช Testing Utilities - Comprehensive testing framework for APIs
- ๐ GraphQL & gRPC Templates - Ready-to-use project scaffolding
// Database with auto-migrations
use ;
let pool = connect_and_migrate.await?;
// Easy API testing
use TestClient;
let client = new;
let response = client.get.await;
response.assert_status;
Why rapid-rs?
Building web APIs in Rust shouldn't require wiring together 10+ crates and writing hundreds of lines of boilerplate. rapid-rs gives you the productivity of FastAPI and Spring Boot, with Rust's performance and type safety.
โก Features
- ๐ฏ Zero Config - Database, migrations, CORS, logging work out of the box
- ๐๏ธ Auto Migrations - Database migrations run automatically on startup (NEW!)
- ๐ Built-in Auth - JWT authentication, password hashing, RBAC
- ๐งช Testing Suite - Comprehensive testing utilities included (NEW!)
- ๐ Type-Safe - Compile-time guarantees for routes, validation, serialization
- ๐ Auto Docs - Swagger UI and OpenAPI specs from your code
- โ Validation - Request validation with helpful error messages
- ๐ฅ Hot Reload - Fast development with
rapid dev - ๐จ Opinionated - Convention over configuration
- ๐ Production Ready - Structured logging, error handling, health checks
Quick Start
Installation
Create Your First API
# REST API (default)
# GraphQL API (NEW!)
# gRPC service (NEW!)
Your API is now running at:
- ๐ http://localhost:8080 - API endpoints
- ๐ http://localhost:8080/docs - Swagger UI
- ๐ http://localhost:8080/health - Health check
Your First Endpoint with Database
use *;
use ;
async
async
That's it! You get:
- โ Automatic database creation
- โ Automatic migration running
- โ Request validation
- โ Type-safe database queries
- โ Structured error handling
- โ OpenAPI documentation
Comparison
| Feature | FastAPI | Spring Boot | rapid-rs |
|---|---|---|---|
| Type Safety | โ Runtime | โ ๏ธ Runtime | โ Compile-time |
| Auto OpenAPI | โ | โ | โ |
| Auto Migrations | โ ๏ธ Alembic | โ | โ |
| Testing Utils | โ ๏ธ Partial | โ | โ |
| Hot Reload | โ | โ | โ |
| Zero Config | โ | โ | โ |
| Performance | โ ๏ธ Good | โ ๏ธ Good | โ Blazing Fast |
| Memory Safety | โ | โ | โ Guaranteed |
| Async by Default | โ ๏ธ Partial | โ | โ |
| Learning Curve | Easy | Medium | Easy |
What's Included?
๐ Out of the Box
- Configuration - TOML files + environment variables
- Authentication - JWT-based auth with role-based access control
- Database - PostgreSQL with connection pooling and migrations
- Validation - Derive-based validation with helpful errors
- Error Handling - Centralized error handling with proper HTTP codes
- CORS - Sensible defaults, fully configurable
- Logging - Structured logging with request correlation
- Health Checks -
/healthendpoint for orchestration - OpenAPI/Swagger - Auto-generated docs at
/docs - Testing - Comprehensive testing utilities (NEW!)
๐ฆ CLI Tool
# Create project with template
||
# Run with hot reload
๐ Project Templates
- REST API - Full CRUD with authentication and database
- GraphQL API - async-graphql with subscriptions support
- gRPC Service - tonic-based microservice template
Database Migrations
Migrations run automatically on startup:
use ;
let config = new
.migrations_path
.auto_migrate
.create_db_if_missing;
let pool = connect_and_migrate.await?;
Create migrations with sqlx-cli:
Learn more about migrations โ
Testing Your API
Built-in testing utilities make API testing a breeze:
use TestClient;
async
Authentication
Complete JWT authentication system included:
use ;
// Protected route
async
async
Learn more about authentication โ
Configuration
Configuration loads from multiple sources:
# config/default.toml
[]
= "0.0.0.0"
= 8080
[]
= "postgres://localhost/mydb"
Override with environment variables:
APP__SERVER__PORT=8080
AUTH_JWT_SECRET="your-secret-key"
Examples
Check out the examples directory:
- โ REST API - Full CRUD with validation and database
- โ Auth API - JWT authentication with protected routes
- โ GraphQL API - Complete GraphQL server (NEW!)
- โ gRPC Service - Microservice with protocol buffers (NEW!)
Roadmap
Phase 1 โ Complete
- Core framework with auto-configuration
- Request validation
- OpenAPI generation
- CLI tool
- Hot reload
Phase 2 โ Complete (v0.3.0)
- Authentication & Authorization
- Database migrations management
- Testing utilities
- GraphQL template
- gRPC template
Phase 3 (Future)
- Background jobs
- WebSocket support
- Multi-tenancy
- Feature flags
- Admin panel generation
- Metrics and observability
- Rate limiting
- Caching layer
Contributing
Contributions welcome! This project has completed Phase 2 with lots of opportunities for Phase 3 features.
Development Setup
# Run examples
Philosophy
rapid-rs is built on these principles:
- Convention over Configuration - Sensible defaults, minimal boilerplate
- Type Safety First - Leverage Rust's type system
- Developer Experience - Make the common case easy
- Production Ready - Observability and best practices by default
- Composable - Built on Axum, use Axum patterns when needed
Why Not Just Use Axum?
Axum is fantastic - rapid-rs is built on it! But Axum is intentionally minimal. You still wire up:
- Configuration loading
- Database connections
- Migrations
- Validation
- Error handling
- OpenAPI generation
- Logging
- CORS
- Authentication
- Testing utilities
rapid-rs gives you all of this out of the box.
Documentation
- ๐ API Documentation
- ๐ Authentication Guide
- ๐๏ธ Migrations Guide
- ๐งช Testing Guide
- ๐ค Contributing Guide
- ๐ Changelog
License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE)
- MIT license (LICENSE-MIT)
at your option.
Credits
Built by Ashish Sharda
Standing on the shoulders of giants:
- Axum - The excellent web framework
- sqlx - Async SQL toolkit
- FastAPI - Inspiration for developer experience
- Spring Boot - Inspiration for conventions
Star โญ this repo if you find it useful!