Architectural Modes
Phexium supports two architectural modes that coexist within the same application.
In This Section
- Bus Mode - CQRS with Command/Query buses
- Direct Mode - Direct UseCase invocation
- Hybrid Mode - Combining both approaches
- Decision Matrix - When to use which mode
Overview
| Mode | Pattern | Use Case |
|---|---|---|
| Bus Mode | Commands/Queries dispatched via buses | Complex business logic, domain events, transactions |
| Direct Mode | UseCase classes called directly | Simple operations, read-only views, rapid prototyping |
Quick Comparison
Bus Mode routes messages through CommandBus or QueryBus. Handlers process messages, publish events, and manage transactions. Middleware can intercept messages for logging, authorization, or validation.
Direct Mode calls UseCase classes directly from controllers. Simpler flow with explicit Request/Response objects. No middleware pipeline, but faster for straightforward operations.
Choosing a Mode
Use Bus Mode when:
- Business logic requires domain events
- Operations need transaction management
- Middleware is needed (authorization, logging)
- Feature may require async processing later
Use Direct Mode when:
- Simple read-only operations
- No domain events needed
- Rapid prototyping
- Homepage, dashboards, basic queries
See Decision Matrix for detailed guidance.