A starter template for building a REST API with extreme performance and an extremely small memory footprint. Built using Axum, SQLx (PostgreSQL), and Utoipa. Optimized specifically for AI Vibe Coding, Zero Errors, and Alpine Linux Deployment.
The Cargo.toml in this template has been stripped of all heavy default-features. We utilize Tokio's single-threaded runtime (new_current_thread) to guarantee the lowest possible memory footprint. The entire application, including database connection pooling, requires less than 5MB of RAM under heavy load.
- Alpine Static Binary: Natively compiles to
x86_64-unknown-linux-muslfor incredibly small, dependency-free deployments on Alpine Linux VPS. - SQL Compile-Time Checking: Using SQLx, your database queries are validated at compile time.
- Centralized Error Handling: Handlers are extremely clean thanks to a centralized
AppErrorinsrc/error.rs. - Feature-Based Architecture: The
src/modules/*folder structure ensures rapid iteration. - Auto API Docs: Built-in Utoipa SwaggerUI at
/swagger-ui.
IMPORTANT: If you are using an AI Agent (Cursor, Windsurf, Antigravity, etc.), please instruct the AI to read
AI_RULES.mdbefore making any modifications.
- Create new features inside
src/modules/<feature_name>/(handlers.rs,models.rs). - Use
?withAppErrorfor all error propagation. - Register routes in
src/lib.rsand update the UtoipaApiDocstruct.
This project uses a standard Makefile for streamlined development.
- Setup Environment:
cp .env.example .env # Adjust DATABASE_URL inside .env - Development:
make dev
- Production Build (Alpine Static):
make build
- Stress Testing:
make stress-test