rust-architecture-patterns

Guide Rust developers in applying Hexagonal, Onion, and Clean architecture patterns.

Updated Jan 20, 2026
One-click install
npx skills add https://github.com/Davincible/GHOSTNET --skill rust-architecture-patterns
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: rust-architecture-patterns
Source: https://github.com/Davincible/GHOSTNET/tree/main/.opencode/skill/rust-architecture-patterns
Command: npx skills add https://github.com/Davincible/GHOSTNET --skill rust-architecture-patterns

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Rust projects often struggle with maintainability as they grow; this Skill provides architectural patterns to keep codebases modular and scalable.

Core Features & Use Cases

  • Hexagonal Architecture (Ports & Adapters): isolates domain logic from infrastructure, enabling easy testing and swapping implementations.
  • Onion/ Clean Architecture patterns: organizes code into concentric layers with clear dependency rules.
  • Domain-Driven Design concepts: bounded contexts, entities, value objects, and domain services to model complex domains in Rust.
  • Module Organization guidance: file-based vs mod.rs structure, visible boundaries, and re-exports to create stable public APIs.
  • Dependency Injection guidelines: constructor-based injection, when to use generics vs trait objects, and composition roots for wiring.

Quick Start

To begin, create a new Rust project and apply the patterns by defining domain models, ports, and adapters; organize modules following the recommended structure; and start implementing services that depend on abstracted interfaces rather than concrete infrastructures.

Frequently Asked Questions about rust-architecture-patterns

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

FAQPage Schema
How do I structure a Rust project for maintainability and scale?

Apply Hexagonal and Onion architecture patterns to enforce clear layer boundaries in Rust. This isolates domain logic from infrastructure, enabling modular, testable, and scalable crates as your codebase grows.

What is the best way to implement Domain-Driven Design in Rust?

Model complex domains in Rust by defining bounded contexts, entities, value objects, and domain services. This approach maintains compile-time safety while strictly separating core domain logic from infrastructure.

How do I organize Rust modules for stable public APIs?

Organize Rust modules using file-based or mod.rs structures to create visible internal boundaries. Apply re-exports and disciplined layering to build stable public APIs and maintain clear component separation.

Should I use generics or trait objects for dependency injection in Rust?

Choose generics for compile-time safety or trait objects for dynamic dispatch when applying dependency injection in Rust. Wire dependencies at a composition root, injecting abstracted interfaces rather than concrete implementations.

When do I need Hexagonal Architecture in my Rust application?

You need Hexagonal Architecture when you must isolate domain logic from infrastructure using ports and adapters. This pattern enables easy testing and swapping of infrastructure implementations in scalable Rust applications.