Skip to content

Domain Model

This document describes the problem domain using Domain-Driven Design (DDD) concepts: the core entities, the ubiquitous language shared by the team, and the bounded contexts that define service boundaries.

Domain Overview

The system manages the delivery of packages using drones. The main entities are:

  • Customer — the user who requests a package delivery.
  • Package — the item to be delivered (characterised by its weight).
  • Delivery — the process and record of transporting a package from source to destination.
  • Drone — the autonomous vehicle that physically performs the delivery.

Domain Model Diagram

Domain

Relationships:

  • A Customer creates a Delivery for a Package.
  • A Delivery is assigned to a Drone.
  • A Drone transports the Package from the source address to the destination address.

Ubiquitous Language

A shared vocabulary used consistently in the code, the API and this documentation.

Term Meaning
Customer A user who requests a delivery.
Order A customer's request to ship a package, identified by a unique orderId.
Package The object to be delivered; its weight constrains which drone can carry it.
Delivery The process and record of moving a package from fromAddress to toAddress.
Drone The autonomous vehicle that performs the delivery.
Drone State The lifecycle phase of a drone: Sleeping, InTransit or Returning.
SAGA The distributed transaction that coordinates an order across all services.
Compensation The rollback action that undoes a completed SAGA step after a later failure.

Bounded Contexts

Each bounded context owns a cohesive part of the domain and maps to exactly one microservice. This strict alignment satisfies requirement NFR-02 (see Analysis).

Bounded Context Responsibility Mapped Service
Order Acquisition Context Handles the interaction with the customer, validates order requests, and captures the intent to ship a package. It also orchestrates the SAGA. customer-service
Delivery Logistics Context Orchestrates the fulfilment of an order. It acts as the "brain" that decides how and when a delivery is executed. delivery-service
Drone Fleet Context Manages the physical resources (drones), their lifecycle (state changes), and the physical-movement simulation. drone-service

Context Map

The context map shows how the bounded contexts relate and integrate (all integration is via asynchronous messaging through RabbitMQ).

Context Map

Example Order Flow

  1. A Customer submits a delivery Order.
  2. The Order Acquisition context validates it and starts a SAGA.
  3. The Delivery Logistics context forwards the order to the drone fleet.
  4. The Drone Fleet context assigns a Drone, which picks up and delivers the Package.
  5. The SAGA records the outcome; the delivery status is then available to the Customer.

If any step fails, the SAGA triggers compensation, undoing the completed steps in reverse order.


See Design for architecture, patterns and sequence diagrams, and API for endpoint details.