Skip to main content
๐Ÿ“œ WAYPOINT LESSON

Checkpoint โ€” Modular Order Processing System

โญโญ intermediateโณ 25 min read๐Ÿ“ Lesson 122 of 265

The DI mini-build: order service with notification and audit, fakes in tests, singletons in the root.

The gate (mini-build)

Assemble the pieces into one composable order pipeline:

  1. IOrderValidator.IsValid(decimal amount) โ€” business rule (amount > 0).
  2. IOrderRepository.Save(Order order) โ€” persistence boundary.
  3. IAuditLog.Record(string message) โ€” audit trail.
  4. OrderProcessor(IOrderValidator, IOrderRepository, IAuditLog) โ€” constructor-injected; Process(decimal amount) returns "ok:<id>" when valid (repository saves, audit records), else "rejected".
  5. BuildProcessor(IOrderRepository repo, IAuditLog audit) โ€” the composition root: registers a singleton validator and transient processor using the provided TinyContainer, resolves and returns the processor.

Order: record Order(int Id, decimal Amount). Repository generates ids starting at 1.