axum-hexagonal

Structure Rust Axum APIs with hexagonal architecture separating domain from infrastructure.

Updated Mar 18, 2025
One-click install
npx skills add https://github.com/zzoohub/mealio --skill axum-hexagonal
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: axum-hexagonal
Source: https://github.com/zzoohub/mealio/tree/main/.claude/skills/axum-hexagonal
Command: npx skills add https://github.com/zzoohub/mealio --skill axum-hexagonal

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Build scalable and maintainable Rust APIs by applying a hexagonal architecture that cleanly separates domain from infrastructure.

Core Features & Use Cases

  • Domain-driven design: model domain entities and business rules isolated from HTTP or DB concerns.
  • Ports & Adapters: define service traits and repository adapters to plug in infrastructure.
  • Service Layer & Testing: orchestrate use cases with testable, replaceable components; supports unit and integration testing.
  • Guidance & Limitations: clarifies when to use this approach versus other patterns.

Quick Start

Set up a Rust Axum API using hexagonal architecture by defining domain models, ports, adapters, and a service layer, then wire HTTP handlers without importing infrastructure crates into the domain.

Frequently Asked Questions about axum-hexagonal

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I separate domain logic from infrastructure in a Rust web service?

Apply hexagonal architecture in Rust by defining domain models, ports as service traits, and infrastructure adapters to cleanly separate business rules from HTTP and database concerns.

What is the best way to structure a testable Rust Axum API?

Structure a testable Rust Axum API using a service layer and ports-and-adapters pattern, keeping framework crates out of the domain code so components remain replaceable for unit and integration testing.

How does the ports and adapters pattern work for domain-driven design in Rust?

Ports and adapters in Rust define service traits representing use cases and repository adapters that plug in infrastructure, allowing domain entities and business rules to remain isolated from external dependencies.

When should I use hexagonal architecture for a Rust API instead of other patterns?

Use hexagonal architecture for Rust APIs when you require strict testability, modularity, and clear separation between domain and infrastructure, but consider simpler patterns if these are not primary concerns.

Can I build a Rust API with hexagonal architecture without coupling my domain to a web framework?

Yes, you can wire HTTP handlers in Axum without importing infrastructure crates into the domain, using service traits to orchestrate use cases while keeping domain code completely framework-agnostic.