https://github.com/arferreira/rapina
An opinionated Rust web framework exploring better DX in an AI-assisted world
https://github.com/arferreira/rapina
api async fastapi http hyper rest-api rust tokio web-framework
Last synced: 4 months ago
JSON representation
An opinionated Rust web framework exploring better DX in an AI-assisted world
- Host: GitHub
- URL: https://github.com/arferreira/rapina
- Owner: arferreira
- License: mit
- Created: 2026-01-15T04:26:05.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2026-01-22T05:08:04.000Z (5 months ago)
- Last Synced: 2026-01-22T18:55:59.408Z (5 months ago)
- Topics: api, async, fastapi, http, hyper, rest-api, rust, tokio, web-framework
- Language: Rust
- Homepage:
- Size: 366 KB
- Stars: 2
- Watchers: 0
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Rapina
A Rust web framework for APIs. So simple it feels like cheating.
---
```rust
use rapina::prelude::*;
#[get("/users")]
async fn list_users(db: Db) -> Result>> {
let users = User::find_all(db.conn()).await?;
Ok(Json(users))
}
#[post("/users")]
async fn create_user(input: Validated>, db: Db) -> Result> {
let user = User::create(db.conn(), input.into_inner()).await?;
Ok(Json(user))
}
#[tokio::main]
async fn main() -> std::io::Result<()> {
Rapina::new()
.discover()
.listen("127.0.0.1:3000")
.await
}
```
No router configuration. No manual wiring. Annotate your handlers, call `.discover()`, ship.
## Get started
```bash
cargo install rapina-cli
rapina new my-app
cd my-app
rapina dev
```
Your API is running. That's it.
## What you get
**Auto-discovery** — annotate handlers with `#[get]`, `#[post]`, `#[put]`, `#[delete]`. Rapina finds them at startup. Your `main.rs` stays three lines.
**Database from day one** — define your schema declaratively. `author: User` becomes a foreign key. `posts: Vec` becomes a relationship. SeaORM entities are auto-generated.
```rust
schema! {
User {
name: String,
email: String,
posts: Vec
}
Post {
title: String,
body: String,
author: User
}
}
```
**Auth that works** — JWT authentication, protected by default. Mark public routes with `#[public]`. Access the current user with the `CurrentUser` extractor.
```rust
#[public]
#[post("/login")]
async fn login(body: Json, auth: State) -> Result> {
let token = auth.create_token(&body.username)?;
Ok(Json(TokenResponse::new(token, auth.expiration())))
}
#[get("/me")]
async fn me(user: CurrentUser) -> Json {
Json(UserResponse { id: user.id })
}
```
**CRUD in one command** — scaffold an entire resource with handlers, DTOs, errors, schema, and migration.
```bash
rapina add resource Post
```
**OpenAPI built-in** — spec generation, breaking change detection, and validation from the CLI.
```bash
rapina openapi export -o openapi.json
rapina openapi diff --base main
```
**Production middleware** — rate limiting, compression, CORS, and Prometheus metrics out of the box.
```rust
Rapina::new()
.with_rate_limit(RateLimitConfig::per_minute(100))
.with_compression(CompressionConfig::default())
.with_cors(CorsConfig::permissive())
.discover()
.listen("0.0.0.0:3000")
.await
```
**CLI for everything** — create, develop, test, inspect, generate.
```bash
rapina new my-app # Scaffold a new project
rapina dev # Dev server with hot reload
rapina test --coverage # Tests with coverage report
rapina test --watch # Watch mode
rapina routes # List all routes
rapina doctor # Health checks and diagnostics
rapina migrate new # Create a migration
rapina add resource Post # Full CRUD scaffolding
```
## 10 extractors
Everything you need to pick apart a request, type-safe and compile-time checked.
`Json` · `Form` · `Path` · `Query` · `Headers` · `Cookie` · `State` · `Validated` · `CurrentUser` · `Db`
## Standardized errors
Every error includes a `trace_id`. No more guessing in production.
```json
{
"error": { "code": "NOT_FOUND", "message": "user not found" },
"trace_id": "550e8400-e29b-41d4-a716-446655440000"
}
```
## Project status
Rapina is in active development. We ship fast and we ship often — 9 releases since January 2026. The API is stabilizing but breaking changes may still occur before `1.0.0`.
See the [roadmap](https://userapina.com/roadmap/) for what's coming next.
## Documentation
Full documentation at [userapina.com](https://userapina.com/)
- [Getting Started](https://userapina.com/guide/getting-started/)
- [Database](https://userapina.com/guide/database/)
- [Authentication](https://userapina.com/guide/authentication/)
- [CLI Reference](https://userapina.com/cli/)
## Contributing
Contributions are welcome. Check out the [open issues](https://github.com/arferreira/rapina/issues) or join us on [Discord](https://discord.gg/Z4ww64YBQj).
## License
MIT