Production-style Axum service layout with Domain-Driven Design (DDD) layering (compare with go-gin-template and fastapi-template): config.ini, health check (Postgres + Redis), OpenAPI + Swagger UI, optional Basic auth for docs, SQLx migrations, Docker Compose.
| Layer | Path | Role |
|---|---|---|
| API (infrastructure entry) | src/api |
HTTP routes, auth for /api/docs, DTO/JSON, Axum Router |
| Application | src/application |
Use cases / application services; orchestrate domain + ports |
| Domain | src/domain |
Entities, value objects, DomainError, ports (traits) |
| Infrastructure | src/infrastructure |
Postgres (SQLx), Redis, adapters implementing domain ports |
| Config | src/config.rs |
config.ini (and CONFIG_INI / CONFIG_PATH override) |
Add new bounded context under src/domain/<name>/, a repository port in domain/ports/, an application service, an adapter in infrastructure/, and routes under src/api/.
- Copy
config.ini.exampletoconfig.iniand set[POSTGRES],[REDIS], and optionally[DOCS]for Basic-protected docs. - Start Postgres and Redis, then run
cargo run(default port8000). - Migrations run automatically on boot unless
SKIP_MIGRATIONS=1.
Endpoints:
GET /→ redirect to/api/docsGET /api/root/health— JSON (database/redis+ HTTP 200 vs 503)GET /api/root/welcome— example domain + application use caseGET /api/docs— Swagger UI (from CDN, loadsopenapi.jsonbelow)GET /api/openapi.json— embeddedassets/openapi.json
From the repository root:
make compose-up
# or: docker compose -f docker/docker-compose.yml up --builddocker/config.docker.ini is baked into the image; migrations/ can be bind-mounted for local iteration.
make run/make build/make test/make clippymake compose-up— full stackmake migrate-up— requires sqlx-cli andDATABASE_URLmatching yourconfig.iniDSN
MIT