blockmine 1.21.0 → 1.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (433) hide show
  1. package/.claude/agents/README.md +469 -0
  2. package/.claude/agents/auth-route-debugger.md +118 -0
  3. package/.claude/agents/auth-route-tester.md +93 -0
  4. package/.claude/agents/auto-error-resolver.md +97 -0
  5. package/.claude/agents/build-optimizer.md +236 -0
  6. package/.claude/agents/code-architecture-reviewer.md +83 -0
  7. package/.claude/agents/code-refactor-master.md +94 -0
  8. package/.claude/agents/cost-optimizer.md +134 -0
  9. package/.claude/agents/deployment-orchestrator.md +113 -0
  10. package/.claude/agents/documentation-architect.md +82 -0
  11. package/.claude/agents/frontend-error-fixer.md +77 -0
  12. package/.claude/agents/iac-code-generator.md +71 -0
  13. package/.claude/agents/incident-responder.md +346 -0
  14. package/.claude/agents/infrastructure-architect.md +31 -0
  15. package/.claude/agents/kubernetes-specialist.md +56 -0
  16. package/.claude/agents/migration-planner.md +181 -0
  17. package/.claude/agents/network-architect.md +196 -0
  18. package/.claude/agents/plan-reviewer.md +52 -0
  19. package/.claude/agents/refactor-planner.md +63 -0
  20. package/.claude/agents/security-scanner.md +102 -0
  21. package/.claude/agents/web-research-specialist.md +78 -0
  22. package/.claude/commands/cost-analysis.md +315 -0
  23. package/.claude/commands/dev-docs-update.md +55 -0
  24. package/.claude/commands/dev-docs.md +51 -0
  25. package/.claude/commands/incident-debug.md +247 -0
  26. package/.claude/commands/infra-plan.md +81 -0
  27. package/.claude/commands/migration-plan.md +478 -0
  28. package/.claude/commands/route-research-for-testing.md +37 -0
  29. package/.claude/commands/security-review.md +66 -0
  30. package/.claude/hooks/CONFIG.md +448 -0
  31. package/.claude/hooks/README.md +163 -0
  32. package/.claude/hooks/SKILL_ACTIVATION_COMPLETE.md +226 -0
  33. package/.claude/hooks/WINDOWS_HOOKS_README.md +151 -0
  34. package/.claude/hooks/add-skill-activation-banners.ts +132 -0
  35. package/.claude/hooks/comprehensive-skill-test.ts +1315 -0
  36. package/.claude/hooks/error-handling-reminder.sh +12 -0
  37. package/.claude/hooks/error-handling-reminder.ts +222 -0
  38. package/.claude/hooks/k8s-manifest-validator.sh +56 -0
  39. package/.claude/hooks/package-lock.json +556 -0
  40. package/.claude/hooks/package.json +16 -0
  41. package/.claude/hooks/post-tool-use-tracker.ps1 +174 -0
  42. package/.claude/hooks/post-tool-use-tracker.sh +183 -0
  43. package/.claude/hooks/security-policy-check.sh +247 -0
  44. package/.claude/hooks/skill-activation-prompt.ps1 +10 -0
  45. package/.claude/hooks/skill-activation-prompt.sh +10 -0
  46. package/.claude/hooks/skill-activation-prompt.ts +141 -0
  47. package/.claude/hooks/stop-build-check-enhanced.sh +130 -0
  48. package/.claude/hooks/terraform-validator.sh +53 -0
  49. package/.claude/hooks/test-input.json +7 -0
  50. package/.claude/hooks/test-skill-activation.ts +427 -0
  51. package/.claude/hooks/trigger-build-resolver.sh +79 -0
  52. package/.claude/hooks/tsc-check.sh +173 -0
  53. package/.claude/hooks/tsconfig.json +19 -0
  54. package/.claude/settings.json +55 -0
  55. package/.claude/settings.local.json +27 -14
  56. package/.claude/skills/README.md +507 -0
  57. package/.claude/skills/api-engineering/SKILL.md +63 -0
  58. package/.claude/skills/api-engineering/resources/api-versioning.md +88 -0
  59. package/.claude/skills/api-engineering/resources/graphql-patterns.md +106 -0
  60. package/.claude/skills/api-engineering/resources/rate-limiting.md +118 -0
  61. package/.claude/skills/api-engineering/resources/rest-api-design.md +105 -0
  62. package/.claude/skills/backend-dev-guidelines/SKILL.md +306 -0
  63. package/.claude/skills/backend-dev-guidelines/resources/architecture-overview.md +451 -0
  64. package/.claude/skills/backend-dev-guidelines/resources/async-and-errors.md +307 -0
  65. package/.claude/skills/backend-dev-guidelines/resources/complete-examples.md +638 -0
  66. package/.claude/skills/backend-dev-guidelines/resources/configuration.md +275 -0
  67. package/.claude/skills/backend-dev-guidelines/resources/database-patterns.md +224 -0
  68. package/.claude/skills/backend-dev-guidelines/resources/middleware-guide.md +213 -0
  69. package/.claude/skills/backend-dev-guidelines/resources/routing-and-controllers.md +756 -0
  70. package/.claude/skills/backend-dev-guidelines/resources/sentry-and-monitoring.md +336 -0
  71. package/.claude/skills/backend-dev-guidelines/resources/services-and-repositories.md +789 -0
  72. package/.claude/skills/backend-dev-guidelines/resources/testing-guide.md +235 -0
  73. package/.claude/skills/backend-dev-guidelines/resources/validation-patterns.md +754 -0
  74. package/.claude/skills/budget-and-cost-management/SKILL.md +850 -0
  75. package/.claude/skills/build-engineering/SKILL.md +431 -0
  76. package/.claude/skills/build-engineering/resources/artifact-repositories.md +72 -0
  77. package/.claude/skills/build-engineering/resources/build-caching.md +96 -0
  78. package/.claude/skills/build-engineering/resources/build-pipelines.md +105 -0
  79. package/.claude/skills/build-engineering/resources/build-security.md +95 -0
  80. package/.claude/skills/build-engineering/resources/build-systems.md +389 -0
  81. package/.claude/skills/build-engineering/resources/compilation-optimization.md +201 -0
  82. package/.claude/skills/build-engineering/resources/dependency-management.md +73 -0
  83. package/.claude/skills/build-engineering/resources/monorepo-builds.md +110 -0
  84. package/.claude/skills/build-engineering/resources/performance-optimization.md +113 -0
  85. package/.claude/skills/build-engineering/resources/reproducible-builds.md +82 -0
  86. package/.claude/skills/cloud-engineering/SKILL.md +675 -0
  87. package/.claude/skills/cloud-engineering/resources/aws-patterns.md +742 -0
  88. package/.claude/skills/cloud-engineering/resources/azure-patterns.md +714 -0
  89. package/.claude/skills/cloud-engineering/resources/cleared-cloud-environments.md +987 -0
  90. package/.claude/skills/cloud-engineering/resources/cloud-cost-optimization.md +757 -0
  91. package/.claude/skills/cloud-engineering/resources/cloud-networking.md +1058 -0
  92. package/.claude/skills/cloud-engineering/resources/cloud-security-tools.md +1530 -0
  93. package/.claude/skills/cloud-engineering/resources/cloud-security.md +990 -0
  94. package/.claude/skills/cloud-engineering/resources/gcp-patterns.md +758 -0
  95. package/.claude/skills/cloud-engineering/resources/migration-strategies.md +820 -0
  96. package/.claude/skills/cloud-engineering/resources/multi-cloud-strategies.md +670 -0
  97. package/.claude/skills/cloud-engineering/resources/oci-patterns.md +1198 -0
  98. package/.claude/skills/cloud-engineering/resources/serverless-patterns.md +795 -0
  99. package/.claude/skills/cloud-engineering/resources/well-architected-frameworks.md +966 -0
  100. package/.claude/skills/cybersecurity/SKILL.md +409 -0
  101. package/.claude/skills/cybersecurity/resources/security-architecture.md +266 -0
  102. package/.claude/skills/database-engineering/SKILL.md +61 -0
  103. package/.claude/skills/database-engineering/resources/backup-and-recovery.md +72 -0
  104. package/.claude/skills/database-engineering/resources/database-replication.md +63 -0
  105. package/.claude/skills/database-engineering/resources/postgresql-fundamentals.md +70 -0
  106. package/.claude/skills/database-engineering/resources/query-optimization.md +68 -0
  107. package/.claude/skills/devsecops/SKILL.md +374 -0
  108. package/.claude/skills/devsecops/resources/ci-cd-security.md +204 -0
  109. package/.claude/skills/devsecops/resources/compliance-automation.md +530 -0
  110. package/.claude/skills/devsecops/resources/compliance-frameworks.md +2322 -0
  111. package/.claude/skills/devsecops/resources/container-security.md +915 -0
  112. package/.claude/skills/devsecops/resources/cspm-integration.md +1440 -0
  113. package/.claude/skills/devsecops/resources/policy-enforcement.md +619 -0
  114. package/.claude/skills/devsecops/resources/secrets-management.md +755 -0
  115. package/.claude/skills/devsecops/resources/security-monitoring.md +146 -0
  116. package/.claude/skills/devsecops/resources/security-scanning.md +887 -0
  117. package/.claude/skills/devsecops/resources/security-testing.md +203 -0
  118. package/.claude/skills/devsecops/resources/supply-chain-security.md +518 -0
  119. package/.claude/skills/devsecops/resources/vulnerability-management.md +481 -0
  120. package/.claude/skills/devsecops/resources/zero-trust-architecture.md +177 -0
  121. package/.claude/skills/documentation-as-code/SKILL.md +323 -0
  122. package/.claude/skills/documentation-as-code/resources/api-documentation.md +90 -0
  123. package/.claude/skills/documentation-as-code/resources/changelog-management.md +79 -0
  124. package/.claude/skills/documentation-as-code/resources/diagram-generation.md +44 -0
  125. package/.claude/skills/documentation-as-code/resources/docs-as-code-workflow.md +99 -0
  126. package/.claude/skills/documentation-as-code/resources/documentation-automation.md +68 -0
  127. package/.claude/skills/documentation-as-code/resources/documentation-sites.md +79 -0
  128. package/.claude/skills/documentation-as-code/resources/markdown-best-practices.md +162 -0
  129. package/.claude/skills/documentation-as-code/resources/openapi-specification.md +77 -0
  130. package/.claude/skills/documentation-as-code/resources/readme-engineering.md +60 -0
  131. package/.claude/skills/documentation-as-code/resources/technical-writing-guide.md +202 -0
  132. package/.claude/skills/engineering-management/SKILL.md +356 -0
  133. package/.claude/skills/engineering-management/resources/career-ladders.md +609 -0
  134. package/.claude/skills/engineering-management/resources/hiring-and-assessment.md +555 -0
  135. package/.claude/skills/engineering-management/resources/one-on-one-guides.md +609 -0
  136. package/.claude/skills/engineering-management/resources/resource-planning.md +557 -0
  137. package/.claude/skills/engineering-management/resources/team-organization-patterns.md +491 -0
  138. package/.claude/skills/engineering-management/resources/technical-interviews.md +474 -0
  139. package/.claude/skills/engineering-operations-management/SKILL.md +817 -0
  140. package/.claude/skills/error-tracking/SKILL.md +379 -0
  141. package/.claude/skills/frontend-dev-guidelines/SKILL.md +403 -0
  142. package/.claude/skills/frontend-dev-guidelines/resources/common-patterns.md +331 -0
  143. package/.claude/skills/frontend-dev-guidelines/resources/complete-examples.md +872 -0
  144. package/.claude/skills/frontend-dev-guidelines/resources/component-patterns.md +502 -0
  145. package/.claude/skills/frontend-dev-guidelines/resources/data-fetching.md +767 -0
  146. package/.claude/skills/frontend-dev-guidelines/resources/file-organization.md +502 -0
  147. package/.claude/skills/frontend-dev-guidelines/resources/loading-and-error-states.md +501 -0
  148. package/.claude/skills/frontend-dev-guidelines/resources/performance.md +406 -0
  149. package/.claude/skills/frontend-dev-guidelines/resources/routing-guide.md +364 -0
  150. package/.claude/skills/frontend-dev-guidelines/resources/styling-guide.md +428 -0
  151. package/.claude/skills/frontend-dev-guidelines/resources/typescript-standards.md +418 -0
  152. package/.claude/skills/general-it-engineering/SKILL.md +393 -0
  153. package/.claude/skills/general-it-engineering/resources/asset-management.md +712 -0
  154. package/.claude/skills/general-it-engineering/resources/automation-orchestration.md +817 -0
  155. package/.claude/skills/general-it-engineering/resources/business-continuity.md +786 -0
  156. package/.claude/skills/general-it-engineering/resources/change-management.md +715 -0
  157. package/.claude/skills/general-it-engineering/resources/enterprise-monitoring.md +729 -0
  158. package/.claude/skills/general-it-engineering/resources/help-desk-operations.md +738 -0
  159. package/.claude/skills/general-it-engineering/resources/incident-service-management.md +834 -0
  160. package/.claude/skills/general-it-engineering/resources/it-governance.md +753 -0
  161. package/.claude/skills/general-it-engineering/resources/itil-framework.md +503 -0
  162. package/.claude/skills/general-it-engineering/resources/service-management.md +669 -0
  163. package/.claude/skills/infrastructure-architecture/SKILL.md +328 -0
  164. package/.claude/skills/infrastructure-architecture/resources/architecture-decision-records.md +505 -0
  165. package/.claude/skills/infrastructure-architecture/resources/architecture-patterns.md +528 -0
  166. package/.claude/skills/infrastructure-architecture/resources/capacity-planning.md +453 -0
  167. package/.claude/skills/infrastructure-architecture/resources/cleared-environment-architecture.md +773 -0
  168. package/.claude/skills/infrastructure-architecture/resources/cost-architecture.md +499 -0
  169. package/.claude/skills/infrastructure-architecture/resources/data-architecture.md +501 -0
  170. package/.claude/skills/infrastructure-architecture/resources/disaster-recovery.md +535 -0
  171. package/.claude/skills/infrastructure-architecture/resources/migration-architecture.md +512 -0
  172. package/.claude/skills/infrastructure-architecture/resources/multi-region-design.md +608 -0
  173. package/.claude/skills/infrastructure-architecture/resources/reference-architectures.md +562 -0
  174. package/.claude/skills/infrastructure-architecture/resources/security-architecture.md +538 -0
  175. package/.claude/skills/infrastructure-architecture/resources/system-design-principles.md +489 -0
  176. package/.claude/skills/infrastructure-architecture/resources/workload-classification.md +1000 -0
  177. package/.claude/skills/infrastructure-strategy/SKILL.md +924 -0
  178. package/.claude/skills/network-engineering/SKILL.md +385 -0
  179. package/.claude/skills/network-engineering/resources/dns-management.md +738 -0
  180. package/.claude/skills/network-engineering/resources/load-balancing.md +820 -0
  181. package/.claude/skills/network-engineering/resources/network-architecture.md +546 -0
  182. package/.claude/skills/network-engineering/resources/network-security.md +921 -0
  183. package/.claude/skills/network-engineering/resources/network-troubleshooting.md +749 -0
  184. package/.claude/skills/network-engineering/resources/routing-switching.md +373 -0
  185. package/.claude/skills/network-engineering/resources/sdn-networking.md +695 -0
  186. package/.claude/skills/network-engineering/resources/service-mesh-networking.md +777 -0
  187. package/.claude/skills/network-engineering/resources/tcp-ip-protocols.md +444 -0
  188. package/.claude/skills/network-engineering/resources/vpn-connectivity.md +672 -0
  189. package/.claude/skills/observability-engineering/SKILL.md +101 -0
  190. package/.claude/skills/observability-engineering/resources/apm-tools.md +97 -0
  191. package/.claude/skills/observability-engineering/resources/correlation-strategies.md +87 -0
  192. package/.claude/skills/observability-engineering/resources/distributed-tracing.md +98 -0
  193. package/.claude/skills/observability-engineering/resources/logs-aggregation.md +118 -0
  194. package/.claude/skills/observability-engineering/resources/observability-cost-optimization.md +141 -0
  195. package/.claude/skills/observability-engineering/resources/opentelemetry.md +110 -0
  196. package/.claude/skills/platform-engineering/SKILL.md +555 -0
  197. package/.claude/skills/platform-engineering/resources/architecture-overview.md +600 -0
  198. package/.claude/skills/platform-engineering/resources/container-orchestration.md +916 -0
  199. package/.claude/skills/platform-engineering/resources/cost-optimization.md +634 -0
  200. package/.claude/skills/platform-engineering/resources/developer-platforms.md +670 -0
  201. package/.claude/skills/platform-engineering/resources/gitops-automation.md +650 -0
  202. package/.claude/skills/platform-engineering/resources/infrastructure-as-code.md +778 -0
  203. package/.claude/skills/platform-engineering/resources/infrastructure-standards.md +708 -0
  204. package/.claude/skills/platform-engineering/resources/multi-tenancy.md +602 -0
  205. package/.claude/skills/platform-engineering/resources/platform-security.md +711 -0
  206. package/.claude/skills/platform-engineering/resources/resource-management.md +592 -0
  207. package/.claude/skills/platform-engineering/resources/service-mesh.md +628 -0
  208. package/.claude/skills/release-engineering/SKILL.md +393 -0
  209. package/.claude/skills/release-engineering/resources/artifact-management.md +108 -0
  210. package/.claude/skills/release-engineering/resources/build-optimization.md +84 -0
  211. package/.claude/skills/release-engineering/resources/ci-cd-pipelines.md +411 -0
  212. package/.claude/skills/release-engineering/resources/deployment-strategies.md +197 -0
  213. package/.claude/skills/release-engineering/resources/pipeline-security.md +62 -0
  214. package/.claude/skills/release-engineering/resources/progressive-delivery.md +83 -0
  215. package/.claude/skills/release-engineering/resources/release-automation.md +68 -0
  216. package/.claude/skills/release-engineering/resources/release-orchestration.md +77 -0
  217. package/.claude/skills/release-engineering/resources/rollback-strategies.md +66 -0
  218. package/.claude/skills/release-engineering/resources/versioning-strategies.md +59 -0
  219. package/.claude/skills/route-tester/SKILL.md +392 -0
  220. package/.claude/skills/skill-developer/ADVANCED.md +197 -0
  221. package/.claude/skills/skill-developer/HOOK_MECHANISMS.md +306 -0
  222. package/.claude/skills/skill-developer/PATTERNS_LIBRARY.md +152 -0
  223. package/.claude/skills/skill-developer/SKILL.md +430 -0
  224. package/.claude/skills/skill-developer/SKILL_RULES_REFERENCE.md +315 -0
  225. package/.claude/skills/skill-developer/TRIGGER_TYPES.md +305 -0
  226. package/.claude/skills/skill-developer/TROUBLESHOOTING.md +514 -0
  227. package/.claude/skills/skill-rules.json +2940 -0
  228. package/.claude/skills/sre/SKILL.md +464 -0
  229. package/.claude/skills/sre/resources/alerting-best-practices.md +282 -0
  230. package/.claude/skills/sre/resources/capacity-planning.md +226 -0
  231. package/.claude/skills/sre/resources/chaos-engineering.md +193 -0
  232. package/.claude/skills/sre/resources/disaster-recovery.md +232 -0
  233. package/.claude/skills/sre/resources/incident-management.md +436 -0
  234. package/.claude/skills/sre/resources/observability-stack.md +240 -0
  235. package/.claude/skills/sre/resources/on-call-runbooks.md +167 -0
  236. package/.claude/skills/sre/resources/performance-optimization.md +108 -0
  237. package/.claude/skills/sre/resources/reliability-patterns.md +183 -0
  238. package/.claude/skills/sre/resources/slo-sli-sla.md +464 -0
  239. package/.claude/skills/sre/resources/toil-reduction.md +145 -0
  240. package/.claude/skills/systems-engineering/SKILL.md +648 -0
  241. package/.claude/skills/systems-engineering/resources/automation-patterns.md +771 -0
  242. package/.claude/skills/systems-engineering/resources/configuration-management.md +998 -0
  243. package/.claude/skills/systems-engineering/resources/linux-administration.md +672 -0
  244. package/.claude/skills/systems-engineering/resources/networking-fundamentals.md +982 -0
  245. package/.claude/skills/systems-engineering/resources/performance-tuning.md +871 -0
  246. package/.claude/skills/systems-engineering/resources/powershell-scripting.md +482 -0
  247. package/.claude/skills/systems-engineering/resources/security-hardening.md +739 -0
  248. package/.claude/skills/systems-engineering/resources/shell-scripting.md +915 -0
  249. package/.claude/skills/systems-engineering/resources/storage-management.md +628 -0
  250. package/.claude/skills/systems-engineering/resources/system-monitoring.md +787 -0
  251. package/.claude/skills/systems-engineering/resources/troubleshooting-guide.md +753 -0
  252. package/.claude/skills/systems-engineering/resources/windows-administration.md +738 -0
  253. package/.claude/skills/technical-leadership/SKILL.md +728 -0
  254. package/CHANGELOG.md +90 -54
  255. package/README.md +94 -0
  256. package/backend/docs/SECRETS_DOCUMENTATION.md +327 -0
  257. package/backend/jest.config.js +59 -0
  258. package/backend/package-lock.json +6129 -0
  259. package/backend/package.json +16 -4
  260. package/backend/prisma/migrations/20251026104609_add_websocket_api/migration.sql +33 -0
  261. package/backend/prisma/schema.prisma +33 -0
  262. package/backend/src/__tests__/core/DependencyService.test.js +336 -0
  263. package/backend/src/__tests__/core/UserService.test.js +875 -0
  264. package/backend/src/__tests__/repositories/BaseRepository.test.js +146 -0
  265. package/backend/src/__tests__/repositories/BotRepository.test.js +118 -0
  266. package/backend/src/__tests__/repositories/CommandRepository.test.js +132 -0
  267. package/backend/src/__tests__/repositories/EventGraphRepository.test.js +93 -0
  268. package/backend/src/__tests__/repositories/GroupRepository.test.js +155 -0
  269. package/backend/src/__tests__/repositories/PermissionRepository.test.js +130 -0
  270. package/backend/src/__tests__/repositories/PluginRepository.test.js +107 -0
  271. package/backend/src/__tests__/repositories/ServerRepository.test.js +80 -0
  272. package/backend/src/__tests__/repositories/UserRepository.test.js +128 -0
  273. package/backend/src/__tests__/secretsFilter.test.js +425 -0
  274. package/backend/src/__tests__/services/BotLifecycleService.test.js +411 -0
  275. package/backend/src/__tests__/services/BotProcessManager.test.js +285 -0
  276. package/backend/src/__tests__/services/CacheManager.test.js +125 -0
  277. package/backend/src/__tests__/services/CommandExecutionService.test.js +460 -0
  278. package/backend/src/__tests__/services/ResourceMonitorService.test.js +207 -0
  279. package/backend/src/__tests__/services/TelemetryService.test.js +291 -0
  280. package/backend/src/__tests__/setup.js +25 -0
  281. package/backend/src/api/routes/apiKeys.js +181 -0
  282. package/backend/src/api/routes/bots.js +49 -7
  283. package/backend/src/api/routes/plugins.js +2 -1
  284. package/backend/src/api/routes/system.js +174 -0
  285. package/backend/src/container.js +82 -0
  286. package/backend/src/core/BotManager.js +142 -871
  287. package/backend/src/core/BotManager.old.js +1093 -0
  288. package/backend/src/core/BotProcess.js +1092 -858
  289. package/backend/src/core/EventGraphManager.js +280 -198
  290. package/backend/src/core/GraphExecutionEngine.js +321 -325
  291. package/backend/src/core/MessageQueue.js +27 -6
  292. package/backend/src/core/NodeRegistry.js +37 -1134
  293. package/backend/src/core/PluginManager.js +62 -12
  294. package/backend/src/core/PrismaService.js +32 -0
  295. package/backend/src/core/UserService.js +3 -3
  296. package/backend/src/core/__tests__/PrismaService.test.js +24 -0
  297. package/backend/src/core/commands/README.md +305 -0
  298. package/backend/src/core/commands/dev.js +13 -7
  299. package/backend/src/core/commands/ping.js +10 -4
  300. package/backend/src/core/commands/whois.js +63 -0
  301. package/backend/src/core/config/validation.js +27 -0
  302. package/backend/src/core/constants/graphTypes.js +21 -0
  303. package/backend/src/core/node-registries/actions.js +132 -0
  304. package/backend/src/core/node-registries/arrays.js +137 -0
  305. package/backend/src/core/node-registries/bot.js +23 -0
  306. package/backend/src/core/node-registries/data.js +290 -0
  307. package/backend/src/core/node-registries/debug.js +26 -0
  308. package/backend/src/core/node-registries/events.js +187 -0
  309. package/backend/src/core/node-registries/flow.js +139 -0
  310. package/backend/src/core/node-registries/logic.js +45 -0
  311. package/backend/src/core/node-registries/math.js +42 -0
  312. package/backend/src/core/node-registries/objects.js +98 -0
  313. package/backend/src/core/node-registries/strings.js +153 -0
  314. package/backend/src/core/node-registries/time.js +113 -0
  315. package/backend/src/core/node-registries/users.js +79 -0
  316. package/backend/src/core/nodes/{action_bot_look_at.js → actions/bot_look_at.js} +36 -36
  317. package/backend/src/core/nodes/{action_bot_set_variable.js → actions/bot_set_variable.js} +32 -32
  318. package/backend/src/core/nodes/{action_send_log.js → actions/send_log.js} +28 -23
  319. package/backend/src/core/nodes/{action_send_message.js → actions/send_message.js} +32 -32
  320. package/backend/src/core/nodes/actions/send_websocket_response.js +33 -0
  321. package/backend/src/core/nodes/arrays/get_next.js +35 -0
  322. package/backend/src/core/nodes/{data_cast.js → data/cast.js} +8 -0
  323. package/backend/src/core/nodes/data/datetime_literal.js +27 -0
  324. package/backend/src/core/nodes/data/entity_info.js +69 -0
  325. package/backend/src/core/nodes/data/get_nearby_entities.js +32 -0
  326. package/backend/src/core/nodes/data/get_nearby_players.js +64 -0
  327. package/backend/src/core/nodes/{data_get_user_field.js → data/get_user_field.js} +1 -1
  328. package/backend/src/core/nodes/data/type_check.js +53 -0
  329. package/backend/src/core/nodes/{debug_log.js → debug/log.js} +16 -16
  330. package/backend/src/core/nodes/{flow_branch.js → flow/branch.js} +15 -15
  331. package/backend/src/core/nodes/{flow_break.js → flow/break.js} +14 -14
  332. package/backend/src/core/nodes/flow/delay.js +43 -0
  333. package/backend/src/core/nodes/{flow_for_each.js → flow/for_each.js} +39 -39
  334. package/backend/src/core/nodes/{flow_sequence.js → flow/sequence.js} +16 -16
  335. package/backend/src/core/nodes/{flow_switch.js → flow/switch.js} +47 -47
  336. package/backend/src/core/nodes/{flow_while.js → flow/while.js} +1 -1
  337. package/backend/src/core/nodes/logic/__tests__/compare.test.js +83 -0
  338. package/backend/src/core/nodes/math/__tests__/operation.test.js +65 -0
  339. package/backend/src/core/nodes/strings/__tests__/concat.test.js +89 -0
  340. package/backend/src/core/nodes/time/__tests__/now.test.js +24 -0
  341. package/backend/src/core/nodes/time/add.js +33 -0
  342. package/backend/src/core/nodes/time/compare.js +35 -0
  343. package/backend/src/core/nodes/time/diff.js +29 -0
  344. package/backend/src/core/nodes/time/format.js +32 -0
  345. package/backend/src/core/nodes/time/now.js +18 -0
  346. package/backend/src/core/nodes/{user_check_blacklist.js → users/check_blacklist.js} +37 -37
  347. package/backend/src/core/nodes/{user_get_groups.js → users/get_groups.js} +36 -36
  348. package/backend/src/core/nodes/{user_get_permissions.js → users/get_permissions.js} +36 -36
  349. package/backend/src/core/nodes/{user_set_blacklist.js → users/set_blacklist.js} +37 -37
  350. package/backend/src/core/services/BotLifecycleService.js +596 -0
  351. package/backend/src/core/services/BotProcessManager.js +163 -0
  352. package/backend/src/core/services/CacheManager.js +111 -0
  353. package/backend/src/core/services/CommandExecutionService.js +351 -0
  354. package/backend/src/core/services/ResourceMonitorService.js +90 -0
  355. package/backend/src/core/services/TelemetryService.js +124 -0
  356. package/backend/src/core/services/ValidationService.js +132 -0
  357. package/backend/src/core/services/__tests__/ValidationService.test.js +148 -0
  358. package/backend/src/core/services.js +20 -5
  359. package/backend/src/core/system/CommandContext.js +84 -0
  360. package/backend/src/core/system/Transport.js +78 -0
  361. package/backend/src/core/utils/__tests__/jsonParser.test.js +44 -0
  362. package/backend/src/core/utils/jsonParser.js +18 -0
  363. package/backend/src/core/utils/secretsFilter.js +262 -0
  364. package/backend/src/core/utils/variableParser.js +89 -0
  365. package/backend/src/core/validation/__tests__/nodeSchemas.test.js +175 -0
  366. package/backend/src/core/validation/nodeSchemas.js +112 -0
  367. package/backend/src/lib/prisma.js +2 -4
  368. package/backend/src/real-time/botApi/handlers/commandHandlers.js +28 -0
  369. package/backend/src/real-time/botApi/handlers/graphHandlers.js +99 -0
  370. package/backend/src/real-time/botApi/handlers/graphWebSocketHandlers.js +147 -0
  371. package/backend/src/real-time/botApi/handlers/index.js +43 -0
  372. package/backend/src/real-time/botApi/handlers/messageHandlers.js +66 -0
  373. package/backend/src/real-time/botApi/handlers/statusHandlers.js +17 -0
  374. package/backend/src/real-time/botApi/handlers/userHandlers.js +141 -0
  375. package/backend/src/real-time/botApi/index.js +40 -0
  376. package/backend/src/real-time/botApi/middleware.js +79 -0
  377. package/backend/src/real-time/botApi/utils.js +54 -0
  378. package/backend/src/real-time/socketHandler.js +6 -2
  379. package/backend/src/repositories/BaseRepository.js +43 -0
  380. package/backend/src/repositories/BotRepository.js +42 -0
  381. package/backend/src/repositories/CommandRepository.js +53 -0
  382. package/backend/src/repositories/EventGraphRepository.js +40 -0
  383. package/backend/src/repositories/GroupRepository.js +69 -0
  384. package/backend/src/repositories/PermissionRepository.js +48 -0
  385. package/backend/src/repositories/PluginRepository.js +42 -0
  386. package/backend/src/repositories/ServerRepository.js +27 -0
  387. package/backend/src/repositories/UserRepository.js +48 -0
  388. package/backend/src/server.js +3 -0
  389. package/backend/src/test-refactor.js +85 -0
  390. package/frontend/dist/assets/index-CfTo92bP.css +1 -0
  391. package/frontend/dist/assets/index-CiFD5X9Z.js +8344 -0
  392. package/frontend/dist/index.html +2 -2
  393. package/frontend/package.json +0 -5
  394. package/package.json +2 -1
  395. package/frontend/dist/assets/index-B9GedHEa.js +0 -8352
  396. package/frontend/dist/assets/index-zLiy9MDx.css +0 -1
  397. package/nul +0 -0
  398. /package/backend/src/core/nodes/{action_http_request.js → actions/http_request.js} +0 -0
  399. /package/backend/src/core/nodes/{array_add_element.js → arrays/add_element.js} +0 -0
  400. /package/backend/src/core/nodes/{array_contains.js → arrays/contains.js} +0 -0
  401. /package/backend/src/core/nodes/{array_find_index.js → arrays/find_index.js} +0 -0
  402. /package/backend/src/core/nodes/{array_get_by_index.js → arrays/get_by_index.js} +0 -0
  403. /package/backend/src/core/nodes/{array_get_random_element.js → arrays/get_random_element.js} +0 -0
  404. /package/backend/src/core/nodes/{array_remove_by_index.js → arrays/remove_by_index.js} +0 -0
  405. /package/backend/src/core/nodes/{bot_get_position.js → bot/get_position.js} +0 -0
  406. /package/backend/src/core/nodes/{data_array_literal.js → data/array_literal.js} +0 -0
  407. /package/backend/src/core/nodes/{data_boolean_literal.js → data/boolean_literal.js} +0 -0
  408. /package/backend/src/core/nodes/{data_get_argument.js → data/get_argument.js} +0 -0
  409. /package/backend/src/core/nodes/{data_get_bot_look.js → data/get_bot_look.js} +0 -0
  410. /package/backend/src/core/nodes/{data_get_entity_field.js → data/get_entity_field.js} +0 -0
  411. /package/backend/src/core/nodes/{data_get_server_players.js → data/get_server_players.js} +0 -0
  412. /package/backend/src/core/nodes/{data_get_variable.js → data/get_variable.js} +0 -0
  413. /package/backend/src/core/nodes/{data_length.js → data/length.js} +0 -0
  414. /package/backend/src/core/nodes/{data_make_object.js → data/make_object.js} +0 -0
  415. /package/backend/src/core/nodes/{data_number_literal.js → data/number_literal.js} +0 -0
  416. /package/backend/src/core/nodes/{data_string_literal.js → data/string_literal.js} +0 -0
  417. /package/backend/src/core/nodes/{logic_compare.js → logic/compare.js} +0 -0
  418. /package/backend/src/core/nodes/{logic_operation.js → logic/operation.js} +0 -0
  419. /package/backend/src/core/nodes/{math_operation.js → math/operation.js} +0 -0
  420. /package/backend/src/core/nodes/{math_random_number.js → math/random_number.js} +0 -0
  421. /package/backend/src/core/nodes/{object_create.js → objects/create.js} +0 -0
  422. /package/backend/src/core/nodes/{object_delete.js → objects/delete.js} +0 -0
  423. /package/backend/src/core/nodes/{object_get.js → objects/get.js} +0 -0
  424. /package/backend/src/core/nodes/{object_has_key.js → objects/has_key.js} +0 -0
  425. /package/backend/src/core/nodes/{object_set.js → objects/set.js} +0 -0
  426. /package/backend/src/core/nodes/{string_concat.js → strings/concat.js} +0 -0
  427. /package/backend/src/core/nodes/{string_contains.js → strings/contains.js} +0 -0
  428. /package/backend/src/core/nodes/{string_ends_with.js → strings/ends_with.js} +0 -0
  429. /package/backend/src/core/nodes/{string_equals.js → strings/equals.js} +0 -0
  430. /package/backend/src/core/nodes/{string_length.js → strings/length.js} +0 -0
  431. /package/backend/src/core/nodes/{string_matches.js → strings/matches.js} +0 -0
  432. /package/backend/src/core/nodes/{string_split.js → strings/split.js} +0 -0
  433. /package/backend/src/core/nodes/{string_starts_with.js → strings/starts_with.js} +0 -0
@@ -0,0 +1,820 @@
1
+ # Cloud Migration Strategies
2
+
3
+ Comprehensive guide to cloud migration approaches, patterns, and best practices for moving workloads to AWS, Azure, and GCP.
4
+
5
+ ## The 6 R's of Migration
6
+
7
+ ```
8
+ ┌─────────────────────────────────────────────────────────────┐
9
+ │ Migration Strategies │
10
+ ├──────────────┬──────────────┬──────────────┬────────────────┤
11
+ │ Rehost │ Replatform │ Refactor │ Repurchase │
12
+ │ "Lift & Shift"│ "Lift, Tinker│ "Re-architect│ "Drop & Shop" │
13
+ │ │ & Shift" │ │ │
14
+ │ Fastest │ Balanced │ Most Value │ Strategic │
15
+ │ Least Cost │ Moderate │ Highest Cost│ Vendor Lock │
16
+ ├──────────────┼──────────────┼──────────────┼────────────────┤
17
+ │ Retire │ Retain │ │ │
18
+ │ "Decommission"│ "Keep as-is" │ │ │
19
+ │ │ │ │ │
20
+ │ Cost Savings │ No Change │ │ │
21
+ └──────────────┴──────────────┴──────────────┴────────────────┘
22
+ ```
23
+
24
+ ### 1. Rehost (Lift and Shift)
25
+
26
+ **When to Use:**
27
+ - Quick migration needed
28
+ - Minimal application changes
29
+ - Legacy applications
30
+ - Limited cloud expertise
31
+ - Tight timeline
32
+
33
+ **AWS Migration:**
34
+ ```hcl
35
+ # AWS Application Migration Service (MGN)
36
+ resource "aws_mgn_replication_configuration_template" "default" {
37
+ associate_default_security_group = false
38
+ bandwidth_throttling = 0
39
+ create_public_ip = false
40
+ data_plane_routing = "PRIVATE_IP"
41
+ default_large_staging_disk_type = "GP3"
42
+ ebs_encryption = "DEFAULT"
43
+ replication_server_instance_type = "t3.small"
44
+ replication_servers_security_groups_ids = [aws_security_group.replication.id]
45
+ staging_area_subnet_id = aws_subnet.private[0].id
46
+ staging_area_tags = {
47
+ Environment = "migration"
48
+ }
49
+ use_dedicated_replication_server = false
50
+ }
51
+
52
+ # Launch template for migrated instances
53
+ resource "aws_launch_template" "migrated_app" {
54
+ name = "migrated-app-template"
55
+
56
+ block_device_mappings {
57
+ device_name = "/dev/sda1"
58
+
59
+ ebs {
60
+ volume_size = 100
61
+ volume_type = "gp3"
62
+ encrypted = true
63
+ kms_key_id = aws_kms_key.main.arn
64
+ delete_on_termination = true
65
+ }
66
+ }
67
+
68
+ iam_instance_profile {
69
+ arn = aws_iam_instance_profile.app.arn
70
+ }
71
+
72
+ network_interfaces {
73
+ associate_public_ip_address = false
74
+ security_groups = [aws_security_group.app.id]
75
+ subnet_id = aws_subnet.private_app[0].id
76
+ }
77
+
78
+ tag_specifications {
79
+ resource_type = "instance"
80
+ tags = {
81
+ Name = "migrated-app"
82
+ Environment = "production"
83
+ Migration = "rehost"
84
+ }
85
+ }
86
+
87
+ user_data = base64encode(<<-EOF
88
+ #!/bin/bash
89
+ # Post-migration configuration
90
+ systemctl enable cloudwatch-agent
91
+ systemctl start cloudwatch-agent
92
+ EOF
93
+ )
94
+ }
95
+ ```
96
+
97
+ **Azure Migrate:**
98
+ ```hcl
99
+ resource "azurerm_site_recovery_replication_policy" "main" {
100
+ name = "migration-policy"
101
+ resource_group_name = azurerm_resource_group.recovery.name
102
+ recovery_vault_name = azurerm_recovery_services_vault.main.name
103
+ recovery_point_retention_in_minutes = 24 * 60
104
+ application_consistent_snapshot_frequency_in_minutes = 4 * 60
105
+ }
106
+
107
+ resource "azurerm_site_recovery_protection_container_mapping" "main" {
108
+ name = "migration-mapping"
109
+ resource_group_name = azurerm_resource_group.recovery.name
110
+ recovery_vault_name = azurerm_recovery_services_vault.main.name
111
+ recovery_fabric_name = azurerm_site_recovery_fabric.primary.name
112
+ recovery_source_protection_container_name = azurerm_site_recovery_protection_container.primary.name
113
+ recovery_target_protection_container_id = azurerm_site_recovery_protection_container.secondary.id
114
+ recovery_replication_policy_id = azurerm_site_recovery_replication_policy.main.id
115
+ }
116
+ ```
117
+
118
+ ### 2. Replatform (Lift, Tinker, and Shift)
119
+
120
+ **When to Use:**
121
+ - Want cloud benefits without full refactoring
122
+ - Database migrations to managed services
123
+ - Minor optimizations acceptable
124
+ - Balance between speed and benefit
125
+
126
+ **Database Migration Example:**
127
+ ```hcl
128
+ # AWS Database Migration Service
129
+ resource "aws_dms_replication_instance" "main" {
130
+ replication_instance_id = "db-migration-instance"
131
+ replication_instance_class = "dms.c5.xlarge"
132
+ allocated_storage = 100
133
+ vpc_security_group_ids = [aws_security_group.dms.id]
134
+ replication_subnet_group_id = aws_dms_replication_subnet_group.main.id
135
+ publicly_accessible = false
136
+ multi_az = true
137
+
138
+ tags = {
139
+ Name = "database-migration"
140
+ }
141
+ }
142
+
143
+ # Source endpoint (on-premises PostgreSQL)
144
+ resource "aws_dms_endpoint" "source" {
145
+ endpoint_id = "source-postgres"
146
+ endpoint_type = "source"
147
+ engine_name = "postgres"
148
+ server_name = var.onprem_db_host
149
+ port = 5432
150
+ database_name = "production"
151
+ username = var.db_username
152
+ password = var.db_password
153
+ ssl_mode = "require"
154
+
155
+ tags = {
156
+ Name = "source-database"
157
+ }
158
+ }
159
+
160
+ # Target endpoint (RDS)
161
+ resource "aws_dms_endpoint" "target" {
162
+ endpoint_id = "target-rds"
163
+ endpoint_type = "target"
164
+ engine_name = "postgres"
165
+ server_name = aws_db_instance.main.address
166
+ port = 5432
167
+ database_name = "production"
168
+ username = var.rds_username
169
+ password = var.rds_password
170
+ ssl_mode = "require"
171
+
172
+ tags = {
173
+ Name = "target-database"
174
+ }
175
+ }
176
+
177
+ # Migration task
178
+ resource "aws_dms_replication_task" "main" {
179
+ migration_type = "full-load-and-cdc"
180
+ replication_instance_arn = aws_dms_replication_instance.main.replication_instance_arn
181
+ replication_task_id = "postgres-migration"
182
+ source_endpoint_arn = aws_dms_endpoint.source.endpoint_arn
183
+ target_endpoint_arn = aws_dms_endpoint.target.endpoint_arn
184
+ table_mappings = jsonencode({
185
+ rules = [
186
+ {
187
+ rule-type = "selection"
188
+ rule-id = "1"
189
+ rule-name = "1"
190
+ object-locator = {
191
+ schema-name = "public"
192
+ table-name = "%"
193
+ }
194
+ rule-action = "include"
195
+ }
196
+ ]
197
+ })
198
+
199
+ tags = {
200
+ Name = "postgres-migration-task"
201
+ }
202
+ }
203
+
204
+ # Target RDS instance
205
+ resource "aws_db_instance" "main" {
206
+ identifier = "migrated-database"
207
+ engine = "postgres"
208
+ engine_version = "14.7"
209
+ instance_class = "db.r6g.xlarge"
210
+
211
+ allocated_storage = 100
212
+ storage_type = "gp3"
213
+ storage_encrypted = true
214
+ kms_key_id = aws_kms_key.rds.arn
215
+
216
+ db_name = "production"
217
+ username = var.rds_username
218
+ password = var.rds_password
219
+
220
+ multi_az = true
221
+ db_subnet_group_name = aws_db_subnet_group.main.name
222
+ vpc_security_group_ids = [aws_security_group.rds.id]
223
+
224
+ backup_retention_period = 7
225
+ backup_window = "03:00-04:00"
226
+ maintenance_window = "sun:04:00-sun:05:00"
227
+
228
+ enabled_cloudwatch_logs_exports = ["postgresql", "upgrade"]
229
+
230
+ tags = {
231
+ Name = "migrated-database"
232
+ Migration = "replatform"
233
+ }
234
+ }
235
+ ```
236
+
237
+ ### 3. Refactor (Re-architect)
238
+
239
+ **When to Use:**
240
+ - Modernize applications
241
+ - Need cloud-native features
242
+ - Improve scalability and resilience
243
+ - Long-term investment
244
+
245
+ **Monolith to Microservices:**
246
+ ```hcl
247
+ # ECS Cluster for microservices
248
+ resource "aws_ecs_cluster" "main" {
249
+ name = "microservices-cluster"
250
+
251
+ setting {
252
+ name = "containerInsights"
253
+ value = "enabled"
254
+ }
255
+
256
+ configuration {
257
+ execute_command_configuration {
258
+ logging = "OVERRIDE"
259
+
260
+ log_configuration {
261
+ cloud_watch_log_group_name = aws_cloudwatch_log_group.ecs.name
262
+ }
263
+ }
264
+ }
265
+ }
266
+
267
+ # Service Discovery
268
+ resource "aws_service_discovery_private_dns_namespace" "main" {
269
+ name = "services.local"
270
+ vpc = aws_vpc.main.id
271
+ }
272
+
273
+ # Microservice: User Service
274
+ module "user_service" {
275
+ source = "./modules/microservice"
276
+
277
+ name = "user-service"
278
+ cluster_id = aws_ecs_cluster.main.id
279
+ image = "user-service:latest"
280
+ cpu = 512
281
+ memory = 1024
282
+ desired_count = 3
283
+
284
+ environment = [
285
+ {
286
+ name = "DB_HOST"
287
+ value = aws_db_instance.users.endpoint
288
+ }
289
+ ]
290
+
291
+ secrets = [
292
+ {
293
+ name = "DB_PASSWORD"
294
+ valueFrom = aws_secretsmanager_secret.user_db_password.arn
295
+ }
296
+ ]
297
+
298
+ service_discovery_namespace_id = aws_service_discovery_private_dns_namespace.main.id
299
+ vpc_id = aws_vpc.main.id
300
+ subnet_ids = aws_subnet.private_app[*].id
301
+ security_group_ids = [aws_security_group.user_service.id]
302
+ }
303
+
304
+ # API Gateway for microservices
305
+ resource "aws_api_gateway_rest_api" "main" {
306
+ name = "microservices-api"
307
+ description = "API Gateway for microservices"
308
+
309
+ endpoint_configuration {
310
+ types = ["REGIONAL"]
311
+ }
312
+ }
313
+
314
+ # VPC Link for private integration
315
+ resource "aws_api_gateway_vpc_link" "main" {
316
+ name = "microservices-vpc-link"
317
+ target_arns = [aws_lb.internal.arn]
318
+ }
319
+ ```
320
+
321
+ **Serverless Refactor:**
322
+ ```yaml
323
+ # AWS SAM template for serverless migration
324
+ AWSTemplateFormatVersion: '2010-09-09'
325
+ Transform: AWS::Serverless-2016-10-31
326
+
327
+ Globals:
328
+ Function:
329
+ Runtime: python3.11
330
+ Timeout: 30
331
+ MemorySize: 256
332
+ Environment:
333
+ Variables:
334
+ TABLE_NAME: !Ref DynamoDBTable
335
+ QUEUE_URL: !Ref ProcessingQueue
336
+
337
+ Resources:
338
+ # API Gateway
339
+ ApiGateway:
340
+ Type: AWS::Serverless::Api
341
+ Properties:
342
+ StageName: prod
343
+ Auth:
344
+ DefaultAuthorizer: CognitoAuthorizer
345
+ Authorizers:
346
+ CognitoAuthorizer:
347
+ UserPoolArn: !GetAtt UserPool.Arn
348
+
349
+ # Lambda: API Handler
350
+ ApiFunction:
351
+ Type: AWS::Serverless::Function
352
+ Properties:
353
+ CodeUri: functions/api/
354
+ Handler: app.handler
355
+ Events:
356
+ GetResource:
357
+ Type: Api
358
+ Properties:
359
+ RestApiId: !Ref ApiGateway
360
+ Path: /resources/{id}
361
+ Method: GET
362
+ Policies:
363
+ - DynamoDBReadPolicy:
364
+ TableName: !Ref DynamoDBTable
365
+
366
+ # Lambda: Async Processing
367
+ ProcessorFunction:
368
+ Type: AWS::Serverless::Function
369
+ Properties:
370
+ CodeUri: functions/processor/
371
+ Handler: app.handler
372
+ Events:
373
+ SQSEvent:
374
+ Type: SQS
375
+ Properties:
376
+ Queue: !GetAtt ProcessingQueue.Arn
377
+ BatchSize: 10
378
+ Policies:
379
+ - DynamoDBCrudPolicy:
380
+ TableName: !Ref DynamoDBTable
381
+ - S3CrudPolicy:
382
+ BucketName: !Ref DataBucket
383
+
384
+ # DynamoDB Table
385
+ DynamoDBTable:
386
+ Type: AWS::DynamoDB::Table
387
+ Properties:
388
+ BillingMode: PAY_PER_REQUEST
389
+ AttributeDefinitions:
390
+ - AttributeName: id
391
+ AttributeType: S
392
+ KeySchema:
393
+ - AttributeName: id
394
+ KeyType: HASH
395
+ StreamSpecification:
396
+ StreamViewType: NEW_AND_OLD_IMAGES
397
+
398
+ # SQS Queue
399
+ ProcessingQueue:
400
+ Type: AWS::SQS::Queue
401
+ Properties:
402
+ VisibilityTimeout: 180
403
+ MessageRetentionPeriod: 1209600
404
+ RedrivePolicy:
405
+ deadLetterTargetArn: !GetAtt DeadLetterQueue.Arn
406
+ maxReceiveCount: 3
407
+
408
+ DeadLetterQueue:
409
+ Type: AWS::SQS::Queue
410
+ Properties:
411
+ MessageRetentionPeriod: 1209600
412
+ ```
413
+
414
+ ### 4. Repurchase (Drop and Shop)
415
+
416
+ **When to Use:**
417
+ - Moving to SaaS solutions
418
+ - Legacy system replacement
419
+ - Cost-effective alternative exists
420
+ - Avoid maintaining custom software
421
+
422
+ **Migration to SaaS:**
423
+ ```
424
+ On-Premises CRM → Salesforce
425
+ Self-hosted Email → Office 365 / Google Workspace
426
+ Custom HR System → Workday
427
+ On-prem Analytics → Snowflake / Databricks
428
+ ```
429
+
430
+ ### 5. Retire
431
+
432
+ **Decommission unused applications:**
433
+ ```bash
434
+ #!/bin/bash
435
+ # Application retirement checklist
436
+
437
+ # 1. Identify unused applications
438
+ echo "Analyzing application usage..."
439
+ aws cloudwatch get-metric-statistics \
440
+ --namespace AWS/ApplicationELB \
441
+ --metric-name RequestCount \
442
+ --dimensions Name=LoadBalancer,Value=app-alb \
443
+ --start-time $(date -u -d '30 days ago' +%Y-%m-%dT%H:%M:%S) \
444
+ --end-time $(date -u +%Y-%m-%dT%H:%M:%S) \
445
+ --period 86400 \
446
+ --statistics Sum
447
+
448
+ # 2. Archive data if needed
449
+ echo "Archiving application data..."
450
+ aws s3 sync s3://app-bucket/ s3://archive-bucket/app-$(date +%Y%m%d)/ \
451
+ --storage-class GLACIER_DEEP_ARCHIVE
452
+
453
+ # 3. Document retirement
454
+ echo "Creating retirement documentation..."
455
+ cat > retirement-report.md <<EOF
456
+ # Application Retirement: Legacy App
457
+
458
+ **Date:** $(date)
459
+ **Reason:** No usage in 90 days
460
+ **Data Archived:** s3://archive-bucket/app-$(date +%Y%m%d)/
461
+ **Annual Savings:** \$50,000
462
+
463
+ ## Decommissioned Resources:
464
+ - EC2 instances: 5
465
+ - RDS database: 1
466
+ - S3 buckets: 3
467
+ - Load balancer: 1
468
+ EOF
469
+
470
+ # 4. Shutdown resources
471
+ echo "Shutting down resources..."
472
+ # (Would use Terraform destroy in practice)
473
+ ```
474
+
475
+ ### 6. Retain
476
+
477
+ **Reasons to retain on-premises:**
478
+ - Regulatory requirements
479
+ - Data sovereignty
480
+ - Performance-sensitive applications
481
+ - Migration not yet justified
482
+
483
+ ## Migration Assessment
484
+
485
+ ### Discovery and Assessment
486
+
487
+ **AWS Migration Hub:**
488
+ ```hcl
489
+ # Migration Hub configuration
490
+ resource "aws_migrationhub_home_region_control" "main" {
491
+ home_region = "us-east-1"
492
+ }
493
+
494
+ # Discovery connector
495
+ data "aws_ssm_parameter" "discovery_agent" {
496
+ name = "/aws/service/migration-hub/discovery-agent/latest/linux/amd64"
497
+ }
498
+
499
+ # Application groups
500
+ resource "aws_applicationinsights_application" "main" {
501
+ resource_group_name = aws_resourcegroups_group.migration.name
502
+ auto_config_enabled = true
503
+ }
504
+
505
+ resource "aws_resourcegroups_group" "migration" {
506
+ name = "migration-wave-1"
507
+
508
+ resource_query {
509
+ query = jsonencode({
510
+ ResourceTypeFilters = ["AWS::EC2::Instance", "AWS::RDS::DBInstance"]
511
+ TagFilters = [
512
+ {
513
+ Key = "MigrationWave"
514
+ Values = ["1"]
515
+ }
516
+ ]
517
+ })
518
+ }
519
+ }
520
+ ```
521
+
522
+ **Assessment Script:**
523
+ ```python
524
+ #!/usr/bin/env python3
525
+ """
526
+ Cloud migration assessment tool
527
+ Analyzes on-premises infrastructure for cloud readiness
528
+ """
529
+
530
+ import json
531
+ from typing import Dict, List
532
+
533
+ class MigrationAssessment:
534
+ def __init__(self):
535
+ self.inventory = []
536
+ self.recommendations = []
537
+
538
+ def assess_application(self, app_config: Dict) -> Dict:
539
+ """Assess application for migration strategy"""
540
+
541
+ assessment = {
542
+ 'name': app_config['name'],
543
+ 'current_state': app_config['infrastructure'],
544
+ 'recommended_strategy': None,
545
+ 'target_services': [],
546
+ 'estimated_cost': 0,
547
+ 'complexity': 'medium',
548
+ 'migration_time': '3-6 months'
549
+ }
550
+
551
+ # Assess based on criteria
552
+ if app_config.get('custom_code', False):
553
+ if app_config.get('cloud_native_compatible', False):
554
+ assessment['recommended_strategy'] = 'refactor'
555
+ assessment['target_services'] = [
556
+ 'ECS Fargate',
557
+ 'RDS',
558
+ 'ElastiCache'
559
+ ]
560
+ assessment['complexity'] = 'high'
561
+ else:
562
+ assessment['recommended_strategy'] = 'rehost'
563
+ assessment['target_services'] = ['EC2', 'EBS']
564
+ assessment['complexity'] = 'low'
565
+ else:
566
+ assessment['recommended_strategy'] = 'repurchase'
567
+ assessment['target_services'] = ['SaaS alternative']
568
+
569
+ # Calculate costs
570
+ assessment['estimated_cost'] = self._estimate_cost(
571
+ assessment['target_services'],
572
+ app_config.get('usage_pattern', {})
573
+ )
574
+
575
+ return assessment
576
+
577
+ def _estimate_cost(self, services: List[str], usage: Dict) -> float:
578
+ """Estimate monthly cloud cost"""
579
+ cost_map = {
580
+ 'EC2': 100,
581
+ 'ECS Fargate': 150,
582
+ 'RDS': 200,
583
+ 'ElastiCache': 50,
584
+ 'Lambda': 20
585
+ }
586
+
587
+ total = sum(cost_map.get(svc, 0) for svc in services)
588
+ return total * usage.get('multiplier', 1.0)
589
+
590
+ def generate_migration_plan(self) -> Dict:
591
+ """Generate phased migration plan"""
592
+ return {
593
+ 'phases': [
594
+ {
595
+ 'name': 'Wave 1: Low-risk Applications',
596
+ 'strategy': 'rehost',
597
+ 'duration': '1-2 months',
598
+ 'applications': ['static-website', 'internal-tools']
599
+ },
600
+ {
601
+ 'name': 'Wave 2: Databases',
602
+ 'strategy': 'replatform',
603
+ 'duration': '2-3 months',
604
+ 'applications': ['customer-db', 'analytics-db']
605
+ },
606
+ {
607
+ 'name': 'Wave 3: Core Applications',
608
+ 'strategy': 'refactor',
609
+ 'duration': '6-9 months',
610
+ 'applications': ['api-service', 'web-app']
611
+ }
612
+ ],
613
+ 'total_duration': '9-14 months',
614
+ 'estimated_cost': 500000
615
+ }
616
+
617
+ # Example usage
618
+ if __name__ == '__main__':
619
+ assessment = MigrationAssessment()
620
+
621
+ app = {
622
+ 'name': 'Customer Portal',
623
+ 'infrastructure': {
624
+ 'servers': 5,
625
+ 'databases': 2,
626
+ 'storage_tb': 10
627
+ },
628
+ 'custom_code': True,
629
+ 'cloud_native_compatible': True,
630
+ 'usage_pattern': {'multiplier': 1.5}
631
+ }
632
+
633
+ result = assessment.assess_application(app)
634
+ print(json.dumps(result, indent=2))
635
+
636
+ plan = assessment.generate_migration_plan()
637
+ print(json.dumps(plan, indent=2))
638
+ ```
639
+
640
+ ## Cutover Planning
641
+
642
+ ### Zero-Downtime Migration
643
+
644
+ **Blue-Green Deployment:**
645
+ ```hcl
646
+ # Route 53 weighted routing for cutover
647
+ resource "aws_route53_record" "app" {
648
+ zone_id = aws_route53_zone.main.zone_id
649
+ name = "app.example.com"
650
+ type = "A"
651
+
652
+ weighted_routing_policy {
653
+ weight = var.blue_weight # Start: 100, End: 0
654
+ }
655
+
656
+ set_identifier = "blue-environment"
657
+
658
+ alias {
659
+ name = aws_lb.blue.dns_name
660
+ zone_id = aws_lb.blue.zone_id
661
+ evaluate_target_health = true
662
+ }
663
+ }
664
+
665
+ resource "aws_route53_record" "app_green" {
666
+ zone_id = aws_route53_zone.main.zone_id
667
+ name = "app.example.com"
668
+ type = "A"
669
+
670
+ weighted_routing_policy {
671
+ weight = var.green_weight # Start: 0, End: 100
672
+ }
673
+
674
+ set_identifier = "green-environment"
675
+
676
+ alias {
677
+ name = aws_lb.green.dns_name
678
+ zone_id = aws_lb.green.zone_id
679
+ evaluate_target_health = true
680
+ }
681
+ }
682
+ ```
683
+
684
+ **Database Cutover Script:**
685
+ ```bash
686
+ #!/bin/bash
687
+ set -euo pipefail
688
+
689
+ echo "=== Database Migration Cutover ==="
690
+
691
+ # 1. Final sync
692
+ echo "Performing final replication sync..."
693
+ aws dms start-replication-task \
694
+ --replication-task-arn "$TASK_ARN" \
695
+ --start-replication-task-type reload-target
696
+
697
+ # 2. Monitor lag
698
+ echo "Monitoring replication lag..."
699
+ while true; do
700
+ LAG=$(aws dms describe-replication-tasks \
701
+ --filters Name=replication-task-arn,Values="$TASK_ARN" \
702
+ --query 'ReplicationTasks[0].ReplicationTaskStats.ElapsedTimeMillis' \
703
+ --output text)
704
+
705
+ if [ "$LAG" -lt 1000 ]; then
706
+ echo "Lag under 1 second, ready for cutover"
707
+ break
708
+ fi
709
+ sleep 5
710
+ done
711
+
712
+ # 3. Maintenance mode
713
+ echo "Enabling maintenance mode..."
714
+ aws ssm send-command \
715
+ --document-name "AWS-RunShellScript" \
716
+ --targets "Key=tag:App,Values=legacy" \
717
+ --parameters 'commands=["systemctl stop application"]'
718
+
719
+ # 4. Final sync
720
+ sleep 10
721
+ echo "Final replication sync..."
722
+ # Wait for replication to catch up
723
+
724
+ # 5. Cutover DNS
725
+ echo "Updating DNS to point to new environment..."
726
+ aws route53 change-resource-record-sets \
727
+ --hosted-zone-id "$ZONE_ID" \
728
+ --change-batch file://dns-cutover.json
729
+
730
+ # 6. Verify
731
+ echo "Verifying new environment..."
732
+ for i in {1..10}; do
733
+ if curl -f https://app.example.com/health; then
734
+ echo "Health check passed"
735
+ break
736
+ fi
737
+ sleep 5
738
+ done
739
+
740
+ echo "=== Cutover Complete ==="
741
+ ```
742
+
743
+ ## Post-Migration Optimization
744
+
745
+ ```hcl
746
+ # Cost optimization - Reserved Instances
747
+ resource "aws_ec2_capacity_reservation" "main" {
748
+ instance_type = "m5.xlarge"
749
+ instance_platform = "Linux/UNIX"
750
+ availability_zone = "us-east-1a"
751
+ instance_count = 10
752
+
753
+ tags = {
754
+ Name = "app-capacity-reservation"
755
+ }
756
+ }
757
+
758
+ # Right-sizing based on CloudWatch metrics
759
+ resource "aws_autoscaling_policy" "scale_down" {
760
+ name = "scale-down"
761
+ scaling_adjustment = -1
762
+ adjustment_type = "ChangeInCapacity"
763
+ cooldown = 300
764
+ autoscaling_group_name = aws_autoscaling_group.main.name
765
+ }
766
+
767
+ resource "aws_cloudwatch_metric_alarm" "cpu_low" {
768
+ alarm_name = "cpu-utilization-low"
769
+ comparison_operator = "LessThanThreshold"
770
+ evaluation_periods = "2"
771
+ metric_name = "CPUUtilization"
772
+ namespace = "AWS/EC2"
773
+ period = "300"
774
+ statistic = "Average"
775
+ threshold = "20"
776
+
777
+ dimensions = {
778
+ AutoScalingGroupName = aws_autoscaling_group.main.name
779
+ }
780
+
781
+ alarm_actions = [aws_autoscaling_policy.scale_down.arn]
782
+ }
783
+ ```
784
+
785
+ ## Best Practices
786
+
787
+ 1. **Assessment:**
788
+ - Comprehensive discovery
789
+ - Identify dependencies
790
+ - Assess technical debt
791
+ - Calculate TCO
792
+
793
+ 2. **Planning:**
794
+ - Phased approach (waves)
795
+ - Pilot migrations first
796
+ - Define success criteria
797
+ - Plan rollback strategy
798
+
799
+ 3. **Execution:**
800
+ - Automate where possible
801
+ - Test thoroughly
802
+ - Monitor continuously
803
+ - Document everything
804
+
805
+ 4. **Optimization:**
806
+ - Right-size resources
807
+ - Leverage reserved capacity
808
+ - Implement auto-scaling
809
+ - Regular cost reviews
810
+
811
+ ## Anti-Patterns
812
+
813
+ - Big-bang migrations
814
+ - No pilot testing
815
+ - Ignoring dependencies
816
+ - No rollback plan
817
+ - Insufficient testing
818
+ - Poor communication
819
+ - No post-migration optimization
820
+ - Recreating on-premises architecture in cloud