Skip to content

Domain Driven Design

Douglas Lourenço edited this page Jul 30, 2024 · 2 revisions

DDD (Domain-Driven Design)

Domain-Driven Design (DDD) is an approach to developing software for complex needs by deeply connecting the implementation to an evolving model of the core business concepts. Here's a breakdown of how DDD principles have been applied in Orderly:

Domain Storytelling

1.1. Entities

  1. Client: Identified optionally by a Brazilian CPF.
  2. Payment: Represents a transaction that will be used with OHS. Has an associated status (perhaps initiated, processed, confirmed).
  3. Order: Represents a customer's request. It has associated status (Received, Preparing, Ready, Finalized).
  4. Service: Represents the production of food. It has associated products and a client.
  5. Notification: A medium for communication with the user and the restaurant. Will utilize an ACL for integration.
  6. Admin: Handles promotional strategies and stock management.
  7. Stock: Represents the available inventory of products.
  8. Product: Items like Hamburger, Fries, Soda, etc.

1.2. Value Objects

  1. ProductDetails: For Product, attributes like Name, Description, NutritionalInfo, etc., can be value objects. They don't have an identity on their own, but they describe a Product.
  2. PaymentDetails: For Payment, attributes like Amount, Currency, QRCode can be value objects.
  3. NotificationContent: For Notification, details like Message, Timestamp, and Type could be value objects.

1.3. Aggregates

  1. Check-in: Rooted at Client, with Order being part of the aggregate.
  2. Check-out: Rooted at Order, which affects both Deliver and Production.
  3. Communication: Rooted at the Notification system, interfacing via an ACL.
  4. Billing: Rooted at Payment, using ACL to conform with OHS.
  5. Admin: Rooted at Admin, influencing the Stock.

1.4. Domain Events

  1. ClientRegistered: Triggered when a client registers.
  2. ProductsSelected: Triggered when products are selected.
  3. OrderCreated: Triggered after order creation.
  4. PaymentProcessed: Triggered during the payment process.
  5. PaymentApproved: Triggered upon payment confirmation.
  6. StatusUpdatedToReceived: Triggered when order status changes.
  7. ClientNotified: Triggered to notify the client.

Event Storming

Event Storming

Context Map

DDD Context Map