Overview
LazyBE (Lazy Backend) is a collection of building blocks for quickly building a backend CRUD application. It provides macros and trait implementations that can be composed without being too opinionated about how to structure your application.
A typical backend application usually has boring parts, where you just need to do basic CRUD, and fun parts, where you get to do crazy stuff. LazyBE lets you skip the boring parts and focus on the fun ones.
Features
- Derive the data access layer from a struct
- Uses
sea-queryandsqlxunder the hood, which means you can usePostgresandSQLite(noMySQLsupport yet, but adding it should be trivial) - Automatically handles
created_atandupdated_attimestamps - See Minimal DAL example
- Uses
- Derive
axumendpoints from a struct (See Minimal API example) - Derive OpenAPI specification from a struct (See Todo example)
- Custom validation support (See Validation example)
- Custom ID generation (See Custom ID example)
- Custom collection API support filter, sort, pagination (See Collection API example)
- Built-in support for JSON field (See JSON example)
- Type-safe URI (See Typed URI example)
A quick glance
Here’s a quick glance at what LazyBE looks like.
The Entity macro derives traits and sibling types to implement commonly used backend layers.
- The attribute
table = "book"defines the database table used for CRUD operations. - The optional attribute
endpoint = "/books"defines the URL path where the resource is exposed. - The optional attribute
derive_to_schemaensures thatutoipa::ToSchemais derived for sibling types. - The attribute
#[lazybe(primary_key)]defines the primary key, allowing you to fetch a book by its ID. - The attributes
#[lazybe(created_at)]and#[lazybe(updated_at)]automatically timestamp when a record is created or updated.
With this macro, the following backend layers are automatically implemented:
- Data access layer – using
sqlxandsea-query - API layer – using
axumandserde - OpenAPI specification – using
utoipa
You can then expose Book on a REST API using axum like this:
async
This will generate the following endpoints for the Book resource:
POST /books– Create a new book and save it to thebooktableGET /books– Retrieve a collection of booksGET /books/{id}– Retrieve a book by its IDPUT /books/{id}– Replace an existing bookPATCH /books/{id}– Partially update an existing bookDELETE /books/{id}– Delete a book by its ID
It will also generate the OpenAPI specification for the Book resource and serve it using the Redoc UI.

This is just a high-level overview. For a complete working example, see the minimal API example.
Documentation
Releasing
# Prepare a new version, then commit and create a tag
# Publish to crates.io