Capstone requirements and architecture
Prerequisite: node-interview-reasoning. Objective: Choose monolith or services for bookstore. Each example is independent. Use Node.js 22.16.0 in a disposable directory; save as main.mjs and run node main.mjs. No external service is contacted.
How it works
Use a modular monolith with native Node HTTP, a domain module and SQLite repository for an offline teaching fixture. The alternative separates catalog and ordering services and requires a reservation protocol, network timeouts, durable messaging and reconciliation. The local monolith keeps inventory decrement, order creation and outbox insert in one transaction. Define integer quantities, tenant identity from a trusted test principal, idempotency keys, response contracts, and recovery requirements. Synthetic identities are not production authentication.
Model a valid order request
function valid(x){return typeof x.bookId==='string'&&x.bookId.length>0&&Number.isInteger(x.quantity)&&x.quantity>=1&&x.quantity<=10;}console.log(valid({bookId:'b1',quantity:2}),valid({bookId:'b1',quantity:0}));Expected output:
true falseThe contract permits bounded positive integer quantities.
Compare two architecture boundaries
const options=[{name:'monolith',atomicStockOrder:true},{name:'split',atomicStockOrder:false}];console.log(options.filter(x=>x.atomicStockOrder).map(x=>x.name).join(','));Expected output:
monolithThe modeled split lacks a shared local transaction; it needs a different consistency protocol.
Common mistake
Do not pretend a distributed service split can reuse a local SQLite transaction across independent databases.
Practice
Read the capstone README and ADR, then describe one condition that could justify separating the catalog service.
Reference candidate: node-capstone-requirements-and-architecture-lookup (route unverified). Original instructional model; independent source review pending.
Administrative lab: staged-capstone/README.md. Run only the supplied synthetic fixture; no production deployment authorized.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Capstone requirements and architecture — knowledge check
Apply the lesson to a fresh scenario and explain the evidence boundary.
Why select a monolith for the local fixture?
Where should tenant identity originate?
What does the split alternative need?