Skip to content

Latest commit

 

History

History
134 lines (98 loc) · 2.59 KB

File metadata and controls

134 lines (98 loc) · 2.59 KB

Domain

Objective

Build a small warehouse GraphQL API with 6 warehouse-domain tables:

  • Organization
  • Supplier
  • StorageArea
  • Product
  • StockMovement
  • MovementLine

Add one supporting identity table outside the warehouse domain:

  • User

User exists for authentication and organization membership. It is not a warehouse concept.

Minimum useful features:

  • Create organization
  • Create supplier
  • Create storage area
  • Create product
  • Create stock movement with lines
  • Read stock movements by storage area
  • Read products by supplier
  • Read products by organization
  • Read one stock movement with its lines and products

The most important business rule

A stock movement must have at least one movement line, and every movement line must have a positive quantity and a non-negative unit cost.

Second important rule

Use only products that belong to the same organization as the storage area.

Money rule

Prices and costs must be represented with a Money value object, not floating point numbers. Store money in the domain as integer cents, and map it carefully at the database and GraphQL boundaries.

lineTotal is computed from quantity * unitCost in the domain model. Do not store it as a movement line column at first.

Simplification

Each product belongs to exactly one supplier in this project. A real inventory system may later introduce a ProductSupplier join table so the same product can be purchased from multiple suppliers.

Domain model

The Ulid suffix is only used here to make identity fields explicit in the domain sketch. The implementation can still use simpler names such as id, organizationId, or productId.

User (identity/authentication)

  • userUlid
  • organizationUlid
  • email
  • passwordHash

Organization

  • organizationUlid
  • name
  • email

Supplier

  • supplierUlid
  • organizationUlid
  • name
  • email

Product

  • productUlid
  • organizationUlid
  • supplierUlid
  • sku
  • label
  • unit
  • purchasePrice
  • isActive

StorageArea

  • storageAreaUlid
  • organizationUlid
  • code
  • label

StockMovement

  • stockMovementUlid
  • storageAreaUlid
  • movementDate
  • reference
  • description

MovementLine

  • movementLineUlid
  • stockMovementUlid
  • productUlid
  • quantity
  • direction
  • unitCost
  • description
StorageArea
   │
   └──────< StockMovement
                 │
                 └──────< MovementLine >────── Product

Vocabulary

  • Money / Montant
  • Product / Produit
  • Supplier / Fournisseur
  • Storage area / Zone de stockage
  • Stock movement / Mouvement de stock
  • Movement line / Ligne de mouvement