# ๐ rapid-rs
> **Zero-config, batteries-included web framework for Rust**
> FastAPI meets Spring Boot, powered by Axum
[](https://crates.io/crates/rapid-rs)
[](https://docs.rs/rapid-rs)
[](LICENSE)
## 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
- ๐ **Type-Safe** - Compile-time guarantees for routes, validation, and serialization
- ๐ **Auto-Generated Docs** - Swagger UI and OpenAPI specs from your code
- โ
**Built-in Validation** - Request validation with helpful error messages
- ๐ฅ **Hot Reload** - Fast development cycle with `rapid dev`
- ๐จ **Opinionated Structure** - Convention over configuration
- ๐ **Production Ready** - Structured logging, error handling, health checks
## Quick Start
### Installation
```bash
cargo install rapid-rs-cli
```
**Note:** By default, rapid-rs includes Swagger UI for API documentation. If you encounter installation issues, you can install without it:
```bash
cargo add rapid-rs --no-default-features
```
To enable Swagger UI later:
```bash
cargo add rapid-rs --features swagger-ui
```
### Create Your First API
```bash
# Create a new project
rapid new myapi
# Run it
cd myapi
cargo run
```
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
```rust
use rapid_rs::prelude::*;
#[derive(Serialize, Deserialize)]
struct User {
id: Uuid,
name: String,
email: String,
}
#[derive(Deserialize, Validate)]
struct CreateUser {
#[validate(length(min = 2))]
name: String,
#[validate(email)]
email: String,
}
async fn create_user(
ValidatedJson(payload): ValidatedJson<CreateUser>
) -> ApiResult<User> {
let user = User {
id: Uuid::new_v4(),
name: payload.name,
email: payload.email,
};
Ok(Json(user))
}
#[tokio::main]
async fn main() {
App::new()
.auto_configure()
.route("/users", post(create_user))
.run()
.await
.unwrap();
}
```
That's it! You get:
- โ
Automatic request validation
- โ
Type-safe JSON serialization
- โ
Structured error responses
- โ
OpenAPI documentation
- โ
Request tracing and logging
## Comparison
| Type Safety | โ Runtime | โ ๏ธ Runtime | โ
Compile-time |
| Auto OpenAPI | โ
| โ
| โ
|
| 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 Management** - TOML files + environment variables
- **Database Integration** - PostgreSQL with connection pooling (SQLx)
- **Request Validation** - Derive-based validation with helpful errors
- **Error Handling** - Centralized error handling with proper HTTP status codes
- **CORS** - Sensible defaults, fully configurable
- **Logging & Tracing** - Structured logging with request correlation
- **Health Checks** - `/health` endpoint for orchestration
- **OpenAPI/Swagger** - Auto-generated docs at `/docs` (with `swagger-ui` feature, enabled by default)
### ๐ Swagger UI Configuration
**Enabled by default** - Swagger UI is included with the default features:
```toml
[dependencies]
rapid-rs = "0.1" # Includes Swagger UI
```
**Disable if needed** (smaller binary, faster compile):
```toml
[dependencies]
rapid-rs = { version = "0.1", default-features = false }
```
**Re-enable later**:
```toml
[dependencies]
rapid-rs = { version = "0.1", features = ["swagger-ui"] }
```
### ๐ฆ CLI Tool
```bash
# Create new project with template
rapid new myapi --template rest-api
# Run with hot reload
rapid dev
# Coming soon:
# rapid generate resource User
# rapid db migrate
```
## Configuration
Configuration is loaded from multiple sources (in order of priority):
1. `config/default.toml` - Base configuration
2. `config/local.toml` - Local overrides (gitignored)
3. Environment variables - Prefixed with `APP__`
```toml
# config/default.toml
[server]
host = "0.0.0.0"
port = 3000
[database]
url = "postgres://localhost/mydb"
max_connections = 10
```
Override with environment variables:
```bash
APP__SERVER__PORT=8080 cargo run
```
## Examples
Check out the [examples](https://github.com/ashishjsharda/rapid-rs/tree/main/examples) directory for:
- โ
**REST API** - Full CRUD with validation
- ๐ **GraphQL API** - Coming soon
- ๐ **gRPC Service** - Coming soon
- ๐ **WebSocket Chat** - Coming soon
## Roadmap
### Phase 1 (Current)
- [x] Core framework with auto-configuration
- [x] Request validation
- [x] OpenAPI generation
- [x] CLI tool for project scaffolding
- [x] Hot reload support
### Phase 2 (Next)
- [ ] Authentication & Authorization (JWT, sessions)
- [ ] Database migrations management
- [ ] Testing utilities
- [ ] More templates (GraphQL, gRPC)
### Phase 3 (Future)
- [ ] Background jobs
- [ ] Multi-tenancy support
- [ ] Feature flags
- [ ] Admin panel generation
## Contributing
Contributions are welcome! This is an early-stage project with lots of opportunities to make an impact.
### Development Setup
```bash
git clone https://github.com/ashishjsharda/rapid-rs
cd rapid-rs
cargo build
cargo test
# Run the example
cd examples/rest-api
cargo run
```
## Philosophy
**rapid-rs** is built on these principles:
1. **Convention over Configuration** - Sensible defaults, minimal boilerplate
2. **Type Safety First** - Leverage Rust's type system to catch errors at compile time
3. **Developer Experience** - Make the common case easy, the hard case possible
4. **Production Ready** - Include observability, error handling, and best practices by default
5. **Composable** - Built on Axum, use Axum patterns when you need them
## Why Not Just Use Axum?
**Axum** is fantastic - it's the foundation of rapid-rs! But Axum is intentionally minimal and unopinionated. You need to wire up:
- Configuration loading
- Database connections
- Validation
- Error handling patterns
- OpenAPI generation
- Logging setup
- CORS
- Project structure
**rapid-rs** gives you all of this out of the box, while still giving you access to the full power of Axum when you need it.
## License
Licensed under either of:
- Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
at your option.
## Credits
Built by [Ashish Sharda](https://github.com/ashishjsharda)
Standing on the shoulders of giants:
- [Axum](https://github.com/tokio-rs/axum) - The excellent web framework this is built on
- [FastAPI](https://fastapi.tiangolo.com/) - Inspiration for developer experience
- [Spring Boot](https://spring.io/projects/spring-boot) - Inspiration for conventions
---
**Star โญ this repo if you find it useful!**
[Report Bug](https://github.com/ashishjsharda/rapid-rs/issues) ยท [Request Feature](https://github.com/ashishjsharda/rapid-rs/issues) ยท [Documentation](https://docs.rs/rapid-rs)