How switchboard-risk/small-order works
tiny-orders is a Ruby order-management app: users create orders, add catalog products, and move orders through submission, payment, fulfillment, or cancellation. The service coordinates the order state machine, inventory rules, and persistence; repositories map domain objects to SQLite. The README documents the CLI workflow and persistent database. Source excerpts show the service and repository calls; cancellation’s effect on reserved inventory is not established by the excerpt, so that relationship is omitted.
Main entry points: order_service.rb Order service · order_repository.rb Order repository · db.rb Database setup · product_repository.rb Product repository
Components 12
CLI entry
- Orders CLI
bin/orders
Order coordination
- Order service
lib/order_service.rb
Order and inventory domain
- Order state machine
lib/order.rb - Line item
lib/line_item.rb - Catalog product
lib/product.rb - Transition error
lib/illegal_transition.rb - Stock error
lib/insufficient_stock.rb
SQLite persistence
- Order repository
lib/order_repository.rb - Product repository
lib/product_repository.rb - Database setup
lib/db.rb - Orders database
db/orders.sqlite3
Other components
- CLI user
Connections 16
- CLI user → Orders CLI: runs commands
README.md - Orders CLI → Order service: requests operations
README.md - Order service → Order repository: loads and saves
lib/order_service.rb - Order service → Product repository: looks up and saves
lib/order_service.rb - Order service → Order state machine: changes state
lib/order_service.rb - Order service → Line item: creates items
lib/order_service.rb - Order service → Catalog product: adjusts inventory
lib/order_service.rb - Order state machine → Transition error: raises on invalid state
lib/order.rb - Catalog product → Stock error: raises on short stock
lib/product.rb - Order repository → Order state machine: reconstructs orders
lib/order_repository.rb - Order repository → Line item: loads and saves items
lib/order_repository.rb - Product repository → Catalog product: maps products
lib/product_repository.rb - Order repository → Database setup: executes SQL
lib/order_repository.rb - Product repository → Database setup: executes SQL
lib/product_repository.rb - Order service → Database setup: wraps transactions
lib/order_service.rb - Database setup → Orders database: persists records
README.md