How inklabs/kommerce-core works
Main Components
• Action Layer (Use Cases): Representing “Commands” and “Queries” that serve as the entry points into the system. These are used to drive the application’s use cases. Display the CommandBusInterface and QueryBusInterface as the core dispatchers that route actions.
• Action Handlers: Separate handlers (grouped by domain, e.g., “Cart”, “Product”, “Order”, “Coupon”, etc.) that process incoming Commands and Queries. They coordinate with other system components.
• Domain Entities: “Plain” PHP objects that encapsulate business logic. These include classes such as Product, Cart, Order, Tag, etc. They hold business behavior and relationships.
• Data Transfer Objects (EntityDTO): Used to flatten the complex object graphs held by Entities into a format suitable for presentation. Emphasize the use of DTO Builders for creating these objects.
• Domain Events and Event Dispatcher: Show how Domain Events (e.g., PasswordChangedEvent or OrderCreatedFromCartEvent) are raised by Entities and later dispatched by services through an event dispatcher.
• Infrastructure/Lib Layer:
• Utility classes (e.g., Mapper, Uuid classes, Authorization, etc.).
• Command and Query Buses (that are responsible for action dispatching).
• Payment Gateway and Shipment Gateway integrations.
• Other utility support elements like the FileManager, XMLSerializer, and pricing utilities.
Relationships and Data Flows
• Directional data flow from the Action layer (Commands/Queries) that are dispatched via the CommandBus/QueryBus.
• Flow from actions to the corresponding Action Handlers which then interact with Domain Entities and Domain Services.
• Flow of Data Transfer Objects being built by DTO Builders from Entities so that view templates (or any presentation layer) can use a clean, flattened data structure.
Architectural Patterns and Design Principles
• CQRS pattern: clearly separate the Command path (which does not return a value but may result in side effects) from the Query path (which constructs DTOs and returns data).
• “Domain Event” mechanism that decouples state changes in Entities from subsequent system reactions.
• “Separation of Concerns” and “Dependency Inversion” principles by showing how the Action Handlers, Domain Services, Repositories, and Infrastructure interact strictly via well-defined interfaces.
• With “SOLID” indicators where each module is responsible for its specific concern.
Relevant Technologies and Frameworks
• PHP/Composer for dependency management.
• Doctrine 2 ORM for entity persistence (reference the mapping files in “config/” and “src/Doctrine/Mapping”).
• PHPUnit (as found under “tests/”) for TDD.
• Adherence to PSR-2 and PSR-4 in naming and auto-loading.
• External Payment and Shipment Gateways (e.g., StripeFake, EasyPostGateway).
Recap for the Principal Software Engineer
• How Action Handlers invoke Domain Entities and Services.
• How the Repository layer abstracts persistence (using Doctrine ORM) and how Entities are built into DTOs for presentation.
• Domain Events mechanism that decouples state changes from reactive processes.
• Be very detailed: capture all major interactions without oversimplification—each architectural layer should be clearly segregated while showing its interaction points with other layers.