DeliveryKing E-Commerce Engine (Rust)
High-performance, modular asynchronous e-commerce backend built in Rust for resilient product catalogs, secure JWT authentication, and sub-millisecond queries.
Why this was built
Traditional e-commerce backends built on heavy monolithic runtimes consume significant server memory, suffer from slow cold-starts, and incur runtime database query crashes due to weak type-safety guarantees.
Technical Approach
Architected a lean, asynchronous backend in Rust (2024 Edition) using Axum and Tokio. Implemented compile-time verified SQL queries via SQLx against PostgreSQL, Argon2 password hashing, JWT authentication middleware, and auto-generated Swagger OpenAPI 3.1 documentation with Utoipa.
// Asynchronous Axum route with type-safe SQLx query execution
pub async fn get_product_by_id(
State(pool): State<PgPool>,
Path(product_id): Path<Uuid>,
) -> Result<Json<ProductResponse>, (StatusCode, String)> {
let product = sqlx::query_as!(
ProductResponse,
"SELECT id, title, price, stock, category_id, created_at FROM products WHERE id = $1",
product_id
)
.fetch_optional(&pool)
.await
.map_err(|e| (StatusCode::INTERNAL_SERVER_ERROR, e.to_string()))?
.ok_or((StatusCode::NOT_FOUND, "Product not found".to_string()))?;
Ok(Json(product))
}Key Architectural Features & Outcomes
Built with Rust (2024 Edition) on Tokio multi-threaded asynchronous runtime
Compile-time verified SQL queries using SQLx and PostgreSQL
Interactive Swagger OpenAPI 3.1 live documentation via Utoipa
Argon2 secure password hashing and JWT token authentication middleware
Containerized deployment setup with Docker Compose