A modular, production-ready Rust monorepo implementing Clean Architecture with a fully structured workspace.
🧩 Multi-crate Monorepo • ⚡ Scalable Architecture • 🧱 Clear Layer Boundaries • 🎯 Best Practices Included
- 📁 Perfectly organized clean architecture workspace (API ▶ Application ▶ Domain ▶ Infrastructure ▶ Common)
- 🔧 Pre-wired modules, handlers, services, repos, mappers, migrations
- 🧪 Test-ready crates
- 🔌 Dependency boundaries enforced by Rust workspaces
- ⚙️ Drop-in ready for real projects
- 📦 Extensible without breaking architecture rules
packages/
├── api/ # Presentation layer (HTTP server, endpoints)
├── application/ # Use cases, handlers, orchestration logic
├── domain/ # Entities, commands, queries, domain events
├── database/ # Database, migrations
├── infrastructure/ # Repositories, mappers
└── common/ # Shared utilities & error types
Below is a crisp overview of what each package does — rewritten as general-purpose modules, not tied to a specific domain.
Purpose: HTTP entrypoint. Handles requests, maps them to application use cases, sets up DI, routing, and service initialization. Based on warp.
Key Components:
main.rs— server startup, config loadstartup.rs— dependency injection + routingendpoints/— request handlers, grouped by feature
Purpose: Implements use cases, command/query handlers, and high-level application services. Coordinates domain logic while staying infrastructure-agnostic.
Key Components:
- Command Handlers
- Query Handlers
- Application Services
- Module registries
Purpose: The core. Pure business logic: entities, value objects, aggregates, commands, queries, domain events.
Key Components:
entities/commands/queries/events/
No external dependencies. 100% pure Rust business rules.
Purpose: Implements storage, persistence, migrations based on sea-orm.
Key Components:
- Database Connection Helper
- Migrations
Purpose: Implements external APIs, mappers, repositories and infra-level services.
Key Components:
- DB models
- Mappers (Domain ↔ Storage)
- Infra services
Shared error types, abstractions, helpers used across crates.
api
↳ application
↳ common
application
↳ domain
↳ common
domain
↳ common
infrastructure
↳ domain
↳ common
common
(no deps)
Rules enforced in this boilerplate:
api= only place where infrastructure is composed and injectedapplication+domainare completely infra-agnosticinfrastructureimplements interfaces, but no crate depends on it except the composition root
Clean Architecture guaranteed.
git clone https://github.com/sushant-at-nitor/warp-microservice
cd warp-microservice
cargo build --workspace
cargo run -p apicargo test # Run tests
cargo fmt # Format code
cargo clippy # Lint- Root
.env— shared workspace config packages/api/.env— API-specific settings (port, DB URL, etc.)
- Fork
- Create branch
- Commit + push
- Open PR
MIT License.
Here is the general sequence flow for a typical create operation in this boilerplate:
sequenceDiagram
participant Client
participant API as api::endpoint
participant AppHandler as application::command_handler
participant AppService as application::service
participant Domain as domain::entity
participant InfraService as infrastructure::service
participant InfraRepo as infrastructure::repository
Client->>API: HTTP Request (data)
API->>AppHandler: Command parsed from request
AppHandler->>AppService: execute(command)
AppService->>Domain: create/validate entity
AppService->>InfraService: persist(entity)
InfraService->>InfraRepo: save(entity)
InfraRepo-->>InfraService: saved (ID/Result)
InfraService-->>AppService: success
AppService-->>AppHandler: response DTO
AppHandler-->>API: result
API-->>Client: HTTP Response
Clean, layered, predictable flow — suitable for any domain.