Actix-Web Server
An async RESTful notes service built with Actix-Web, Tokio, SQLx and SQLite: the architecture, the routes and the setup.
A lightweight backend service built with modern Rust web technologies, usable as the backend for a full-stack app or an API-centric one.
Tools
rust 1.83.0actix_web 4.0tokio 1.0sqlx 0.8.2serde 1.0- CI
The service is a RESTful backend built with the Actix-Web framework, handling fast, asynchronous HTTP operations.
The crates it leans on:
actix_webfor the web servertokiofor the async runtimesqlxfor SQL database interaction (with SQLite in this case)serdefor data serialization
Architecture overview
Note Service is structured as a standalone binary crate designed to perform common backend tasks:
- Asynchronous request handling
- Persistent database support via SQLite
- JSON serialization and deserialization
- RESTful route definitions
- Clean separation of logic and data access
Features
- Fully async, using
tokioandactix-web - CRUD API for a simple note model:
GET /notesGET /notes/{id}POST /notesPUT /notes/{id}DELETE /notes/{id}
- Database abstraction via
sqlx - Ready to run with migrations and seed setup
- Structured error handling and API responses
Installation and setup
-
Install Rust (if not already):
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -
Install the
sqlxCLI:cargo install sqlx-cli --features sqlite -
Prepare the database:
cargo sqlx prepare cargo sqlx migrate run -
Run the server:
cargo build cargo run -
Open your browser:
http://127.0.0.1:8080
API endpoints
| Method | Endpoint | Description |
|---|---|---|
| GET | /notes | List all notes |
| GET | /notes/{id} | Get a specific note |
| POST | /notes | Create a new note |
| PUT | /notes/{id} | Update an existing note |
| DELETE | /notes/{id} | Delete a note |
Use cases
- A lightweight backend for a frontend SPA (e.g. Yew, React)
- A way to learn real-world Actix patterns
- Boilerplate for full-stack Rust apps with a WebAssembly frontend
License
This project is licensed under the MIT License, free for personal or commercial use.
Neighbors in time
Related: the posts that share this one's subject, and where the thread goes next.