Features Get Started Compare Ecosystem Docs GitHub
MIT Licensed · Built for Production

Build Rust APIs
at lightspeed.

Floz is a batteries-included MVC framework for Rust. Auth, ORM, workers, OpenAPI, caching — everything you need, wired together. Zero assembly required.

$ cargo install floz-cli && floz new my-app click to copy
6+
Crates
5 Macros
Zero Boilerplate
3 Templates
Instant Start
0 Config
Convention First
src/app/note/model.rs
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.
src/app/note/controller.rs
#[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))
}
src/main.rs
#[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.

Everything you need.
Nothing you don't.

Floz ships with every module a production API needs. Feature-gated — pay zero cost for what you don't use.

Auto CRUD Generation

Add crud(tag = "...") to your model and get full REST endpoints with pagination, validation, and OpenAPI docs — automatically.

🗄️

Floz ORM

First-class ORM with dirty tracking, type-safe queries, relations, and auto DDL generation. Define your struct, get your database.

🔐

Auth Module

JWT tokens, API key generation, bcrypt hashing, and cookie auth — all built in. Feature-gated so you only pay for what you use.

📋

OpenAPI + Swagger

Every route auto-generates OpenAPI specs via utoipa. Swagger UI served at /ui out of the box. Your API is always documented.

💾

Smart Cache Layer

Declarative endpoint caching with #[route(cache(ttl = 60))]. Automatic key generation and invalidation built into the middleware pipeline.

🔄

Background Workers

Redis-backed task queue with #[task] macro for background jobs. Auto-discovered at boot. No manual registration needed.

🛡️

Compile-Time Middleware

Generic type-parameter chaining — your middleware stack is monomorphized. Zero runtime dispatch overhead. Fully type-safe.

🚀

CLI Scaffolding

floz new, floz generate scaffold — spin up projects, models, and controllers in seconds. Three starter templates included.

📡

PG LISTEN/NOTIFY

Real-time Postgres event bridge built in. Subscribe to database changes and react instantly — no polling required.

Convention over configuration.

Write your domain logic. Floz handles the plumbing.

The Model Macro

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] #[col] dirty tracking auto DDL
#[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(), ...

The Route Macro

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] auto-register OpenAPI cache(ttl)
#[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)
}

Up and running in 60 seconds.

Three commands. One struct. A production-ready API.

Scaffold

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

Define

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,
}

Ship

Run your app. Routes are auto-discovered. Swagger docs are ready at /ui.

$ cp .env.example .env
$ cargo run

→ Listening on 0.0.0.0:3000
→ Swagger UI: /ui
→ 5 routes registered

How Floz stacks up.

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

A complete toolkit.

Six focused crates, each with a single responsibility. Use the full framework or pick what you need.

🏗️

floz

crates.io/crates/floz

The main framework crate. App builder, router, middleware, auth, workers, and error handling.

🗄️

floz-orm

crates.io/crates/floz-orm

ORM runtime with Executor, query builder, type aliases, and database pool management.

🔧

floz-macros

crates.io/crates/floz-macros

Proc macro crate providing #[model], #[route], #[task], #[crud], and schema! macros.

🧠

floz-macros-core

crates.io/crates/floz-macros-core

Pure logic crate for macro expansion — AST parsing, codegen, fully testable without proc-macro constraints.

floz-cli

crates.io/crates/floz-cli

Command-line tool for scaffolding projects, generating models, controllers, and domain modules.

🖥️

floz-editor

crates.io/crates/floz-editor

Standalone TUI database editor. Browse, query, and edit your database directly from the terminal.

Ready to build?

Join the growing ecosystem of Rust developers shipping faster with Floz.