A web framework designed for both AI agents and developers. Simple, intuitive, productive.
β οΈ IMPORTANT NOTICE: This project is under heavy active development. APIs may change, features are being added rapidly, and breaking changes can occur between versions. While the core functionality is stable, please pin to specific versions in production and expect frequent updates.
elif.rs combines Rust's performance and safety with exceptional developer experience. Convention over configuration, zero boilerplate, and intuitive APIs that maximize productivity.
# Install elif CLI
cargo install elifrs
# Create a new app
elifrs new my-app
cd my-app
# Start developing
cargo run
Your API server starts at http://localhost:3000
with zero configuration π
The new #[elif::bootstrap]
macro requires zero configuration:
use elif::prelude::*;
#[elif::bootstrap] // β That's it!
async fn main() -> Result<(), HttpError> {
// Everything happens automatically:
// β¨ Controllers auto-discovered
// β¨ Dependencies auto-injected
// β¨ Routes auto-registered
// β¨ Server auto-started
Ok(())
}
No AppModule. No configuration. No boilerplate. Just works.
Build production-ready APIs with minimal code:
use elif::prelude::*;
// Your controllers - declarative and clean
#[controller("/api/users")]
#[middleware("cors")]
impl UserController {
#[get("")]
async fn list(&self) -> HttpResult<ElifResponse> {
let users = vec!["Alice", "Bob"];
Ok(ElifResponse::ok().json(&users)?)
}
#[post("")]
#[middleware("auth")]
async fn create(&self, req: ElifRequest) -> HttpResult<ElifResponse> {
let user: CreateUser = req.json().await?;
Ok(ElifResponse::created().json(&user)?)
}
}
// Your services - dependency injection built-in
#[derive(Default)]
struct UserService;
// Your app module - NestJS-style organization
#[module(
controllers: [UserController],
providers: [UserService],
is_app
)]
struct AppModule;
// Zero-boilerplate server setup! β¨
#[elif::bootstrap(AppModule)]
async fn main() -> Result<(), HttpError> {
println!("π Server starting...");
// Everything happens automatically:
// β
Module discovery and dependency injection
// β
Route registration with middleware
// β
Server startup on 127.0.0.1:3000
}
That's it! From project creation to running server - zero configuration, zero boilerplate.
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let container = IocContainer::new();
container.register::<UserService>();
let router = Router::new()
.route("/users", get(list_users))
.route("/users", post(create_user));
let app = App::new()
.wrap(Logger::default())
.wrap(Cors::default())
.service(scope("/api").configure(|cfg| {
cfg.service(router);
}));
HttpServer::new(move || app.clone())
.bind("127.0.0.1:3000")?
.run()
.await
}
use elif::prelude::*;
#[elif::bootstrap] // β Zero boilerplate!
async fn main() -> Result<(), HttpError> {
println!("π Server starting!");
// Everything automatic:
// - Controllers auto-discovered and registered
// - IoC container auto-configured
// - Router setup automatically
// - Server starts on 127.0.0.1:3000
Ok(())
}
Result: 85% less code, exceptional developer experience, full Rust performance.
Need custom settings? elif.rs scales with your needs:
// Development setup - zero boilerplate!
#[elif::bootstrap]
async fn main() -> Result<(), HttpError> {
// Everything auto-configured!
Ok(())
}
// Production setup with custom config
#[elif::bootstrap(
addr = "0.0.0.0:8080",
config = HttpConfig::production(),
middleware = [cors(), auth(), rate_limiting(), logging()]
)]
async fn main() -> Result<(), HttpError> {
run_migrations().await?;
warm_caches().await?;
println!("π Production server ready!");
Ok(())
}
#[controller("/api/posts")]
#[middleware("cors", "auth")]
impl PostController {
// GET /api/posts
#[get("")]
#[middleware("cache")]
async fn list(&self) -> HttpResult<ElifResponse> {
Ok(ElifResponse::ok().json(&get_posts())?)
}
// POST /api/posts
#[post("")]
async fn create(&self, req: ElifRequest) -> HttpResult<ElifResponse> {
let post: CreatePost = req.json().await?;
Ok(ElifResponse::created().json(&create_post(post))?)
}
// GET /api/posts/{id}
#[get("/{id}")]
#[param(id: int)]
async fn show(&self, id: u32) -> HttpResult<ElifResponse> {
let post = find_post(id)?;
Ok(ElifResponse::ok().json(&post)?)
}
}
#[module(
controllers: [PostController, CommentController],
providers: [PostService, EmailService],
imports: [DatabaseModule, AuthModule],
exports: [PostService]
)]
struct BlogModule;
// Models with relationships
#[derive(Debug, Serialize, Model)]
struct User {
id: Uuid,
name: String,
email: String,
created_at: DateTime<Utc>,
}
// Laravel-style query builder
let users = User::query()
.where_eq("active", true)
.where_gt("age", 18)
.with("posts.comments") // Eager loading relationships
.order_by("created_at", "DESC")
.paginate(10)
.get(&db)
.await?;
elif.rs was designed with AI agents in mind:
β
Intuitive patterns that LLMs understand naturally
β
Convention over configuration reduces decision complexity
β
Consistent APIs across the entire framework
β
Self-documenting code with derive macros
β
Clear error messages with actionable suggestions
Perfect for Claude, GPT-4, Cursor, and GitHub Copilot.
# Project Management
elifrs new blog-api # Create new project with modular structure
elifrs generate # AI-powered code generation
elifrs serve --reload # Hot reload development server
# Code Scaffolding
elifrs make:module UserModule # Generate complete module
elifrs make:controller UserController # Generate declarative controller
elifrs make:service UserService # Generate injectable service
elifrs make:resource User # Generate complete CRUD resource
# Database Management
elifrs migrate run # Run pending migrations
elifrs migrate create create_users # Create new migration
elifrs db:seed # Seed database with test data
# API Documentation
elifrs openapi generate # Generate OpenAPI spec
elifrs openapi serve # Start Swagger UI server
Generated projects use a clean, organized structure:
my-app/
βββ src/
β βββ main.rs # Zero-boilerplate bootstrap
β βββ modules/
β βββ app/
β β βββ app.module.rs # Root app module
β β βββ app.controller.rs # Health check endpoints
β β βββ app.service.rs # Core services
β βββ users/
β βββ users.module.rs # Feature module
β βββ users.controller.rs
β βββ users.service.rs
β βββ dto/
β βββ create_user.rs
β βββ update_user.rs
βββ migrations/ # Database migrations
βββ tests/ # Integration tests
βββ Cargo.toml # Minimal dependencies
use elif::testing::*;
#[tokio::test]
async fn test_user_api() {
let app = TestApp::new(AppModule).await;
// Test API endpoints
let response = app.get("/api/users").await;
assert_eq!(response.status(), 200);
// Test with authentication
let response = app
.post("/api/users")
.auth("Bearer token")
.json(&new_user)
.await;
assert_eq!(response.status(), 201);
}
-
elif-http
v0.8.2
- HTTP server, routing, middleware + declarative macros -
elif-http-derive
v0.2.0
- Controller and module derivation macros -
elif-macros
v0.1.1
- Bootstrap and main function macros -
elif-core
v0.7.0
- Dependency injection and IoC container with auto-configuration -
elifrs
v0.10.3
- Powerful CLI with modular project generation -
elif-orm
v0.7.0
- Type-safe ORM with relationships -
elif-auth
v0.4.0
- Authentication and authorization -
elif-cache
v0.3.0
- Caching with multiple backends
-
elifrs
v0.10.3
- Enhanced CLI with auto-configuration support - Modular project generation with NestJS-style module discovery
- Provider auto-configuration with dependency injection optimization
- Controller auto-registration with route conflict detection
- AI-powered code generation from natural language specs
- Hot reload development with automatic recompilation
- Built-in testing framework with mocking support
- WebSocket channels for real-time features
- Advanced validation with custom rule sets
- GraphQL integration with automatic schema generation
- Enhanced ORM relationships with eager loading optimization
- Background job processing with Redis/database queues
MIT License - see LICENSE for details.
elif.rs
Convention over Configuration β’ Zero Boilerplate β’ AI-Native
elif.rs β’
GitHub β’
Docs