Runique
A Django-inspired Rust web framework
Runique is a modern web framework that combines Rust's safety and performance with Django's ergonomics. It offers a familiar development experience for Django developers while leveraging the power of Rust's type system.
🤔 Why Runique?
- For Django developers: Familiar API and patterns with Rust's performance and safety
- For Rust developers: Django-inspired ergonomics without sacrificing type safety
- For everyone: Security built-in from day one, not bolted-on as an afterthought
🚀 Main Features
Django-like Architecture
- Declarative routing with
urlpatterns!macro - Intuitive ORM based on SeaORM with Django-style API
- Template system Tera with custom preprocessing
- Automatic form generation via procedural macros
- Flash messages between requests
- Static and media file management
Built-in Security
- ✅ CSRF Protection (HMAC-SHA256)
- ✅ Content Security Policy (CSP) with nonces
- ✅ XSS Sanitization (ammonia)
- ✅ Automatic Security Headers (HSTS, X-Frame-Options, etc.)
- ✅ ALLOWED_HOSTS Validation
- ✅ Integrated Argon2id Hashing
Multi-database Support
- PostgreSQL
- MySQL / MariaDB
- SQLite
Modern Development
- Native Async/await with Tokio
- Type-safe thanks to Rust's type system
- Zero-cost abstractions
- Hot reload in development
- Complete documentation
📦 Installation
Prerequisites
- Rust 1.75+ (install Rust)
- Cargo
Add Runique to Your Project
# Cargo.toml
# Minimal configuration (SQLite by default)
[]
= "1.0.5"
# With PostgreSQL
[]
= { = "1.0.5", = ["postgres"] }
# With MySQL
[]
= { = "1.0.5", = ["mysql"] }
# With MariaDB
[]
= { = "1.0.5", = ["mariadb"] }
# With all databases
[]
= { = "1.0.5", = ["all-databases"] }
Available Cargo Features
| Feature | Description | Default |
|---|---|---|
default |
Enables ORM support with SQLite | ✅ |
orm |
Enables SeaORM | ✅ (included in default) |
sqlite |
SQLite driver | ✅ (included in orm) |
postgres |
PostgreSQL driver | ❌ |
mysql |
MySQL driver | ❌ |
mariadb |
MariaDB driver (uses MySQL driver) | ❌ |
all-databases |
Enables all drivers simultaneously | ❌ |
Configuration examples:
# SQLite only (default configuration)
[]
= "1.0.5"
# PostgreSQL + MySQL
[]
= { = "1.0.5", = ["postgres", "mysql"] }
# All databases
[]
= { = "1.0.5", = ["all-databases"] }
# Without ORM (minimal framework)
[]
= { = "1.0.5", = false }
Create a New Project
Add Runique to Cargo.toml:
[]
= { = "1.0.5", = ["sqlite"] }
= { = "1", = ["full"] }
= { = "1", = ["derive"] }
🏁 Quick Start
Minimal Application
// src/main.rs
use *;
async
async
async
Configuration (.env)
HOST=127.0.0.1
PORT=8000
SECRET_KEY=your-secret-key-here
ALLOWED_HOSTS=localhost,127.0.0.1
DEBUG=true
# PostgreSQL (optional)
DB_ENGINE=postgres
DB_USER=user
DB_PASSWORD=password
DB_HOST=localhost
DB_PORT=5432
DB_NAME=mydb
Launch
For more advanced examples, see the Complete Example section below.
📚 Documentation
- 🚀 Getting Started
- ⚙️ Configuration
- 🗄️ Database
- 📝 Forms
- 🎨 Templates
- 🔒 Security
- 🛣️ Macro
- 🔧 Changelog
- 🚀 Contributing
- 🆕 New project
- 📖 API Documentation
🎯 Complete Example
Project Structure
You can use: cargo install runique → runique new project_name
my_app/
├── Cargo.toml
├── .env
├── src/
│ ├── main.rs
│ ├── models/
│ │ └── mod.rs
│ ├── views/
│ │ └── mod.rs
│ ├── forms/
│ | └── mod.rs
│ └── urls/
│ └── mod.rs
├── templates/
│ ├── base.html
│ └── index.html
└── static/
├── css/
└── js/
Advanced Handler with Form Validation
use *;
// Form handler with validation
pub async
// Form submission with error handling
pub async
🔒 Security
CSRF Protection
CSRF protection is automatically enabled when using .with_default_middleware().
use *;
new.await?
.with_default_middleware // Includes CSRF protection
.routes
.run
.await?;
In your templates:
{% csrf %}
<!-- form fields -->
Content Security Policy
use *;
new.await?
.with_security_headers
.with_default_middleware
.routes
.run
.await?;
Security Headers
new.await?
.with_static_files?
.with_allowed_hosts
.with_default_middleware
.routes
.run
.await?;
Headers automatically configured:
Strict-Transport-SecurityX-Content-Type-OptionsX-Frame-OptionsX-XSS-ProtectionReferrer-PolicyPermissions-Policy
🗄️ Database
Configuration
new.await?
.with_database
.with_static_files?
.with_allowed_hosts
.with_sanitize_text_inputs
.with_default_middleware
.routes
.run
.await?;
Django-like API
use crate;
// Retrieval
let all_users = objects.all.all.await?;
let user = objects.get.await?;
// Filtering
let active_users = objects
.filter
.filter
.all
.await?;
// Ordering and pagination
let recent_users = objects
.order_by_desc
.limit
.all
.await?;
// Count
let count = objects.count.await?;
Migrations
Use sea-orm-cli for migrations:
# Create a migration
# Apply
# Rollback
🎨 Templates
Custom Tags
<!-- Static files -->
<!-- Media files -->
<!-- CSRF token -->
{% csrf %}
<!-- ... -->
<!-- Flash messages -->
{% messages %}
<!-- Links with reverse routing -->
Details
<!-- CSP nonce (if enabled) -->
📦 Utility Macros
Runique provides macros to simplify common operations.
Flash Messages
use *;
async
Advantages:
- Concise and expressive syntax
- Automatic handling of
.await.unwrap() - Support for multiple messages
- More readable and maintainable code
Available macros:
success!(message, "text")- Success messageserror!(message, "text")- Error messagesinfo!(message, "text")- Information messageswarning!(message, "text")- Warning messages
🚀 Performance
Runique leverages Rust and Tokio performance:
- Zero-cost abstractions: No runtime overhead
- Native async/await: Efficient concurrency with Tokio
- Connection pooling: Optimized DB connection management
- Optimized compilation: Highly optimized binary
Benchmark (indicative)
Setup: Local development machine
Requests/sec: ~50,000
Latency p50: ~1ms
Latency p99: ~5ms
Memory: ~20MB
Note: Actual performance depends on your hardware and application complexity. Run your own benchmarks for production estimates.
🛠️ Development
Tests
# Run all tests
# Run integration tests
# Run doc tests
Linting
Formatting
Documentation
# Generate and open documentation
# Test documentation examples
🤝 Contributing
Contributions are welcome! Here's how to contribute:
- Fork the project
- Create a branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Guidelines
- Write tests for new features
- Follow Rust code conventions (rustfmt)
- Document public APIs
- Add examples if relevant
See CONTRIBUTING.md for more details.
📝 Roadmap
Version 1.1 (Q1 2026)
- Integrated authentication system
- Auto-generated admin panel
- Rate limiting middleware
- WebSocket support
- Cache layer (Redis)
Version 1.2 (Q2 2026)
- CLI for scaffolding
- Improved hot reload
- GraphQL support
- Background jobs (Tokio tasks)
Version 2.0 (Q3 2026)
- Plugin system
- Multi-tenancy
- Internationalization (i18n)
- Advanced ORM features
📄 License
This project is licensed under the MIT License. See the LICENSE-MIT file for details.
🙏 Acknowledgments
Runique builds upon excellent libraries from the Rust ecosystem:
- Axum - Web framework
- Tokio - Async runtime
- SeaORM - ORM
- Tera - Template engine
- Tower - Middleware
- Argon2 - Password hashing
- ammonia - HTML sanitization
Special thanks to all contributors and the Rust community!
📧 Contact
- GitHub Issues: Report bugs or request features
- Discord: Join our community
- Email: alliotsebastien04@gmail.com
- Crates.io: View on crates.io
- Docs.rs: Read the API documentation
⭐ Support the Project
If Runique is useful to you, consider:
- ⭐ Starring on GitHub
- 🐛 Reporting bugs
- 💡 Suggesting features
- 📖 Improving documentation
- 🤝 Contributing code
- 💬 Joining our Discord community
Build secure and performant web applications with Runique! 🚀
Version: 1.0.5 License: MIT Status: Stable
Made with ❤️ and 🦀 by the Runique community