@wazir-dev/cli 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +111 -0
- package/CHANGELOG.md +14 -0
- package/CONTRIBUTING.md +101 -0
- package/LICENSE +21 -0
- package/README.md +314 -0
- package/assets/composition-engine.mmd +34 -0
- package/assets/demo-script.sh +17 -0
- package/assets/logo-dark.svg +14 -0
- package/assets/logo.svg +14 -0
- package/assets/pipeline.mmd +39 -0
- package/assets/record-demo.sh +51 -0
- package/docs/README.md +51 -0
- package/docs/adapters/context-mode.md +60 -0
- package/docs/concepts/architecture.md +87 -0
- package/docs/concepts/artifact-model.md +60 -0
- package/docs/concepts/composition-engine.md +36 -0
- package/docs/concepts/indexing-and-recall.md +160 -0
- package/docs/concepts/observability.md +41 -0
- package/docs/concepts/roles-and-workflows.md +59 -0
- package/docs/concepts/terminology-policy.md +27 -0
- package/docs/getting-started/01-installation.md +78 -0
- package/docs/getting-started/02-first-run.md +102 -0
- package/docs/getting-started/03-adding-to-project.md +15 -0
- package/docs/getting-started/04-host-setup.md +15 -0
- package/docs/guides/ci-integration.md +15 -0
- package/docs/guides/creating-skills.md +15 -0
- package/docs/guides/expertise-module-authoring.md +15 -0
- package/docs/guides/hook-development.md +15 -0
- package/docs/guides/memory-and-learnings.md +34 -0
- package/docs/guides/multi-host-export.md +15 -0
- package/docs/guides/troubleshooting.md +101 -0
- package/docs/guides/writing-custom-roles.md +15 -0
- package/docs/plans/2026-03-15-cli-pipeline-integration-design.md +592 -0
- package/docs/plans/2026-03-15-cli-pipeline-integration-plan.md +598 -0
- package/docs/plans/2026-03-15-docs-enforcement-plan.md +238 -0
- package/docs/readmes/INDEX.md +99 -0
- package/docs/readmes/features/expertise/README.md +171 -0
- package/docs/readmes/features/exports/README.md +222 -0
- package/docs/readmes/features/hooks/README.md +103 -0
- package/docs/readmes/features/hooks/loop-cap-guard.md +133 -0
- package/docs/readmes/features/hooks/post-tool-capture.md +121 -0
- package/docs/readmes/features/hooks/post-tool-lint.md +130 -0
- package/docs/readmes/features/hooks/pre-compact-summary.md +122 -0
- package/docs/readmes/features/hooks/pre-tool-capture-route.md +100 -0
- package/docs/readmes/features/hooks/protected-path-write-guard.md +128 -0
- package/docs/readmes/features/hooks/session-start.md +119 -0
- package/docs/readmes/features/hooks/stop-handoff-harvest.md +125 -0
- package/docs/readmes/features/roles/README.md +157 -0
- package/docs/readmes/features/roles/clarifier.md +152 -0
- package/docs/readmes/features/roles/content-author.md +190 -0
- package/docs/readmes/features/roles/designer.md +193 -0
- package/docs/readmes/features/roles/executor.md +184 -0
- package/docs/readmes/features/roles/learner.md +210 -0
- package/docs/readmes/features/roles/planner.md +182 -0
- package/docs/readmes/features/roles/researcher.md +164 -0
- package/docs/readmes/features/roles/reviewer.md +184 -0
- package/docs/readmes/features/roles/specifier.md +162 -0
- package/docs/readmes/features/roles/verifier.md +215 -0
- package/docs/readmes/features/schemas/README.md +178 -0
- package/docs/readmes/features/skills/README.md +63 -0
- package/docs/readmes/features/skills/brainstorming.md +96 -0
- package/docs/readmes/features/skills/debugging.md +148 -0
- package/docs/readmes/features/skills/design.md +120 -0
- package/docs/readmes/features/skills/prepare-next.md +109 -0
- package/docs/readmes/features/skills/run-audit.md +159 -0
- package/docs/readmes/features/skills/scan-project.md +109 -0
- package/docs/readmes/features/skills/self-audit.md +176 -0
- package/docs/readmes/features/skills/tdd.md +137 -0
- package/docs/readmes/features/skills/using-skills.md +92 -0
- package/docs/readmes/features/skills/verification.md +120 -0
- package/docs/readmes/features/skills/writing-plans.md +104 -0
- package/docs/readmes/features/tooling/README.md +320 -0
- package/docs/readmes/features/workflows/README.md +186 -0
- package/docs/readmes/features/workflows/author.md +181 -0
- package/docs/readmes/features/workflows/clarify.md +154 -0
- package/docs/readmes/features/workflows/design-review.md +171 -0
- package/docs/readmes/features/workflows/design.md +169 -0
- package/docs/readmes/features/workflows/discover.md +162 -0
- package/docs/readmes/features/workflows/execute.md +173 -0
- package/docs/readmes/features/workflows/learn.md +167 -0
- package/docs/readmes/features/workflows/plan-review.md +165 -0
- package/docs/readmes/features/workflows/plan.md +170 -0
- package/docs/readmes/features/workflows/prepare-next.md +167 -0
- package/docs/readmes/features/workflows/review.md +169 -0
- package/docs/readmes/features/workflows/run-audit.md +191 -0
- package/docs/readmes/features/workflows/spec-challenge.md +159 -0
- package/docs/readmes/features/workflows/specify.md +160 -0
- package/docs/readmes/features/workflows/verify.md +177 -0
- package/docs/readmes/packages/README.md +50 -0
- package/docs/readmes/packages/ajv.md +117 -0
- package/docs/readmes/packages/context-mode.md +118 -0
- package/docs/readmes/packages/gray-matter.md +116 -0
- package/docs/readmes/packages/node-test.md +137 -0
- package/docs/readmes/packages/yaml.md +112 -0
- package/docs/reference/configuration-reference.md +159 -0
- package/docs/reference/expertise-index.md +52 -0
- package/docs/reference/git-flow.md +43 -0
- package/docs/reference/hooks.md +87 -0
- package/docs/reference/host-exports.md +50 -0
- package/docs/reference/launch-checklist.md +172 -0
- package/docs/reference/marketplace-listings.md +76 -0
- package/docs/reference/release-process.md +34 -0
- package/docs/reference/roles-reference.md +77 -0
- package/docs/reference/skills.md +33 -0
- package/docs/reference/templates.md +29 -0
- package/docs/reference/tooling-cli.md +94 -0
- package/docs/truth-claims.yaml +222 -0
- package/expertise/PROGRESS.md +63 -0
- package/expertise/README.md +18 -0
- package/expertise/antipatterns/PROGRESS.md +56 -0
- package/expertise/antipatterns/backend/api-design-antipatterns.md +1271 -0
- package/expertise/antipatterns/backend/auth-antipatterns.md +1195 -0
- package/expertise/antipatterns/backend/caching-antipatterns.md +622 -0
- package/expertise/antipatterns/backend/database-antipatterns.md +1038 -0
- package/expertise/antipatterns/backend/index.md +24 -0
- package/expertise/antipatterns/backend/microservices-antipatterns.md +850 -0
- package/expertise/antipatterns/code/architecture-antipatterns.md +919 -0
- package/expertise/antipatterns/code/async-antipatterns.md +622 -0
- package/expertise/antipatterns/code/code-smells.md +1186 -0
- package/expertise/antipatterns/code/dependency-antipatterns.md +1209 -0
- package/expertise/antipatterns/code/error-handling-antipatterns.md +1360 -0
- package/expertise/antipatterns/code/index.md +27 -0
- package/expertise/antipatterns/code/naming-and-abstraction.md +1118 -0
- package/expertise/antipatterns/code/state-management-antipatterns.md +1076 -0
- package/expertise/antipatterns/code/testing-antipatterns.md +1053 -0
- package/expertise/antipatterns/design/accessibility-antipatterns.md +1136 -0
- package/expertise/antipatterns/design/dark-patterns.md +1121 -0
- package/expertise/antipatterns/design/index.md +22 -0
- package/expertise/antipatterns/design/ui-antipatterns.md +1202 -0
- package/expertise/antipatterns/design/ux-antipatterns.md +680 -0
- package/expertise/antipatterns/frontend/css-layout-antipatterns.md +691 -0
- package/expertise/antipatterns/frontend/flutter-antipatterns.md +1827 -0
- package/expertise/antipatterns/frontend/index.md +23 -0
- package/expertise/antipatterns/frontend/mobile-antipatterns.md +573 -0
- package/expertise/antipatterns/frontend/react-antipatterns.md +1128 -0
- package/expertise/antipatterns/frontend/spa-antipatterns.md +1235 -0
- package/expertise/antipatterns/index.md +31 -0
- package/expertise/antipatterns/performance/index.md +20 -0
- package/expertise/antipatterns/performance/performance-antipatterns.md +1013 -0
- package/expertise/antipatterns/performance/premature-optimization.md +623 -0
- package/expertise/antipatterns/performance/scaling-antipatterns.md +785 -0
- package/expertise/antipatterns/process/ai-coding-antipatterns.md +853 -0
- package/expertise/antipatterns/process/code-review-antipatterns.md +656 -0
- package/expertise/antipatterns/process/deployment-antipatterns.md +920 -0
- package/expertise/antipatterns/process/index.md +23 -0
- package/expertise/antipatterns/process/technical-debt-antipatterns.md +647 -0
- package/expertise/antipatterns/security/index.md +20 -0
- package/expertise/antipatterns/security/secrets-antipatterns.md +849 -0
- package/expertise/antipatterns/security/security-theater.md +843 -0
- package/expertise/antipatterns/security/vulnerability-patterns.md +801 -0
- package/expertise/architecture/PROGRESS.md +70 -0
- package/expertise/architecture/data/caching-architecture.md +671 -0
- package/expertise/architecture/data/data-consistency.md +574 -0
- package/expertise/architecture/data/data-modeling.md +536 -0
- package/expertise/architecture/data/event-streams-and-queues.md +634 -0
- package/expertise/architecture/data/index.md +25 -0
- package/expertise/architecture/data/search-architecture.md +663 -0
- package/expertise/architecture/data/sql-vs-nosql.md +708 -0
- package/expertise/architecture/decisions/architecture-decision-records.md +640 -0
- package/expertise/architecture/decisions/build-vs-buy.md +616 -0
- package/expertise/architecture/decisions/index.md +23 -0
- package/expertise/architecture/decisions/monolith-to-microservices.md +790 -0
- package/expertise/architecture/decisions/technology-selection.md +616 -0
- package/expertise/architecture/distributed/cap-theorem-and-tradeoffs.md +800 -0
- package/expertise/architecture/distributed/circuit-breaker-bulkhead.md +741 -0
- package/expertise/architecture/distributed/consensus-and-coordination.md +796 -0
- package/expertise/architecture/distributed/distributed-systems-fundamentals.md +564 -0
- package/expertise/architecture/distributed/idempotency-and-retry.md +796 -0
- package/expertise/architecture/distributed/index.md +25 -0
- package/expertise/architecture/distributed/saga-pattern.md +797 -0
- package/expertise/architecture/foundations/architectural-thinking.md +460 -0
- package/expertise/architecture/foundations/coupling-and-cohesion.md +770 -0
- package/expertise/architecture/foundations/design-principles-solid.md +649 -0
- package/expertise/architecture/foundations/domain-driven-design.md +719 -0
- package/expertise/architecture/foundations/index.md +25 -0
- package/expertise/architecture/foundations/separation-of-concerns.md +472 -0
- package/expertise/architecture/foundations/twelve-factor-app.md +797 -0
- package/expertise/architecture/index.md +34 -0
- package/expertise/architecture/integration/api-design-graphql.md +638 -0
- package/expertise/architecture/integration/api-design-grpc.md +804 -0
- package/expertise/architecture/integration/api-design-rest.md +892 -0
- package/expertise/architecture/integration/index.md +25 -0
- package/expertise/architecture/integration/third-party-integration.md +795 -0
- package/expertise/architecture/integration/webhooks-and-callbacks.md +1152 -0
- package/expertise/architecture/integration/websockets-realtime.md +791 -0
- package/expertise/architecture/mobile-architecture/index.md +22 -0
- package/expertise/architecture/mobile-architecture/mobile-app-architecture.md +780 -0
- package/expertise/architecture/mobile-architecture/mobile-backend-for-frontend.md +670 -0
- package/expertise/architecture/mobile-architecture/offline-first.md +719 -0
- package/expertise/architecture/mobile-architecture/push-and-sync.md +782 -0
- package/expertise/architecture/patterns/cqrs-event-sourcing.md +717 -0
- package/expertise/architecture/patterns/event-driven.md +797 -0
- package/expertise/architecture/patterns/hexagonal-clean-architecture.md +870 -0
- package/expertise/architecture/patterns/index.md +27 -0
- package/expertise/architecture/patterns/layered-architecture.md +736 -0
- package/expertise/architecture/patterns/microservices.md +753 -0
- package/expertise/architecture/patterns/modular-monolith.md +692 -0
- package/expertise/architecture/patterns/monolith.md +626 -0
- package/expertise/architecture/patterns/plugin-architecture.md +735 -0
- package/expertise/architecture/patterns/serverless.md +780 -0
- package/expertise/architecture/scaling/database-scaling.md +615 -0
- package/expertise/architecture/scaling/feature-flags-and-rollouts.md +757 -0
- package/expertise/architecture/scaling/horizontal-vs-vertical.md +606 -0
- package/expertise/architecture/scaling/index.md +24 -0
- package/expertise/architecture/scaling/multi-tenancy.md +800 -0
- package/expertise/architecture/scaling/stateless-design.md +787 -0
- package/expertise/backend/embedded-firmware.md +625 -0
- package/expertise/backend/go.md +853 -0
- package/expertise/backend/index.md +24 -0
- package/expertise/backend/java-spring.md +448 -0
- package/expertise/backend/node-typescript.md +625 -0
- package/expertise/backend/python-fastapi.md +724 -0
- package/expertise/backend/rust.md +458 -0
- package/expertise/backend/solidity.md +711 -0
- package/expertise/composition-map.yaml +443 -0
- package/expertise/content/foundations/content-modeling.md +395 -0
- package/expertise/content/foundations/editorial-standards.md +449 -0
- package/expertise/content/foundations/index.md +24 -0
- package/expertise/content/foundations/microcopy.md +455 -0
- package/expertise/content/foundations/terminology-governance.md +509 -0
- package/expertise/content/index.md +34 -0
- package/expertise/content/patterns/accessibility-copy.md +518 -0
- package/expertise/content/patterns/index.md +24 -0
- package/expertise/content/patterns/notification-content.md +433 -0
- package/expertise/content/patterns/sample-content.md +486 -0
- package/expertise/content/patterns/state-copy.md +439 -0
- package/expertise/design/PROGRESS.md +58 -0
- package/expertise/design/disciplines/dark-mode-theming.md +577 -0
- package/expertise/design/disciplines/design-systems.md +595 -0
- package/expertise/design/disciplines/index.md +25 -0
- package/expertise/design/disciplines/information-architecture.md +800 -0
- package/expertise/design/disciplines/interaction-design.md +788 -0
- package/expertise/design/disciplines/responsive-design.md +552 -0
- package/expertise/design/disciplines/usability-testing.md +516 -0
- package/expertise/design/disciplines/user-research.md +792 -0
- package/expertise/design/foundations/accessibility-design.md +796 -0
- package/expertise/design/foundations/color-theory.md +797 -0
- package/expertise/design/foundations/iconography.md +795 -0
- package/expertise/design/foundations/index.md +26 -0
- package/expertise/design/foundations/motion-and-animation.md +653 -0
- package/expertise/design/foundations/rtl-design.md +585 -0
- package/expertise/design/foundations/spacing-and-layout.md +607 -0
- package/expertise/design/foundations/typography.md +800 -0
- package/expertise/design/foundations/visual-hierarchy.md +761 -0
- package/expertise/design/index.md +32 -0
- package/expertise/design/patterns/authentication-flows.md +474 -0
- package/expertise/design/patterns/content-consumption.md +789 -0
- package/expertise/design/patterns/data-display.md +618 -0
- package/expertise/design/patterns/e-commerce.md +1494 -0
- package/expertise/design/patterns/feedback-and-states.md +642 -0
- package/expertise/design/patterns/forms-and-input.md +819 -0
- package/expertise/design/patterns/gamification.md +801 -0
- package/expertise/design/patterns/index.md +31 -0
- package/expertise/design/patterns/microinteractions.md +449 -0
- package/expertise/design/patterns/navigation.md +800 -0
- package/expertise/design/patterns/notifications.md +705 -0
- package/expertise/design/patterns/onboarding.md +700 -0
- package/expertise/design/patterns/search-and-filter.md +601 -0
- package/expertise/design/patterns/settings-and-preferences.md +768 -0
- package/expertise/design/patterns/social-and-community.md +748 -0
- package/expertise/design/platforms/desktop-native.md +612 -0
- package/expertise/design/platforms/index.md +25 -0
- package/expertise/design/platforms/mobile-android.md +825 -0
- package/expertise/design/platforms/mobile-cross-platform.md +983 -0
- package/expertise/design/platforms/mobile-ios.md +699 -0
- package/expertise/design/platforms/tablet.md +794 -0
- package/expertise/design/platforms/web-dashboard.md +790 -0
- package/expertise/design/platforms/web-responsive.md +550 -0
- package/expertise/design/psychology/behavioral-nudges.md +449 -0
- package/expertise/design/psychology/cognitive-load.md +1191 -0
- package/expertise/design/psychology/error-psychology.md +778 -0
- package/expertise/design/psychology/index.md +22 -0
- package/expertise/design/psychology/persuasive-design.md +736 -0
- package/expertise/design/psychology/user-mental-models.md +623 -0
- package/expertise/design/tooling/open-pencil.md +266 -0
- package/expertise/frontend/angular.md +1073 -0
- package/expertise/frontend/desktop-electron.md +546 -0
- package/expertise/frontend/flutter.md +782 -0
- package/expertise/frontend/index.md +27 -0
- package/expertise/frontend/native-android.md +409 -0
- package/expertise/frontend/native-ios.md +490 -0
- package/expertise/frontend/react-native.md +1160 -0
- package/expertise/frontend/react.md +808 -0
- package/expertise/frontend/vue.md +1089 -0
- package/expertise/humanize/domain-rules-code.md +79 -0
- package/expertise/humanize/domain-rules-content.md +67 -0
- package/expertise/humanize/domain-rules-technical-docs.md +56 -0
- package/expertise/humanize/index.md +35 -0
- package/expertise/humanize/self-audit-checklist.md +87 -0
- package/expertise/humanize/sentence-patterns.md +218 -0
- package/expertise/humanize/vocabulary-blacklist.md +105 -0
- package/expertise/i18n/PROGRESS.md +65 -0
- package/expertise/i18n/advanced/accessibility-and-i18n.md +28 -0
- package/expertise/i18n/advanced/bidirectional-text-algorithm.md +38 -0
- package/expertise/i18n/advanced/complex-scripts.md +30 -0
- package/expertise/i18n/advanced/performance-and-i18n.md +27 -0
- package/expertise/i18n/advanced/testing-i18n.md +28 -0
- package/expertise/i18n/content/content-adaptation.md +23 -0
- package/expertise/i18n/content/locale-specific-formatting.md +23 -0
- package/expertise/i18n/content/machine-translation-integration.md +28 -0
- package/expertise/i18n/content/translation-management.md +29 -0
- package/expertise/i18n/foundations/date-time-calendars.md +67 -0
- package/expertise/i18n/foundations/i18n-architecture.md +272 -0
- package/expertise/i18n/foundations/locale-and-language-tags.md +79 -0
- package/expertise/i18n/foundations/numbers-currency-units.md +61 -0
- package/expertise/i18n/foundations/pluralization-and-gender.md +109 -0
- package/expertise/i18n/foundations/string-externalization.md +236 -0
- package/expertise/i18n/foundations/text-direction-bidi.md +241 -0
- package/expertise/i18n/foundations/unicode-and-encoding.md +86 -0
- package/expertise/i18n/index.md +38 -0
- package/expertise/i18n/platform/backend-i18n.md +31 -0
- package/expertise/i18n/platform/flutter-i18n.md +148 -0
- package/expertise/i18n/platform/native-android-i18n.md +36 -0
- package/expertise/i18n/platform/native-ios-i18n.md +36 -0
- package/expertise/i18n/platform/react-i18n.md +103 -0
- package/expertise/i18n/platform/web-css-i18n.md +81 -0
- package/expertise/i18n/rtl/arabic-specific.md +175 -0
- package/expertise/i18n/rtl/hebrew-specific.md +149 -0
- package/expertise/i18n/rtl/rtl-animations-and-transitions.md +111 -0
- package/expertise/i18n/rtl/rtl-forms-and-input.md +161 -0
- package/expertise/i18n/rtl/rtl-fundamentals.md +211 -0
- package/expertise/i18n/rtl/rtl-icons-and-images.md +181 -0
- package/expertise/i18n/rtl/rtl-layout-mirroring.md +252 -0
- package/expertise/i18n/rtl/rtl-navigation-and-gestures.md +107 -0
- package/expertise/i18n/rtl/rtl-testing-and-qa.md +147 -0
- package/expertise/i18n/rtl/rtl-typography.md +160 -0
- package/expertise/index.md +113 -0
- package/expertise/index.yaml +216 -0
- package/expertise/infrastructure/cloud-aws.md +597 -0
- package/expertise/infrastructure/cloud-gcp.md +599 -0
- package/expertise/infrastructure/cybersecurity.md +816 -0
- package/expertise/infrastructure/database-mongodb.md +447 -0
- package/expertise/infrastructure/database-postgres.md +400 -0
- package/expertise/infrastructure/devops-cicd.md +787 -0
- package/expertise/infrastructure/index.md +27 -0
- package/expertise/performance/PROGRESS.md +50 -0
- package/expertise/performance/backend/api-latency.md +1204 -0
- package/expertise/performance/backend/background-jobs.md +506 -0
- package/expertise/performance/backend/connection-pooling.md +1209 -0
- package/expertise/performance/backend/database-query-optimization.md +515 -0
- package/expertise/performance/backend/index.md +23 -0
- package/expertise/performance/backend/rate-limiting-and-throttling.md +971 -0
- package/expertise/performance/foundations/algorithmic-complexity.md +954 -0
- package/expertise/performance/foundations/caching-strategies.md +489 -0
- package/expertise/performance/foundations/concurrency-and-parallelism.md +847 -0
- package/expertise/performance/foundations/index.md +24 -0
- package/expertise/performance/foundations/measuring-and-profiling.md +440 -0
- package/expertise/performance/foundations/memory-management.md +964 -0
- package/expertise/performance/foundations/performance-budgets.md +1314 -0
- package/expertise/performance/index.md +31 -0
- package/expertise/performance/infrastructure/auto-scaling.md +1059 -0
- package/expertise/performance/infrastructure/cdn-and-edge.md +1081 -0
- package/expertise/performance/infrastructure/index.md +22 -0
- package/expertise/performance/infrastructure/load-balancing.md +1081 -0
- package/expertise/performance/infrastructure/observability.md +1079 -0
- package/expertise/performance/mobile/index.md +23 -0
- package/expertise/performance/mobile/mobile-animations.md +544 -0
- package/expertise/performance/mobile/mobile-memory-battery.md +416 -0
- package/expertise/performance/mobile/mobile-network.md +452 -0
- package/expertise/performance/mobile/mobile-rendering.md +599 -0
- package/expertise/performance/mobile/mobile-startup-time.md +505 -0
- package/expertise/performance/platform-specific/flutter-performance.md +647 -0
- package/expertise/performance/platform-specific/index.md +22 -0
- package/expertise/performance/platform-specific/node-performance.md +1307 -0
- package/expertise/performance/platform-specific/postgres-performance.md +1366 -0
- package/expertise/performance/platform-specific/react-performance.md +1403 -0
- package/expertise/performance/web/bundle-optimization.md +1239 -0
- package/expertise/performance/web/image-and-media.md +636 -0
- package/expertise/performance/web/index.md +24 -0
- package/expertise/performance/web/network-optimization.md +1133 -0
- package/expertise/performance/web/rendering-performance.md +1098 -0
- package/expertise/performance/web/ssr-and-hydration.md +918 -0
- package/expertise/performance/web/web-vitals.md +1374 -0
- package/expertise/quality/accessibility.md +985 -0
- package/expertise/quality/evidence-based-verification.md +499 -0
- package/expertise/quality/index.md +24 -0
- package/expertise/quality/ml-model-audit.md +614 -0
- package/expertise/quality/performance.md +600 -0
- package/expertise/quality/testing-api.md +891 -0
- package/expertise/quality/testing-mobile.md +496 -0
- package/expertise/quality/testing-web.md +849 -0
- package/expertise/security/PROGRESS.md +54 -0
- package/expertise/security/agentic-identity.md +540 -0
- package/expertise/security/compliance-frameworks.md +601 -0
- package/expertise/security/data/data-encryption.md +364 -0
- package/expertise/security/data/data-privacy-gdpr.md +692 -0
- package/expertise/security/data/database-security.md +1171 -0
- package/expertise/security/data/index.md +22 -0
- package/expertise/security/data/pii-handling.md +531 -0
- package/expertise/security/foundations/authentication.md +1041 -0
- package/expertise/security/foundations/authorization.md +603 -0
- package/expertise/security/foundations/cryptography.md +1001 -0
- package/expertise/security/foundations/index.md +25 -0
- package/expertise/security/foundations/owasp-top-10.md +1354 -0
- package/expertise/security/foundations/secrets-management.md +1217 -0
- package/expertise/security/foundations/secure-sdlc.md +700 -0
- package/expertise/security/foundations/supply-chain-security.md +698 -0
- package/expertise/security/index.md +31 -0
- package/expertise/security/infrastructure/cloud-security-aws.md +1296 -0
- package/expertise/security/infrastructure/cloud-security-gcp.md +1376 -0
- package/expertise/security/infrastructure/container-security.md +721 -0
- package/expertise/security/infrastructure/incident-response.md +1295 -0
- package/expertise/security/infrastructure/index.md +24 -0
- package/expertise/security/infrastructure/logging-and-monitoring.md +1618 -0
- package/expertise/security/infrastructure/network-security.md +1337 -0
- package/expertise/security/mobile/index.md +23 -0
- package/expertise/security/mobile/mobile-android-security.md +1218 -0
- package/expertise/security/mobile/mobile-binary-protection.md +1229 -0
- package/expertise/security/mobile/mobile-data-storage.md +1265 -0
- package/expertise/security/mobile/mobile-ios-security.md +1401 -0
- package/expertise/security/mobile/mobile-network-security.md +1520 -0
- package/expertise/security/smart-contract-security.md +594 -0
- package/expertise/security/testing/index.md +22 -0
- package/expertise/security/testing/penetration-testing.md +1258 -0
- package/expertise/security/testing/security-code-review.md +1765 -0
- package/expertise/security/testing/threat-modeling.md +1074 -0
- package/expertise/security/testing/vulnerability-scanning.md +1062 -0
- package/expertise/security/web/api-security.md +586 -0
- package/expertise/security/web/cors-and-headers.md +433 -0
- package/expertise/security/web/csrf.md +562 -0
- package/expertise/security/web/file-upload.md +1477 -0
- package/expertise/security/web/index.md +25 -0
- package/expertise/security/web/injection.md +1375 -0
- package/expertise/security/web/session-management.md +1101 -0
- package/expertise/security/web/xss.md +1158 -0
- package/exports/README.md +17 -0
- package/exports/hosts/claude/.claude/agents/clarifier.md +42 -0
- package/exports/hosts/claude/.claude/agents/content-author.md +63 -0
- package/exports/hosts/claude/.claude/agents/designer.md +55 -0
- package/exports/hosts/claude/.claude/agents/executor.md +55 -0
- package/exports/hosts/claude/.claude/agents/learner.md +51 -0
- package/exports/hosts/claude/.claude/agents/planner.md +53 -0
- package/exports/hosts/claude/.claude/agents/researcher.md +43 -0
- package/exports/hosts/claude/.claude/agents/reviewer.md +54 -0
- package/exports/hosts/claude/.claude/agents/specifier.md +47 -0
- package/exports/hosts/claude/.claude/agents/verifier.md +71 -0
- package/exports/hosts/claude/.claude/commands/author.md +42 -0
- package/exports/hosts/claude/.claude/commands/clarify.md +38 -0
- package/exports/hosts/claude/.claude/commands/design-review.md +46 -0
- package/exports/hosts/claude/.claude/commands/design.md +44 -0
- package/exports/hosts/claude/.claude/commands/discover.md +37 -0
- package/exports/hosts/claude/.claude/commands/execute.md +48 -0
- package/exports/hosts/claude/.claude/commands/learn.md +38 -0
- package/exports/hosts/claude/.claude/commands/plan-review.md +42 -0
- package/exports/hosts/claude/.claude/commands/plan.md +39 -0
- package/exports/hosts/claude/.claude/commands/prepare-next.md +37 -0
- package/exports/hosts/claude/.claude/commands/review.md +40 -0
- package/exports/hosts/claude/.claude/commands/run-audit.md +41 -0
- package/exports/hosts/claude/.claude/commands/spec-challenge.md +41 -0
- package/exports/hosts/claude/.claude/commands/specify.md +38 -0
- package/exports/hosts/claude/.claude/commands/verify.md +37 -0
- package/exports/hosts/claude/.claude/settings.json +34 -0
- package/exports/hosts/claude/CLAUDE.md +19 -0
- package/exports/hosts/claude/export.manifest.json +38 -0
- package/exports/hosts/claude/host-package.json +67 -0
- package/exports/hosts/codex/AGENTS.md +19 -0
- package/exports/hosts/codex/export.manifest.json +38 -0
- package/exports/hosts/codex/host-package.json +41 -0
- package/exports/hosts/cursor/.cursor/hooks.json +16 -0
- package/exports/hosts/cursor/.cursor/rules/wazir-core.mdc +19 -0
- package/exports/hosts/cursor/export.manifest.json +38 -0
- package/exports/hosts/cursor/host-package.json +42 -0
- package/exports/hosts/gemini/GEMINI.md +19 -0
- package/exports/hosts/gemini/export.manifest.json +38 -0
- package/exports/hosts/gemini/host-package.json +41 -0
- package/hooks/README.md +18 -0
- package/hooks/definitions/loop_cap_guard.yaml +21 -0
- package/hooks/definitions/post_tool_capture.yaml +24 -0
- package/hooks/definitions/pre_compact_summary.yaml +19 -0
- package/hooks/definitions/pre_tool_capture_route.yaml +19 -0
- package/hooks/definitions/protected_path_write_guard.yaml +19 -0
- package/hooks/definitions/session_start.yaml +19 -0
- package/hooks/definitions/stop_handoff_harvest.yaml +20 -0
- package/hooks/loop-cap-guard +17 -0
- package/hooks/post-tool-lint +36 -0
- package/hooks/protected-path-write-guard +17 -0
- package/hooks/session-start +41 -0
- package/llms-full.txt +2355 -0
- package/llms.txt +43 -0
- package/package.json +79 -0
- package/roles/README.md +20 -0
- package/roles/clarifier.md +42 -0
- package/roles/content-author.md +63 -0
- package/roles/designer.md +55 -0
- package/roles/executor.md +55 -0
- package/roles/learner.md +51 -0
- package/roles/planner.md +53 -0
- package/roles/researcher.md +43 -0
- package/roles/reviewer.md +54 -0
- package/roles/specifier.md +47 -0
- package/roles/verifier.md +71 -0
- package/schemas/README.md +24 -0
- package/schemas/accepted-learning.schema.json +20 -0
- package/schemas/author-artifact.schema.json +156 -0
- package/schemas/clarification.schema.json +19 -0
- package/schemas/design-artifact.schema.json +80 -0
- package/schemas/docs-claim.schema.json +18 -0
- package/schemas/export-manifest.schema.json +20 -0
- package/schemas/hook.schema.json +67 -0
- package/schemas/host-export-package.schema.json +18 -0
- package/schemas/implementation-plan.schema.json +19 -0
- package/schemas/proposed-learning.schema.json +19 -0
- package/schemas/research.schema.json +18 -0
- package/schemas/review.schema.json +29 -0
- package/schemas/run-manifest.schema.json +18 -0
- package/schemas/spec-challenge.schema.json +18 -0
- package/schemas/spec.schema.json +20 -0
- package/schemas/usage.schema.json +102 -0
- package/schemas/verification-proof.schema.json +29 -0
- package/schemas/wazir-manifest.schema.json +173 -0
- package/skills/README.md +40 -0
- package/skills/brainstorming/SKILL.md +77 -0
- package/skills/debugging/SKILL.md +50 -0
- package/skills/design/SKILL.md +61 -0
- package/skills/dispatching-parallel-agents/SKILL.md +128 -0
- package/skills/executing-plans/SKILL.md +70 -0
- package/skills/finishing-a-development-branch/SKILL.md +169 -0
- package/skills/humanize/SKILL.md +123 -0
- package/skills/init-pipeline/SKILL.md +124 -0
- package/skills/prepare-next/SKILL.md +20 -0
- package/skills/receiving-code-review/SKILL.md +123 -0
- package/skills/requesting-code-review/SKILL.md +105 -0
- package/skills/requesting-code-review/code-reviewer.md +108 -0
- package/skills/run-audit/SKILL.md +197 -0
- package/skills/scan-project/SKILL.md +41 -0
- package/skills/self-audit/SKILL.md +153 -0
- package/skills/subagent-driven-development/SKILL.md +154 -0
- package/skills/subagent-driven-development/code-quality-reviewer-prompt.md +26 -0
- package/skills/subagent-driven-development/implementer-prompt.md +102 -0
- package/skills/subagent-driven-development/spec-reviewer-prompt.md +61 -0
- package/skills/tdd/SKILL.md +23 -0
- package/skills/using-git-worktrees/SKILL.md +163 -0
- package/skills/using-skills/SKILL.md +95 -0
- package/skills/verification/SKILL.md +22 -0
- package/skills/wazir/SKILL.md +463 -0
- package/skills/writing-plans/SKILL.md +30 -0
- package/skills/writing-skills/SKILL.md +157 -0
- package/skills/writing-skills/anthropic-best-practices.md +122 -0
- package/skills/writing-skills/persuasion-principles.md +50 -0
- package/templates/README.md +20 -0
- package/templates/artifacts/README.md +10 -0
- package/templates/artifacts/accepted-learning.md +19 -0
- package/templates/artifacts/accepted-learning.template.json +12 -0
- package/templates/artifacts/author.md +74 -0
- package/templates/artifacts/author.template.json +19 -0
- package/templates/artifacts/clarification.md +21 -0
- package/templates/artifacts/clarification.template.json +12 -0
- package/templates/artifacts/execute-notes.md +19 -0
- package/templates/artifacts/implementation-plan.md +21 -0
- package/templates/artifacts/implementation-plan.template.json +11 -0
- package/templates/artifacts/learning-proposal.md +19 -0
- package/templates/artifacts/next-run-handoff.md +21 -0
- package/templates/artifacts/plan-review.md +19 -0
- package/templates/artifacts/proposed-learning.template.json +12 -0
- package/templates/artifacts/research.md +21 -0
- package/templates/artifacts/research.template.json +12 -0
- package/templates/artifacts/review-findings.md +19 -0
- package/templates/artifacts/review.template.json +11 -0
- package/templates/artifacts/run-manifest.template.json +8 -0
- package/templates/artifacts/spec-challenge.md +19 -0
- package/templates/artifacts/spec-challenge.template.json +11 -0
- package/templates/artifacts/spec.md +21 -0
- package/templates/artifacts/spec.template.json +12 -0
- package/templates/artifacts/verification-proof.md +19 -0
- package/templates/artifacts/verification-proof.template.json +11 -0
- package/templates/examples/accepted-learning.example.json +14 -0
- package/templates/examples/author.example.json +152 -0
- package/templates/examples/clarification.example.json +15 -0
- package/templates/examples/docs-claim.example.json +8 -0
- package/templates/examples/export-manifest.example.json +7 -0
- package/templates/examples/host-export-package.example.json +11 -0
- package/templates/examples/implementation-plan.example.json +17 -0
- package/templates/examples/proposed-learning.example.json +13 -0
- package/templates/examples/research.example.json +15 -0
- package/templates/examples/research.example.md +6 -0
- package/templates/examples/review.example.json +17 -0
- package/templates/examples/run-manifest.example.json +9 -0
- package/templates/examples/spec-challenge.example.json +14 -0
- package/templates/examples/spec.example.json +21 -0
- package/templates/examples/verification-proof.example.json +21 -0
- package/templates/examples/wazir-manifest.example.yaml +65 -0
- package/templates/task-definition-schema.md +99 -0
- package/tooling/README.md +20 -0
- package/tooling/src/adapters/context-mode.js +50 -0
- package/tooling/src/capture/command.js +376 -0
- package/tooling/src/capture/store.js +99 -0
- package/tooling/src/capture/usage.js +270 -0
- package/tooling/src/checks/branches.js +50 -0
- package/tooling/src/checks/brand-truth.js +110 -0
- package/tooling/src/checks/changelog.js +231 -0
- package/tooling/src/checks/command-registry.js +36 -0
- package/tooling/src/checks/commits.js +102 -0
- package/tooling/src/checks/docs-drift.js +103 -0
- package/tooling/src/checks/docs-truth.js +201 -0
- package/tooling/src/checks/runtime-surface.js +156 -0
- package/tooling/src/cli.js +116 -0
- package/tooling/src/command-options.js +56 -0
- package/tooling/src/commands/validate.js +320 -0
- package/tooling/src/doctor/command.js +91 -0
- package/tooling/src/export/command.js +77 -0
- package/tooling/src/export/compiler.js +498 -0
- package/tooling/src/guards/loop-cap-guard.js +52 -0
- package/tooling/src/guards/protected-path-write-guard.js +67 -0
- package/tooling/src/index/command.js +152 -0
- package/tooling/src/index/storage.js +1061 -0
- package/tooling/src/index/summarizers.js +261 -0
- package/tooling/src/loaders.js +18 -0
- package/tooling/src/project-root.js +22 -0
- package/tooling/src/recall/command.js +225 -0
- package/tooling/src/schema-validator.js +30 -0
- package/tooling/src/state-root.js +40 -0
- package/tooling/src/status/command.js +71 -0
- package/wazir.manifest.yaml +135 -0
- package/workflows/README.md +19 -0
- package/workflows/author.md +42 -0
- package/workflows/clarify.md +38 -0
- package/workflows/design-review.md +46 -0
- package/workflows/design.md +44 -0
- package/workflows/discover.md +37 -0
- package/workflows/execute.md +48 -0
- package/workflows/learn.md +38 -0
- package/workflows/plan-review.md +42 -0
- package/workflows/plan.md +39 -0
- package/workflows/prepare-next.md +37 -0
- package/workflows/review.md +40 -0
- package/workflows/run-audit.md +41 -0
- package/workflows/spec-challenge.md +41 -0
- package/workflows/specify.md +38 -0
- package/workflows/verify.md +37 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Directory Purpose
|
|
2
|
+
|
|
3
|
+
The `foundations` directory contains the core principles and philosophies of software architecture, focusing on structure, modularity, and maintainability.
|
|
4
|
+
|
|
5
|
+
# Key Concepts
|
|
6
|
+
|
|
7
|
+
- Principles of clean code and design
|
|
8
|
+
- Aligning software with business domains
|
|
9
|
+
- Managing system complexity
|
|
10
|
+
- Cloud-native application standards
|
|
11
|
+
|
|
12
|
+
# File Map
|
|
13
|
+
|
|
14
|
+
- `architectural-thinking.md` — mindset and approach to system design
|
|
15
|
+
- `coupling-and-cohesion.md` — managing dependencies and module focus
|
|
16
|
+
- `design-principles-solid.md` — SOLID, DRY, and YAGNI principles
|
|
17
|
+
- `domain-driven-design.md` — bounded contexts, aggregates, and ubiquitous language
|
|
18
|
+
- `separation-of-concerns.md` — dividing systems into distinct features
|
|
19
|
+
- `twelve-factor-app.md` — methodology for modern cloud-native apps
|
|
20
|
+
|
|
21
|
+
# Reading Guide
|
|
22
|
+
|
|
23
|
+
If designing module boundaries → read `domain-driven-design.md` and `coupling-and-cohesion.md`
|
|
24
|
+
If writing object-oriented code → read `design-principles-solid.md`
|
|
25
|
+
If deploying to the cloud → read `twelve-factor-app.md`
|
|
@@ -0,0 +1,472 @@
|
|
|
1
|
+
# Separation of Concerns — Architecture Expertise Module
|
|
2
|
+
|
|
3
|
+
> Separation of Concerns (SoC) is the practice of dividing a system so that each part addresses one distinct responsibility, making each part independently understandable, changeable, and replaceable. It is a prerequisite for maintainable systems at any scale — not because it enforces tidiness, but because it controls the blast radius of change.
|
|
4
|
+
|
|
5
|
+
> **Category:** Foundation
|
|
6
|
+
> **Complexity:** Simple
|
|
7
|
+
> **Applies when:** Any project where code responsibilities need to be organized to enable independent change
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## What This Is (and What It Isn't)
|
|
12
|
+
|
|
13
|
+
### Dijkstra's Original Formulation
|
|
14
|
+
|
|
15
|
+
Edsger Dijkstra introduced the term in his 1974 paper "On the role of scientific thought." His framing was epistemic, not structural: "It is what I sometimes have called 'the separation of concerns', which, even if not perfectly possible, is yet the only available technique for the effective ordering of one's thoughts." The point was about *mental focus* — the ability to think about one thing at a time by factoring a problem into parts that can be reasoned about independently.
|
|
16
|
+
|
|
17
|
+
The architectural implementation of SoC is downstream of this insight: if you want to *think* about the database layer independently from the business rules, you must also *code* them independently. Structure follows thought.
|
|
18
|
+
|
|
19
|
+
### Three Dimensions of Separation
|
|
20
|
+
|
|
21
|
+
**Horizontal (Layered) Concerns**
|
|
22
|
+
Separates the system by technical role. Presentation handles display. Business logic handles rules. Data access handles persistence. Each layer knows about the layer below it but not above. This is the most familiar form — MVC, three-tier architecture, and clean architecture are all horizontal separations. The classic web stack (HTML/CSS/JavaScript) is a canonical example: HTML handles content structure, CSS handles presentation, JavaScript handles behavior. Each can be changed without rewriting the others.
|
|
23
|
+
|
|
24
|
+
**Vertical (Feature/Module) Concerns**
|
|
25
|
+
Separates the system by business capability rather than technical role. An "orders" module contains its own presentation, business logic, and data access — all vertically sliced. Microservices and modular monoliths are vertical separations. Netflix's decomposition into hundreds of independent services (catalog, streaming, recommendations, billing) is vertical SoC: each service owns its full stack for one bounded capability.
|
|
26
|
+
|
|
27
|
+
**Aspect-Oriented (Cross-Cutting) Concerns**
|
|
28
|
+
Some behaviors genuinely span all other concerns: logging, authentication, caching, transaction management, error handling. These are called cross-cutting concerns because they cannot be neatly assigned to a single layer or module — they appear everywhere. Aspect-Oriented Programming (AOP) addresses this by defining an "aspect" (the what) and "pointcuts" (the where) separately from the core business code. Spring AOP in Java, for example, allows you to declare "log entry and exit for every method in the service layer" in one place rather than 200 places.
|
|
29
|
+
|
|
30
|
+
### What SoC Is NOT
|
|
31
|
+
|
|
32
|
+
**Not folder structure.** Moving files into subdirectories does not create separation. If `services/UserService.js` still directly queries the database and renders HTML, the folders are cosmetic.
|
|
33
|
+
|
|
34
|
+
**Not "one class, one purpose."** SoC operates at the boundary level — concern boundaries are defined by what varies independently and what needs to be understood independently. A class serving a single well-bounded concern may have dozens of methods.
|
|
35
|
+
|
|
36
|
+
**Not the same as SOLID's Single Responsibility Principle.** SRP says a class should have one reason to change. SoC is a broader architectural principle about which *parts of the system* are cognitively and technically independent. SRP is one implementation strategy for SoC at the class level, but SoC applies at module, service, layer, and system levels where SRP does not.
|
|
37
|
+
|
|
38
|
+
**Not about minimizing coupling at all costs.** SoC accepts that concerns must communicate. The goal is to make the communication explicit, narrow, and stable — not to eliminate it. A well-separated system has clear interfaces between concerns, not zero connections.
|
|
39
|
+
|
|
40
|
+
**Not a goal in itself.** Separation that does not enable independent change, independent testing, or independent understanding is not SoC — it is indirection. The test is always: "Can I change or reason about this concern without touching the others?"
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## When to Use It
|
|
45
|
+
|
|
46
|
+
### The Primary Signal: Change Propagation
|
|
47
|
+
|
|
48
|
+
The strongest signal that SoC is needed is when a single logical change requires edits in many unrelated files. When you fix a business rule and must also change database queries and update UI rendering in the same commit, concerns are entangled. When a one-line business logic change becomes a 10-file PR, separation is overdue.
|
|
49
|
+
|
|
50
|
+
### Specific Triggers
|
|
51
|
+
|
|
52
|
+
**Multiple teams touching the same files.** If the frontend team and backend team both edit `app.js`, the file is doing too many things. At two-team scale, separating presentation from business logic becomes a coordination mechanism, not just a code quality preference.
|
|
53
|
+
|
|
54
|
+
**Testing is impossible without the whole system.** When unit tests require database connections because business logic is tangled with data access, separation is the prerequisite for testability. The inability to test a business rule in isolation is a structural problem, not a test-writing problem.
|
|
55
|
+
|
|
56
|
+
**The same logic appears in multiple layers.** If validation logic appears in the UI, in the API controller, and in the database layer, it will diverge. Centralizing it in one place (the business/domain layer) eliminates the synchronization problem.
|
|
57
|
+
|
|
58
|
+
**Reasoning about one change requires understanding everything.** When a developer must hold the entire codebase in their head to make a small change, the cognitive cost is a symptom of insufficient separation. Dijkstra's original insight applies directly: if you cannot focus on one thing, the structure is working against you.
|
|
59
|
+
|
|
60
|
+
### Real Costs of Poor SoC
|
|
61
|
+
|
|
62
|
+
**The Big Ball of Mud.** Brian Foote and Joseph Yoder's 1997 paper described this pattern by name: systems where no dominant architectural structure exists, where changes ripple unpredictably, where developers are afraid to touch anything. The paper noted that this is the most common architecture pattern in production systems — not by design, but by entropy.
|
|
63
|
+
|
|
64
|
+
**Satellite embedded systems.** Research on embedded real-time satellite software (AOCS, thermal regulation, power management) found that without explicit concern separation, cross-subsystem dependencies caused certification failures: a change to the thermal regulation subsystem invalidated assumptions in the attitude control subsystem because shared state was not cleanly isolated. The cost was not code quality — it was re-certification cycles measured in months.
|
|
65
|
+
|
|
66
|
+
**Large-scale monoliths.** Companies that delayed concern separation in monolithic codebases (the "majestic monolith" that grew ungoverned) faced migration costs in the millions of engineering hours. The canonical pattern: a startup builds fast with entangled concerns, reaches 50-100 engineers, and discovers that deploy times are 45 minutes, any change breaks something unrelated, and a full rewrite becomes the only option. The rewrite is the tax on deferred SoC.
|
|
67
|
+
|
|
68
|
+
### Team and Project Size Thresholds
|
|
69
|
+
|
|
70
|
+
- **Solo developer, <3 months:** Light separation. Keep related code co-located. Defer to "extract when it hurts."
|
|
71
|
+
- **2-5 developers, 3-12 months:** Separate data access from business logic. Introduce explicit interface contracts at concern boundaries.
|
|
72
|
+
- **5+ developers or multiple teams:** Enforce vertical separation by module or domain. Cross-cutting concerns must be centralized (logging, auth, error handling).
|
|
73
|
+
- **Microservices threshold:** Only cross service boundaries when deployment independence is required. Premature service extraction (splitting before the concern boundary is stable) creates distributed monoliths — all the cost, none of the benefit.
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## When NOT to Use It
|
|
78
|
+
|
|
79
|
+
This section is as important as the preceding one. The failure mode of understanding SoC only as "separate more" produces systems that are harder to work with than the entangled code they replaced.
|
|
80
|
+
|
|
81
|
+
### The Premature Abstraction Trap
|
|
82
|
+
|
|
83
|
+
The maxim "duplication is far cheaper than the wrong abstraction" (Sandi Metz) applies directly. Separating a concern before its boundaries are understood creates an abstraction that *looks* like a contract but *is* a constraint. Every module that depends on a premature abstraction inherits its incorrect assumptions. Untangling a bad abstraction is more expensive than untangling duplicated code, because duplication can be deleted — a bad abstraction must be unwound from every dependent.
|
|
84
|
+
|
|
85
|
+
The pattern: a developer sees two functions with similar structure and extracts a shared abstraction. Six months later, one of the two use cases diverges. Now the abstraction must be parameterized, bent, or worked around. The abstraction has become a maintenance burden instead of a simplification.
|
|
86
|
+
|
|
87
|
+
### Over-Separation: Death by Indirection
|
|
88
|
+
|
|
89
|
+
A practical example of over-separation: a developer follows "clean architecture" strictly for a 200-line CRUD application. The result: a `UserController`, a `UserService`, a `UserRepository`, a `UserRepositoryInterface`, a `UserDomainModel`, a `UserDTO`, a `UserMapper`, and a `UserValidator` — eight files for what is, functionally, "store and retrieve a user." Reading a simple query now requires tracing through six layers of indirection.
|
|
90
|
+
|
|
91
|
+
This is the "astronaut architect" anti-pattern (Joel Spolsky's term): architects who abstract so high above the actual code that they lose contact with what the system actually does. The indirection does not serve independent change — the business logic, the data model, and the API contract all change in lockstep, because the domain is simple. The separation creates navigation overhead without separation benefit.
|
|
92
|
+
|
|
93
|
+
**The Proliferation of Code anti-pattern** (formally named in software engineering literature) describes objects that exist only to invoke another object. A `LoggingServiceFacadeFactory` that does nothing but call `new LoggingService()` adds a layer of indirection with zero semantic content. These appear in over-separated systems as the architect fills in the "gaps" between layers with glue objects.
|
|
94
|
+
|
|
95
|
+
### When Co-Location Beats Separation
|
|
96
|
+
|
|
97
|
+
**The Locality Principle.** Code that changes together should live together. If every feature change requires editing five files across five directories, the separation is fighting the natural grain of the system. Feature-sliced vertical architectures often outperform strictly layered architectures for co-located development: `features/checkout/` containing its own components, logic, and queries is easier to navigate than `components/Checkout.tsx`, `services/checkoutService.ts`, `repositories/orderRepository.ts`, and `types/checkout.ts` spread across a tree.
|
|
98
|
+
|
|
99
|
+
**Simple scripts and utilities.** A 50-line data transformation script does not need a repository layer, a service layer, and a domain model. Co-location is correct here. The tax of separation exceeds the benefit when the system is small enough to hold in one screen.
|
|
100
|
+
|
|
101
|
+
**Prototypes and proof-of-concept code.** Separation in a prototype is premature investment in code that may be thrown away. Prototype code should optimize for speed of iteration. The concern separation of production code is a deliberate choice, not a quality signal — applying it prematurely to exploration code wastes time and creates false permanence.
|
|
102
|
+
|
|
103
|
+
**When the "concern" is not stable.** Separation creates a contract — an interface that downstream code depends on. If the concern boundary itself is uncertain (you do not yet know whether "user authentication" and "user authorization" will be handled by one system or two), stabilizing the boundary prematurely forces a refactor later. Wait until the boundary is stable before formalizing it.
|
|
104
|
+
|
|
105
|
+
### The False Abstraction Anti-Pattern
|
|
106
|
+
|
|
107
|
+
A false abstraction is any interface, base class, or adaptor that exists without a second implementation and has no realistic prospect of one. `IUserRepository` implemented by exactly one class, `UserRepository`, is not SoC — it is ceremony. The interface provides no actual separation because there is nothing to swap behind it. The added indirection makes the code harder to read and the stack traces harder to follow, with no compensating benefit.
|
|
108
|
+
|
|
109
|
+
Rule of thumb: an abstraction is justified when you have (or can clearly foresee) at least two implementations, or when the interface boundary is required for testing (a mock/stub will be the second implementation). One class, one interface, no test benefit = false abstraction.
|
|
110
|
+
|
|
111
|
+
### When Integration Is the Right Answer
|
|
112
|
+
|
|
113
|
+
Some problems are integrative by nature. A reporting module that must aggregate data from orders, users, products, and inventory cannot be cleanly separated — it is, by definition, a cross-cutting read model. Forcing it through strict separation creates N+1 query problems, unnecessary DTO mapping, and performance overhead. Read models and reporting layers are legitimately allowed to reach across concern boundaries, because their purpose is to integrate.
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
## How It Works
|
|
118
|
+
|
|
119
|
+
### Identifying Concerns
|
|
120
|
+
|
|
121
|
+
A "concern" in SoC is not a synonym for "class" or "function." It is a dimension along which the system can change. The identification question is: "What would have to change if X changed?" If changing the database schema requires also changing the API response format, schema and API format are not separate concerns — they are entangled.
|
|
122
|
+
|
|
123
|
+
Practical identification technique: draw a change matrix. For each type of foreseeable change (new business rule, new UI design, new data store, new third-party API, new compliance requirement), list which code modules must change. Modules that must change together are either correctly co-located or incorrectly entangled — the distinction is whether the co-change is *semantic* (they represent the same concern) or *accidental* (one leaked into the other).
|
|
124
|
+
|
|
125
|
+
### Stable vs. Volatile Concerns
|
|
126
|
+
|
|
127
|
+
Not all concerns deserve equal separation investment. Stable concerns — things unlikely to change — do not need to be isolated defensively. Volatile concerns — things likely to change independently — must be isolated aggressively.
|
|
128
|
+
|
|
129
|
+
Common stability profiles:
|
|
130
|
+
- **Stable:** Core business rules (what an order is, what constitutes a valid transaction), domain entities.
|
|
131
|
+
- **Volatile:** External API contracts (third-party services change), UI rendering (design systems evolve), infrastructure specifics (cloud provider, database engine).
|
|
132
|
+
- **Variable by context:** Authentication mechanism (stable in B2B SaaS, volatile when adding OAuth providers), caching strategy (stable until scale changes).
|
|
133
|
+
|
|
134
|
+
Robert Martin's Stable Dependencies Principle: stable modules should not depend on volatile modules. Your domain model should not depend on your database schema. Your business rules should not depend on your HTTP framework.
|
|
135
|
+
|
|
136
|
+
### Interface Contracts at Concern Boundaries
|
|
137
|
+
|
|
138
|
+
Concern boundaries must be formalized as contracts. In statically typed languages, these are interfaces or abstract types. In dynamically typed languages, they are documented protocols (explicit duck typing). The contract specifies what one concern promises to another — and nothing more. Leaking internal implementation details through a contract defeats the separation.
|
|
139
|
+
|
|
140
|
+
A well-formed contract at a concern boundary has three properties:
|
|
141
|
+
1. **Minimal**: exposes only what the downstream concern needs, not what the upstream concern happens to have.
|
|
142
|
+
2. **Stable**: changes rarely, even when the implementation behind it changes often.
|
|
143
|
+
3. **Explicit**: there is no implicit coupling (shared global state, implicit ordering dependencies, hidden side effects).
|
|
144
|
+
|
|
145
|
+
### Cross-Cutting Concerns and AOP
|
|
146
|
+
|
|
147
|
+
Cross-cutting concerns (logging, auth, caching, transactions, validation, error handling) are the hardest to separate cleanly because they genuinely belong everywhere. Three handling strategies:
|
|
148
|
+
|
|
149
|
+
**Aspect-Oriented Programming (AOP).** Defines concerns as "aspects" applied to "joinpoints" (specific points in execution: method entry, method exit, exception throw). Spring AOP (Java/Kotlin), PostSharp (.NET), and similar frameworks allow declaring "wrap every service method with transaction management" in one file rather than 200. The core business code is unaware of the aspect; the aspect is applied by the framework at compile time (weaving) or runtime (proxy).
|
|
150
|
+
|
|
151
|
+
**Decorator/Middleware Pattern.** Used in web frameworks universally. Express.js middleware, Django middleware, and ASP.NET filters are all decorator patterns for cross-cutting concerns. A request passes through an authentication middleware, then a logging middleware, then a rate-limiting middleware before reaching the handler. Each middleware is a separate concern, each independently testable, each independently removable.
|
|
152
|
+
|
|
153
|
+
**Convention-Based Centralization.** For concerns that cannot be injected cleanly, establish a single entry point. All errors flow through one error handler. All logging is initiated from one logger factory. All external API calls pass through one HTTP client with retry logic and circuit breaking built in. The concern is not *separated from* the business code — the business code calls it explicitly — but it is *centralized* so changes to the concern require one edit.
|
|
154
|
+
|
|
155
|
+
---
|
|
156
|
+
|
|
157
|
+
## Trade-Offs Matrix
|
|
158
|
+
|
|
159
|
+
| You Get | You Pay |
|
|
160
|
+
|---------|---------|
|
|
161
|
+
| Testability of individual concerns in isolation | Indirection overhead — more files, more layers to trace |
|
|
162
|
+
| Independent deployment of separated modules | Integration testing burden — concerns must be tested together too |
|
|
163
|
+
| Team autonomy — teams own their concern | Coordination overhead at concern boundaries (API contracts, versioning) |
|
|
164
|
+
| Changeability — modify one concern without ripple effects | Discovery cost — finding where a behavior lives requires knowing the structure |
|
|
165
|
+
| Replaceability — swap implementations behind interfaces | Mapping overhead — DTOs, adapters, and translators at every boundary |
|
|
166
|
+
| Cognitive focus — reason about one thing at a time | Onboarding tax — new developers must learn the separation model before contributing |
|
|
167
|
+
| Fault isolation — failures in one concern don't corrupt others | Latency in distributed systems — network calls replace in-process calls |
|
|
168
|
+
| Compliance auditability — trace where sensitive data flows | Risk of premature separation — wrong boundaries are expensive to undo |
|
|
169
|
+
| Parallel development — teams work independently | Integration friction — independently developed concerns must still fit together |
|
|
170
|
+
| Evolutionary architecture — change one concern's technology independently | Abstraction leakage — underlying details often surface despite separation |
|
|
171
|
+
|
|
172
|
+
---
|
|
173
|
+
|
|
174
|
+
## Evolution Path
|
|
175
|
+
|
|
176
|
+
### Stage 0: Co-Located Everything
|
|
177
|
+
|
|
178
|
+
All logic in one file or one layer. Valid at project start — you do not yet know where the boundaries are. Do not fight this. The cost of wrong separation exceeds the cost of no separation at this stage.
|
|
179
|
+
|
|
180
|
+
**Signal to move to Stage 1:** The file is growing beyond 300-400 lines, or two different *types* of changes are landing in the same file (e.g., UI changes and business rule changes both touch `App.js`).
|
|
181
|
+
|
|
182
|
+
### Stage 1: Identify Stable vs. Volatile Concerns
|
|
183
|
+
|
|
184
|
+
Before splitting code, map concerns. Answer: "What changes independently?" Draw the change matrix described above. Identify the most volatile boundary: typically data access vs. business logic, or UI vs. everything else.
|
|
185
|
+
|
|
186
|
+
### Stage 2: Extract Along One Boundary
|
|
187
|
+
|
|
188
|
+
Extract the single most valuable separation first. Usually: separate data access from business logic. Add an explicit interface at the boundary. Do not reorganize the whole codebase — extract one concern.
|
|
189
|
+
|
|
190
|
+
**Migration pattern for legacy systems:** The Strangler Fig Pattern. New code respects the separation. Old code is refactored incrementally as it is touched. Never attempt a full-codebase separation in one pass — it creates a multi-month branch that can never be merged cleanly.
|
|
191
|
+
|
|
192
|
+
### Stage 3: Enforce Boundaries with Tooling
|
|
193
|
+
|
|
194
|
+
Separation without enforcement degrades. Teams under deadline pressure will import directly across concern boundaries. Enforce with:
|
|
195
|
+
- **Dependency analysis tools**: `dependency-cruiser` (Node.js), `ArchUnit` (Java/Kotlin), `enforce-module-boundaries` (Nx for TypeScript monorepos), `import-linter` (Python).
|
|
196
|
+
- **Package/module structure**: In languages with strong module systems (Go packages, Rust crates, Java modules), encode the separation in the build system. Crossing a boundary requires an explicit dependency declaration — accidental coupling becomes a build error.
|
|
197
|
+
|
|
198
|
+
### Stage 4: Centralize Cross-Cutting Concerns
|
|
199
|
+
|
|
200
|
+
Once horizontal/vertical separation is established, address cross-cutting concerns. Audit the codebase: where does logging appear? Where is authentication checked? Where is caching implemented? Centralize each one.
|
|
201
|
+
|
|
202
|
+
### Signals That SoC Is Breaking Down
|
|
203
|
+
|
|
204
|
+
- PRs for simple features touch 10+ files across multiple layers.
|
|
205
|
+
- Test setup requires instantiating half the application.
|
|
206
|
+
- The same business rule is implemented (slightly differently) in multiple places.
|
|
207
|
+
- Developers cannot describe where a concern "lives" — the answer is "everywhere."
|
|
208
|
+
- A change to one dependency (database driver, HTTP library) requires changes throughout the codebase.
|
|
209
|
+
- Onboarding a new developer takes weeks before they can make any change safely.
|
|
210
|
+
|
|
211
|
+
---
|
|
212
|
+
|
|
213
|
+
## Failure Modes
|
|
214
|
+
|
|
215
|
+
### Over-Separation: Death by Abstraction
|
|
216
|
+
|
|
217
|
+
Described above in "When NOT to Use It." The measurable symptom: adding a new field requires editing 8 files (entity, DTO, mapper, repository, service, controller, test, migration). The diagnosis: the separation is at a finer granularity than the system's actual change rate. Fix: merge layers that always change together.
|
|
218
|
+
|
|
219
|
+
A documented real-world example: enterprise Java systems in the early 2000s following J2EE's strict layering produced applications where a "Hello World" required 15 classes across 5 packages. The industry reaction was Spring Framework (2003), which preserved concern separation while eliminating the mandatory ceremony. The lesson: separation must be proportionate to the volatility of the concern.
|
|
220
|
+
|
|
221
|
+
### Under-Separation: God Classes and Files
|
|
222
|
+
|
|
223
|
+
The opposite failure. A single `UserManager` class that handles authentication, authorization, profile management, notification preferences, billing, and audit logging. When it breaks, nobody knows where to look. When it must change, every team is affected. When it must be tested, the entire dependency graph must be instantiated.
|
|
224
|
+
|
|
225
|
+
God classes are not always the result of laziness — they often grow by accretion, each addition individually reasonable, the whole becoming unmaintainable. The diagnostic question: "How many different *types* of changes has this class received in the last 6 months?" More than 3-4 distinct types indicates it is doing too many things.
|
|
226
|
+
|
|
227
|
+
### Leaky Abstractions
|
|
228
|
+
|
|
229
|
+
Joel Spolsky's Law of Leaky Abstractions: "All non-trivial abstractions, to some degree, are leaky." A concern boundary that leaks internal details forces callers to know what they should not. An ORM that requires callers to understand N+1 queries leaks its database implementation details into the business layer. A "service" that returns database entity objects instead of domain objects leaks persistence concerns into the API layer.
|
|
230
|
+
|
|
231
|
+
The fix is not to deny that abstractions leak, but to design the boundary so that the leak is minimal and the leaked knowledge is stable. Accept that HTTP details will sometimes surface in service layer tests — design the tests to be resilient to it rather than pretending the leak does not exist.
|
|
232
|
+
|
|
233
|
+
### Incorrect Concern Identification
|
|
234
|
+
|
|
235
|
+
The most insidious failure: the separations exist, but they are drawn at the wrong boundaries. A system that separates by technical role (MVC) when it should separate by business domain (DDD bounded contexts) will have correct-looking structure but constant cross-cutting changes. Every new feature requires changes in every layer because features are not aligned with layers.
|
|
236
|
+
|
|
237
|
+
This is the argument for "vertical slicing" over pure horizontal layering in feature-rich applications: if features are independent, separate by feature. If technical roles are independent, separate by role. The wrong choice here produces a system that is well-separated in the wrong dimension — which is often worse than no separation, because the wrong structure creates confident-but-incorrect navigation.
|
|
238
|
+
|
|
239
|
+
### Production Incidents Linked to Poor SoC
|
|
240
|
+
|
|
241
|
+
**The Therac-25 radiation machine (1985-1987).** A software-controlled radiation therapy machine caused six documented overdose accidents, three fatal. Post-incident analysis found that race conditions in shared state occurred because safety-critical and UI concerns were not separated — a UI event could overwrite a safety interlock variable. The failure mode was direct entanglement of concerns that should have been isolated behind strict interfaces with safety guarantees.
|
|
242
|
+
|
|
243
|
+
**Distributed monolith failures.** Teams that split a monolith into microservices without first identifying clean concern boundaries produce "distributed monoliths": services that cannot be deployed independently because they share databases, call each other synchronously in long chains, and have no independent business capability. The service boundaries are structural (separate processes) but not semantic (shared concerns). This architecture has the operational overhead of microservices and the coupling of a monolith — the worst of both worlds. The fix requires the SoC analysis that should have preceded the split.
|
|
244
|
+
|
|
245
|
+
---
|
|
246
|
+
|
|
247
|
+
## Technology Landscape
|
|
248
|
+
|
|
249
|
+
### Layer Enforcement
|
|
250
|
+
|
|
251
|
+
| Tool | Language/Ecosystem | What It Enforces |
|
|
252
|
+
|------|--------------------|-----------------|
|
|
253
|
+
| `dependency-cruiser` | Node.js/TypeScript | Import rules across modules, layers, features |
|
|
254
|
+
| `ArchUnit` | Java/Kotlin | Package dependency rules, layer constraints |
|
|
255
|
+
| `Nx enforce-module-boundaries` | TypeScript monorepos | Cross-project import rules |
|
|
256
|
+
| `import-linter` | Python | Import contracts between packages |
|
|
257
|
+
| `go mod` + internal packages | Go | `internal/` packages prevent external access |
|
|
258
|
+
| Rust crate visibility | Rust | `pub`/`pub(crate)`/private module boundaries |
|
|
259
|
+
|
|
260
|
+
### Aspect-Oriented Programming Frameworks
|
|
261
|
+
|
|
262
|
+
| Framework | Language | Typical Uses |
|
|
263
|
+
|-----------|----------|-------------|
|
|
264
|
+
| Spring AOP | Java/Kotlin | Transactions, logging, security, caching |
|
|
265
|
+
| AspectJ | Java | Full AOP (compile-time and load-time weaving) |
|
|
266
|
+
| PostSharp | .NET/C# | Logging, caching, validation, exception handling |
|
|
267
|
+
| `aspectlib` / `wrapt` | Python | Method interception, logging |
|
|
268
|
+
| `go-aop` | Go | Limited AOP via interfaces |
|
|
269
|
+
| Proxies / decorators | JavaScript/TypeScript | Logging, caching (no formal AOP framework) |
|
|
270
|
+
|
|
271
|
+
### Feature Slicing Frameworks
|
|
272
|
+
|
|
273
|
+
| Framework | Ecosystem | Approach |
|
|
274
|
+
|-----------|-----------|---------|
|
|
275
|
+
| Nx | TypeScript/JS monorepos | Enforced module boundaries, project graph |
|
|
276
|
+
| Feature-Sliced Design (FSD) | Frontend (React/Vue) | Strict vertical feature + layer hierarchy |
|
|
277
|
+
| Vertical Slice Architecture | .NET (MediatR) | One folder per feature with handler, command, query |
|
|
278
|
+
| Domain-Driven Design | Language-agnostic | Bounded contexts as primary separation unit |
|
|
279
|
+
|
|
280
|
+
### Module Boundary Checkers
|
|
281
|
+
|
|
282
|
+
For enforcing that concern boundaries do not erode over time:
|
|
283
|
+
- **SonarQube**: detects circular dependencies and package coupling metrics.
|
|
284
|
+
- **Structure101**: visualizes and enforces architecture diagrams as code.
|
|
285
|
+
- **Deptrac** (.php/multi-language): YAML-defined layer rules, CI integration.
|
|
286
|
+
- **Checkstyle + custom rules**: Java import rule enforcement.
|
|
287
|
+
|
|
288
|
+
---
|
|
289
|
+
|
|
290
|
+
## Decision Tree
|
|
291
|
+
|
|
292
|
+
```
|
|
293
|
+
Is the behavior expected to vary independently of its neighbors?
|
|
294
|
+
├── YES → Separate it.
|
|
295
|
+
│ Does separating require more than 2 indirection layers?
|
|
296
|
+
│ ├── YES → Question whether the layers are all necessary.
|
|
297
|
+
│ │ Do all layers have at least 2 implementations (or test mocks)?
|
|
298
|
+
│ │ ├── YES → The indirection is justified.
|
|
299
|
+
│ │ └── NO → Collapse redundant layers (false abstraction risk).
|
|
300
|
+
│ └── NO → Separate freely.
|
|
301
|
+
│
|
|
302
|
+
└── NO → Keep it together.
|
|
303
|
+
Is this the second time you've needed to change these two things independently?
|
|
304
|
+
├── YES → The boundary is becoming real. Begin extracting.
|
|
305
|
+
└── NO → Wait. Co-locate. Revisit when you have more evidence.
|
|
306
|
+
|
|
307
|
+
Are you handling a cross-cutting concern (logging, auth, caching, transactions)?
|
|
308
|
+
├── YES → Centralize in an aspect, middleware, or single utility.
|
|
309
|
+
│ Does your language/framework support AOP?
|
|
310
|
+
│ ├── YES → Use AOP (Spring, AspectJ, PostSharp).
|
|
311
|
+
│ └── NO → Use middleware, decorators, or explicit call to centralized utility.
|
|
312
|
+
│
|
|
313
|
+
└── NO → Proceed with horizontal or vertical separation.
|
|
314
|
+
|
|
315
|
+
What is the project size?
|
|
316
|
+
├── Solo / <3 months → Minimal separation. Extract data access from business logic.
|
|
317
|
+
│ No formal interfaces. No layers. Just functions and modules.
|
|
318
|
+
│
|
|
319
|
+
├── 2-5 devs / 3-12 months → Separate presentation, business, data. Interfaces at
|
|
320
|
+
│ data access boundary for testability. Feature folders.
|
|
321
|
+
│
|
|
322
|
+
├── 5+ devs / multi-team → Enforce vertical modules per domain/feature.
|
|
323
|
+
│ ArchUnit/dependency-cruiser in CI. Centralize cross-cutting.
|
|
324
|
+
│
|
|
325
|
+
└── Microservices scale → Only split service boundary when deployment independence
|
|
326
|
+
is required AND the concern boundary is stable AND you
|
|
327
|
+
have observed it change independently at least once.
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
### Size-Based Heuristics
|
|
331
|
+
|
|
332
|
+
| Project Size | Team Size | Recommended Separation Depth |
|
|
333
|
+
|-------------|-----------|------------------------------|
|
|
334
|
+
| <5K lines | 1-2 devs | 1-2 layers (business + data access) |
|
|
335
|
+
| 5K-50K lines | 2-10 devs | 3 layers + feature modules |
|
|
336
|
+
| 50K-500K lines | 10-50 devs | Domain modules + enforced boundaries + centralized cross-cutting |
|
|
337
|
+
| >500K lines | 50+ devs | Bounded contexts, separate deployable modules or services |
|
|
338
|
+
|
|
339
|
+
---
|
|
340
|
+
|
|
341
|
+
## Implementation Sketch
|
|
342
|
+
|
|
343
|
+
### Entangled Code (Before)
|
|
344
|
+
|
|
345
|
+
```
|
|
346
|
+
src/
|
|
347
|
+
app.js ← 800 lines: renders HTML, validates input,
|
|
348
|
+
queries database, sends email, logs everything
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
A representative excerpt:
|
|
352
|
+
```javascript
|
|
353
|
+
// app.js — everything in one place
|
|
354
|
+
app.post('/orders', async (req, res) => {
|
|
355
|
+
console.log(`[${new Date()}] POST /orders from ${req.ip}`);
|
|
356
|
+
if (!req.body.userId || !req.body.items) {
|
|
357
|
+
console.log('Validation failed');
|
|
358
|
+
return res.status(400).json({ error: 'Missing required fields' });
|
|
359
|
+
}
|
|
360
|
+
const user = await db.query('SELECT * FROM users WHERE id = ?', [req.body.userId]);
|
|
361
|
+
if (!user) return res.status(404).json({ error: 'User not found' });
|
|
362
|
+
const total = req.body.items.reduce((sum, item) => sum + item.price * item.qty, 0);
|
|
363
|
+
const order = await db.query('INSERT INTO orders ...', [...]);
|
|
364
|
+
await sendgrid.send({ to: user.email, subject: 'Order confirmed', ... });
|
|
365
|
+
console.log(`Order ${order.id} created`);
|
|
366
|
+
res.json({ orderId: order.id, total });
|
|
367
|
+
});
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
Problems: logging is scattered, validation is inline, database is direct, email is hardcoded to SendGrid. Change any one thing and you touch this function.
|
|
371
|
+
|
|
372
|
+
### Separated by Horizontal Layers
|
|
373
|
+
|
|
374
|
+
```
|
|
375
|
+
src/
|
|
376
|
+
routes/
|
|
377
|
+
orders.js ← HTTP: parse request, call service, format response
|
|
378
|
+
services/
|
|
379
|
+
orderService.js ← Business rules: validate, calculate total, orchestrate
|
|
380
|
+
repositories/
|
|
381
|
+
orderRepository.js ← Data access: SQL queries only
|
|
382
|
+
notifications/
|
|
383
|
+
emailNotifier.js ← Notification: email logic, SendGrid coupling here only
|
|
384
|
+
middleware/
|
|
385
|
+
logger.js ← Cross-cutting: all logging centralized here
|
|
386
|
+
auth.js ← Cross-cutting: authentication here only
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
Each file has one reason to change:
|
|
390
|
+
- Routes change when the API contract changes.
|
|
391
|
+
- Service changes when business rules change.
|
|
392
|
+
- Repository changes when the database schema or engine changes.
|
|
393
|
+
- EmailNotifier changes when the notification vendor changes.
|
|
394
|
+
- Logger changes when the logging strategy changes.
|
|
395
|
+
|
|
396
|
+
### Separated by Vertical Feature Slices
|
|
397
|
+
|
|
398
|
+
For larger applications where features are the primary unit of change:
|
|
399
|
+
|
|
400
|
+
```
|
|
401
|
+
src/
|
|
402
|
+
features/
|
|
403
|
+
orders/
|
|
404
|
+
OrderRoute.js ← HTTP handler for orders
|
|
405
|
+
OrderService.js ← Order business rules
|
|
406
|
+
OrderRepository.js ← Order data access
|
|
407
|
+
OrderNotifier.js ← Order-specific notifications
|
|
408
|
+
order.test.js ← All order tests co-located
|
|
409
|
+
users/
|
|
410
|
+
UserRoute.js
|
|
411
|
+
UserService.js
|
|
412
|
+
UserRepository.js
|
|
413
|
+
user.test.js
|
|
414
|
+
shared/
|
|
415
|
+
middleware/
|
|
416
|
+
logger.js ← Cross-cutting: shared across features
|
|
417
|
+
auth.js
|
|
418
|
+
db/
|
|
419
|
+
connection.js ← Shared infrastructure
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
Benefit over pure horizontal: a developer working on the orders feature navigates one directory. A new order requirement is implemented in one place. The feature can potentially be extracted to a separate service when it needs to scale independently.
|
|
423
|
+
|
|
424
|
+
### Cross-Cutting Concern Before and After
|
|
425
|
+
|
|
426
|
+
**Before (scattered logging):**
|
|
427
|
+
```javascript
|
|
428
|
+
// In UserService.js
|
|
429
|
+
console.log('Creating user...');
|
|
430
|
+
// In OrderService.js
|
|
431
|
+
console.log('Creating order...');
|
|
432
|
+
// In PaymentService.js
|
|
433
|
+
console.log('Processing payment...');
|
|
434
|
+
// 200 more instances across the codebase
|
|
435
|
+
```
|
|
436
|
+
|
|
437
|
+
**After (centralized via middleware/aspect):**
|
|
438
|
+
```javascript
|
|
439
|
+
// middleware/logger.js — one place
|
|
440
|
+
function loggingMiddleware(req, res, next) {
|
|
441
|
+
const start = Date.now();
|
|
442
|
+
res.on('finish', () => {
|
|
443
|
+
logger.info({ method: req.method, path: req.path,
|
|
444
|
+
status: res.statusCode, ms: Date.now() - start });
|
|
445
|
+
});
|
|
446
|
+
next();
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
// All services — no logging code
|
|
450
|
+
class OrderService {
|
|
451
|
+
async createOrder(data) {
|
|
452
|
+
// Pure business logic. Logging applied at the middleware layer.
|
|
453
|
+
return this.orderRepository.save(new Order(data));
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
```
|
|
457
|
+
|
|
458
|
+
The business logic is now readable without logging noise. The logging strategy can be changed in one file. The logging can be tested independently.
|
|
459
|
+
|
|
460
|
+
---
|
|
461
|
+
|
|
462
|
+
## Cross-References
|
|
463
|
+
|
|
464
|
+
- **coupling-and-cohesion** — SoC and cohesion are complementary: high cohesion within a concern, low coupling between concerns. Coupling is the mechanism; SoC is the goal.
|
|
465
|
+
- **layered-architecture** — The horizontal instantiation of SoC. Covers layer dependencies, anti-corruption layers, and enforcement.
|
|
466
|
+
- **hexagonal-clean-architecture** — Domain-centric SoC. Ports and adapters enforce the boundary between business logic and everything volatile (databases, frameworks, UIs).
|
|
467
|
+
- **domain-driven-design** — Provides the vocabulary for identifying vertical concern boundaries: bounded contexts, aggregates, and domain services map to separable concerns at the business level.
|
|
468
|
+
- **design-principles-solid** — SRP is the class-level expression of SoC. Open/Closed Principle requires stable concern boundaries that can be extended without modification. Dependency Inversion is the mechanism for enforcing concern boundaries at compile time.
|
|
469
|
+
|
|
470
|
+
---
|
|
471
|
+
|
|
472
|
+
*Researched: 2026-03-08 | Sources: [Dijkstra, E.W. (1974) "On the role of scientific thought"; Foote & Yoder (1997) "Big Ball of Mud"; Spolsky, J. "The Law of Leaky Abstractions"; Metz, S. "The Wrong Abstraction"; Wikipedia — Separation of Concerns (https://en.wikipedia.org/wiki/Separation_of_concerns); Wikipedia — Aspect-Oriented Programming (https://en.wikipedia.org/wiki/Aspect-oriented_programming); Wikipedia — Cross-cutting concern (https://en.wikipedia.org/wiki/Cross-cutting_concern); Nalexn, A. "Separation of Concerns in Software Design" (https://nalexn.github.io/separation-of-concerns/); Number Analytics "Separation of Concerns in Practice" (https://www.numberanalytics.com/blog/separation-of-concerns-in-practice); arendjr.nl "Post-Architecture: Premature Abstraction Is the Root of All Evil" (https://www.arendjr.nl/blog/2024/07/post-architecture-premature-abstraction-is-the-root-of-all-evil/); Spring Boot Tutorial — SoC (https://www.springboottutorial.com/software-design-seperation-of-concerns-with-examples); Spring Boot Tutorial — AOP (https://www.springboottutorial.com/introduction-to-aspect-oriented-programming-and-cross-cutting-concerns); Jorganxhi, A. "How AOP Solves Cross-Cutting Concerns" (https://ardijorganxhi.medium.com/how-can-aspect-oriented-programming-aop-solve-cross-cutting-concerns-of-your-application-18332c0e2f9a); mortoray.com "The False Abstraction Anti-pattern" (https://mortoray.com/the-false-abstraction-antipattern/); ScienceDirect — Embedded real-time SoC (https://www.sciencedirect.com/article/pii/S1383762114000824)]*
|