Skip to content

Overview

Introduction to NestForge, the modular backend framework for Rust.

NestForge is a framework for building efficient, scalable Rust server-side applications. It uses a modular architecture inspired by NestJS, bringing familiar patterns like Dependency Injection, Modules, and Middleware to the high-performance world of Rust.

In recent years, the Rust ecosystem has seen incredible growth in web development. However, while crates like Axum, Tokio, and Tower provide amazing foundations, they often leave the developer to figure out their own architectural patterns. This can lead to fragmented codebases that are difficult to scale and maintain.

NestForge provides an out-of-the-box application architecture which allows developers and teams to create highly testable, scalable, loosely coupled, and easily maintainable applications. The architecture is heavily inspired by NestJS, but built from the ground up to leverage Rust’s unique strengths: Zero-cost abstractions, Memory safety, and Fearless concurrency.

  • Modular Architecture: Group your code into logical feature sets using Modules.
  • Dependency Injection: First-class DI system that makes testing and decoupling a breeze.
  • Declarative Routing: Use simple attributes like #[get("/")] to define your API surface.
  • Request Pipeline: Robust support for Middleware, Guards, and Interceptors.
  • Route Versioning: Version routes with #[nestforge::version("1")] and the factory version helper.
  • Auto-OpenAPI: Generate documentation directly from your controller metadata.
  • Multi-Transport: First-class support for REST, GraphQL, gRPC, WebSockets, and Microservices.

If you’re coming from the NestJS world, you’ll feel right at home. Here’s how the concepts map:

NestJS (TypeScript)NestForge (Rust)
@Module()#[nestforge::module]
@Controller()#[nestforge::controller]
@Injectable()#[nestforge::provider] or plain structs registered in modules
NestFactory.create()NestForgeFactory::create()
Pipe / ValidationPipeValidatedBody<T>
NestForgeFactory::<AppModule>::create()?
.with_global_prefix("api")
.with_version("v1")
.listen(3000)
.await?;

The default HTTP scaffold keeps the application bootstrap files at the root of src/:

src/
app_config.rs
app_controller.rs
app_service.rs
app_module.rs
health_controller.rs
main.rs
#[controller("/versioning")]
pub struct VersioningController;
#[routes]
impl VersioningController {
#[nestforge::get("/hello")]
#[nestforge::version("1")]
async fn hello_v1() -> String {
"Hello from API v1".to_string()
}
}

We recommend following the documentation in this order:

  1. Installation: Set up your environment.
  2. Quick Start: Build your first app and inspect the generated scaffold.
  3. First Steps: Build a real feature with DTOs and Services.
  4. Core Concepts: Understand the mental model.

Whether you’re building a new API or helping us build the framework, we’ve got you covered.

Application Developer

Learn how to build scalable server-side applications with NestForge. Get Started

Framework Contributor

Help us build the future of Rust backend development. View Internal Docs