Architecture decisions and modularity
Prerequisite: node-secrets-rotation-and-incident-readiness. Objective: Write an ADR for service split. 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
A modular monolith can preserve simple transactions and deployment while allowing separate ownership of code modules. Services introduce network failure, independently deployed versions, eventual consistency and operational overhead, but can help when teams or scaling requirements genuinely differ. Choose using workload, failure boundaries, team ownership and migration cost. Record why a rejected alternative is not appropriate now and define a trigger for reconsideration.
Evaluate a fictional decision rule
function choose(r){return r.independentDeploy&&r.separateTeam&&r.opsReady?'consider split':'modular monolith';}console.log(choose({independentDeploy:true,separateTeam:false,opsReady:true}));Expected output:
modular monolithThe heuristic is illustrative, not a general architecture classifier.
Check an ADR has review criteria
const adr={context:'one team',decision:'monolith',alternative:'services',consequence:'shared deployment',revisit:'independent scaling demand'};console.log(['context','decision','alternative','consequence','revisit'].every(k=>Boolean(adr[k])));Expected output:
trueA record includes rationale and a condition for revisiting the choice.
Common mistake
Do not count services, layers or folders as evidence of maintainability.
Practice
Write an ADR for a two-person team with one transactional database and an order workload that grows seasonally.
Reference candidate: node-architecture-decisions-and-modularity-lookup (route unverified). Original instructional model; independent source review pending.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Architecture decisions and modularity — knowledge check
Apply the lesson to a fresh scenario and explain the evidence boundary.
What is an ADR for?
What does a service split add?
When should the ADR be revisited?