Skip to content

benracine/axum-rest-api-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rust + Axum + SQLx + Utoipa Minimal REST API

Quick Start

  • Git clone the repo
  • Move into the root
  • cargo run
  • visit localhost:3000/docs to see the interactive OpenAPI / Swagger UI

Summary

A lightweight REST API for managing users, built with:

  • Axum for the async web framework
  • SQLx for compile-time safe SQL queries
  • Utoipa for automatic OpenAPI documentation

Features

  • Fast and safe: Built in async Rust, combining performance with safety guarantees
    • Very resource efficient
  • Type-safe SQL: All queries are validated at compile time with sqlx
  • Self-documenting API: OpenAPI docs are generated directly from the route definitions using utoipa
  • Developer-friendly: Simple cargo watch -x check -x test -x run dev cycle
  • Health check endpoint: Easily monitored with Prometheus or external uptime tools
  • Basic endpoint tests included — easy to extend to full integration tests
  • Deployable to AWS Lambda in just a few lines of code
  • Could also be run on a small EC2 instance or ECS container
    • On premises, use Docker to run the app in a container on local hardware
  • Low cost on AWS:
    • ~$1.20 per million requests using Lambda + API Gateway
  • Clean architecture:
    • Separation of routes, state, and error handling makes it Lambda- and container-friendly

What’s Next

  • Add schemars to help create a connection between the structs and the database structure
  • Add full integration tests for DB + API behavior using Schemathesis or similar against the public API and docs
  • Set up a CI/CD pipeline for building, testing, and deploying the app

About

Simple Axum Service that is self-validating, self-documenting, and supports type-safe SQL queries

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages