NestForgeNestForge
//docs v1.4

Build Rust backends without wiring everything by hand.

NestForge brings Nest-style structure to Axum: modules, dependency injection, guards, and interceptors built in. These docs cover building on it, and building it.

cargo install nestforge-cli
  1. 01RouterAxum router, request context
  2. 02MiddlewareLogging, header preparation
  3. 03GuardsAccess rules, early exits
  4. 04InterceptorsWrap handler execution
  5. 05HandlerYour code, finally
  6. 06ResponseFilters run, 200 leaves

Full request pipeline

// What NestForge Solves

Built-in solutions for the hard problems

Wiring every service by hand at boot.

Modules & DI

Read the guide

Auth checks scattered across every handler.

Guards & Interceptors

Read the guide

API docs that rot behind the code.

OpenAPI

Read the guide

A new database, a new mess of glue.

Data Layer

Read the guide

REST today, gRPC tomorrow, rewrite everything.

Transports

Read the guide

Untested glue holding it all together.

Testing & CLI

Read the guide

// The Mental Model

Every module declares its wiring

The #[module] attribute tells the injector everything it needs. Nothing is wired by hand, nothing is hidden.

  • No more manual constructor plumbing
  • Dependencies are explicit, nothing is hidden
  • The compiler catches what you miss
How modules work
#[module](
imports = [DatabaseModule],
controllers = [UsersController],
providers = [UsersService],
exports = [UsersService]
)
pub struct UsersModule;

imports

Pull in providers exported by other modules.

controllers

Route handlers instantiated with the module.

providers

Services built by the injector, shared in scope.

exports

The subset other modules may use.

// FAQ

Questions we get asked a lot

Can't find what you're looking for? Open an issue. The framework is developed in the open.

Ask on GitHub
Why a Nest-style framework in Rust?

Structure scales. Nest proved that opinionated architecture, with modules, dependency injection, and guards, removes a whole class of decisions. NestForge brings that structure to Axum without the runtime cost of a JavaScript framework.

Is NestForge just macros over Axum?

Macros are the surface. Underneath there is a real dependency injector, a request-scoped container, and a guard and interceptor pipeline that Axum alone does not give you.

Can I drop down to plain Axum?

Yes. Every handler is an Axum handler. You can mount raw routes beside NestForge modules and migrate one feature at a time.

What does the CLI scaffold?

A complete feature module: DTOs, service, controller, tests, and OpenAPI registration, wired into your workspace and ready to run.

How does it handle multiple databases?

Data layer modules wrap SQL, Mongo, and Redis behind the same provider interface, so swapping a store does not ripple through your services.

use nestforge::prelude::*;

Stop wiring boilerplate.

cargo install nestforge-cli