Floz is a batteries-included MVC framework for Rust. Auth, ORM, workers, OpenAPI, caching — everything you need, wired together. Zero assembly required.
use floz::prelude::*;
// 1 struct = full REST API + OpenAPI + DB migrations
#[model("notes", crud(tag = "Notes"))]
pub struct Note {
#[col(key, auto)]
pub id: i32,
pub title: Varchar,
pub content: Text,
#[col(default = "now()")]
pub created_at: Timestamp,
}
// That's it. GET, POST, PUT, DELETE — auto-generated.
// OpenAPI docs? Also generated. Swagger UI included.
#[route(
get: "/notes/search",
tag: "Notes",
desc: "Search notes by keyword",
cache(ttl = 60),
)]
async fn search_notes(
db: web::types::State<Db>,
query: web::types::Query<SearchParams>,
) -> HttpResponse {
let notes = Note::find_by("title", &query.q, &db)
.await
.unwrap_or_default();
res!(pp!(¬es))
}
#[floz::main]
async fn main() -> std::io::Result<()> {
App::new()
.config(|cfg| {
cfg.with_middleware(Cors::permissive())
.with_middleware(Trace::default())
.with_middleware(CacheMiddleware::new())
})
.run()
.await
}
// Routes auto-discovered via inventory.
// Database pool auto-configured from .env.
// Zero manual wiring. Just run it.
Floz ships with every module a production API needs. Feature-gated — pay zero cost for what you don't use.
Add crud(tag = "...") to your model and get full REST endpoints with pagination, validation, and OpenAPI docs — automatically.
First-class ORM with dirty tracking, type-safe queries, relations, and auto DDL generation. Define your struct, get your database.
JWT tokens, API key generation, bcrypt hashing, and cookie auth — all built in. Feature-gated so you only pay for what you use.
Every route auto-generates OpenAPI specs via utoipa. Swagger UI served at /swagger out of the box. Your API is always documented.
Declarative endpoint caching with #[route(cache(ttl = 60))]. Automatic key generation and invalidation built into the middleware pipeline.
Redis-backed task queue with #[task] macro for background jobs. Auto-discovered at boot. No manual registration needed.
Generic type-parameter chaining — your middleware stack is monomorphized. Zero runtime dispatch overhead. Fully type-safe.
floz new, floz generate scaffold — spin up projects, models, and controllers in seconds. Three starter templates included.
Real-time Postgres event bridge built in. Subscribe to database changes and react instantly — no polling required.
Write your domain logic. Floz handles the plumbing.
Write a plain Rust struct with #[model]. Floz generates the SQL table DDL,
column metadata, CRUD methods (.all(), .find(), .insert(), .update(), .delete()),
dirty tracking, and OpenAPI schemas — all at compile time.
#[model("users")]
pub struct User {
#[col(key, auto)]
pub id: i32,
#[col(unique)]
pub email: Varchar,
pub name: Varchar,
#[col(default = "now()")]
pub created_at: Timestamp,
}
// Generated: User::all(), User::find(),
// User::insert(), User::update(), ...
Annotate any async function with #[route]. It auto-registers via inventory — no manual wiring.
Add OpenAPI docs, caching, and auth guards declaratively in the macro attributes.
#[route(
post: "/users",
tag: "Users",
desc: "Create a new user",
)]
async fn create_user(
db: web::types::State<Db>,
body: web::types::Json<NewUser>,
) -> HttpResponse {
let user = User::insert(&body, &db)
.await.unwrap();
res!(pp!(&user), 201)
}
Three commands. One struct. A production-ready API.
Create a new project from one of three templates: minimal, api, or saas.
$ cargo install floz-cli
$ floz new my-app --template api
$ cd my-app
Write your model. The macro generates everything — tables, queries, endpoints.
#[model("posts", crud(tag = "Posts"))]
pub struct Post {
#[col(key, auto)]
pub id: i32,
pub title: Varchar,
pub body: Text,
}
Run your app. Routes are auto-discovered. Swagger docs are ready at /swagger.
$ cp .env.example .env
$ cargo run
→ Listening on 0.0.0.0:3000
→ Swagger UI: /swagger
→ 5 routes registered
We built Floz because we needed everything in one place. Here's how it compares to the alternatives.
| Feature | Floz | Loco.rs | Actix + SeaORM | Rocket |
|---|---|---|---|---|
| HTTP engine | ntex | Axum | Actix Web | Rocket (Hyper) |
| Built-in ORM | ✓ Floz ORM | SeaORM | SeaORM (separate) | — |
| Auto CRUD generation | ✓ | ✓ | — | — |
| Auth built-in | ✓ JWT + API Key | ✓ Sessions | — | — |
| OpenAPI + Swagger | ✓ | — | — | — |
| Background workers | ✓ Redis | ✓ | — | — |
| Declarative caching | ✓ | — | — | — |
| PG LISTEN/NOTIFY | ✓ | — | — | — |
| CLI scaffolding | ✓ | ✓ | — | — |
| Zero-config middleware | ✓ Compile-time | ✓ | Manual | Fairings |
Six focused crates, each with a single responsibility. Use the full framework or pick what you need.
The main framework crate. App builder, router, middleware, auth, workers, and error handling.
ORM runtime with Executor, query builder, type aliases, and database pool management.
Proc macro crate providing #[model], #[route], #[task], #[crud], and schema! macros.
Pure logic crate for macro expansion — AST parsing, codegen, fully testable without proc-macro constraints.
Command-line tool for scaffolding projects, generating models, controllers, and domain modules.
Standalone TUI database editor. Browse, query, and edit your database directly from the terminal.
Join the growing ecosystem of Rust developers shipping faster with Floz.