Skip to content

MSC29/clean-architecture-rust

Repository files navigation

Clean architecture: rust

A Clean Architecture template for a Rest API in rust

How it works

Motivations, explanations, requirements & more details in my article Practical Clean Architecture in Typescript, Rust & Python

Installing

cargo build

Database setup

It's currently configured to run with PostgreSQL through Diesel (ORM), but this being clean architecture feel free to change it :)

I suggest

Then install diesel_cli

diesel setup --database-url postgresql://postgres:postgres@localhost/animal_fact_db
diesel migration run --database-url postgresql://postgres:postgres@localhost/animal_fact_db

Running

define the environment on which we're running by adding ENV=<env>, which will use the .env.<env> file

ENV=dev cargo run

Code quality & security

Used in CI/CD

cargo fmt --all -- --check
cargo clippy --all-targets
cargo audit
cargo outdated

Testing

Here's what done in order to mock the SPI

  • db: every test is creating a new database from TestContextPostgreSQL with json fixtures in test/fixtures & spawns the app with this database
  • http: every test also spins up another rust api (if not already up) with the expected routes but test data in test/fixtures
ENV=test cargo test

API Documentation

TODO: https://github.com/paperclip-rs/paperclip

About

A Clean Archtiecture template for a Rest API in rust

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published