Ferrite gives Rust backends a structured, modular shape — modules, compile-time dependency injection, and macro-based routing on top of Axum, Tokio and Tower.
Ferrite resolves every dependency at compile time. Controllers, providers and routes are discovered, wired and type-checked before your binary ever run.
use ferrite_framework::{
bootstrap, controller, impl_controller, inject, injectable,
module, Ferrite, Json,
};
#[injectable]
pub struct AppService {
config: ferrite_framework::ConfigService,
}
impl AppService {
#[inject]
pub fn new(config: ferrite_framework::ConfigService) -> Self {
Self { config }
}
pub fn health(&self) -> String {
self.config.get_or("APP_ENV", "development")
}
}
#[controller("/health")]
pub struct HealthController {
service: AppService,
}
#[impl_controller]
impl HealthController {
#[inject]
pub fn new(service: AppService) -> Self {
Self { service }
}
#[get("/")]
pub async fn health(&self) -> Json<String> {
Json(self.service.health())
}
}
#[module(controllers = [HealthController], providers = [AppService])]
pub struct AppModule;
#[bootstrap]
async fn main() {
let app = Ferrite::create::<AppModule>().await;
app.listen("0.0.0.0:3000").await.expect("failed to bind");
} Pull any ecosystem crate in with a single fr add command.
Providers are registered and resolved at build time. Missing dependencies and cycles surface as compiler errors, never runtime panics.
Declare imports, providers, controllers and exports on a struct with the #[module] macro — your whole dependency graph in one place.
Annotate handlers with #[get], #[post], #[patch] and #[delete]. Ferrite wires Axum routes, pipelines and metadata for you.
Guards, interceptors, middleware, pipes and exception filters compose as attribute macros along a documented pipeline.
Layered .env and ferrite.toml via ConfigService, plus derive-based DTO validation that returns rich 422 responses.
Export an OpenAPI 3.1 spec from route, body and guard metadata — and browse it in the bundled Swagger UI.
One Repository abstraction over SQLx, Diesel and SeaORM adapters, with SQL migration tooling built into the CLI.
WebSocket gateways, gRPC transports, NATS and Kafka share the same module and controller model as HTTP.
Redis cache services, background job queues and cron scheduling are one fr add away from your service.
Every ferrite-* crate is released in lockstep and pinned to the matching framework release, so your dependency tree always resolves to one consistent version.
Browse the cratesFrom scaffolding to production — controllers, guards, validation, OpenAPI and a CLI that does the boring work for you.