@haposoft/cafekit 0.16.0-rc.8 → 0.16.1
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/README.md +117 -28
- package/bin/__tests__/codex-hooks-ownership.test.js +239 -0
- package/bin/__tests__/codex-hooks.test.js +175 -0
- package/bin/__tests__/codex-native.test.js +1882 -70
- package/bin/__tests__/develop-contract.test.js +442 -23
- package/bin/__tests__/grok-envelope.test.js +271 -0
- package/bin/__tests__/grok-platform.test.js +133 -0
- package/bin/__tests__/hook-payload.test.js +194 -0
- package/bin/__tests__/installer-safety.test.js +3 -3
- package/bin/__tests__/omp-bridge.test.js +168 -0
- package/bin/__tests__/omp-hooks.test.js +178 -0
- package/bin/__tests__/omp-runtime.test.js +150 -0
- package/bin/__tests__/optional-skill-inventory.test.js +249 -0
- package/bin/__tests__/output-styles.test.js +214 -0
- package/bin/__tests__/package-inventory.test.js +1735 -98
- package/bin/__tests__/runtime-dir.test.js +158 -0
- package/bin/__tests__/runtime-schema.test.js +113 -0
- package/bin/__tests__/secret-output-guardrail.test.js +122 -0
- package/bin/__tests__/skill-routing-source.test.js +172 -0
- package/bin/__tests__/specs-v2-execution-closeout.test.js +28 -1
- package/bin/install.js +15 -5
- package/bin/lib/codex-install.js +170 -5
- package/bin/lib/context.js +64 -3
- package/bin/lib/i18n.js +15 -36
- package/bin/lib/skill-deps.js +5 -5
- package/bin/phases/claude-runtime.js +23 -0
- package/bin/phases/claude-settings.js +8 -0
- package/bin/phases/codex-hooks.js +156 -0
- package/bin/phases/codex-runtime.js +29 -38
- package/bin/phases/copy-payload.js +15 -2
- package/bin/phases/omp-runtime.js +140 -0
- package/bin/phases/root-config.js +3 -0
- package/bin/phases/select-platform.js +22 -1
- package/bin/phases/select-skill-bundles.js +96 -0
- package/bin/phases/skill-inventory.js +71 -0
- package/bin/phases/skills-setup.js +9 -2
- package/bin/phases/summary.js +0 -4
- package/bin/phases/write-metadata.js +8 -5
- package/package.json +8 -2
- package/src/claude/CLAUDE.md +3 -3
- package/src/claude/agents/brainstormer.md +52 -69
- package/src/claude/agents/code-auditor.md +32 -14
- package/src/claude/agents/debugger.md +35 -20
- package/src/claude/agents/deployer.md +12 -5
- package/src/claude/agents/docs-keeper.md +11 -1
- package/src/claude/agents/implementer.md +25 -13
- package/src/claude/agents/inspector.md +6 -3
- package/src/claude/agents/project-manager.md +1 -1
- package/src/claude/agents/researcher.md +26 -55
- package/src/claude/agents/spec-maker.md +12 -7
- package/src/claude/agents/strategist.md +52 -0
- package/src/claude/agents/test-runner.md +117 -132
- package/src/claude/agents/ui-ux-designer.md +1 -1
- package/src/claude/hooks/__tests__/fixtures/statusline-default.golden +1 -0
- package/src/claude/hooks/__tests__/precompact.test.js +158 -0
- package/src/claude/hooks/__tests__/semantic-review-authority.test.js +2 -0
- package/src/claude/hooks/__tests__/spec-gate.test.js +348 -3
- package/src/claude/hooks/__tests__/state.test.js +7 -0
- package/src/claude/hooks/__tests__/statusline.test.js +196 -0
- package/src/claude/hooks/agent.cjs +13 -8
- package/src/claude/hooks/completion-authority.cjs +10 -4
- package/src/claude/hooks/docs-sync.cjs +14 -11
- package/src/claude/hooks/inspect-block.cjs +28 -8
- package/src/claude/hooks/lib/config.cjs +8 -2
- package/src/claude/hooks/lib/counter.cjs +7 -5
- package/src/claude/hooks/lib/hook-payload.cjs +160 -0
- package/src/claude/hooks/lib/hook-state-dir.cjs +39 -0
- package/src/claude/hooks/lib/runtime-dir.cjs +49 -0
- package/src/claude/hooks/lib/secret-keywords.cjs +42 -0
- package/src/claude/hooks/precompact.cjs +106 -0
- package/src/claude/hooks/privacy-block.cjs +4 -2
- package/src/claude/hooks/rules.cjs +5 -3
- package/src/claude/hooks/secret-output-guardrail.cjs +44 -0
- package/src/claude/hooks/semantic-review-authority.cjs +6 -4
- package/src/claude/hooks/session.cjs +37 -9
- package/src/claude/hooks/spec-gate.cjs +21 -11
- package/src/claude/hooks/spec-state.cjs +11 -7
- package/src/claude/hooks/state.cjs +7 -5
- package/src/claude/hooks/task-scaffold-guard.cjs +30 -9
- package/src/claude/hooks/usage.cjs +6 -5
- package/src/claude/migration-manifest.json +31 -15
- package/src/claude/output-styles/coding-level-0-eli5.md +103 -0
- package/src/claude/output-styles/coding-level-1-junior.md +124 -0
- package/src/claude/output-styles/coding-level-2-mid.md +146 -0
- package/src/claude/output-styles/coding-level-3-senior.md +148 -0
- package/src/claude/output-styles/coding-level-4-lead.md +159 -0
- package/src/claude/output-styles/coding-level-5-god.md +91 -0
- package/src/claude/references/debugger/core-philosophy.md +5 -3
- package/src/claude/references/debugger/frontend-verification.md +2 -2
- package/src/claude/references/debugger/log-ci-analysis.md +13 -1
- package/src/claude/references/debugger/parallel-agent-hydration.md +19 -34
- package/src/claude/references/debugger/performance-diagnostics.md +2 -2
- package/src/claude/references/debugger/root-cause-tracing.md +37 -6
- package/src/claude/references/debugger/side-effect-gate.md +3 -1
- package/src/claude/references/debugger/verification-protocol.md +13 -12
- package/src/claude/rules/orchestrator.md +7 -1
- package/src/claude/rules/process-management.md +39 -0
- package/src/claude/rules/review-audit-self-decision.md +48 -0
- package/src/claude/rules/skill-domain-routing.md +26 -24
- package/src/claude/rules/skill-workflow-routing.md +22 -14
- package/src/claude/rules/state-sync.md +7 -1
- package/src/claude/rules/workflow.md +5 -3
- package/src/claude/runtime.json +1 -0
- package/src/claude/runtime.schema.json +205 -0
- package/src/claude/scripts/generate-skill-catalog.cjs +156 -122
- package/src/claude/scripts/provenance.cjs +29 -9
- package/src/claude/scripts/spec-receipt.cjs +65 -4
- package/src/claude/scripts/workflow-policy.cjs +1 -1
- package/src/claude/settings/settings.json +16 -0
- package/src/claude/skills/agent-browser/SKILL.md +1 -1
- package/src/claude/skills/ai-multimodal/SKILL.md +1 -1
- package/src/claude/skills/brainstorm/SKILL.md +193 -172
- package/src/claude/skills/brainstorm/references/question-framework.md +105 -167
- package/src/claude/skills/chrome-devtools/SKILL.md +1 -1
- package/src/claude/skills/code-review/SKILL.md +43 -25
- package/src/claude/skills/code-review/references/spec-compliance-review.md +3 -4
- package/src/claude/skills/code-review/references/verification-gate.md +1 -1
- package/src/claude/skills/debug/SKILL.md +48 -19
- package/src/claude/skills/delegate/SKILL.md +1 -1
- package/src/claude/skills/develop/SKILL.md +92 -65
- package/src/claude/skills/develop/references/parallel-waves.md +36 -63
- package/src/claude/skills/develop/references/quality-gate.md +31 -4
- package/src/claude/skills/develop/references/subagent-patterns.md +21 -7
- package/src/claude/skills/docs/SKILL.md +42 -23
- package/src/claude/skills/docs/references/init-workflow.md +4 -4
- package/src/claude/skills/docs/references/reconstruct-workflow.md +6 -6
- package/src/claude/skills/docs/references/standard-docs-workflow.md +6 -2
- package/src/claude/skills/docs/references/summarize-workflow.md +2 -2
- package/src/claude/skills/docs/references/update-workflow.md +9 -7
- package/src/claude/skills/docs/templates/requirements-as-is.md +1 -1
- package/src/claude/skills/docx/SKILL.md +1 -1
- package/src/claude/skills/git/SKILL.md +1 -1
- package/src/claude/skills/git/references/commit-protocols.md +1 -1
- package/src/claude/skills/git/references/finish-branch.md +1 -1
- package/src/claude/skills/hotfix/SKILL.md +159 -170
- package/src/claude/skills/hotfix/references/diagnosis-protocol.md +14 -9
- package/src/claude/skills/hotfix/references/parallel-patterns.md +27 -13
- package/src/claude/skills/hotfix/references/prevention-gate.md +5 -0
- package/src/claude/skills/hotfix/references/review-cycle.md +21 -15
- package/src/claude/skills/hotfix/references/workflow-specialized.md +53 -21
- package/src/claude/skills/inspect/SKILL.md +55 -46
- package/src/claude/skills/inspect/references/internal-inspection.md +21 -5
- package/src/claude/skills/loop/SKILL.md +114 -0
- package/src/claude/skills/loop/references/bounded-loop-protocol.md +104 -0
- package/src/claude/skills/loop/references/metric-and-guard-contract.md +76 -0
- package/src/claude/skills/pdf/SKILL.md +1 -1
- package/src/claude/skills/pptx/SKILL.md +1 -1
- package/src/claude/skills/question/SKILL.md +16 -13
- package/src/claude/skills/research/SKILL.md +70 -43
- package/src/claude/skills/route/SKILL.md +94 -0
- package/src/claude/skills/route/references/agent-timing.md +46 -0
- package/src/claude/skills/route/references/chaining-patterns.md +53 -0
- package/src/claude/skills/route/references/task-taxonomy.md +48 -0
- package/src/claude/skills/specs/SKILL.md +51 -71
- package/src/claude/skills/specs/references/review.md +11 -8
- package/src/claude/skills/specs/references/templates.md +34 -18
- package/src/claude/skills/specs/templates/requirements-init.md +1 -1
- package/src/claude/skills/specs/templates/research.md +2 -2
- package/src/claude/skills/sync/SKILL.md +6 -6
- package/src/claude/skills/sync/references/sync-protocols.md +1 -1
- package/src/claude/skills/test/SKILL.md +120 -120
- package/src/claude/skills/test/references/execution-strategy.md +208 -361
- package/src/claude/skills/test/references/failure-triage.md +55 -121
- package/src/claude/skills/test/references/test-memory.md +20 -34
- package/src/claude/skills/ui-ux-pro-max/SKILL.md +1 -1
- package/src/claude/skills/web-testing/SKILL.md +1 -1
- package/src/claude/skills/xlsx/SKILL.md +1 -1
- package/src/claude/status.cjs +135 -33
- package/src/codex/AGENTS.md +14 -4
- package/src/codex/hooks/docs-sync.cjs +8 -3
- package/src/codex/hooks/lib/hook-context.cjs +18 -4
- package/src/codex/hooks/rules.cjs +29 -1
- package/src/codex/hooks/secret-output-guardrail.cjs +30 -0
- package/src/codex/hooks/spec-gate.cjs +3 -8
- package/src/codex/hooks/spec-state.cjs +3 -2
- package/src/codex/hooks.json +5 -0
- package/src/codex/rules/state-sync.md +7 -1
- package/src/codex/runtime.json +2 -0
- package/src/common/.env.example +1 -1
- package/src/omp/extensions/cafekit-bridge.mjs +233 -0
- package/src/omp/hooks/privacy-block.cjs +250 -0
- package/src/omp/runtime.json +33 -0
- package/bin/lib/rtk-run.js +0 -28
- package/bin/phases/setup-rtk.js +0 -159
- package/src/claude/skills/backend-development/SKILL.md +0 -101
- package/src/claude/skills/backend-development/references/backend-api-design.md +0 -495
- package/src/claude/skills/backend-development/references/backend-architecture.md +0 -454
- package/src/claude/skills/backend-development/references/backend-authentication.md +0 -338
- package/src/claude/skills/backend-development/references/backend-code-quality.md +0 -659
- package/src/claude/skills/backend-development/references/backend-debugging.md +0 -904
- package/src/claude/skills/backend-development/references/backend-devops.md +0 -491
- package/src/claude/skills/backend-development/references/backend-mindset.md +0 -387
- package/src/claude/skills/backend-development/references/backend-performance.md +0 -397
- package/src/claude/skills/backend-development/references/backend-security.md +0 -342
- package/src/claude/skills/backend-development/references/backend-technologies.md +0 -256
- package/src/claude/skills/backend-development/references/backend-testing.md +0 -429
- package/src/claude/skills/devops/.env.example +0 -76
- package/src/claude/skills/devops/SKILL.md +0 -102
- package/src/claude/skills/devops/references/browser-rendering.md +0 -305
- package/src/claude/skills/devops/references/cloudflare-d1-kv.md +0 -123
- package/src/claude/skills/devops/references/cloudflare-platform.md +0 -271
- package/src/claude/skills/devops/references/cloudflare-r2-storage.md +0 -280
- package/src/claude/skills/devops/references/cloudflare-workers-advanced.md +0 -312
- package/src/claude/skills/devops/references/cloudflare-workers-apis.md +0 -309
- package/src/claude/skills/devops/references/cloudflare-workers-basics.md +0 -418
- package/src/claude/skills/devops/references/docker-basics.md +0 -297
- package/src/claude/skills/devops/references/docker-compose.md +0 -292
- package/src/claude/skills/devops/references/gcloud-platform.md +0 -297
- package/src/claude/skills/devops/references/gcloud-services.md +0 -304
- package/src/claude/skills/devops/references/kubernetes-basics.md +0 -95
- package/src/claude/skills/devops/references/kubernetes-helm-advanced.md +0 -70
- package/src/claude/skills/devops/references/kubernetes-helm.md +0 -81
- package/src/claude/skills/devops/references/kubernetes-kubectl.md +0 -74
- package/src/claude/skills/devops/references/kubernetes-security-advanced.md +0 -94
- package/src/claude/skills/devops/references/kubernetes-security.md +0 -89
- package/src/claude/skills/devops/references/kubernetes-troubleshooting-advanced.md +0 -74
- package/src/claude/skills/devops/references/kubernetes-troubleshooting.md +0 -49
- package/src/claude/skills/devops/references/kubernetes-workflows-advanced.md +0 -75
- package/src/claude/skills/devops/references/kubernetes-workflows.md +0 -76
- package/src/claude/skills/devops/scripts/cloudflare_deploy.py +0 -269
- package/src/claude/skills/devops/scripts/docker_optimize.py +0 -332
- package/src/claude/skills/devops/scripts/requirements.txt +0 -20
- package/src/claude/skills/devops/scripts/tests/requirements.txt +0 -3
- package/src/claude/skills/devops/scripts/tests/test_cloudflare_deploy.py +0 -285
- package/src/claude/skills/devops/scripts/tests/test_docker_optimize.py +0 -436
- package/src/claude/skills/frontend-design/SKILL.md +0 -135
- package/src/claude/skills/frontend-design/references/ai-multimodal-overview.md +0 -165
- package/src/claude/skills/frontend-design/references/analysis-best-practices.md +0 -80
- package/src/claude/skills/frontend-design/references/analysis-prompts.md +0 -141
- package/src/claude/skills/frontend-design/references/analysis-techniques.md +0 -118
- package/src/claude/skills/frontend-design/references/animejs.md +0 -396
- package/src/claude/skills/frontend-design/references/anti-slop-rules.md +0 -103
- package/src/claude/skills/frontend-design/references/asset-generation.md +0 -337
- package/src/claude/skills/frontend-design/references/bento-motion-engine.md +0 -142
- package/src/claude/skills/frontend-design/references/design-extraction-overview.md +0 -71
- package/src/claude/skills/frontend-design/references/extraction-best-practices.md +0 -141
- package/src/claude/skills/frontend-design/references/extraction-output-templates.md +0 -162
- package/src/claude/skills/frontend-design/references/extraction-prompts.md +0 -127
- package/src/claude/skills/frontend-design/references/magicui-components.md +0 -129
- package/src/claude/skills/frontend-design/references/performance-guardrails.md +0 -169
- package/src/claude/skills/frontend-design/references/premium-design-patterns.md +0 -93
- package/src/claude/skills/frontend-design/references/redesign-audit-checklist.md +0 -114
- package/src/claude/skills/frontend-design/references/technical-accessibility.md +0 -119
- package/src/claude/skills/frontend-design/references/technical-best-practices.md +0 -97
- package/src/claude/skills/frontend-design/references/technical-optimization.md +0 -44
- package/src/claude/skills/frontend-design/references/technical-overview.md +0 -90
- package/src/claude/skills/frontend-design/references/technical-workflows.md +0 -150
- package/src/claude/skills/frontend-design/references/visual-analysis-overview.md +0 -95
- package/src/claude/skills/frontend-design/references/workflow-3d.md +0 -102
- package/src/claude/skills/frontend-design/references/workflow-describe.md +0 -87
- package/src/claude/skills/frontend-design/references/workflow-immersive.md +0 -87
- package/src/claude/skills/frontend-design/references/workflow-quick.md +0 -57
- package/src/claude/skills/frontend-design/references/workflow-screenshot.md +0 -63
- package/src/claude/skills/frontend-design/references/workflow-video.md +0 -74
- package/src/claude/skills/frontend-development/SKILL.md +0 -406
- package/src/claude/skills/frontend-development/resources/common-patterns.md +0 -331
- package/src/claude/skills/frontend-development/resources/complete-examples.md +0 -872
- package/src/claude/skills/frontend-development/resources/component-patterns.md +0 -502
- package/src/claude/skills/frontend-development/resources/data-fetching.md +0 -767
- package/src/claude/skills/frontend-development/resources/file-organization.md +0 -502
- package/src/claude/skills/frontend-development/resources/loading-and-error-states.md +0 -501
- package/src/claude/skills/frontend-development/resources/performance.md +0 -406
- package/src/claude/skills/frontend-development/resources/routing-guide.md +0 -364
- package/src/claude/skills/frontend-development/resources/styling-guide.md +0 -428
- package/src/claude/skills/frontend-development/resources/typescript-standards.md +0 -418
- package/src/claude/skills/mobile-development/SKILL.md +0 -218
- package/src/claude/skills/mobile-development/references/mobile-android.md +0 -604
- package/src/claude/skills/mobile-development/references/mobile-best-practices.md +0 -544
- package/src/claude/skills/mobile-development/references/mobile-debugging.md +0 -1089
- package/src/claude/skills/mobile-development/references/mobile-frameworks.md +0 -465
- package/src/claude/skills/mobile-development/references/mobile-ios.md +0 -496
- package/src/claude/skills/mobile-development/references/mobile-mindset.md +0 -542
- package/src/claude/skills/react-best-practices/AGENTS.md +0 -2249
- package/src/claude/skills/react-best-practices/README.md +0 -123
- package/src/claude/skills/react-best-practices/SKILL.md +0 -128
- package/src/claude/skills/react-best-practices/metadata.json +0 -15
- package/src/claude/skills/react-best-practices/rules/_sections.md +0 -46
- package/src/claude/skills/react-best-practices/rules/_template.md +0 -28
- package/src/claude/skills/react-best-practices/rules/advanced-event-handler-refs.md +0 -55
- package/src/claude/skills/react-best-practices/rules/advanced-use-latest.md +0 -49
- package/src/claude/skills/react-best-practices/rules/async-api-routes.md +0 -38
- package/src/claude/skills/react-best-practices/rules/async-defer-await.md +0 -80
- package/src/claude/skills/react-best-practices/rules/async-dependencies.md +0 -36
- package/src/claude/skills/react-best-practices/rules/async-parallel.md +0 -28
- package/src/claude/skills/react-best-practices/rules/async-suspense-boundaries.md +0 -99
- package/src/claude/skills/react-best-practices/rules/bundle-barrel-imports.md +0 -59
- package/src/claude/skills/react-best-practices/rules/bundle-conditional.md +0 -31
- package/src/claude/skills/react-best-practices/rules/bundle-defer-third-party.md +0 -49
- package/src/claude/skills/react-best-practices/rules/bundle-dynamic-imports.md +0 -35
- package/src/claude/skills/react-best-practices/rules/bundle-preload.md +0 -50
- package/src/claude/skills/react-best-practices/rules/client-event-listeners.md +0 -74
- package/src/claude/skills/react-best-practices/rules/client-swr-dedup.md +0 -56
- package/src/claude/skills/react-best-practices/rules/js-batch-dom-css.md +0 -82
- package/src/claude/skills/react-best-practices/rules/js-cache-function-results.md +0 -80
- package/src/claude/skills/react-best-practices/rules/js-cache-property-access.md +0 -28
- package/src/claude/skills/react-best-practices/rules/js-cache-storage.md +0 -70
- package/src/claude/skills/react-best-practices/rules/js-combine-iterations.md +0 -32
- package/src/claude/skills/react-best-practices/rules/js-early-exit.md +0 -50
- package/src/claude/skills/react-best-practices/rules/js-hoist-regexp.md +0 -45
- package/src/claude/skills/react-best-practices/rules/js-index-maps.md +0 -37
- package/src/claude/skills/react-best-practices/rules/js-length-check-first.md +0 -49
- package/src/claude/skills/react-best-practices/rules/js-min-max-loop.md +0 -82
- package/src/claude/skills/react-best-practices/rules/js-set-map-lookups.md +0 -24
- package/src/claude/skills/react-best-practices/rules/js-tosorted-immutable.md +0 -57
- package/src/claude/skills/react-best-practices/rules/rendering-activity.md +0 -26
- package/src/claude/skills/react-best-practices/rules/rendering-animate-svg-wrapper.md +0 -47
- package/src/claude/skills/react-best-practices/rules/rendering-conditional-render.md +0 -40
- package/src/claude/skills/react-best-practices/rules/rendering-content-visibility.md +0 -38
- package/src/claude/skills/react-best-practices/rules/rendering-hoist-jsx.md +0 -46
- package/src/claude/skills/react-best-practices/rules/rendering-hydration-no-flicker.md +0 -82
- package/src/claude/skills/react-best-practices/rules/rendering-svg-precision.md +0 -28
- package/src/claude/skills/react-best-practices/rules/rerender-defer-reads.md +0 -39
- package/src/claude/skills/react-best-practices/rules/rerender-dependencies.md +0 -45
- package/src/claude/skills/react-best-practices/rules/rerender-derived-state.md +0 -29
- package/src/claude/skills/react-best-practices/rules/rerender-functional-setstate.md +0 -74
- package/src/claude/skills/react-best-practices/rules/rerender-lazy-state-init.md +0 -58
- package/src/claude/skills/react-best-practices/rules/rerender-memo.md +0 -44
- package/src/claude/skills/react-best-practices/rules/rerender-transitions.md +0 -40
- package/src/claude/skills/react-best-practices/rules/server-after-nonblocking.md +0 -73
- package/src/claude/skills/react-best-practices/rules/server-cache-lru.md +0 -41
- package/src/claude/skills/react-best-practices/rules/server-cache-react.md +0 -26
- package/src/claude/skills/react-best-practices/rules/server-parallel-fetching.md +0 -79
- package/src/claude/skills/react-best-practices/rules/server-serialization.md +0 -38
|
@@ -1,342 +0,0 @@
|
|
|
1
|
-
# Backend Security
|
|
2
|
-
|
|
3
|
-
Security best practices, OWASP Top 10 mitigation, and modern security standards (2025).
|
|
4
|
-
|
|
5
|
-
## OWASP Top 10 (2025 RC1)
|
|
6
|
-
|
|
7
|
-
### New Entries (2025)
|
|
8
|
-
- **Supply Chain Failures** - Vulnerable dependencies, compromised packages
|
|
9
|
-
- **Mishandling of Exceptional Conditions** - Improper error handling exposing system info
|
|
10
|
-
|
|
11
|
-
### Top Vulnerabilities & Mitigation
|
|
12
|
-
|
|
13
|
-
#### 1. Broken Access Control
|
|
14
|
-
**Risk:** Users access unauthorized resources
|
|
15
|
-
|
|
16
|
-
**Mitigation:**
|
|
17
|
-
- Implement RBAC (Role-Based Access Control)
|
|
18
|
-
- Deny by default, explicitly allow
|
|
19
|
-
- Log access control failures
|
|
20
|
-
- Enforce authorization on backend (never client-side)
|
|
21
|
-
- Use JWT with proper claims validation
|
|
22
|
-
|
|
23
|
-
```typescript
|
|
24
|
-
// Good: Server-side authorization check
|
|
25
|
-
@UseGuards(JwtAuthGuard, RolesGuard)
|
|
26
|
-
@Roles('admin')
|
|
27
|
-
async deleteUser(@Param('id') id: string) {
|
|
28
|
-
// Verify user can access this resource
|
|
29
|
-
return this.usersService.delete(id);
|
|
30
|
-
}
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
#### 2. Cryptographic Failures
|
|
34
|
-
**Risk:** Sensitive data exposure, weak encryption
|
|
35
|
-
|
|
36
|
-
**Mitigation:**
|
|
37
|
-
- Use Argon2id for password hashing (replaces bcrypt as of 2025)
|
|
38
|
-
- TLS 1.3 for data in transit
|
|
39
|
-
- Encrypt sensitive data at rest (AES-256)
|
|
40
|
-
- Use crypto.randomBytes() for tokens, not Math.random()
|
|
41
|
-
- Never store passwords in plain text
|
|
42
|
-
|
|
43
|
-
```python
|
|
44
|
-
# Good: Argon2id password hashing
|
|
45
|
-
from argon2 import PasswordHasher
|
|
46
|
-
|
|
47
|
-
ph = PasswordHasher()
|
|
48
|
-
hash = ph.hash("password123") # Auto-salted, memory-hard
|
|
49
|
-
ph.verify(hash, "password123") # Verify password
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
#### 3. Injection Attacks
|
|
53
|
-
**Risk:** SQL injection, NoSQL injection, command injection (6x increase 2020-2024)
|
|
54
|
-
|
|
55
|
-
**Mitigation:** Parameterized queries prevent SQL injection.
|
|
56
|
-
- Use parameterized queries ALWAYS
|
|
57
|
-
- Input validation with allow-lists
|
|
58
|
-
- Escape special characters
|
|
59
|
-
- Use ORMs properly (avoid raw queries)
|
|
60
|
-
|
|
61
|
-
```typescript
|
|
62
|
-
// Bad: Vulnerable to SQL injection
|
|
63
|
-
const query = `SELECT * FROM users WHERE email = '${email}'`;
|
|
64
|
-
|
|
65
|
-
// Good: Parameterized query
|
|
66
|
-
const query = 'SELECT * FROM users WHERE email = $1';
|
|
67
|
-
const result = await db.query(query, [email]);
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
#### 4. Insecure Design
|
|
71
|
-
**Risk:** Flawed architecture, missing security controls
|
|
72
|
-
|
|
73
|
-
**Mitigation:**
|
|
74
|
-
- Threat modeling during design phase
|
|
75
|
-
- Security requirements from start
|
|
76
|
-
- Principle of least privilege
|
|
77
|
-
- Defense in depth (multiple security layers)
|
|
78
|
-
|
|
79
|
-
#### 5. Security Misconfiguration
|
|
80
|
-
**Risk:** Default credentials, verbose errors, unnecessary features enabled
|
|
81
|
-
|
|
82
|
-
**Mitigation:**
|
|
83
|
-
- Remove default accounts
|
|
84
|
-
- Disable directory listing
|
|
85
|
-
- Use security headers (CSP, HSTS, X-Frame-Options)
|
|
86
|
-
- Minimize attack surface
|
|
87
|
-
- Regular security audits
|
|
88
|
-
|
|
89
|
-
```typescript
|
|
90
|
-
// Security headers middleware
|
|
91
|
-
app.use(helmet({
|
|
92
|
-
contentSecurityPolicy: {
|
|
93
|
-
directives: {
|
|
94
|
-
defaultSrc: ["'self'"],
|
|
95
|
-
scriptSrc: ["'self'", "'unsafe-inline'"],
|
|
96
|
-
},
|
|
97
|
-
},
|
|
98
|
-
hsts: {
|
|
99
|
-
maxAge: 31536000,
|
|
100
|
-
includeSubDomains: true,
|
|
101
|
-
},
|
|
102
|
-
}));
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
#### 6. Vulnerable Components
|
|
106
|
-
**Risk:** Outdated dependencies with known vulnerabilities
|
|
107
|
-
|
|
108
|
-
**Mitigation:**
|
|
109
|
-
- Regular dependency updates (npm audit, pip-audit)
|
|
110
|
-
- Use Dependabot/Renovate for automated updates
|
|
111
|
-
- Monitor CVE databases
|
|
112
|
-
- Software composition analysis (SCA) in CI/CD
|
|
113
|
-
- Lock file integrity checks
|
|
114
|
-
|
|
115
|
-
```bash
|
|
116
|
-
# Check for vulnerabilities
|
|
117
|
-
npm audit fix
|
|
118
|
-
pip-audit --fix
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
#### 7. Authentication Failures
|
|
122
|
-
**Risk:** Weak passwords, session hijacking, credential stuffing
|
|
123
|
-
|
|
124
|
-
**Mitigation:**
|
|
125
|
-
- MFA mandatory for admin accounts
|
|
126
|
-
- Rate limiting on login endpoints (10 attempts/minute)
|
|
127
|
-
- Strong password policies (12+ chars, complexity)
|
|
128
|
-
- Session timeout (15 mins idle, 8 hours absolute)
|
|
129
|
-
- FIDO2/WebAuthn for passwordless auth
|
|
130
|
-
|
|
131
|
-
#### 8. Software & Data Integrity Failures
|
|
132
|
-
**Risk:** CI/CD pipeline compromise, unsigned updates
|
|
133
|
-
|
|
134
|
-
**Mitigation:**
|
|
135
|
-
- Code signing for releases
|
|
136
|
-
- Verify integrity of packages (lock files)
|
|
137
|
-
- Secure CI/CD pipelines (immutable builds)
|
|
138
|
-
- Checksum verification
|
|
139
|
-
|
|
140
|
-
#### 9. Logging & Monitoring Failures
|
|
141
|
-
**Risk:** Breaches undetected, insufficient audit trail
|
|
142
|
-
|
|
143
|
-
**Mitigation:**
|
|
144
|
-
- Log authentication events (success/failure)
|
|
145
|
-
- Log access control failures
|
|
146
|
-
- Centralized logging (ELK Stack, Splunk)
|
|
147
|
-
- Alerting on suspicious patterns
|
|
148
|
-
- Log rotation and retention policies
|
|
149
|
-
|
|
150
|
-
#### 10. Server-Side Request Forgery (SSRF)
|
|
151
|
-
**Risk:** Server makes malicious requests to internal resources
|
|
152
|
-
|
|
153
|
-
**Mitigation:**
|
|
154
|
-
- Validate and sanitize URLs
|
|
155
|
-
- Allow-list for remote resources
|
|
156
|
-
- Network segmentation
|
|
157
|
-
- Disable unnecessary protocols (file://, gopher://)
|
|
158
|
-
|
|
159
|
-
## Input Validation (Prevents Vulnerabilities)
|
|
160
|
-
|
|
161
|
-
### Validation Strategies
|
|
162
|
-
|
|
163
|
-
**1. Type Validation**
|
|
164
|
-
```typescript
|
|
165
|
-
// Use class-validator with NestJS
|
|
166
|
-
class CreateUserDto {
|
|
167
|
-
@IsEmail()
|
|
168
|
-
email: string;
|
|
169
|
-
|
|
170
|
-
@IsString()
|
|
171
|
-
@MinLength(12)
|
|
172
|
-
@Matches(/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)/)
|
|
173
|
-
password: string;
|
|
174
|
-
|
|
175
|
-
@IsInt()
|
|
176
|
-
@Min(18)
|
|
177
|
-
age: number;
|
|
178
|
-
}
|
|
179
|
-
```
|
|
180
|
-
|
|
181
|
-
**2. Sanitization**
|
|
182
|
-
```typescript
|
|
183
|
-
import DOMPurify from 'isomorphic-dompurify';
|
|
184
|
-
|
|
185
|
-
// Sanitize HTML input
|
|
186
|
-
const clean = DOMPurify.sanitize(userInput);
|
|
187
|
-
```
|
|
188
|
-
|
|
189
|
-
**3. Allow-lists (Preferred over Deny-lists)**
|
|
190
|
-
```typescript
|
|
191
|
-
// Good: Allow-list approach
|
|
192
|
-
const allowedFields = ['name', 'email', 'age'];
|
|
193
|
-
const sanitized = Object.keys(input)
|
|
194
|
-
.filter(key => allowedFields.includes(key))
|
|
195
|
-
.reduce((obj, key) => ({ ...obj, [key]: input[key] }), {});
|
|
196
|
-
```
|
|
197
|
-
|
|
198
|
-
## Rate Limiting
|
|
199
|
-
|
|
200
|
-
### Token Bucket Algorithm (Industry Standard)
|
|
201
|
-
|
|
202
|
-
```typescript
|
|
203
|
-
import rateLimit from 'express-rate-limit';
|
|
204
|
-
|
|
205
|
-
const limiter = rateLimit({
|
|
206
|
-
windowMs: 15 * 60 * 1000, // 15 minutes
|
|
207
|
-
max: 100, // 100 requests per window
|
|
208
|
-
standardHeaders: true,
|
|
209
|
-
legacyHeaders: false,
|
|
210
|
-
message: 'Too many requests, please try again later',
|
|
211
|
-
});
|
|
212
|
-
|
|
213
|
-
app.use('/api/', limiter);
|
|
214
|
-
```
|
|
215
|
-
|
|
216
|
-
### API-Specific Limits
|
|
217
|
-
|
|
218
|
-
- **Authentication:** 10 attempts/15 min
|
|
219
|
-
- **Public APIs:** 100 requests/15 min
|
|
220
|
-
- **Authenticated APIs:** 1000 requests/15 min
|
|
221
|
-
- **Admin endpoints:** 50 requests/15 min
|
|
222
|
-
|
|
223
|
-
## Security Headers
|
|
224
|
-
|
|
225
|
-
```typescript
|
|
226
|
-
// Essential security headers (2025)
|
|
227
|
-
{
|
|
228
|
-
'Strict-Transport-Security': 'max-age=31536000; includeSubDomains',
|
|
229
|
-
'Content-Security-Policy': "default-src 'self'",
|
|
230
|
-
'X-Frame-Options': 'DENY',
|
|
231
|
-
'X-Content-Type-Options': 'nosniff',
|
|
232
|
-
'Referrer-Policy': 'strict-origin-when-cross-origin',
|
|
233
|
-
'Permissions-Policy': 'geolocation=(), microphone=()',
|
|
234
|
-
}
|
|
235
|
-
```
|
|
236
|
-
|
|
237
|
-
## Secrets Management
|
|
238
|
-
|
|
239
|
-
### Best Practices
|
|
240
|
-
|
|
241
|
-
1. **Never commit secrets** - Use .env files (gitignored)
|
|
242
|
-
2. **Environment-specific** - Different secrets per environment
|
|
243
|
-
3. **Rotation policy** - Rotate secrets every 90 days
|
|
244
|
-
4. **Encryption at rest** - Encrypt secrets in secret managers
|
|
245
|
-
5. **Least privilege** - Minimal permissions per secret
|
|
246
|
-
|
|
247
|
-
### Tools
|
|
248
|
-
|
|
249
|
-
- **HashiCorp Vault** - Multi-cloud, dynamic secrets
|
|
250
|
-
- **AWS Secrets Manager** - Managed service, auto-rotation
|
|
251
|
-
- **Azure Key Vault** - Integrated with Azure services
|
|
252
|
-
- **Pulumi ESC** - Unified secrets orchestration (2025 trend)
|
|
253
|
-
|
|
254
|
-
```typescript
|
|
255
|
-
// Good: Secrets from environment
|
|
256
|
-
const dbPassword = process.env.DB_PASSWORD;
|
|
257
|
-
if (!dbPassword) throw new Error('DB_PASSWORD not set');
|
|
258
|
-
```
|
|
259
|
-
|
|
260
|
-
## Critical Security Invariants (apply only when the task touches these surfaces)
|
|
261
|
-
|
|
262
|
-
These invariants are lane-aware: enforce them for Critical tasks that touch the
|
|
263
|
-
named surface; for Direct/Standard tasks that happen to touch it, apply the same
|
|
264
|
-
checks with proportional evidence (targeted unit test + diff self-check for Direct,
|
|
265
|
-
bounded suite for Standard). Do not impose a fixed heavy ceremony on every task.
|
|
266
|
-
|
|
267
|
-
### Logging & Secret Redaction
|
|
268
|
-
|
|
269
|
-
- Match secret names by exact token boundaries, not broad substrings. Never redact
|
|
270
|
-
by substring inside safe identifiers — e.g. names ending in `_file`, `_path`,
|
|
271
|
-
`_hint`, `_label` or containing `tokenizer` must stay intact. Preserve the
|
|
272
|
-
field/key name, replace only the value with `[REDACTED]` (use `[REDACTED-PEM]`
|
|
273
|
-
for PEM blocks, keeping the surrounding structure).
|
|
274
|
-
- Leave public URLs and credential-free strings untouched. URL redaction applies
|
|
275
|
-
only when a credential is present in the URL (e.g. `user:pass@host`).
|
|
276
|
-
- Authorization redaction is quote-aware and delimiter-safe: match schemes
|
|
277
|
-
`Bearer`/`Basic` case-insensitively, redact only the credential that follows,
|
|
278
|
-
preserve surrounding quotes and trailing delimiters (`,`, `;`, whitespace) outside
|
|
279
|
-
the redacted value, and never drop the closing quote.
|
|
280
|
-
- Idempotence: `redact(redact(x)) === redact(x)`. The markers `[REDACTED]` /
|
|
281
|
-
`[REDACTED-PEM]` are stable and not re-wrapped or corrupted.
|
|
282
|
-
- Verification guidance: cover true-positive credential cases, false-positive
|
|
283
|
-
safe-identifier and public-URL cases, quoted `Bearer`/`Basic` with trailing
|
|
284
|
-
delimiters, multi-line/PEM cases when relevant, and an idempotence round-trip.
|
|
285
|
-
Assert that no secret appears in error messages or completion reports and that
|
|
286
|
-
safe values are byte-identical after redaction.
|
|
287
|
-
|
|
288
|
-
### Filesystem Write Boundary
|
|
289
|
-
|
|
290
|
-
- Require an existing real directory as root. Reject before any mutation when
|
|
291
|
-
`targetPath` is empty or whitespace-only, contains a URI scheme, is absolute,
|
|
292
|
-
escapes via `..` segments, or escapes via sibling-prefix (`root` vs
|
|
293
|
-
`root-evil`).
|
|
294
|
-
- Containment needs two checks: lexical containment of the resolved path
|
|
295
|
-
(`path.resolve(root, target)` inside root) **and** `realpath` containment of
|
|
296
|
-
the deepest existing parent directory. This blocks symlink-pointing-outside
|
|
297
|
-
and traversal that lexical check alone would miss. Never follow or overwrite a
|
|
298
|
-
symlink at the final target; never create parent directories outside root.
|
|
299
|
-
- Perform atomic same-directory write: create a temporary file in the target
|
|
300
|
-
directory, write fully, then `rename` into place. Remove the temp file on any
|
|
301
|
-
error. Rejections must happen before creating or modifying anything outside root.
|
|
302
|
-
- Return the canonical `realpath` of the target on success (e.g. macOS
|
|
303
|
-
`/var` → `/private/var` alias must resolve). Keep the public API otherwise
|
|
304
|
-
unchanged.
|
|
305
|
-
- Verification guidance: nested success, traversal / absolute / URI / sibling-prefix
|
|
306
|
-
rejection, parent-symlink rejection, final-symlink rejection (do not follow or
|
|
307
|
-
overwrite), no-outside-mutation assertion (filesystem outside root unchanged on
|
|
308
|
-
failure), atomic temp cleanup, and canonical return-path equality. Critical runs
|
|
309
|
-
the full project suite; Direct/Standard use proportional lane evidence (targeted
|
|
310
|
-
unit test + diff self-check for Direct, bounded suite for Standard).
|
|
311
|
-
|
|
312
|
-
## API Security Checklist
|
|
313
|
-
|
|
314
|
-
- [ ] Use HTTPS/TLS 1.3 only
|
|
315
|
-
- [ ] Implement OAuth 2.1 + JWT for authentication
|
|
316
|
-
- [ ] Rate limiting on all endpoints
|
|
317
|
-
- [ ] Input validation on all inputs
|
|
318
|
-
- [ ] Parameterized queries (prevent SQL injection)
|
|
319
|
-
- [ ] Security headers configured
|
|
320
|
-
- [ ] CORS properly configured (not `*` in production)
|
|
321
|
-
- [ ] API versioning implemented
|
|
322
|
-
- [ ] Error messages don't leak system info
|
|
323
|
-
- [ ] Logging authentication events
|
|
324
|
-
- [ ] MFA for admin accounts
|
|
325
|
-
- [ ] Regular security audits (quarterly)
|
|
326
|
-
|
|
327
|
-
## Common Security Pitfalls
|
|
328
|
-
|
|
329
|
-
1. **Client-side validation only** - Always validate on server
|
|
330
|
-
2. **Using Math.random() for tokens** - Use crypto.randomBytes()
|
|
331
|
-
3. **Storing passwords with bcrypt** - Use Argon2id (2025 standard)
|
|
332
|
-
4. **Trusting user input** - Validate and sanitize everything
|
|
333
|
-
5. **Weak CORS configuration** - Don't use `*` in production
|
|
334
|
-
6. **Insufficient logging** - Log all authentication/authorization events
|
|
335
|
-
7. **No rate limiting** - Implement on all public endpoints
|
|
336
|
-
|
|
337
|
-
## Resources
|
|
338
|
-
|
|
339
|
-
- **OWASP Top 10 (2025):** https://owasp.org/www-project-top-ten/
|
|
340
|
-
- **OWASP Cheat Sheets:** https://cheatsheetseries.owasp.org/
|
|
341
|
-
- **CWE Top 25:** https://cwe.mitre.org/top25/
|
|
342
|
-
- **NIST Guidelines:** https://www.nist.gov/cybersecurity
|
|
@@ -1,256 +0,0 @@
|
|
|
1
|
-
# Backend Technologies
|
|
2
|
-
|
|
3
|
-
Core technologies, frameworks, databases, and message queues for modern backend development (2025).
|
|
4
|
-
|
|
5
|
-
## Programming Languages
|
|
6
|
-
|
|
7
|
-
### Node.js/TypeScript
|
|
8
|
-
**Market Position:** TypeScript dominance in Node.js backend (industry standard)
|
|
9
|
-
|
|
10
|
-
**Best For:**
|
|
11
|
-
- Full-stack JavaScript teams
|
|
12
|
-
- Real-time applications (WebSockets, Socket.io)
|
|
13
|
-
- Rapid prototyping with npm ecosystem (2M+ packages)
|
|
14
|
-
- Event-driven architectures
|
|
15
|
-
|
|
16
|
-
**Popular Frameworks:**
|
|
17
|
-
- **NestJS** - Enterprise-grade, TypeScript-first, modular architecture
|
|
18
|
-
- **Express** - Lightweight, flexible, most popular (23M weekly downloads)
|
|
19
|
-
- **Fastify** - High performance (20k req/sec vs Express 15k req/sec)
|
|
20
|
-
- **tRPC** - End-to-end typesafe APIs without GraphQL
|
|
21
|
-
|
|
22
|
-
**When to Choose:** Team already using JavaScript/TypeScript, real-time features needed, rapid development priority
|
|
23
|
-
|
|
24
|
-
### Python
|
|
25
|
-
**Market Position:** FastAPI adoption is increasing among Flask users
|
|
26
|
-
|
|
27
|
-
**Best For:**
|
|
28
|
-
- Data-heavy applications
|
|
29
|
-
- ML/AI integration (TensorFlow, PyTorch)
|
|
30
|
-
- Scientific computing
|
|
31
|
-
- Scripting and automation
|
|
32
|
-
|
|
33
|
-
**Popular Frameworks:**
|
|
34
|
-
- **FastAPI** - Modern, async, auto-generated OpenAPI docs, validation via Pydantic
|
|
35
|
-
- **Django** - Batteries-included, ORM, admin panel, authentication
|
|
36
|
-
- **Flask** - Lightweight, flexible, microservices-friendly
|
|
37
|
-
|
|
38
|
-
**When to Choose:** Data science integration, ML/AI features, rapid prototyping, team Python expertise
|
|
39
|
-
|
|
40
|
-
### Go
|
|
41
|
-
**Market Position:** Preferred for microservices at scale (Docker, Kubernetes written in Go)
|
|
42
|
-
|
|
43
|
-
**Best For:**
|
|
44
|
-
- High-concurrency systems (goroutines)
|
|
45
|
-
- Microservices architectures
|
|
46
|
-
- CLI tools and DevOps tooling
|
|
47
|
-
- System programming
|
|
48
|
-
|
|
49
|
-
**Popular Frameworks:**
|
|
50
|
-
- **Gin** - Fast HTTP router (40x faster than Martini)
|
|
51
|
-
- **Echo** - High performance, extensible
|
|
52
|
-
- **Fiber** - Express-like API, built on Fasthttp
|
|
53
|
-
|
|
54
|
-
**When to Choose:** Microservices, high concurrency needs, DevOps tooling, simple deployment (single binary)
|
|
55
|
-
|
|
56
|
-
### Rust
|
|
57
|
-
**Market Position:** Highly admired language, faster than Go
|
|
58
|
-
|
|
59
|
-
**Best For:**
|
|
60
|
-
- Performance-critical systems
|
|
61
|
-
- Memory-safe system programming
|
|
62
|
-
- High-reliability requirements
|
|
63
|
-
- WebAssembly backends
|
|
64
|
-
|
|
65
|
-
**Popular Frameworks:**
|
|
66
|
-
- **Axum** - Ergonomic, modular, tokio-based
|
|
67
|
-
- **Actix-web** - Fastest web framework (benchmark leader)
|
|
68
|
-
- **Rocket** - Type-safe, easy to use
|
|
69
|
-
|
|
70
|
-
**When to Choose:** Maximum performance needed, memory safety critical, low-level control required
|
|
71
|
-
|
|
72
|
-
## Databases
|
|
73
|
-
|
|
74
|
-
### Relational (SQL)
|
|
75
|
-
|
|
76
|
-
#### PostgreSQL
|
|
77
|
-
**Market Position:** Most popular SQL database for new projects
|
|
78
|
-
|
|
79
|
-
**Strengths:**
|
|
80
|
-
- ACID compliance, data integrity
|
|
81
|
-
- JSON/JSONB support (hybrid SQL + NoSQL)
|
|
82
|
-
- Full-text search, geospatial (PostGIS)
|
|
83
|
-
- Advanced indexing (B-tree, Hash, GiST, GIN)
|
|
84
|
-
- Window functions, CTEs, materialized views
|
|
85
|
-
|
|
86
|
-
**Use Cases:**
|
|
87
|
-
- E-commerce (transactions critical)
|
|
88
|
-
- Financial applications
|
|
89
|
-
- Complex reporting requirements
|
|
90
|
-
- Multi-tenant applications
|
|
91
|
-
|
|
92
|
-
**When to Choose:** Need ACID guarantees, complex queries/joins, data integrity critical
|
|
93
|
-
|
|
94
|
-
### NoSQL
|
|
95
|
-
|
|
96
|
-
#### MongoDB
|
|
97
|
-
**Market Position:** Leading document database
|
|
98
|
-
|
|
99
|
-
**Strengths:**
|
|
100
|
-
- Flexible/evolving schemas
|
|
101
|
-
- Horizontal scaling (sharding built-in)
|
|
102
|
-
- Aggregation pipeline (powerful data processing)
|
|
103
|
-
- GridFS for large files
|
|
104
|
-
|
|
105
|
-
**Use Cases:**
|
|
106
|
-
- Content management systems
|
|
107
|
-
- Real-time analytics
|
|
108
|
-
- IoT data collection
|
|
109
|
-
- Catalogs with varied attributes
|
|
110
|
-
|
|
111
|
-
**When to Choose:** Schema flexibility needed, rapid iteration, horizontal scaling required
|
|
112
|
-
|
|
113
|
-
### Caching & In-Memory
|
|
114
|
-
|
|
115
|
-
#### Redis
|
|
116
|
-
**Market Position:** Industry standard for caching and session storage
|
|
117
|
-
|
|
118
|
-
**Capabilities:**
|
|
119
|
-
- In-memory key-value store
|
|
120
|
-
- Pub/sub messaging
|
|
121
|
-
- Sorted sets (leaderboards)
|
|
122
|
-
- Geospatial indexes
|
|
123
|
-
- Streams (event sourcing)
|
|
124
|
-
|
|
125
|
-
**Performance:** 10-100x faster than disk-based databases
|
|
126
|
-
|
|
127
|
-
**Use Cases:**
|
|
128
|
-
- Session storage
|
|
129
|
-
- Rate limiting
|
|
130
|
-
- Real-time leaderboards
|
|
131
|
-
- Job queues (Bull, BullMQ)
|
|
132
|
-
- Caching layer (reduces DB load)
|
|
133
|
-
|
|
134
|
-
**When to Choose:** Need sub-millisecond latency, caching layer, session management
|
|
135
|
-
|
|
136
|
-
## ORMs & Database Tools
|
|
137
|
-
|
|
138
|
-
### Modern ORMs (2025)
|
|
139
|
-
|
|
140
|
-
**Drizzle ORM** (TypeScript)
|
|
141
|
-
- Winning NestJS performance race
|
|
142
|
-
- 7.4kb, zero dependencies
|
|
143
|
-
- SQL-like syntax, full type safety
|
|
144
|
-
- Best for: Performance-critical TypeScript apps
|
|
145
|
-
|
|
146
|
-
**Prisma** (TypeScript)
|
|
147
|
-
- Auto-generated type-safe client
|
|
148
|
-
- Database migrations included
|
|
149
|
-
- Excellent DX with Prisma Studio
|
|
150
|
-
- Best for: Rapid development, type safety
|
|
151
|
-
|
|
152
|
-
**TypeORM** (TypeScript)
|
|
153
|
-
- Mature, feature-complete
|
|
154
|
-
- Supports Active Record + Data Mapper
|
|
155
|
-
- Best for: Complex enterprise apps
|
|
156
|
-
|
|
157
|
-
**SQLAlchemy** (Python)
|
|
158
|
-
- Industry standard Python ORM
|
|
159
|
-
- Powerful query builder
|
|
160
|
-
- Best for: Python backends
|
|
161
|
-
|
|
162
|
-
## Message Queues & Event Streaming
|
|
163
|
-
|
|
164
|
-
### RabbitMQ
|
|
165
|
-
**Best For:** Task queues, request/reply patterns
|
|
166
|
-
|
|
167
|
-
**Strengths:**
|
|
168
|
-
- Flexible routing (direct, topic, fanout, headers)
|
|
169
|
-
- Message acknowledgment and durability
|
|
170
|
-
- Dead letter exchanges
|
|
171
|
-
- Wide protocol support (AMQP, MQTT, STOMP)
|
|
172
|
-
|
|
173
|
-
**Use Cases:**
|
|
174
|
-
- Background job processing
|
|
175
|
-
- Microservices communication
|
|
176
|
-
- Email/notification queues
|
|
177
|
-
|
|
178
|
-
**When to Choose:** Traditional message queue needs, complex routing, moderate throughput
|
|
179
|
-
|
|
180
|
-
### Apache Kafka
|
|
181
|
-
**Best For:** Event streaming, millions messages/second
|
|
182
|
-
|
|
183
|
-
**Strengths:**
|
|
184
|
-
- Distributed, fault-tolerant
|
|
185
|
-
- High throughput (millions msg/sec)
|
|
186
|
-
- Message replay (retention-based)
|
|
187
|
-
- Stream processing (Kafka Streams)
|
|
188
|
-
|
|
189
|
-
**Use Cases:**
|
|
190
|
-
- Real-time analytics
|
|
191
|
-
- Event sourcing
|
|
192
|
-
- Log aggregation
|
|
193
|
-
- Netflix/Uber scale (billions events/day)
|
|
194
|
-
|
|
195
|
-
**When to Choose:** Event streaming, high throughput, event replay needed, real-time analytics
|
|
196
|
-
|
|
197
|
-
## Framework Comparisons
|
|
198
|
-
|
|
199
|
-
### Node.js Frameworks
|
|
200
|
-
|
|
201
|
-
| Framework | Performance | Learning Curve | Use Case |
|
|
202
|
-
|-----------|------------|----------------|----------|
|
|
203
|
-
| Express | Moderate | Easy | Simple APIs, learning |
|
|
204
|
-
| NestJS | Moderate | Steep | Enterprise apps |
|
|
205
|
-
| Fastify | High | Moderate | Performance-critical |
|
|
206
|
-
| tRPC | High | Moderate | Full-stack TypeScript |
|
|
207
|
-
|
|
208
|
-
### Python Frameworks
|
|
209
|
-
|
|
210
|
-
| Framework | Performance | Features | Use Case |
|
|
211
|
-
|-----------|------------|----------|----------|
|
|
212
|
-
| FastAPI | High | Modern, async | New projects, APIs |
|
|
213
|
-
| Django | Moderate | Batteries-included | Full-featured apps |
|
|
214
|
-
| Flask | Moderate | Minimal | Microservices, simple APIs |
|
|
215
|
-
|
|
216
|
-
## Technology Selection Flowchart
|
|
217
|
-
|
|
218
|
-
```
|
|
219
|
-
Start → Need real-time features?
|
|
220
|
-
→ Yes → Node.js + Socket.io
|
|
221
|
-
→ No → Need ML/AI integration?
|
|
222
|
-
→ Yes → Python + FastAPI
|
|
223
|
-
→ No → Need maximum performance?
|
|
224
|
-
→ Yes → Rust + Axum
|
|
225
|
-
→ No → Need high concurrency?
|
|
226
|
-
→ Yes → Go + Gin
|
|
227
|
-
→ No → Node.js + NestJS (safe default)
|
|
228
|
-
|
|
229
|
-
Database Selection:
|
|
230
|
-
ACID needed? → Yes → PostgreSQL
|
|
231
|
-
→ No → Flexible schema? → Yes → MongoDB
|
|
232
|
-
→ No → PostgreSQL (default)
|
|
233
|
-
|
|
234
|
-
Caching needed? → Always use Redis
|
|
235
|
-
|
|
236
|
-
Message Queue:
|
|
237
|
-
Millions msg/sec? → Yes → Kafka
|
|
238
|
-
→ No → RabbitMQ
|
|
239
|
-
```
|
|
240
|
-
|
|
241
|
-
## Common Pitfalls
|
|
242
|
-
|
|
243
|
-
1. **Choosing NoSQL for relational data** - Use PostgreSQL if data has clear relationships
|
|
244
|
-
2. **Not using connection pooling** - Implement pooling for 5-10x performance boost
|
|
245
|
-
3. **Ignoring indexes** - Add indexes to frequently queried columns (reduces I/O)
|
|
246
|
-
4. **Over-engineering with microservices** - Start monolith, split when needed
|
|
247
|
-
5. **Not caching** - Redis caching reduces DB load
|
|
248
|
-
|
|
249
|
-
## Resources
|
|
250
|
-
|
|
251
|
-
- **NestJS:** https://nestjs.com
|
|
252
|
-
- **FastAPI:** https://fastapi.tiangolo.com
|
|
253
|
-
- **PostgreSQL:** https://www.postgresql.org/docs/
|
|
254
|
-
- **MongoDB:** https://www.mongodb.com/docs/
|
|
255
|
-
- **Redis:** https://redis.io/docs/
|
|
256
|
-
- **Kafka:** https://kafka.apache.org/documentation/
|