aiwf 0.3.1 → 0.3.2
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/.aiwf/.claude/commands/aiwf/aiwf_compress_aggressive_persona.md +53 -0
- package/.aiwf/.claude/commands/aiwf/aiwf_compress_minimal_persona.md +48 -0
- package/.aiwf/.claude/commands/aiwf/aiwf_compress_stats.md +79 -0
- package/.aiwf/.claude/commands/aiwf/aiwf_compress_with_persona.md +51 -0
- package/.aiwf/.claude/commands/aiwf/aiwf_evaluate.md +92 -0
- package/.aiwf/00_PROJECT_MANIFEST.md +183 -0
- package/.aiwf/01_PROJECT_DOCS/ARCHITECTURE.md +121 -0
- package/.aiwf/01_PROJECT_DOCS/FEATURE_LEDGER_ADVANCED_USE_CASES.md +412 -0
- package/.aiwf/01_PROJECT_DOCS/FEATURE_LEDGER_API_REFERENCE.md +361 -0
- package/.aiwf/01_PROJECT_DOCS/FEATURE_LEDGER_COMMANDS_GUIDE.md +254 -0
- package/.aiwf/01_PROJECT_DOCS/FEATURE_LEDGER_FAQ.md +365 -0
- package/.aiwf/01_PROJECT_DOCS/FEATURE_LEDGER_SYSTEM_OVERVIEW.md +305 -0
- package/.aiwf/01_PROJECT_DOCS/FEATURE_LEDGER_USER_GUIDE.md +416 -0
- package/.aiwf/01_PROJECT_DOCS/FEATURE_LEDGER_/354/213/234/354/236/221_/352/260/200/354/235/264/353/223/234.md +247 -0
- package/.aiwf/02_REQUIREMENTS/CLAUDE.md +78 -0
- package/.aiwf/02_REQUIREMENTS/M02_Context_Engineering_Enhancement/M02_milestone_meta.md +34 -0
- package/.aiwf/02_REQUIREMENTS/M02_Context_Engineering_Enhancement/PRD_Context_Engineering_Enhancement.md +108 -0
- package/.aiwf/02_REQUIREMENTS/M02_Context_Engineering_Enhancement/SPECS_AI_Persona_System.md +299 -0
- package/.aiwf/02_REQUIREMENTS/M02_Context_Engineering_Enhancement/SPECS_Feature_Ledger_System.md +330 -0
- package/.aiwf/02_REQUIREMENTS/M02_Context_Engineering_Enhancement/SPECS_Token_Optimization.md +833 -0
- package/.aiwf/03_SPRINTS/CLAUDE.md +83 -0
- package/.aiwf/03_SPRINTS/S01_M02_context_foundation/S01_M02_sprint_meta.md +95 -0
- package/.aiwf/03_SPRINTS/S01_M02_context_foundation/TX01_S01_Feature_Ledger_/353/215/260/354/235/264/355/204/260_/352/265/254/354/241/260_/354/204/244/352/263/204.md +111 -0
- package/.aiwf/03_SPRINTS/S01_M02_context_foundation/TX02_S01_Feature_Ledger_CLI_/353/252/205/353/240/271/354/226/264_/352/260/234/353/260/234.md +115 -0
- package/.aiwf/03_SPRINTS/S01_M02_context_foundation/TX03_S01_Git_/354/227/260/353/217/231_Feature_/354/266/224/354/240/201.md +141 -0
- package/.aiwf/03_SPRINTS/S01_M02_context_foundation/TX04_S01_Feature_Ledger_/353/254/270/354/204/234/355/231/224.md +114 -0
- package/.aiwf/03_SPRINTS/S01_M02_context_foundation/TX05_S01_AI_/355/216/230/353/245/264/354/206/214/353/202/230_/353/215/260/354/235/264/355/204/260_/352/265/254/354/241/260_/354/204/244/352/263/204.md +123 -0
- package/.aiwf/03_SPRINTS/S01_M02_context_foundation/TX06_S01_/355/216/230/353/245/264/354/206/214/353/202/230_/352/264/200/353/246/254_/353/252/205/353/240/271/354/226/264_/352/265/254/355/230/204.md +114 -0
- package/.aiwf/03_SPRINTS/S01_M02_context_foundation/TX07_S01_Context_/354/225/225/354/266/225_/354/225/204/355/202/244/355/205/215/354/262/230_/354/204/244/352/263/204.md +114 -0
- package/.aiwf/03_SPRINTS/S01_M02_context_foundation/TX08_S01_/355/206/240/355/201/260_/354/266/224/354/240/201_/354/213/234/354/212/244/355/205/234_/355/224/204/353/241/234/355/206/240/355/203/200/354/236/205.md +112 -0
- package/.aiwf/03_SPRINTS/S01_M02_context_foundation/TX09_S01_/354/225/225/354/266/225_/354/225/214/352/263/240/353/246/254/354/246/230_/355/224/204/353/241/234/355/206/240/355/203/200/354/236/205.md +118 -0
- package/.aiwf/03_SPRINTS/S01_M02_context_foundation/TX10_S01_update_docs_/353/252/205/353/240/271/354/226/264_/353/263/265/352/265/254.md +118 -0
- package/.aiwf/03_SPRINTS/S01_M02_context_foundation/TX11_S01_/355/206/265/355/225/251_/355/205/214/354/212/244/355/212/270_Suite_/352/265/254/354/266/225.md +128 -0
- package/.aiwf/03_SPRINTS/S01_M02_context_foundation/TX12_S01_/354/204/261/353/212/245_/354/265/234/354/240/201/355/231/224_/353/260/217_/353/254/270/354/204/234/355/231/224.md +122 -0
- package/.aiwf/03_SPRINTS/S02_M02_ai_enhancement/S02_M02_sprint_meta.md +107 -0
- package/.aiwf/03_SPRINTS/S02_M02_ai_enhancement/TX01_S02_AI_/355/216/230/353/245/264/354/206/214/353/202/230_/353/252/205/353/240/271/354/226/264_/352/265/254/355/230/204.md +129 -0
- package/.aiwf/03_SPRINTS/S02_M02_ai_enhancement/TX02_S02_/355/216/230/353/245/264/354/206/214/353/202/230_/354/273/250/355/205/215/354/212/244/355/212/270_/354/240/201/354/232/251_/354/213/234/354/212/244/355/205/234.md +152 -0
- package/.aiwf/03_SPRINTS/S02_M02_ai_enhancement/TX03_S02_Context_/354/225/225/354/266/225_/354/225/214/352/263/240/353/246/254/354/246/230_/352/265/254/355/230/204.md +186 -0
- package/.aiwf/03_SPRINTS/S02_M02_ai_enhancement/TX05_S02_S02_/355/206/265/355/225/251_/355/205/214/354/212/244/355/212/270_/353/260/217_/353/254/270/354/204/234/355/231/224.md +192 -0
- package/.aiwf/03_SPRINTS/S02_M02_ai_enhancement/TX4_S02_Feature_Git_/354/227/260/353/217/231_/353/260/217_/354/236/220/353/217/231/355/231/224.md +162 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/S03_FINAL_SPRINT_SUMMARY.md +137 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/S03_M02_sprint_meta.md +106 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/TX14_S03_M02_/353/247/210/354/235/274/354/212/244/355/206/244_/354/265/234/354/242/205_/352/262/200/354/246/235_/353/260/217_/353/254/270/354/204/234/355/231/224.md +214 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/TX15_S03_/352/270/260/353/263/270_/355/224/204/353/241/234/354/240/235/355/212/270_/355/205/234/355/224/214/353/246/277_/352/260/234/353/260/234.md +177 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/TX16_S03_/354/230/244/355/224/204/353/235/274/354/235/270_/355/205/234/355/224/214/353/246/277_/354/272/220/354/213/234_/354/213/234/354/212/244/355/205/234.md +206 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/TX_T13_S03_AI_/353/217/204/352/265/254_/355/206/265/355/225/251_/355/205/234/355/224/214/353/246/277_/352/260/234/353/260/234.md +151 -0
- package/.aiwf/04_GENERAL_TASKS/CLAUDE.md +96 -0
- package/.aiwf/04_GENERAL_TASKS/TX001_complete_english_translation.md +127 -0
- package/.aiwf/05_DOCUMENTATION/performance-report.md +33 -0
- package/.aiwf/06_FEATURE_LEDGERS/FEATURE_GIT_INTEGRATION.md +314 -0
- package/.aiwf/06_FEATURE_LEDGERS/FEATURE_INTEGRATION_GUIDE.md +227 -0
- package/.aiwf/06_FEATURE_LEDGERS/FEATURE_LEDGER_INDEX.md +23 -0
- package/.aiwf/06_FEATURE_LEDGERS/FEATURE_SCHEMA.md +205 -0
- package/.aiwf/06_FEATURE_LEDGERS/FEATURE_STATE_DIAGRAM.md +190 -0
- package/.aiwf/06_FEATURE_LEDGERS/active/FL001_user_authentication_system.md +47 -0
- package/.aiwf/06_FEATURE_LEDGERS/active/FL002_user_authentication_system.md +47 -0
- package/.aiwf/07_AI_PERSONAS/PERSONA_INDEX.md +57 -0
- package/.aiwf/07_AI_PERSONAS/architect/best_practices.md +104 -0
- package/.aiwf/07_AI_PERSONAS/architect/context_rules.md +46 -0
- package/.aiwf/07_AI_PERSONAS/architect/knowledge_base.md +235 -0
- package/.aiwf/07_AI_PERSONAS/backend/best_practices.md +363 -0
- package/.aiwf/07_AI_PERSONAS/backend/context_rules.md +61 -0
- package/.aiwf/07_AI_PERSONAS/backend/knowledge_base.md +623 -0
- package/.aiwf/07_AI_PERSONAS/data_analyst/best_practices.md +32 -0
- package/.aiwf/07_AI_PERSONAS/data_analyst/context_rules.md +43 -0
- package/.aiwf/07_AI_PERSONAS/data_analyst/knowledge_base.md +36 -0
- package/.aiwf/07_AI_PERSONAS/frontend/best_practices.md +31 -0
- package/.aiwf/07_AI_PERSONAS/frontend/context_rules.md +43 -0
- package/.aiwf/07_AI_PERSONAS/frontend/knowledge_base.md +32 -0
- package/.aiwf/07_AI_PERSONAS/security/best_practices.md +63 -0
- package/.aiwf/07_AI_PERSONAS/security/context_rules.md +53 -0
- package/.aiwf/07_AI_PERSONAS/security/knowledge_base.md +93 -0
- package/.aiwf/10_PERSONAS/active.json +1 -0
- package/.aiwf/10_PERSONAS/developer.md +37 -0
- package/.aiwf/10_STATE_OF_PROJECT/2025-07-09-07-20-solid-progress.md +144 -0
- package/.aiwf/98_PROMPTS/SAAS_DEVELOPMENT_GUIDE.md +302 -0
- package/.aiwf/98_PROMPTS/github_integration.md +130 -0
- package/.aiwf/98_PROMPTS/useful-prompts.md +31 -0
- package/.aiwf/98_PROMPTS/vibe-front-prompts.md +89 -0
- package/.aiwf/99_TEMPLATES/adr_template.md +49 -0
- package/.aiwf/99_TEMPLATES/feature_template.md +263 -0
- package/.aiwf/99_TEMPLATES/milestone_meta_template.md +25 -0
- package/.aiwf/99_TEMPLATES/project_manifest_template.md +39 -0
- package/.aiwf/99_TEMPLATES/sprint_meta_template.md +23 -0
- package/.aiwf/99_TEMPLATES/task_template.md +36 -0
- package/.aiwf/CLAUDE.md +76 -0
- package/.aiwf/ai-tools/README.md +105 -0
- package/.aiwf/ai-tools/augment/README.md +371 -0
- package/.aiwf/ai-tools/augment/config.json +30 -0
- package/.aiwf/ai-tools/augment/template/.augment/aiwf-integration.md +387 -0
- package/.aiwf/ai-tools/augment/template/.augment/augment.yaml +347 -0
- package/.aiwf/ai-tools/augment/template/augment.config.json +64 -0
- package/.aiwf/ai-tools/claude-code/README.md +151 -0
- package/.aiwf/ai-tools/claude-code/config.json +28 -0
- package/.aiwf/ai-tools/claude-code/template/CLAUDE.md +91 -0
- package/.aiwf/ai-tools/cursor/README.md +314 -0
- package/.aiwf/ai-tools/cursor/config.json +29 -0
- package/.aiwf/ai-tools/cursor/template/.cursorrules +362 -0
- package/.aiwf/ai-tools/github-copilot/README.md +195 -0
- package/.aiwf/ai-tools/github-copilot/config.json +24 -0
- package/.aiwf/ai-tools/github-copilot/template/.github/copilot-instructions.md +202 -0
- package/.aiwf/ai-tools/windsurf/README.md +355 -0
- package/.aiwf/ai-tools/windsurf/config.json +29 -0
- package/.aiwf/ai-tools/windsurf/template/.windsurf/aiwf-rules.md +260 -0
- package/.aiwf/ai-tools/windsurf/template/.windsurf/windsurf.config.js +312 -0
- package/.aiwf/ai-tools/windsurf/template/windsurf.config.json +63 -0
- package/.aiwf/config/language.json +6 -0
- package/.aiwf/feature-ledger/FL-001-authentication.json +52 -0
- package/.aiwf/feature-ledger/feature-index.json +20 -0
- package/.aiwf/personas/analyst.json +44 -0
- package/.aiwf/personas/architect/best_practices.md +136 -0
- package/.aiwf/personas/architect/knowledge_base.md +377 -0
- package/.aiwf/personas/architect.json +44 -0
- package/.aiwf/personas/backend/best_practices.md +766 -0
- package/.aiwf/personas/backend/knowledge_base.md +1070 -0
- package/.aiwf/personas/data_analyst/best_practices.md +594 -0
- package/.aiwf/personas/data_analyst/knowledge_base.md +1057 -0
- package/.aiwf/personas/developer.json +44 -0
- package/.aiwf/personas/evaluation_criteria.json +137 -0
- package/.aiwf/personas/frontend/best_practices.md +445 -0
- package/.aiwf/personas/frontend/knowledge_base.md +729 -0
- package/.aiwf/personas/persona-index.json +31 -0
- package/.aiwf/personas/reviewer.json +44 -0
- package/.aiwf/personas/security/best_practices.md +307 -0
- package/.aiwf/personas/security/knowledge_base.md +498 -0
- package/.aiwf/personas/tester.json +44 -0
- package/.aiwf/scripts/cache-templates.js +209 -0
- package/.aiwf/scripts/create-offline.js +86 -0
- package/.aiwf/scripts/create-project.js +151 -0
- package/.aiwf/scripts/feature-progress-calculator.cjs +236 -0
- package/.aiwf/scripts/git-integration.cjs +391 -0
- package/.aiwf/scripts/install-git-hooks.cjs +226 -0
- package/.aiwf/scripts/test-commit-parsing.cjs +125 -0
- package/.aiwf/scripts/update-feature-status.cjs +198 -0
- package/.aiwf/templates/README.md +78 -0
- package/.aiwf/templates/api-server/config.json +64 -0
- package/.aiwf/templates/api-server/template/.aiwf/config.json +56 -0
- package/.aiwf/templates/api-server/template/.aiwf/feature-ledger.json +42 -0
- package/.aiwf/templates/api-server/template/.aiwf/personas/backend-engineer.json +40 -0
- package/.aiwf/templates/api-server/template/.aiwf/scripts/cli.js +111 -0
- package/.aiwf/templates/api-server/template/.env.example +29 -0
- package/.aiwf/templates/api-server/template/.eslintrc.json +23 -0
- package/.aiwf/templates/api-server/template/README.md +171 -0
- package/.aiwf/templates/api-server/template/jest.config.js +26 -0
- package/.aiwf/templates/api-server/template/nodemon.json +9 -0
- package/.aiwf/templates/api-server/template/package.json +61 -0
- package/.aiwf/templates/api-server/template/src/app.ts +60 -0
- package/.aiwf/templates/api-server/template/src/config/swagger.ts +38 -0
- package/.aiwf/templates/api-server/template/src/controllers/aiwfController.ts +68 -0
- package/.aiwf/templates/api-server/template/src/controllers/authController.ts +128 -0
- package/.aiwf/templates/api-server/template/src/controllers/statusController.ts +28 -0
- package/.aiwf/templates/api-server/template/src/index.ts +28 -0
- package/.aiwf/templates/api-server/template/src/middleware/aiwfMiddleware.ts +50 -0
- package/.aiwf/templates/api-server/template/src/middleware/authMiddleware.ts +41 -0
- package/.aiwf/templates/api-server/template/src/middleware/errorHandler.ts +42 -0
- package/.aiwf/templates/api-server/template/src/middleware/notFoundHandler.ts +14 -0
- package/.aiwf/templates/api-server/template/src/middleware/requestLogger.ts +20 -0
- package/.aiwf/templates/api-server/template/src/routes/aiwf.ts +42 -0
- package/.aiwf/templates/api-server/template/src/routes/index.ts +13 -0
- package/.aiwf/templates/api-server/template/src/routes/v1/index.ts +67 -0
- package/.aiwf/templates/api-server/template/src/utils/logger.ts +37 -0
- package/.aiwf/templates/api-server/template/tests/app.test.ts +40 -0
- package/.aiwf/templates/api-server/template/tsconfig.json +43 -0
- package/.aiwf/templates/npm-library/config.json +61 -0
- package/.aiwf/templates/npm-library/template/LICENSE +21 -0
- package/.aiwf/templates/npm-library/template/README.md +201 -0
- package/.aiwf/templates/npm-library/template/package.json +78 -0
- package/.aiwf/templates/web-app/config.json +53 -0
- package/.aiwf/templates/web-app/template/.aiwf/config.json +54 -0
- package/.aiwf/templates/web-app/template/.aiwf/feature-ledger.json +37 -0
- package/.aiwf/templates/web-app/template/.aiwf/personas/fullstack-developer.json +40 -0
- package/.aiwf/templates/web-app/template/.aiwf/scripts/cli.js +110 -0
- package/.aiwf/templates/web-app/template/.eslintrc.cjs +20 -0
- package/.aiwf/templates/web-app/template/README.md +151 -0
- package/.aiwf/templates/web-app/template/index.html +14 -0
- package/.aiwf/templates/web-app/template/package.json +44 -0
- package/.aiwf/templates/web-app/template/postcss.config.js +6 -0
- package/.aiwf/templates/web-app/template/public/vite.svg +1 -0
- package/.aiwf/templates/web-app/template/src/App.tsx +21 -0
- package/.aiwf/templates/web-app/template/src/components/Layout.tsx +57 -0
- package/.aiwf/templates/web-app/template/src/components/aiwf/ContextStatus.tsx +107 -0
- package/.aiwf/templates/web-app/template/src/components/aiwf/FeatureLedger.tsx +93 -0
- package/.aiwf/templates/web-app/template/src/components/aiwf/TokenUsage.tsx +71 -0
- package/.aiwf/templates/web-app/template/src/index.css +60 -0
- package/.aiwf/templates/web-app/template/src/main.tsx +10 -0
- package/.aiwf/templates/web-app/template/src/pages/AiwfDashboard.tsx +60 -0
- package/.aiwf/templates/web-app/template/src/pages/HomePage.tsx +89 -0
- package/.aiwf/templates/web-app/template/src/pages/NotFound.tsx +25 -0
- package/.aiwf/templates/web-app/template/src/stores/aiwfStore.ts +126 -0
- package/.aiwf/templates/web-app/template/src/types/global.d.ts +9 -0
- package/.aiwf/templates/web-app/template/src/vite-env.d.ts +1 -0
- package/.aiwf/templates/web-app/template/tailwind.config.js +30 -0
- package/.aiwf/templates/web-app/template/tsconfig.json +37 -0
- package/.aiwf/templates/web-app/template/tsconfig.node.json +10 -0
- package/.aiwf/templates/web-app/template/vite.config.ts +23 -0
- package/.aiwf/test-cache/86c7f9e80251abb8bedd58953ab0d1779e46b4f43ea33b63bffdb778106373b0.json +6 -0
- package/.aiwf/test-cache/9e252a90b80fce0585d7ed0646e7a9b4343e109f661f42a3ae678ba1ec5e22c7.json +7 -0
- package/.aiwf/test-results-s02.json +36 -0
- package/.aiwf/token-data/alerts.json +293 -0
- package/.aiwf/token-data/monitor-config.json +12 -0
- package/CHANGELOG.md +95 -11
- package/CHANGELOG_M02.md +52 -0
- package/CLAUDE.md +135 -0
- package/README.ko.md +5 -0
- package/README.md +6 -0
- package/RELEASE_NOTES_M02.md +177 -0
- package/claude-code/aiwf/en/.claude/commands/aiwf/aiwf_create_feature_ledger.md +54 -0
- package/claude-code/aiwf/en/.claude/commands/aiwf/aiwf_default_mode.md +66 -0
- package/claude-code/aiwf/en/.claude/commands/aiwf/aiwf_get_feature_details.md +78 -0
- package/claude-code/aiwf/en/.claude/commands/aiwf/aiwf_link_feature_to_milestone.md +57 -0
- package/claude-code/aiwf/en/.claude/commands/aiwf/aiwf_list_features.md +54 -0
- package/claude-code/aiwf/en/.claude/commands/aiwf/aiwf_persona_architect.md +60 -0
- package/claude-code/aiwf/en/.claude/commands/aiwf/aiwf_persona_backend.md +60 -0
- package/claude-code/aiwf/en/.claude/commands/aiwf/aiwf_persona_data_analyst.md +60 -0
- package/claude-code/aiwf/en/.claude/commands/aiwf/aiwf_persona_frontend.md +60 -0
- package/claude-code/aiwf/en/.claude/commands/aiwf/aiwf_persona_security.md +60 -0
- package/claude-code/aiwf/en/.claude/commands/aiwf/aiwf_persona_status.md +72 -0
- package/claude-code/aiwf/en/.claude/commands/aiwf/aiwf_update_feature_status.md +53 -0
- package/claude-code/aiwf/en/commands/ai-persona.js +667 -0
- package/claude-code/aiwf/en/commands/compress-context.js +355 -0
- package/claude-code/aiwf/en/commands/feature-ledger.js +565 -0
- package/claude-code/aiwf/en/commands/feature_commit_report.js +370 -0
- package/claude-code/aiwf/en/commands/scan_git_history.js +234 -0
- package/claude-code/aiwf/en/commands/sync_feature_commits.js +154 -0
- package/claude-code/aiwf/en/commands/token-tracking.js +443 -0
- package/claude-code/aiwf/en/config/commit-patterns.js +103 -0
- package/claude-code/aiwf/en/hooks/install-hooks.sh +100 -0
- package/claude-code/aiwf/en/hooks/post-commit +84 -0
- package/claude-code/aiwf/en/tests/compression-test-suite.js +1252 -0
- package/claude-code/aiwf/en/tests/test-git-integration.js +164 -0
- package/claude-code/aiwf/en/tests/token-tracking.test.js +537 -0
- package/claude-code/aiwf/en/utils/compression-metrics.js +1031 -0
- package/claude-code/aiwf/en/utils/compression-strategies.js +557 -0
- package/claude-code/aiwf/en/utils/content-normalizer.js +455 -0
- package/claude-code/aiwf/en/utils/context-compressor.js +583 -0
- package/claude-code/aiwf/en/utils/feature-updater.js +271 -0
- package/claude-code/aiwf/en/utils/git-utils.js +220 -0
- package/claude-code/aiwf/en/utils/importance-classifier.js +645 -0
- package/claude-code/aiwf/en/utils/information-filter.js +710 -0
- package/claude-code/aiwf/en/utils/text-summarizer.js +487 -0
- package/claude-code/aiwf/en/utils/token-counter.js +177 -0
- package/claude-code/aiwf/en/utils/token-monitor.js +484 -0
- package/claude-code/aiwf/en/utils/token-reporter.js +453 -0
- package/claude-code/aiwf/en/utils/token-storage.js +433 -0
- package/claude-code/aiwf/en/utils/token-tracker.js +283 -0
- package/claude-code/aiwf/ko/.aiwf/06_FEATURE_LEDGERS/FEATURE_ID_GENERATOR.md +138 -0
- package/claude-code/aiwf/ko/.aiwf/06_FEATURE_LEDGERS/FEATURE_INDEX.md +186 -0
- package/claude-code/aiwf/ko/.aiwf/06_FEATURE_LEDGERS/FEATURE_METADATA.md +240 -0
- package/claude-code/aiwf/ko/.aiwf/06_FEATURE_LEDGERS/FEATURE_WORKFLOW.md +183 -0
- package/claude-code/aiwf/ko/.aiwf/06_FEATURE_LEDGERS/README.md +94 -0
- package/claude-code/aiwf/ko/.aiwf/06_FEATURE_LEDGERS/active/FL001_/354/202/254/354/232/251/354/236/220_/354/235/270/354/246/235_/354/213/234/354/212/244/355/205/234.md +154 -0
- package/claude-code/aiwf/ko/.aiwf/06_FEATURE_LEDGERS/active/FL002_ai_/355/216/230/353/245/264/354/206/214/353/202/230_/354/213/234/354/212/244/355/205/234.md +272 -0
- package/claude-code/aiwf/ko/.aiwf/06_FEATURE_LEDGERS/completed/FL003_/353/213/244/352/265/255/354/226/264_/353/252/205/353/240/271/354/226/264_/355/221/234/354/244/200/355/231/224.md +266 -0
- package/claude-code/aiwf/ko/.aiwf/06_FEATURE_LEDGERS/schemas/feature_schema.json +122 -0
- package/claude-code/aiwf/ko/.aiwf/06_FEATURE_LEDGERS/schemas/feature_validator.cjs +406 -0
- package/claude-code/aiwf/ko/.claude/commands/aiwf/aiwf_compress_aggressive_persona.md +53 -0
- package/claude-code/aiwf/ko/.claude/commands/aiwf/aiwf_compress_context.md +116 -0
- package/claude-code/aiwf/ko/.claude/commands/aiwf/aiwf_compress_minimal_persona.md +48 -0
- package/claude-code/aiwf/ko/.claude/commands/aiwf/aiwf_compress_stats.md +79 -0
- package/claude-code/aiwf/ko/.claude/commands/aiwf/aiwf_compress_with_persona.md +51 -0
- package/claude-code/aiwf/ko/.claude/commands/aiwf/aiwf_create_feature_ledger.md +54 -0
- package/claude-code/aiwf/ko/.claude/commands/aiwf/aiwf_default_mode.md +44 -0
- package/claude-code/aiwf/ko/.claude/commands/aiwf/aiwf_evaluate.md +92 -0
- package/claude-code/aiwf/ko/.claude/commands/aiwf/aiwf_get_feature_details.md +78 -0
- package/claude-code/aiwf/ko/.claude/commands/aiwf/aiwf_link_feature_to_milestone.md +57 -0
- package/claude-code/aiwf/ko/.claude/commands/aiwf/aiwf_list_features.md +54 -0
- package/claude-code/aiwf/ko/.claude/commands/aiwf/aiwf_persona_architect.md +48 -0
- package/claude-code/aiwf/ko/.claude/commands/aiwf/aiwf_persona_backend.md +37 -0
- package/claude-code/aiwf/ko/.claude/commands/aiwf/aiwf_persona_data_analyst.md +37 -0
- package/claude-code/aiwf/ko/.claude/commands/aiwf/aiwf_persona_frontend.md +37 -0
- package/claude-code/aiwf/ko/.claude/commands/aiwf/aiwf_persona_security.md +48 -0
- package/claude-code/aiwf/ko/.claude/commands/aiwf/aiwf_persona_status.md +50 -0
- package/claude-code/aiwf/ko/.claude/commands/aiwf/aiwf_update_docs_kr.md +25 -0
- package/claude-code/aiwf/ko/.claude/commands/aiwf/aiwf_update_feature_status.md +53 -0
- package/claude-code/aiwf/ko/.claude/commands/aiwf/aiwf_yolo.md +2 -2
- package/claude-code/aiwf/ko/CLAUDE.md +76 -0
- package/claude-code/aiwf/ko/ai-tools/README.md +105 -0
- package/claude-code/aiwf/ko/ai-tools/augment/README.md +371 -0
- package/claude-code/aiwf/ko/ai-tools/augment/config.json +30 -0
- package/claude-code/aiwf/ko/ai-tools/augment/template/.augment/aiwf-integration.md +387 -0
- package/claude-code/aiwf/ko/ai-tools/augment/template/.augment/augment.yaml +347 -0
- package/claude-code/aiwf/ko/ai-tools/augment/template/augment.config.json +64 -0
- package/claude-code/aiwf/ko/ai-tools/claude-code/README.md +151 -0
- package/claude-code/aiwf/ko/ai-tools/claude-code/config.json +28 -0
- package/claude-code/aiwf/ko/ai-tools/claude-code/template/CLAUDE.md +91 -0
- package/claude-code/aiwf/ko/ai-tools/cursor/README.md +314 -0
- package/claude-code/aiwf/ko/ai-tools/cursor/config.json +29 -0
- package/claude-code/aiwf/ko/ai-tools/cursor/template/.cursorrules +362 -0
- package/claude-code/aiwf/ko/ai-tools/github-copilot/README.md +195 -0
- package/claude-code/aiwf/ko/ai-tools/github-copilot/config.json +24 -0
- package/claude-code/aiwf/ko/ai-tools/github-copilot/template/.github/copilot-instructions.md +202 -0
- package/claude-code/aiwf/ko/ai-tools/windsurf/README.md +355 -0
- package/claude-code/aiwf/ko/ai-tools/windsurf/config.json +29 -0
- package/claude-code/aiwf/ko/ai-tools/windsurf/template/.windsurf/aiwf-rules.md +260 -0
- package/claude-code/aiwf/ko/ai-tools/windsurf/template/.windsurf/windsurf.config.js +312 -0
- package/claude-code/aiwf/ko/ai-tools/windsurf/template/windsurf.config.json +63 -0
- package/claude-code/aiwf/ko/bin/aiwf-create.js +56 -0
- package/claude-code/aiwf/ko/bin/aiwf.js +21 -0
- package/claude-code/aiwf/ko/commands/ai-persona.js +602 -0
- package/claude-code/aiwf/ko/commands/compress-context.js +389 -0
- package/claude-code/aiwf/ko/commands/evaluate.js +246 -0
- package/claude-code/aiwf/ko/commands/feature-ledger.js +565 -0
- package/claude-code/aiwf/ko/commands/feature_commit_report.js +370 -0
- package/claude-code/aiwf/ko/commands/persona-context-apply.js +562 -0
- package/claude-code/aiwf/ko/commands/scan_git_history.js +234 -0
- package/claude-code/aiwf/ko/commands/sync_feature_commits.js +154 -0
- package/claude-code/aiwf/ko/commands/token-tracking.js +443 -0
- package/claude-code/aiwf/ko/config/commit-patterns.js +103 -0
- package/claude-code/aiwf/ko/config/language.json +6 -0
- package/claude-code/aiwf/ko/docs/00_PROJECT_MANIFEST.md +183 -0
- package/claude-code/aiwf/ko/docs/ARCHITECTURE.md +121 -0
- package/claude-code/aiwf/ko/docs/FEATURE_LEDGER_ADVANCED_USE_CASES.md +412 -0
- package/claude-code/aiwf/ko/docs/FEATURE_LEDGER_API_REFERENCE.md +361 -0
- package/claude-code/aiwf/ko/docs/FEATURE_LEDGER_COMMANDS_GUIDE.md +254 -0
- package/claude-code/aiwf/ko/docs/FEATURE_LEDGER_FAQ.md +365 -0
- package/claude-code/aiwf/ko/docs/FEATURE_LEDGER_SYSTEM_OVERVIEW.md +305 -0
- package/claude-code/aiwf/ko/docs/FEATURE_LEDGER_USER_GUIDE.md +416 -0
- package/claude-code/aiwf/ko/docs/FEATURE_LEDGER_/354/213/234/354/236/221_/352/260/200/354/235/264/353/223/234.md +247 -0
- package/claude-code/aiwf/ko/feature-ledger/FL-001-authentication.json +52 -0
- package/claude-code/aiwf/ko/feature-ledger/feature-index.json +20 -0
- package/claude-code/aiwf/ko/hooks/install-hooks.sh +100 -0
- package/claude-code/aiwf/ko/hooks/post-commit +84 -0
- package/claude-code/aiwf/ko/personas/PERSONA_INDEX.md +57 -0
- package/claude-code/aiwf/ko/personas/analyst.json +44 -0
- package/claude-code/aiwf/ko/personas/architect/best_practices.md +136 -0
- package/claude-code/aiwf/ko/personas/architect/knowledge_base.md +377 -0
- package/claude-code/aiwf/ko/personas/architect.json +44 -0
- package/claude-code/aiwf/ko/personas/backend/best_practices.md +766 -0
- package/claude-code/aiwf/ko/personas/backend/knowledge_base.md +1070 -0
- package/claude-code/aiwf/ko/personas/data_analyst/best_practices.md +594 -0
- package/claude-code/aiwf/ko/personas/data_analyst/knowledge_base.md +1057 -0
- package/claude-code/aiwf/ko/personas/developer.json +44 -0
- package/claude-code/aiwf/ko/personas/developer.md +37 -0
- package/claude-code/aiwf/ko/personas/evaluation_criteria.json +137 -0
- package/claude-code/aiwf/ko/personas/frontend/best_practices.md +445 -0
- package/claude-code/aiwf/ko/personas/frontend/knowledge_base.md +729 -0
- package/claude-code/aiwf/ko/personas/persona-index.json +31 -0
- package/claude-code/aiwf/ko/personas/reviewer.json +44 -0
- package/claude-code/aiwf/ko/personas/security/best_practices.md +307 -0
- package/claude-code/aiwf/ko/personas/security/knowledge_base.md +498 -0
- package/claude-code/aiwf/ko/personas/tester.json +44 -0
- package/claude-code/aiwf/ko/scripts/cache-templates.js +209 -0
- package/claude-code/aiwf/ko/scripts/create-offline.js +86 -0
- package/claude-code/aiwf/ko/scripts/create-project.js +151 -0
- package/claude-code/aiwf/ko/scripts/feature-progress-calculator.cjs +236 -0
- package/claude-code/aiwf/ko/scripts/git-integration.cjs +391 -0
- package/claude-code/aiwf/ko/scripts/install-git-hooks.cjs +226 -0
- package/claude-code/aiwf/ko/scripts/test-commit-parsing.cjs +125 -0
- package/claude-code/aiwf/ko/scripts/update-feature-status.cjs +198 -0
- package/claude-code/aiwf/ko/templates/README.md +78 -0
- package/claude-code/aiwf/ko/templates/api-server/config.json +64 -0
- package/claude-code/aiwf/ko/templates/api-server/template/.aiwf/config.json +56 -0
- package/claude-code/aiwf/ko/templates/api-server/template/.aiwf/feature-ledger.json +42 -0
- package/claude-code/aiwf/ko/templates/api-server/template/.aiwf/personas/backend-engineer.json +40 -0
- package/claude-code/aiwf/ko/templates/api-server/template/.aiwf/scripts/cli.js +111 -0
- package/claude-code/aiwf/ko/templates/api-server/template/.env.example +29 -0
- package/claude-code/aiwf/ko/templates/api-server/template/.eslintrc.json +23 -0
- package/claude-code/aiwf/ko/templates/api-server/template/README.md +171 -0
- package/claude-code/aiwf/ko/templates/api-server/template/jest.config.js +26 -0
- package/claude-code/aiwf/ko/templates/api-server/template/nodemon.json +9 -0
- package/claude-code/aiwf/ko/templates/api-server/template/package.json +61 -0
- package/claude-code/aiwf/ko/templates/api-server/template/src/app.ts +60 -0
- package/claude-code/aiwf/ko/templates/api-server/template/src/config/swagger.ts +38 -0
- package/claude-code/aiwf/ko/templates/api-server/template/src/controllers/aiwfController.ts +68 -0
- package/claude-code/aiwf/ko/templates/api-server/template/src/controllers/authController.ts +128 -0
- package/claude-code/aiwf/ko/templates/api-server/template/src/controllers/statusController.ts +28 -0
- package/claude-code/aiwf/ko/templates/api-server/template/src/index.ts +28 -0
- package/claude-code/aiwf/ko/templates/api-server/template/src/middleware/aiwfMiddleware.ts +50 -0
- package/claude-code/aiwf/ko/templates/api-server/template/src/middleware/authMiddleware.ts +41 -0
- package/claude-code/aiwf/ko/templates/api-server/template/src/middleware/errorHandler.ts +42 -0
- package/claude-code/aiwf/ko/templates/api-server/template/src/middleware/notFoundHandler.ts +14 -0
- package/claude-code/aiwf/ko/templates/api-server/template/src/middleware/requestLogger.ts +20 -0
- package/claude-code/aiwf/ko/templates/api-server/template/src/routes/aiwf.ts +42 -0
- package/claude-code/aiwf/ko/templates/api-server/template/src/routes/index.ts +13 -0
- package/claude-code/aiwf/ko/templates/api-server/template/src/routes/v1/index.ts +67 -0
- package/claude-code/aiwf/ko/templates/api-server/template/src/utils/logger.ts +37 -0
- package/claude-code/aiwf/ko/templates/api-server/template/tests/app.test.ts +40 -0
- package/claude-code/aiwf/ko/templates/api-server/template/tsconfig.json +43 -0
- package/claude-code/aiwf/ko/templates/npm-library/config.json +61 -0
- package/claude-code/aiwf/ko/templates/npm-library/template/LICENSE +21 -0
- package/claude-code/aiwf/ko/templates/npm-library/template/README.md +201 -0
- package/claude-code/aiwf/ko/templates/npm-library/template/package.json +78 -0
- package/claude-code/aiwf/ko/templates/web-app/config.json +53 -0
- package/claude-code/aiwf/ko/templates/web-app/template/.aiwf/config.json +54 -0
- package/claude-code/aiwf/ko/templates/web-app/template/.aiwf/feature-ledger.json +37 -0
- package/claude-code/aiwf/ko/templates/web-app/template/.aiwf/personas/fullstack-developer.json +40 -0
- package/claude-code/aiwf/ko/templates/web-app/template/.aiwf/scripts/cli.js +110 -0
- package/claude-code/aiwf/ko/templates/web-app/template/.eslintrc.cjs +20 -0
- package/claude-code/aiwf/ko/templates/web-app/template/README.md +151 -0
- package/claude-code/aiwf/ko/templates/web-app/template/index.html +14 -0
- package/claude-code/aiwf/ko/templates/web-app/template/package.json +44 -0
- package/claude-code/aiwf/ko/templates/web-app/template/postcss.config.js +6 -0
- package/claude-code/aiwf/ko/templates/web-app/template/public/vite.svg +1 -0
- package/claude-code/aiwf/ko/templates/web-app/template/src/App.tsx +21 -0
- package/claude-code/aiwf/ko/templates/web-app/template/src/components/Layout.tsx +57 -0
- package/claude-code/aiwf/ko/templates/web-app/template/src/components/aiwf/ContextStatus.tsx +107 -0
- package/claude-code/aiwf/ko/templates/web-app/template/src/components/aiwf/FeatureLedger.tsx +93 -0
- package/claude-code/aiwf/ko/templates/web-app/template/src/components/aiwf/TokenUsage.tsx +71 -0
- package/claude-code/aiwf/ko/templates/web-app/template/src/index.css +60 -0
- package/claude-code/aiwf/ko/templates/web-app/template/src/main.tsx +10 -0
- package/claude-code/aiwf/ko/templates/web-app/template/src/pages/AiwfDashboard.tsx +60 -0
- package/claude-code/aiwf/ko/templates/web-app/template/src/pages/HomePage.tsx +89 -0
- package/claude-code/aiwf/ko/templates/web-app/template/src/pages/NotFound.tsx +25 -0
- package/claude-code/aiwf/ko/templates/web-app/template/src/stores/aiwfStore.ts +126 -0
- package/claude-code/aiwf/ko/templates/web-app/template/src/types/global.d.ts +9 -0
- package/claude-code/aiwf/ko/templates/web-app/template/src/vite-env.d.ts +1 -0
- package/claude-code/aiwf/ko/templates/web-app/template/tailwind.config.js +30 -0
- package/claude-code/aiwf/ko/templates/web-app/template/tsconfig.json +37 -0
- package/claude-code/aiwf/ko/templates/web-app/template/tsconfig.node.json +10 -0
- package/claude-code/aiwf/ko/templates/web-app/template/vite.config.ts +23 -0
- package/claude-code/aiwf/ko/tests/compression-test-suite.js +1252 -0
- package/claude-code/aiwf/ko/tests/test-git-integration.js +164 -0
- package/claude-code/aiwf/ko/tests/token-tracking.test.js +537 -0
- package/claude-code/aiwf/ko/token-data/alerts.json +293 -0
- package/claude-code/aiwf/ko/token-data/monitor-config.json +12 -0
- package/claude-code/aiwf/ko/utils/background-monitor.js +223 -0
- package/claude-code/aiwf/ko/utils/compression-metrics.js +1031 -0
- package/claude-code/aiwf/ko/utils/compression-strategies.js +557 -0
- package/claude-code/aiwf/ko/utils/content-normalizer.js +455 -0
- package/claude-code/aiwf/ko/utils/context-compressor.js +583 -0
- package/claude-code/aiwf/ko/utils/context-rule-parser.js +180 -0
- package/claude-code/aiwf/ko/utils/context-token-monitor.js +463 -0
- package/claude-code/aiwf/ko/utils/context-update-manager.js +502 -0
- package/claude-code/aiwf/ko/utils/feature-updater.js +271 -0
- package/claude-code/aiwf/ko/utils/git-utils.js +220 -0
- package/claude-code/aiwf/ko/utils/importance-classifier.js +645 -0
- package/claude-code/aiwf/ko/utils/information-filter.js +710 -0
- package/claude-code/aiwf/ko/utils/persona-aware-compressor.js +598 -0
- package/claude-code/aiwf/ko/utils/prompt-injector.js +242 -0
- package/claude-code/aiwf/ko/utils/simplified-evaluator.js +119 -0
- package/claude-code/aiwf/ko/utils/text-summarizer.js +492 -0
- package/claude-code/aiwf/ko/utils/token-counter.js +177 -0
- package/claude-code/aiwf/ko/utils/token-monitor.js +484 -0
- package/claude-code/aiwf/ko/utils/token-reporter.js +453 -0
- package/claude-code/aiwf/ko/utils/token-storage.js +433 -0
- package/claude-code/aiwf/ko/utils/token-tracker.js +283 -0
- package/docs/AI_PERSONA_SYSTEM_DESIGN.md +516 -0
- package/docs/API_DOCUMENTATION.md +932 -0
- package/docs/API_REFERENCE.md +979 -0
- package/docs/COMMANDS_GUIDE.ko.md +8 -2
- package/docs/COMMANDS_GUIDE.md +196 -2
- package/docs/CONTRIBUTING.ko.md +408 -0
- package/docs/CONTRIBUTING.md +205 -203
- package/docs/EXAMPLES.md +691 -0
- package/docs/GETTING_STARTED.md +480 -0
- package/docs/PERFORMANCE_ARCHITECTURE.md +494 -0
- package/docs/PERFORMANCE_GUIDELINES.md +553 -0
- package/docs/TROUBLESHOOTING.md +721 -0
- package/docs/git-feature-integration-guide.md +253 -0
- package/docs/guides/ai-personas-guide-ko.md +239 -0
- package/docs/guides/ai-personas-guide.md +239 -0
- package/docs/guides/context-compression-guide-ko.md +313 -0
- package/docs/guides/context-compression-guide.md +313 -0
- package/docs/guides/feature-git-integration-guide-ko.md +481 -0
- package/docs/guides/feature-git-integration-guide.md +481 -0
- package/docs/lightweight-evaluation.md +198 -0
- package/docs/m02-dod-checklist.md +125 -0
- package/docs/m02-gap-analysis.md +214 -0
- package/docs/m02-milestone-completion-report.md +186 -0
- package/docs/m02-milestone-executive-summary.md +68 -0
- package/docs/offline-template-cache.md +323 -0
- package/docs/performance-benchmark-report.md +159 -0
- package/docs/persona-aware-compression.md +168 -0
- package/docs/reports/S02-sprint-report.md +190 -0
- package/docs/usability-test-report.md +170 -0
- package/index.js +109 -1
- package/jest.config.js +20 -1
- package/language-utils.js +1 -1
- package/lib/ai-persona-manager.js +711 -0
- package/lib/cache-cli.js +459 -0
- package/lib/cache-integration.js +401 -0
- package/lib/cache-system.js +332 -0
- package/lib/context-engine.js +568 -0
- package/lib/file-batch-processor.js +401 -0
- package/lib/memory-profiler.js +471 -0
- package/lib/metrics-collector.js +885 -0
- package/lib/offline-detector.js +386 -0
- package/lib/performance-benchmark.js +621 -0
- package/lib/task-analyzer.js +599 -0
- package/lib/template-cache-system.js +559 -0
- package/lib/template-downloader.js +467 -0
- package/lib/template-manager.js +310 -0
- package/lib/template-version-manager.js +491 -0
- package/lib/token-optimizer.js +517 -0
- package/package.json +6 -3
- package/scripts/run-integration-tests.js +317 -0
- package/src/commands/ai-tool.js +383 -0
- package/test-token-system.js +88 -0
- package/tests/application.test.js +260 -0
- package/tests/basic.test.js +1 -1
- package/tests/integration/ai-persona-system.test.js +396 -0
- package/tests/integration/ai-persona.test.js +390 -0
- package/tests/integration/command-integration.test.js +600 -0
- package/tests/integration/context-compression.test.js +361 -0
- package/tests/integration/feature-ledger.test.js +226 -0
- package/tests/integration/git-integration.test.js +307 -0
- package/tests/integration/m02-milestone.test.js +420 -0
- package/tests/integration/persona-context-application.test.js +508 -0
- package/tests/integration/setup.js +174 -0
- package/tests/integration/test-persona-aware-compression.js +93 -0
- package/tests/language-utils.test.js +25 -9
- package/tests/s02-integration.test.js +422 -0
- package/tests/unit/ai-persona-manager.test.js +514 -0
- package/claude-code/aiwf/en/.claude/commands/aiwf/aiwf_language_manager.md +0 -287
- package/claude-code/aiwf/en/.claude/commands/aiwf/aiwf_language_status.md +0 -246
- package/claude-code/aiwf/ko/.claude/commands/aiwf/aiwf_language_manager.md +0 -287
- package/claude-code/aiwf/ko/.claude/commands/aiwf/aiwf_language_status.md +0 -246
|
@@ -0,0 +1,766 @@
|
|
|
1
|
+
# Backend 페르소나 Best Practices
|
|
2
|
+
|
|
3
|
+
## 개요
|
|
4
|
+
Backend 페르소나는 서버 사이드 로직, 데이터베이스 설계, API 개발에 중점을 둡니다. 확장성, 성능, 데이터 무결성을 최우선으로 고려합니다.
|
|
5
|
+
|
|
6
|
+
## 핵심 원칙
|
|
7
|
+
|
|
8
|
+
### 1. API 설계 원칙
|
|
9
|
+
- RESTful 원칙 준수
|
|
10
|
+
- GraphQL 스키마 최적화
|
|
11
|
+
- API 버전 관리
|
|
12
|
+
- 일관된 응답 형식
|
|
13
|
+
|
|
14
|
+
### 2. 데이터베이스 설계
|
|
15
|
+
```sql
|
|
16
|
+
-- 정규화와 성능의 균형
|
|
17
|
+
CREATE TABLE users (
|
|
18
|
+
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
19
|
+
email VARCHAR(255) UNIQUE NOT NULL,
|
|
20
|
+
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
|
|
21
|
+
updated_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
-- 인덱스 전략
|
|
25
|
+
CREATE INDEX idx_users_email ON users(email);
|
|
26
|
+
CREATE INDEX idx_users_created_at ON users(created_at DESC);
|
|
27
|
+
|
|
28
|
+
-- 파티셔닝 (대용량 테이블)
|
|
29
|
+
CREATE TABLE orders (
|
|
30
|
+
id BIGSERIAL,
|
|
31
|
+
user_id UUID REFERENCES users(id),
|
|
32
|
+
order_date DATE NOT NULL,
|
|
33
|
+
total_amount DECIMAL(10,2),
|
|
34
|
+
PRIMARY KEY (id, order_date)
|
|
35
|
+
) PARTITION BY RANGE (order_date);
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### 3. 마이크로서비스 아키텍처
|
|
39
|
+
```javascript
|
|
40
|
+
// 서비스 간 통신 패턴
|
|
41
|
+
class OrderService {
|
|
42
|
+
constructor(eventBus, userService, inventoryService) {
|
|
43
|
+
this.eventBus = eventBus;
|
|
44
|
+
this.userService = userService;
|
|
45
|
+
this.inventoryService = inventoryService;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async createOrder(orderData) {
|
|
49
|
+
// Saga 패턴으로 분산 트랜잭션 처리
|
|
50
|
+
const saga = new OrderSaga();
|
|
51
|
+
|
|
52
|
+
try {
|
|
53
|
+
// 1. 사용자 검증
|
|
54
|
+
const user = await this.userService.validateUser(orderData.userId);
|
|
55
|
+
saga.addCompensation(() => this.userService.rollback(user));
|
|
56
|
+
|
|
57
|
+
// 2. 재고 확인 및 예약
|
|
58
|
+
const reservation = await this.inventoryService.reserve(orderData.items);
|
|
59
|
+
saga.addCompensation(() => this.inventoryService.release(reservation));
|
|
60
|
+
|
|
61
|
+
// 3. 주문 생성
|
|
62
|
+
const order = await this.createOrderRecord(orderData);
|
|
63
|
+
saga.addCompensation(() => this.deleteOrder(order.id));
|
|
64
|
+
|
|
65
|
+
// 4. 이벤트 발행
|
|
66
|
+
await this.eventBus.publish('order.created', {
|
|
67
|
+
orderId: order.id,
|
|
68
|
+
userId: user.id,
|
|
69
|
+
items: orderData.items
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
return order;
|
|
73
|
+
} catch (error) {
|
|
74
|
+
await saga.compensate();
|
|
75
|
+
throw error;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## API 개발 Best Practices
|
|
82
|
+
|
|
83
|
+
### RESTful API 설계
|
|
84
|
+
```javascript
|
|
85
|
+
// Express.js 라우터
|
|
86
|
+
class UserController {
|
|
87
|
+
// GET /api/v1/users?page=1&limit=20&sort=created_at:desc
|
|
88
|
+
async getUsers(req, res) {
|
|
89
|
+
const { page = 1, limit = 20, sort, filter } = req.query;
|
|
90
|
+
|
|
91
|
+
try {
|
|
92
|
+
const users = await this.userService.findAll({
|
|
93
|
+
pagination: { page, limit },
|
|
94
|
+
sorting: this.parseSortParam(sort),
|
|
95
|
+
filters: this.parseFilterParam(filter)
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
res.json({
|
|
99
|
+
success: true,
|
|
100
|
+
data: users,
|
|
101
|
+
meta: {
|
|
102
|
+
page: parseInt(page),
|
|
103
|
+
limit: parseInt(limit),
|
|
104
|
+
total: users.total,
|
|
105
|
+
totalPages: Math.ceil(users.total / limit)
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
} catch (error) {
|
|
109
|
+
this.handleError(error, res);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// POST /api/v1/users
|
|
114
|
+
async createUser(req, res) {
|
|
115
|
+
try {
|
|
116
|
+
// 입력 검증
|
|
117
|
+
const validatedData = await this.validator.validate(req.body, UserSchema);
|
|
118
|
+
|
|
119
|
+
// 비즈니스 로직
|
|
120
|
+
const user = await this.userService.create(validatedData);
|
|
121
|
+
|
|
122
|
+
// 201 Created with Location header
|
|
123
|
+
res.status(201)
|
|
124
|
+
.location(`/api/v1/users/${user.id}`)
|
|
125
|
+
.json({
|
|
126
|
+
success: true,
|
|
127
|
+
data: user
|
|
128
|
+
});
|
|
129
|
+
} catch (error) {
|
|
130
|
+
this.handleError(error, res);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// Error handling
|
|
135
|
+
handleError(error, res) {
|
|
136
|
+
if (error instanceof ValidationError) {
|
|
137
|
+
return res.status(400).json({
|
|
138
|
+
success: false,
|
|
139
|
+
error: {
|
|
140
|
+
code: 'VALIDATION_ERROR',
|
|
141
|
+
message: error.message,
|
|
142
|
+
details: error.details
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
if (error instanceof NotFoundError) {
|
|
148
|
+
return res.status(404).json({
|
|
149
|
+
success: false,
|
|
150
|
+
error: {
|
|
151
|
+
code: 'NOT_FOUND',
|
|
152
|
+
message: error.message
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// 500 Internal Server Error
|
|
158
|
+
console.error('Unexpected error:', error);
|
|
159
|
+
res.status(500).json({
|
|
160
|
+
success: false,
|
|
161
|
+
error: {
|
|
162
|
+
code: 'INTERNAL_ERROR',
|
|
163
|
+
message: 'An unexpected error occurred'
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### GraphQL 스키마 설계
|
|
171
|
+
```graphql
|
|
172
|
+
# Schema Definition
|
|
173
|
+
type User {
|
|
174
|
+
id: ID!
|
|
175
|
+
email: String!
|
|
176
|
+
profile: Profile!
|
|
177
|
+
orders(
|
|
178
|
+
first: Int = 10
|
|
179
|
+
after: String
|
|
180
|
+
filter: OrderFilter
|
|
181
|
+
): OrderConnection!
|
|
182
|
+
createdAt: DateTime!
|
|
183
|
+
updatedAt: DateTime!
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
type Profile {
|
|
187
|
+
firstName: String!
|
|
188
|
+
lastName: String!
|
|
189
|
+
avatar: String
|
|
190
|
+
preferences: UserPreferences!
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
# Pagination using Relay specification
|
|
194
|
+
type OrderConnection {
|
|
195
|
+
edges: [OrderEdge!]!
|
|
196
|
+
pageInfo: PageInfo!
|
|
197
|
+
totalCount: Int!
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
type OrderEdge {
|
|
201
|
+
node: Order!
|
|
202
|
+
cursor: String!
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
# Input types
|
|
206
|
+
input CreateUserInput {
|
|
207
|
+
email: String!
|
|
208
|
+
password: String!
|
|
209
|
+
profile: ProfileInput!
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
# Queries
|
|
213
|
+
type Query {
|
|
214
|
+
user(id: ID!): User
|
|
215
|
+
users(
|
|
216
|
+
first: Int
|
|
217
|
+
after: String
|
|
218
|
+
filter: UserFilter
|
|
219
|
+
orderBy: UserOrderBy
|
|
220
|
+
): UserConnection!
|
|
221
|
+
me: User @auth
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
# Mutations
|
|
225
|
+
type Mutation {
|
|
226
|
+
createUser(input: CreateUserInput!): CreateUserPayload!
|
|
227
|
+
updateUser(id: ID!, input: UpdateUserInput!): UpdateUserPayload!
|
|
228
|
+
deleteUser(id: ID!): DeleteUserPayload!
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
# Subscriptions
|
|
232
|
+
type Subscription {
|
|
233
|
+
userUpdated(userId: ID!): User!
|
|
234
|
+
orderCreated(userId: ID!): Order!
|
|
235
|
+
}
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
## 데이터베이스 최적화
|
|
239
|
+
|
|
240
|
+
### 쿼리 최적화
|
|
241
|
+
```javascript
|
|
242
|
+
// Query Builder Pattern
|
|
243
|
+
class UserRepository {
|
|
244
|
+
constructor(db) {
|
|
245
|
+
this.db = db;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
// N+1 문제 방지
|
|
249
|
+
async findWithOrders(userId) {
|
|
250
|
+
const query = `
|
|
251
|
+
SELECT
|
|
252
|
+
u.id, u.email, u.created_at,
|
|
253
|
+
o.id as order_id, o.total_amount, o.order_date,
|
|
254
|
+
oi.product_id, oi.quantity, oi.price
|
|
255
|
+
FROM users u
|
|
256
|
+
LEFT JOIN orders o ON u.id = o.user_id
|
|
257
|
+
LEFT JOIN order_items oi ON o.id = oi.order_id
|
|
258
|
+
WHERE u.id = $1
|
|
259
|
+
ORDER BY o.order_date DESC
|
|
260
|
+
`;
|
|
261
|
+
|
|
262
|
+
const result = await this.db.query(query, [userId]);
|
|
263
|
+
return this.mapResultToUser(result.rows);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
// Batch loading
|
|
267
|
+
async findByIds(userIds) {
|
|
268
|
+
if (userIds.length === 0) return [];
|
|
269
|
+
|
|
270
|
+
const query = `
|
|
271
|
+
SELECT * FROM users
|
|
272
|
+
WHERE id = ANY($1::uuid[])
|
|
273
|
+
`;
|
|
274
|
+
|
|
275
|
+
const result = await this.db.query(query, [userIds]);
|
|
276
|
+
|
|
277
|
+
// 순서 보장
|
|
278
|
+
const userMap = new Map(
|
|
279
|
+
result.rows.map(row => [row.id, row])
|
|
280
|
+
);
|
|
281
|
+
|
|
282
|
+
return userIds.map(id => userMap.get(id)).filter(Boolean);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
// 동적 쿼리 빌더
|
|
286
|
+
async search(criteria) {
|
|
287
|
+
let query = 'SELECT * FROM users WHERE 1=1';
|
|
288
|
+
const params = [];
|
|
289
|
+
let paramIndex = 1;
|
|
290
|
+
|
|
291
|
+
if (criteria.email) {
|
|
292
|
+
query += ` AND email ILIKE $${paramIndex}`;
|
|
293
|
+
params.push(`%${criteria.email}%`);
|
|
294
|
+
paramIndex++;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
if (criteria.createdAfter) {
|
|
298
|
+
query += ` AND created_at >= $${paramIndex}`;
|
|
299
|
+
params.push(criteria.createdAfter);
|
|
300
|
+
paramIndex++;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
if (criteria.sortBy) {
|
|
304
|
+
const validColumns = ['email', 'created_at'];
|
|
305
|
+
if (validColumns.includes(criteria.sortBy)) {
|
|
306
|
+
query += ` ORDER BY ${criteria.sortBy} ${
|
|
307
|
+
criteria.sortOrder === 'desc' ? 'DESC' : 'ASC'
|
|
308
|
+
}`;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
query += ` LIMIT $${paramIndex} OFFSET $${paramIndex + 1}`;
|
|
313
|
+
params.push(criteria.limit || 20, criteria.offset || 0);
|
|
314
|
+
|
|
315
|
+
return this.db.query(query, params);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
### 캐싱 전략
|
|
321
|
+
```javascript
|
|
322
|
+
// Redis 캐싱 레이어
|
|
323
|
+
class CacheService {
|
|
324
|
+
constructor(redis, ttl = 3600) {
|
|
325
|
+
this.redis = redis;
|
|
326
|
+
this.ttl = ttl;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
// Cache-Aside Pattern
|
|
330
|
+
async get(key, fetchFn) {
|
|
331
|
+
// 1. 캐시 확인
|
|
332
|
+
const cached = await this.redis.get(key);
|
|
333
|
+
if (cached) {
|
|
334
|
+
return JSON.parse(cached);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
// 2. 캐시 미스 시 데이터 조회
|
|
338
|
+
const data = await fetchFn();
|
|
339
|
+
|
|
340
|
+
// 3. 캐시 저장
|
|
341
|
+
await this.redis.setex(
|
|
342
|
+
key,
|
|
343
|
+
this.ttl,
|
|
344
|
+
JSON.stringify(data)
|
|
345
|
+
);
|
|
346
|
+
|
|
347
|
+
return data;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
// Write-Through Pattern
|
|
351
|
+
async set(key, data, ttl = this.ttl) {
|
|
352
|
+
await this.redis.setex(
|
|
353
|
+
key,
|
|
354
|
+
ttl,
|
|
355
|
+
JSON.stringify(data)
|
|
356
|
+
);
|
|
357
|
+
return data;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
// Cache Invalidation
|
|
361
|
+
async invalidate(pattern) {
|
|
362
|
+
const keys = await this.redis.keys(pattern);
|
|
363
|
+
if (keys.length > 0) {
|
|
364
|
+
await this.redis.del(...keys);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
// Distributed Lock (분산 환경)
|
|
369
|
+
async acquireLock(lockKey, ttl = 10) {
|
|
370
|
+
const identifier = uuidv4();
|
|
371
|
+
const result = await this.redis.set(
|
|
372
|
+
`lock:${lockKey}`,
|
|
373
|
+
identifier,
|
|
374
|
+
'NX',
|
|
375
|
+
'EX',
|
|
376
|
+
ttl
|
|
377
|
+
);
|
|
378
|
+
|
|
379
|
+
return result === 'OK' ? identifier : null;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
async releaseLock(lockKey, identifier) {
|
|
383
|
+
const script = `
|
|
384
|
+
if redis.call("get", KEYS[1]) == ARGV[1] then
|
|
385
|
+
return redis.call("del", KEYS[1])
|
|
386
|
+
else
|
|
387
|
+
return 0
|
|
388
|
+
end
|
|
389
|
+
`;
|
|
390
|
+
|
|
391
|
+
return this.redis.eval(
|
|
392
|
+
script,
|
|
393
|
+
1,
|
|
394
|
+
`lock:${lockKey}`,
|
|
395
|
+
identifier
|
|
396
|
+
);
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
## 메시지 큐와 이벤트 처리
|
|
402
|
+
|
|
403
|
+
### RabbitMQ 패턴
|
|
404
|
+
```javascript
|
|
405
|
+
// Publisher/Subscriber Pattern
|
|
406
|
+
class EventPublisher {
|
|
407
|
+
constructor(channel) {
|
|
408
|
+
this.channel = channel;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
async publish(exchange, routingKey, message) {
|
|
412
|
+
const messageBuffer = Buffer.from(JSON.stringify({
|
|
413
|
+
...message,
|
|
414
|
+
timestamp: new Date().toISOString(),
|
|
415
|
+
messageId: uuidv4()
|
|
416
|
+
}));
|
|
417
|
+
|
|
418
|
+
await this.channel.publish(
|
|
419
|
+
exchange,
|
|
420
|
+
routingKey,
|
|
421
|
+
messageBuffer,
|
|
422
|
+
{
|
|
423
|
+
persistent: true,
|
|
424
|
+
contentType: 'application/json',
|
|
425
|
+
headers: {
|
|
426
|
+
'x-retry-count': 0
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
);
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
// Consumer with Error Handling
|
|
434
|
+
class EventConsumer {
|
|
435
|
+
constructor(channel, options = {}) {
|
|
436
|
+
this.channel = channel;
|
|
437
|
+
this.maxRetries = options.maxRetries || 3;
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
async consume(queue, handler) {
|
|
441
|
+
await this.channel.consume(queue, async (msg) => {
|
|
442
|
+
if (!msg) return;
|
|
443
|
+
|
|
444
|
+
try {
|
|
445
|
+
const content = JSON.parse(msg.content.toString());
|
|
446
|
+
await handler(content);
|
|
447
|
+
|
|
448
|
+
// Acknowledge message
|
|
449
|
+
this.channel.ack(msg);
|
|
450
|
+
} catch (error) {
|
|
451
|
+
console.error('Error processing message:', error);
|
|
452
|
+
|
|
453
|
+
// Retry logic
|
|
454
|
+
const retryCount = (msg.properties.headers['x-retry-count'] || 0) + 1;
|
|
455
|
+
|
|
456
|
+
if (retryCount <= this.maxRetries) {
|
|
457
|
+
// Requeue with delay
|
|
458
|
+
setTimeout(() => {
|
|
459
|
+
this.channel.sendToQueue(
|
|
460
|
+
queue,
|
|
461
|
+
msg.content,
|
|
462
|
+
{
|
|
463
|
+
...msg.properties,
|
|
464
|
+
headers: {
|
|
465
|
+
...msg.properties.headers,
|
|
466
|
+
'x-retry-count': retryCount
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
);
|
|
470
|
+
}, Math.pow(2, retryCount) * 1000); // Exponential backoff
|
|
471
|
+
} else {
|
|
472
|
+
// Send to DLQ
|
|
473
|
+
await this.sendToDeadLetter(msg, error);
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
// Reject without requeue
|
|
477
|
+
this.channel.nack(msg, false, false);
|
|
478
|
+
}
|
|
479
|
+
});
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
async sendToDeadLetter(msg, error) {
|
|
483
|
+
const dlq = `${msg.fields.routingKey}.dlq`;
|
|
484
|
+
await this.channel.sendToQueue(
|
|
485
|
+
dlq,
|
|
486
|
+
msg.content,
|
|
487
|
+
{
|
|
488
|
+
headers: {
|
|
489
|
+
'x-death-reason': error.message,
|
|
490
|
+
'x-original-queue': msg.fields.routingKey
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
);
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
```
|
|
497
|
+
|
|
498
|
+
## 보안 구현
|
|
499
|
+
|
|
500
|
+
### 인증/인가 미들웨어
|
|
501
|
+
```javascript
|
|
502
|
+
// JWT Authentication
|
|
503
|
+
class AuthMiddleware {
|
|
504
|
+
constructor(jwtService, userService) {
|
|
505
|
+
this.jwtService = jwtService;
|
|
506
|
+
this.userService = userService;
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
authenticate() {
|
|
510
|
+
return async (req, res, next) => {
|
|
511
|
+
try {
|
|
512
|
+
const token = this.extractToken(req);
|
|
513
|
+
if (!token) {
|
|
514
|
+
return res.status(401).json({
|
|
515
|
+
error: 'No authentication token provided'
|
|
516
|
+
});
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
const payload = await this.jwtService.verify(token);
|
|
520
|
+
|
|
521
|
+
// Token blacklist check
|
|
522
|
+
if (await this.isTokenBlacklisted(payload.jti)) {
|
|
523
|
+
return res.status(401).json({
|
|
524
|
+
error: 'Token has been revoked'
|
|
525
|
+
});
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
req.user = await this.userService.findById(payload.sub);
|
|
529
|
+
next();
|
|
530
|
+
} catch (error) {
|
|
531
|
+
if (error.name === 'TokenExpiredError') {
|
|
532
|
+
return res.status(401).json({
|
|
533
|
+
error: 'Token has expired'
|
|
534
|
+
});
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
return res.status(401).json({
|
|
538
|
+
error: 'Invalid authentication token'
|
|
539
|
+
});
|
|
540
|
+
}
|
|
541
|
+
};
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
authorize(...roles) {
|
|
545
|
+
return (req, res, next) => {
|
|
546
|
+
if (!req.user) {
|
|
547
|
+
return res.status(401).json({
|
|
548
|
+
error: 'Authentication required'
|
|
549
|
+
});
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
if (roles.length > 0 && !roles.includes(req.user.role)) {
|
|
553
|
+
return res.status(403).json({
|
|
554
|
+
error: 'Insufficient permissions'
|
|
555
|
+
});
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
next();
|
|
559
|
+
};
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
extractToken(req) {
|
|
563
|
+
const authHeader = req.headers.authorization;
|
|
564
|
+
if (authHeader && authHeader.startsWith('Bearer ')) {
|
|
565
|
+
return authHeader.substring(7);
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
return req.cookies?.accessToken;
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
```
|
|
572
|
+
|
|
573
|
+
## 테스팅 전략
|
|
574
|
+
|
|
575
|
+
### 단위 테스트
|
|
576
|
+
```javascript
|
|
577
|
+
describe('UserService', () => {
|
|
578
|
+
let userService;
|
|
579
|
+
let userRepository;
|
|
580
|
+
let emailService;
|
|
581
|
+
|
|
582
|
+
beforeEach(() => {
|
|
583
|
+
userRepository = {
|
|
584
|
+
findByEmail: jest.fn(),
|
|
585
|
+
create: jest.fn(),
|
|
586
|
+
update: jest.fn()
|
|
587
|
+
};
|
|
588
|
+
|
|
589
|
+
emailService = {
|
|
590
|
+
sendWelcomeEmail: jest.fn()
|
|
591
|
+
};
|
|
592
|
+
|
|
593
|
+
userService = new UserService(userRepository, emailService);
|
|
594
|
+
});
|
|
595
|
+
|
|
596
|
+
describe('createUser', () => {
|
|
597
|
+
it('should create user with hashed password', async () => {
|
|
598
|
+
const userData = {
|
|
599
|
+
email: 'test@example.com',
|
|
600
|
+
password: 'password123'
|
|
601
|
+
};
|
|
602
|
+
|
|
603
|
+
userRepository.findByEmail.mockResolvedValue(null);
|
|
604
|
+
userRepository.create.mockResolvedValue({
|
|
605
|
+
id: 'user-123',
|
|
606
|
+
...userData,
|
|
607
|
+
password: 'hashed-password'
|
|
608
|
+
});
|
|
609
|
+
|
|
610
|
+
const user = await userService.createUser(userData);
|
|
611
|
+
|
|
612
|
+
expect(userRepository.findByEmail).toHaveBeenCalledWith(userData.email);
|
|
613
|
+
expect(userRepository.create).toHaveBeenCalledWith({
|
|
614
|
+
email: userData.email,
|
|
615
|
+
password: expect.stringMatching(/^\$2[aby]\$/)
|
|
616
|
+
});
|
|
617
|
+
expect(emailService.sendWelcomeEmail).toHaveBeenCalledWith(userData.email);
|
|
618
|
+
expect(user).not.toHaveProperty('password');
|
|
619
|
+
});
|
|
620
|
+
|
|
621
|
+
it('should throw error if email already exists', async () => {
|
|
622
|
+
userRepository.findByEmail.mockResolvedValue({ id: 'existing-user' });
|
|
623
|
+
|
|
624
|
+
await expect(
|
|
625
|
+
userService.createUser({ email: 'test@example.com', password: 'pass' })
|
|
626
|
+
).rejects.toThrow('Email already registered');
|
|
627
|
+
});
|
|
628
|
+
});
|
|
629
|
+
});
|
|
630
|
+
```
|
|
631
|
+
|
|
632
|
+
### 통합 테스트
|
|
633
|
+
```javascript
|
|
634
|
+
describe('API Integration Tests', () => {
|
|
635
|
+
let app;
|
|
636
|
+
let db;
|
|
637
|
+
|
|
638
|
+
beforeAll(async () => {
|
|
639
|
+
// Test database setup
|
|
640
|
+
db = await createTestDatabase();
|
|
641
|
+
app = createApp(db);
|
|
642
|
+
});
|
|
643
|
+
|
|
644
|
+
afterAll(async () => {
|
|
645
|
+
await db.close();
|
|
646
|
+
});
|
|
647
|
+
|
|
648
|
+
describe('POST /api/users', () => {
|
|
649
|
+
it('should create user and return 201', async () => {
|
|
650
|
+
const response = await request(app)
|
|
651
|
+
.post('/api/users')
|
|
652
|
+
.send({
|
|
653
|
+
email: 'newuser@example.com',
|
|
654
|
+
password: 'SecurePass123!',
|
|
655
|
+
profile: {
|
|
656
|
+
firstName: 'John',
|
|
657
|
+
lastName: 'Doe'
|
|
658
|
+
}
|
|
659
|
+
});
|
|
660
|
+
|
|
661
|
+
expect(response.status).toBe(201);
|
|
662
|
+
expect(response.headers.location).toMatch(/\/api\/users\/[\w-]+/);
|
|
663
|
+
expect(response.body).toMatchObject({
|
|
664
|
+
success: true,
|
|
665
|
+
data: {
|
|
666
|
+
email: 'newuser@example.com',
|
|
667
|
+
profile: {
|
|
668
|
+
firstName: 'John',
|
|
669
|
+
lastName: 'Doe'
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
});
|
|
673
|
+
|
|
674
|
+
// Verify database
|
|
675
|
+
const user = await db.query(
|
|
676
|
+
'SELECT * FROM users WHERE email = $1',
|
|
677
|
+
['newuser@example.com']
|
|
678
|
+
);
|
|
679
|
+
expect(user.rows).toHaveLength(1);
|
|
680
|
+
});
|
|
681
|
+
});
|
|
682
|
+
});
|
|
683
|
+
```
|
|
684
|
+
|
|
685
|
+
## 모니터링과 로깅
|
|
686
|
+
|
|
687
|
+
### 구조화된 로깅
|
|
688
|
+
```javascript
|
|
689
|
+
class Logger {
|
|
690
|
+
constructor(service) {
|
|
691
|
+
this.service = service;
|
|
692
|
+
this.winston = winston.createLogger({
|
|
693
|
+
format: winston.format.combine(
|
|
694
|
+
winston.format.timestamp(),
|
|
695
|
+
winston.format.errors({ stack: true }),
|
|
696
|
+
winston.format.json()
|
|
697
|
+
),
|
|
698
|
+
defaultMeta: { service },
|
|
699
|
+
transports: [
|
|
700
|
+
new winston.transports.Console({
|
|
701
|
+
format: winston.format.simple()
|
|
702
|
+
}),
|
|
703
|
+
new winston.transports.File({
|
|
704
|
+
filename: 'error.log',
|
|
705
|
+
level: 'error'
|
|
706
|
+
}),
|
|
707
|
+
new winston.transports.File({
|
|
708
|
+
filename: 'combined.log'
|
|
709
|
+
})
|
|
710
|
+
]
|
|
711
|
+
});
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
log(level, message, meta = {}) {
|
|
715
|
+
this.winston.log({
|
|
716
|
+
level,
|
|
717
|
+
message,
|
|
718
|
+
...meta,
|
|
719
|
+
timestamp: new Date().toISOString()
|
|
720
|
+
});
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
// Request logging middleware
|
|
724
|
+
requestLogger() {
|
|
725
|
+
return (req, res, next) => {
|
|
726
|
+
const start = Date.now();
|
|
727
|
+
|
|
728
|
+
res.on('finish', () => {
|
|
729
|
+
const duration = Date.now() - start;
|
|
730
|
+
|
|
731
|
+
this.log('info', 'HTTP Request', {
|
|
732
|
+
method: req.method,
|
|
733
|
+
path: req.path,
|
|
734
|
+
statusCode: res.statusCode,
|
|
735
|
+
duration,
|
|
736
|
+
ip: req.ip,
|
|
737
|
+
userAgent: req.get('user-agent'),
|
|
738
|
+
userId: req.user?.id
|
|
739
|
+
});
|
|
740
|
+
});
|
|
741
|
+
|
|
742
|
+
next();
|
|
743
|
+
};
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
```
|
|
747
|
+
|
|
748
|
+
## 배포 전 체크리스트
|
|
749
|
+
|
|
750
|
+
### 성능
|
|
751
|
+
- [ ] 데이터베이스 인덱스 최적화
|
|
752
|
+
- [ ] N+1 쿼리 제거
|
|
753
|
+
- [ ] 캐싱 전략 구현
|
|
754
|
+
- [ ] 비동기 처리 적용
|
|
755
|
+
|
|
756
|
+
### 보안
|
|
757
|
+
- [ ] 환경 변수로 민감 정보 관리
|
|
758
|
+
- [ ] SQL Injection 방지
|
|
759
|
+
- [ ] Rate Limiting 설정
|
|
760
|
+
- [ ] CORS 정책 구성
|
|
761
|
+
|
|
762
|
+
### 안정성
|
|
763
|
+
- [ ] 에러 처리 및 복구 메커니즘
|
|
764
|
+
- [ ] 서킷 브레이커 패턴
|
|
765
|
+
- [ ] 헬스체크 엔드포인트
|
|
766
|
+
- [ ] 우아한 종료(Graceful Shutdown)
|