Ask HN: How to structure Rust, Axum, and SQLx for clean architecture?
9 points by ekusiadadus 1 year ago | 4 commentsSpecifically, I have created a mock-up as shown in the URL below: https://github.com/ekusiadadus/rust-clean-arch
The structure is as follows:
``` . ├── Cargo.lock ├── Cargo.toml ├── Makefile ├── README.md ├── cfn │ ├── Cargo.toml │ └── src │ └── main.rs ├── docker-compose.yml ├── migrations │ └── 20240504184155_create_user.sql └── src ├── application │ ├── Cargo.toml │ └── src │ ├── lib.rs │ ├── session_service.rs │ └── user_service.rs ├── controller │ ├── Cargo.toml │ └── src │ ├── lib.rs │ └── user_controller.rs ├── domain │ ├── Cargo.toml │ └── src │ ├── lib.rs │ ├── repository.rs │ ├── session.rs │ └── user.rs ├── infrastructure │ ├── Cargo.toml │ └── src │ ├── db.rs │ ├── lib.rs │ ├── session_repository.rs │ └── user_repository.rs └── main.rs ```
Please let me know if there is anyone familiar with DDD (Domain-Driven Design) or clean architecture.
- AA-BA-94-2A-56 1 year agoArchitecture looks good. I went off the deep end looking into ways to structure Axum projects. I looked into separating services and having them talk to each other with channels.
In the end, the best practice for engineering software is usually to keep it simple. I've had to learn that I'm too often trying to overengineer things, and I end up getting nothing done.
- ekusiadadus 1 year agoThank you. Indeed, that's true. I'll create this and use it as a template to avoid focusing too much on directory structures in the future.
- ekusiadadus 1 year ago
- 1 year ago
- ianpurton 1 year agoYou can check out https://github.com/bionic-gpt/bionic-gpt
Basically I put db in it's own crate then crates for controller and another for pages.
The folders for each section of the web application.
- ekusiadadus 1 year agoIt looks good... But what I want to know is the DDD (or clean architecture) based project.
It seems that bionic-gpt is not based on them :(
Anyway, thank you!
- ekusiadadus 1 year ago