This project is a boilerplate for building a Rust application server using the Axum framework and MongoDB as the database. It provides a solid starting point for building your own Rust applications, with many common features already implemented.
- Axum server: A modern and fast web framework with a focus on ergonomics and modularity.
- MongoDB driver: A Rust driver for MongoDB, allowing you to interact with MongoDB collections.
- Logging: Logging support using
tracing
andtracing-subscriber
for async-compatible logging. - Error handler: Application error handling system.
- Router: A router for mapping requests to handlers, cors, and static files.
- Static: Static file serving using
tower-http
. - Extractors: Validation extractor for getting data from requests and validate with
validator
crate. - App config (dotenvy): Load your application's configuration from a
.env
file.
- Authentication: User authentication system.
- Hashing: Password hashing
- Jwt utils: Utilities for working with JWTs.
- Server Metrics
The project is organized into several crates:
database
: Contains the MongoDB driver and user model and repository.server
: Contains the main application server, including the API, router, and services.utils
: Contains utility modules like config and errors.
- Clone the repository.
- Install the Rust toolchain if you haven't already.
- Run
cargo build
to build the project. - Run
cargo run
to start the server.
You can install cargo-watch to automatically recompile the project when changes are made:
cargo install cargo-watch
Then run cargo watch -x run
to start the server.
Contributions are welcome!
This project is licensed under the MIT License - see the LICENSE file for details.