MIT licensed · v0.1.0 · crates.io

Backend, batteries included.

Ferrite gives Rust backends a structured, modular shape — modules, compile-time dependency injection, and macro-based routing on top of Axum, Tokio and Tower.

Rust
Axum 0.8
Tokio
Tower
Compile-time DI
Macro routing
OpenAPI 3.1
A minimal application

Describe the whole app in one module.

Ferrite resolves every dependency at compile time. Controllers, providers and routes are discovered, wired and type-checked before your binary ever run.

src/main.rs
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");
}
Features

Everything you need, already wired in.

Pull any ecosystem crate in with a single fr add command.

Compile-time dependency injection

Providers are registered and resolved at build time. Missing dependencies and cycles surface as compiler errors, never runtime panics.

Modules & providers

Declare imports, providers, controllers and exports on a struct with the #[module] macro — your whole dependency graph in one place.

Macro-based routing

Annotate handlers with #[get], #[post], #[patch] and #[delete]. Ferrite wires Axum routes, pipelines and metadata for you.

Cross-cutting concerns

Guards, interceptors, middleware, pipes and exception filters compose as attribute macros along a documented pipeline.

Configuration & validation

Layered .env and ferrite.toml via ConfigService, plus derive-based DTO validation that returns rich 422 responses.

OpenAPI out of the box

Export an OpenAPI 3.1 spec from route, body and guard metadata — and browse it in the bundled Swagger UI.

Persistence

One Repository abstraction over SQLx, Diesel and SeaORM adapters, with SQL migration tooling built into the CLI.

Realtime & messaging

WebSocket gateways, gRPC transports, NATS and Kafka share the same module and controller model as HTTP.

Caching, jobs & cron

Redis cache services, background job queues and cron scheduling are one fr add away from your service.

Ecosystem

One consistent, pinned release line.

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 crates

Structure your first Ferrite service.

From scaffolding to production — controllers, guards, validation, OpenAPI and a CLI that does the boring work for you.