Toni Framework
Toni is a Rust backend framework designed for building modular and scalable applications inspired by the Nest.js architecture. It provides a structured approach to organizing your code with controllers, services, and modules, while remaining decoupled from the HTTP server (Axum adapted and used by default).
Features
- Modular Architecture: Organize your application into reusable modules.
- HTTP Server Flexibility: Use Axum or integrate your preferred server.
- Dependency Injection: Manage dependencies cleanly with module providers.
- Macro-Driven Syntax: Reduce boilerplate with intuitive procedural macros.
Installation
Prerequisites
- Rust & Cargo: Ensure Rust is installed.
- Toni CLI: Install the CLI tool globally:
Quickstart: Build a CRUD App
Use the Toni CLI to create a new project:
Project Structure
src/
├── app/
│ ├── app.controller.rs
│ ├── app.module.rs
│ ├── app.service.rs
│ └── mod.rs
└── main.rs
Run the Server
Test your endpoints at http://localhost:3000/app.
Key Concepts
Project Structure
| File | Role |
|---|---|
app.controller.rs |
Defines routes and handles HTTP requests. |
app.module.rs |
Configures dependencies and module setup. |
app.service.rs |
Implements core business logic. |
Decoupled HTTP Server
Toni decouples your application from the HTTP server, and by default we use Axum. In the future we plan to integrate other HTTP adapters.
Code Example
main.rs
use ;
async
app/app.module.rs (Root Module)
;
app/app.controller.rs (HTTP Routes)
app/app.service.rs (Business Logic)
License
- License: MIT.