ulo 0.1.0-alpha.1

Fast and modular web framework for scalable applications
Documentation

Ulo Framework

Ulo 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.
  • Ulo CLI: Install the CLI tool globally:
    cargo install ulo-cli
    

Quickstart: Build a CRUD App

Use the Ulo CLI to create a new project:

ulo new my_app

Project Structure

src/
├── app/
│   ├── app.controller.rs
│   ├── app.module.rs
│   ├── app.service.rs
│   └── mod.rs
└── main.rs

Run the Server

cargo run

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

Ulo is decoupled from the HTTP server. Adapters exist for Axum (ulo-http-axum), Actix-web (ulo-http-actix), Poem (ulo-http-poem), Salvo (ulo-http-salvo), and Rocket (ulo-http-rocket); any other server can be integrated by implementing the HttpAdapter trait.

Code Example

main.rs

use ulo::UloFactory;
use ulo_http_axum::AxumAdapter;

#[tokio::main]
async fn main() {
    let mut app = UloFactory::create(AppModule).await.unwrap();
    app.use_http_adapter(AxumAdapter::new(), 3000, "127.0.0.1")
        .unwrap();
    app.start().await.unwrap();
}

app/app.module.rs (Root Module)

#[module(
    imports: [],
    controllers: [AppController],
    providers: [AppService],
    exports: []
)]
pub struct AppModule;

app/app.controller.rs (HTTP Routes)

#[controller("/app")]
pub struct AppController {
    #[inject]
    app_service: AppService,
}

#[routes]
impl AppController {
    #[post("/")]
    fn create(&self) -> Body {
        Body::text(self.app_service.create())
    }

    #[get("/")]
    fn find_all(&self) -> Body {
        Body::text(self.app_service.find_all())
    }
}

app/app.service.rs (Business Logic)

#[injectable]
pub struct AppService;

impl AppService {
    pub fn create(&self) -> String {
        "Item created!".into()
    }

    pub fn find_all(&self) -> String {
        "All items!".into()
    }
}

License

  • License: MIT.