TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: How to structure Rust, Axum, and SQLx for clean architecture?

9 pointsby ekusiadadusabout 1 year ago
I would like to know the best practices for structuring directories and packages to implement clean architecture using Rust, Axum, and SQLx.<p>Specifically, I have created a mock-up as shown in the URL below: https:&#x2F;&#x2F;github.com&#x2F;ekusiadadus&#x2F;rust-clean-arch<p>The structure is as follows:<p>``` . ├── 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 ```<p>Please let me know if there is anyone familiar with DDD (Domain-Driven Design) or clean architecture.

2 comments

AA-BA-94-2A-56about 1 year ago
Architecture 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.<p>In the end, the best practice for engineering software is usually to keep it simple. I&#x27;ve had to learn that I&#x27;m too often trying to overengineer things, and I end up getting nothing done.
评论 #40310764 未加载
ianpurtonabout 1 year ago
You can check out <a href="https:&#x2F;&#x2F;github.com&#x2F;bionic-gpt&#x2F;bionic-gpt">https:&#x2F;&#x2F;github.com&#x2F;bionic-gpt&#x2F;bionic-gpt</a><p>Basically I put db in it&#x27;s own crate then crates for controller and another for pages.<p>The folders for each section of the web application.
评论 #40310783 未加载