Architecture Best Practices
Optimize for change isolation, not premature distribution. These practices keep Node.js backends evolvable without microservice tax on day one.
Search across all documentation pages
Optimize for change isolation, not premature distribution. These practices keep Node.js backends evolvable without microservice tax on day one.
modules/orders/ owns orders end-to-end; avoid global controllers/ and services/ folders that hide ownership.index.ts exports are cheaper than Kubernetes YAML.infrastructure/.index.ts only. Ban deep imports into peer infrastructure/ with ESLint or dependency-cruiser in CI.main.ts wires adapters; it does not contain business rules.schemaVersion fields; consumers must ignore unknown versions safely.requestId on every line. pino or equivalent; no unstructured console.log in production paths.engines and CI. Node 24.18.0 Active LTS; test upgrades in a dedicated release.Tier A and B. Skip microservice extraction items until you have a second squad blocked on deploys.
Automate in CI with dependency-cruiser. Local npm run lint:arch should match CI exactly.
Yes if versions are semver'd and consumers tolerate lag. Avoid importing another service's internal types from a monolithic shared package that changes daily.
Nest modules map to feature modules, but domain folders should still avoid @Injectable() if you want fast pure unit tests.
No. Use a spike folder with explicit tech-debt ticket to refactor into modules before hiring squad #2.
Prisma client imported from route handlers with 200 lines of business logic - untestable and unextractable.
ADRs record decisions; this list records ongoing hygiene. Link ADRs when a checkbox implies a major fork.
Module boundaries still matter in repo layout. Each Lambda is a nano-service - ops cost shifts to IAM and cold starts.
Quarterly for repos past 12 months old, or after any incident blamed on "unexpected coupling."
Cross-module deep imports trending to zero in CI, and deploy lead time stable as engineer count grows.
Stack versions: This page was written for Node.js 24.18.0 (Active LTS), npm 10+, TypeScript 5.6+, Express 5, Fastify 5, and NestJS 11.
Reviewed by Chris St. John·Last updated Jul 16, 2026