This project is a study application created to explore Clean Architecture principles in Rust. It is based on the tutorial provided in this video: Building a Clean Architecture in Rust. The project aims to demonstrate how to structure a Rust application following clean architectural practices, utilizing Actix-web for the web framework and Diesel for ORM with PostgreSQL.
- Rust
- Docker
- Docker Compose
- PostgreSQL (or use Docker Compose to set it up automatically)
-
Clone the repository:
git clone https://github.com/loanmatteusz/clean-arch-rust.git cd clean-arch-rust
-
Set up the database using Docker Compose:
docker-compose up -d
-
Configure environment variables:
Create a
.env
file in the root of the project with the following content:DATABASE_URL=postgres://admin:admin@localhost:5434/user_db
-
Install project dependencies:
cargo build
-
Run database migrations:
diesel migration run
Make sure you have Diesel CLI installed:
cargo install diesel_cli --no-default-features --features postgres
-
Start the server:
cargo run
-
API Endpoints:
POST /api/v1/users/
: Register a new user.GET /api/v1/users/{email}
: Retrieve a user by email.
Use tools like Insomnia or Postman to test the endpoints.
Example JSON body for registering a new user:
{
"name": "User Test",
"email": "usertest@example.com",
"phone": "1234567890",
"address": "User's Street"
}