| Crates.io | axion |
| lib.rs | axion |
| version | 0.0.4 |
| created_at | 2025-05-28 00:22:58.56304+00 |
| updated_at | 2025-06-18 06:06:10.062159+00 |
| description | Automatic API generator that creates a REST API mirror of a database in Rust |
| homepage | |
| repository | https://github.com/Yrrrrrf/axion |
| max_upload_size | |
| id | 1692128 |
| size | 127,937 |
High-performance Rust library for automatic API generation from database schemas.It empowers you to create a blazingly fast REST API that mirrors your database structure, effortlessly handling tables, views, functions, and procedures with Rust's renowned memory safety and zero-cost abstractions. Focused on speed and resource efficiency, it's the ideal solution for microservices and high-traffic APIs.
The name axion not only hints at its foundation on Axum but also resonates with the Spanish word "acciรณn" (action), reflecting its core promise: to take decisive action in transforming your database schema into a fully functional API with minimal effort.
Note: This library is part of a broader ecosystem aimed at simplifying database-to-client workflows, which also includes Python (prism-py) and TypeScript (prism-ts) variants. Axion represents the high-performance Rust engine within this ecosystem.
Note: This is an early version of the library. While functional, it may not be fully stable. Please report any issues you encounter.
๐ High Performance: Built on Tokio and Hyper for maximum throughput.
๐ Memory Safety: Rust's ownership model guarantees thread safety.
โก Async Everything: Fully asynchronous I/O operations without blocking.
๐ Automatic Route Generation: Create CRUD endpoints for database objects.
๐ Database Independence: Support for PostgreSQL, MySQL, and SQLite.
๐งฉ Schema-Based Organization: Routes organized by database schemas for clean API structure.
๐ Enhanced Filtering: Sorting, pagination, and complex query support.
๐ Metadata API: Explore your database structure programmatically.
๐ฅ Health Monitoring: Built-in health check endpoints.
๐ฆ Zero Boilerplate: Generate complete APIs with minimal code โ true "acciรณn"!
๐ Low Resource Usage: Minimal memory footprint and CPU utilization.
Add to your Cargo.toml
cargo add axion
Here's a minimal example to get you started with axion:
use axion::prelude::*;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
// Initialize tracing for logs
tracing_subscriber::fmt::init();
// Configure database connection
let db_config = DbConfig::new()
.database_type(DatabaseType::Postgres) // Example
.host("localhost")
.port(5432)
.database("yourdb")
.username("username")
.password("password")
.build()?;
// Create database client
let db_client = Arc::new(DbClient::new(db_config).await?);
db_client.test_connection().await?;
// Create model manager with selected schemas
let model_manager = Arc::new(ModelManager::new(
db_client.clone(),
vec!["public".to_string(), "app".to_string()]
).await?);
// Initialize API generator
let axion_api = AxionApi::new(model_manager.clone());
// Build router with all generated routes
let app = axion_api.build_router();
// Serve the application
let addr = std::net::SocketAddr::from(([127, 0, 0, 1], 8000));
println!("Listening on http://{}", addr);
axum::Server::bind(&addr)
.serve(app.into_make_service())
.await?;
Ok(())
}
axion is engineered for exceptional performance and minimal resource usage:
This project is licensed under the MIT License. See the LICENSE file for details.