A Rust-based web API built with Axum, Tokio, and Tracing.
- High Performance: Built on top of Axum and Tokio.
- Observability: Integrated tracing for logging and diagnostics.
- Simple Architecture: Clean separation of concerns (Routes, Handlers, Models).
- Background Removal: AI-powered background removal using BiRefNet on Modal.
- Image Upscaling: AI-powered upscaling using Real-ESRGAN on Modal.
- Rust (2024 edition)
-
Clone the repository:
git clone ssh://git@codeberg.org/hanaworks-opensource-project/nijika-api.git cd nijika-api -
Set up environment variables: Copy
.env.exampleto.env(if available) or create one.cp .env.example .env
-
Run the server:
cargo run
-
Test the health check:
curl http://127.0.0.1:3000/health
The application can be configured using environment variables.
| Variable | Description | Default |
|---|---|---|
HOST |
The interface to bind to | 127.0.0.1 |
PORT |
The port to listen on | 3000 |
RUST_LOG |
Log level (e.g., info, debug) |
error (default if unset) |
MODAL_REMOVEBG_URL |
URL of the deployed Modal worker | http://localhost:8000 |
MODAL_UPSCALER_URL |
URL of the deployed Upscaler worker | http://localhost:8001 |
RATE_LIMIT_PER_SECOND |
Max requests per second | 50 |
RATE_LIMIT_BURST |
Max burst size | 100 |
The project follows a modular structure:
- Routes: Route definitions.
- Handlers: Business logic.
- Models: Data structures.
For a detailed overview, see Architecture Overview.
For detailed endpoint documentation, see the API Reference.
GET /health
Returns the status of the API.
Response:
- 200 OK
{ "status": "ok" }
cargo testcargo fmt
cargo clippy