@invictus-group-ai/orchestra 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/LICENSING.md +49 -0
- package/README.md +507 -0
- package/assets/settings-template.json +99 -0
- package/bin/invi.js +6 -0
- package/content-dist/LICENSE +95 -0
- package/content-dist/PIPELINE.md +823 -0
- package/content-dist/README.md +128 -0
- package/content-dist/agents/README.md +135 -0
- package/content-dist/agents/mapping.json +476 -0
- package/content-dist/agents/stacks/backend-django.md +66 -0
- package/content-dist/agents/stacks/backend-dotnet.md +72 -0
- package/content-dist/agents/stacks/backend-fastapi.md +66 -0
- package/content-dist/agents/stacks/backend-laravel.md +66 -0
- package/content-dist/agents/stacks/backend-node.md +66 -0
- package/content-dist/agents/stacks/backend-spring.md +66 -0
- package/content-dist/agents/stacks/desktop-delphi.md +73 -0
- package/content-dist/agents/stacks/frontend-angular.md +65 -0
- package/content-dist/agents/stacks/frontend-react.md +67 -0
- package/content-dist/agents/stacks/frontend-svelte.md +67 -0
- package/content-dist/agents/stacks/frontend-vue.md +66 -0
- package/content-dist/agents/stacks/mobile-flutter.md +68 -0
- package/content-dist/agents/stacks/wordpress.md +66 -0
- package/content-dist/agents/universal/invi-qa.md +57 -0
- package/content-dist/agents/universal/invi-reviewer.md +61 -0
- package/content-dist/agents/universal/invi-security.md +55 -0
- package/content-dist/agents/universal/invi-tester.md +55 -0
- package/content-dist/agents/universal/invi-ui.md +85 -0
- package/content-dist/fragments/base.md +37 -0
- package/content-dist/fragments/domain/api-publica-rate-limiting.md +83 -0
- package/content-dist/fragments/domain/autenticacao-enterprise.md +86 -0
- package/content-dist/fragments/domain/busca-elasticsearch.md +86 -0
- package/content-dist/fragments/domain/dashboard-admin-rbac.md +80 -0
- package/content-dist/fragments/domain/design-system.md +71 -0
- package/content-dist/fragments/domain/ecommerce-completo.md +86 -0
- package/content-dist/fragments/domain/filas-jobs.md +80 -0
- package/content-dist/fragments/domain/integracao-crm-erp.md +82 -0
- package/content-dist/fragments/domain/lgpd.md +84 -0
- package/content-dist/fragments/domain/multi-tenancy.md +79 -0
- package/content-dist/fragments/domain/notificacoes-multicanal.md +81 -0
- package/content-dist/fragments/domain/pagamentos-brasil.md +85 -0
- package/content-dist/fragments/domain/plataforma-conteudo.md +77 -0
- package/content-dist/fragments/domain/realtime-websockets.md +92 -0
- package/content-dist/fragments/domain/relatorios-analytics.md +80 -0
- package/content-dist/fragments/domain/saas-stripe-billing.md +79 -0
- package/content-dist/fragments/domain/sistema-pagamentos.md +81 -0
- package/content-dist/fragments/domain/upload-midia.md +81 -0
- package/content-dist/fragments/domain/whatsapp-business.md +82 -0
- package/content-dist/fragments/index.json +1670 -0
- package/content-dist/fragments/references/angular-ngrx/app-config-and-testing.md +81 -0
- package/content-dist/fragments/references/angular-ngrx/store-pattern.md +155 -0
- package/content-dist/fragments/references/ansible-server-setup/layout-and-config.md +143 -0
- package/content-dist/fragments/references/ansible-server-setup/roles.md +238 -0
- package/content-dist/fragments/references/api-publica-rate-limiting/patterns.md +68 -0
- package/content-dist/fragments/references/astro-static/content-and-islands.md +117 -0
- package/content-dist/fragments/references/autenticacao-enterprise/pitfalls.md +70 -0
- package/content-dist/fragments/references/busca-elasticsearch/patterns.md +100 -0
- package/content-dist/fragments/references/chrome-extension-mv3/messaging-and-storage.md +109 -0
- package/content-dist/fragments/references/cli-typescript-commander/commands-and-config.md +136 -0
- package/content-dist/fragments/references/cloud-run-gcp/build-and-deploy.md +127 -0
- package/content-dist/fragments/references/cloud-run-gcp/iam-secrets-networking.md +65 -0
- package/content-dist/fragments/references/computer-vision-yolo/serving-and-export.md +182 -0
- package/content-dist/fragments/references/computer-vision-yolo/training-and-validation.md +131 -0
- package/content-dist/fragments/references/convex-react/functions.md +117 -0
- package/content-dist/fragments/references/convex-react/react-and-storage.md +109 -0
- package/content-dist/fragments/references/dashboard-admin-rbac/patterns.md +73 -0
- package/content-dist/fragments/references/data-pipeline-airflow/dag-patterns.md +149 -0
- package/content-dist/fragments/references/data-pipeline-airflow/operations.md +74 -0
- package/content-dist/fragments/references/delphi-object-pascal/legacy-extraction.md +175 -0
- package/content-dist/fragments/references/django-drf-celery/celery-tasks.md +47 -0
- package/content-dist/fragments/references/django-drf-celery/viewsets-and-serializers.md +92 -0
- package/content-dist/fragments/references/docker-compose-dev/compose-files.md +146 -0
- package/content-dist/fragments/references/docker-compose-dev/dockerfile-and-proxy.md +108 -0
- package/content-dist/fragments/references/dotnet-aspnet/data-and-di.md +90 -0
- package/content-dist/fragments/references/dotnet-aspnet/web-layer.md +88 -0
- package/content-dist/fragments/references/ecommerce-completo/patterns.md +76 -0
- package/content-dist/fragments/references/electron-app/ipc-bridge.md +123 -0
- package/content-dist/fragments/references/electron-app/security-and-packaging.md +134 -0
- package/content-dist/fragments/references/elixir-phoenix/context-and-web.md +112 -0
- package/content-dist/fragments/references/elixir-phoenix/processes.md +65 -0
- package/content-dist/fragments/references/filas-jobs/patterns.md +116 -0
- package/content-dist/fragments/references/fine-tuning-huggingface/data-and-export.md +114 -0
- package/content-dist/fragments/references/fine-tuning-huggingface/training-and-lora.md +123 -0
- package/content-dist/fragments/references/flutter/platform-channels-and-goldens.md +68 -0
- package/content-dist/fragments/references/flutter/state-and-widgets.md +95 -0
- package/content-dist/fragments/references/github-actions-cicd/workflows.md +235 -0
- package/content-dist/fragments/references/go-chi-gorm/http-layer.md +87 -0
- package/content-dist/fragments/references/go-chi-gorm/service-layer.md +58 -0
- package/content-dist/fragments/references/graphql-apollo/resolvers-and-loaders.md +128 -0
- package/content-dist/fragments/references/hono-bun/patterns.md +144 -0
- package/content-dist/fragments/references/integracao-crm-erp/patterns.md +100 -0
- package/content-dist/fragments/references/kubernetes-helm/chart-templates.md +162 -0
- package/content-dist/fragments/references/kubernetes-helm/secrets-storage-deploy.md +78 -0
- package/content-dist/fragments/references/langchain-python-agent/agent-and-cost.md +120 -0
- package/content-dist/fragments/references/langchain-python-agent/memory-and-resilience.md +76 -0
- package/content-dist/fragments/references/laravel/eloquent-and-queues.md +126 -0
- package/content-dist/fragments/references/laravel/http-layer.md +110 -0
- package/content-dist/fragments/references/lgpd/patterns.md +110 -0
- package/content-dist/fragments/references/llm-ops-production/routing-and-budget.md +118 -0
- package/content-dist/fragments/references/llm-ops-production/tracing-eval-ab.md +102 -0
- package/content-dist/fragments/references/microservices-docker/compose-and-gateway.md +93 -0
- package/content-dist/fragments/references/microservices-docker/events-and-correlation.md +88 -0
- package/content-dist/fragments/references/ml-fastapi-serving/metrics-drift-docker.md +97 -0
- package/content-dist/fragments/references/ml-fastapi-serving/serving-core.md +155 -0
- package/content-dist/fragments/references/ml-training-pipeline/dvc-pipeline.md +102 -0
- package/content-dist/fragments/references/ml-training-pipeline/mlflow-registry-ci.md +139 -0
- package/content-dist/fragments/references/monitoring-observability/alerts-and-config.md +169 -0
- package/content-dist/fragments/references/monitoring-observability/instrumentation-node.md +139 -0
- package/content-dist/fragments/references/multi-tenancy/patterns.md +85 -0
- package/content-dist/fragments/references/nestjs-typescript/guards-and-decorators.md +103 -0
- package/content-dist/fragments/references/nestjs-typescript/modules-dtos-setup.md +106 -0
- package/content-dist/fragments/references/nextjs-app-router/patterns.md +177 -0
- package/content-dist/fragments/references/nextjs-prisma-postgres/billing.md +167 -0
- package/content-dist/fragments/references/nextjs-trpc-drizzle/data-and-auth.md +121 -0
- package/content-dist/fragments/references/nextjs-trpc-drizzle/trpc-setup.md +62 -0
- package/content-dist/fragments/references/nodejs-express-typescript/config-and-tokens.md +48 -0
- package/content-dist/fragments/references/nodejs-express-typescript/middleware.md +108 -0
- package/content-dist/fragments/references/notificacoes-multicanal/patterns.md +78 -0
- package/content-dist/fragments/references/nuxt3-tailwind/server-routes.md +79 -0
- package/content-dist/fragments/references/nuxt3-tailwind/state-and-fetching.md +129 -0
- package/content-dist/fragments/references/openai-api-integration/calls.md +210 -0
- package/content-dist/fragments/references/openai-api-integration/client-and-cost.md +71 -0
- package/content-dist/fragments/references/pagamentos-brasil/gateways-reconciliation.md +92 -0
- package/content-dist/fragments/references/pagamentos-brasil/pix-boleto.md +115 -0
- package/content-dist/fragments/references/plataforma-conteudo/patterns.md +74 -0
- package/content-dist/fragments/references/python-fastapi/dependency-injection.md +99 -0
- package/content-dist/fragments/references/python-fastapi/settings-and-tasks.md +47 -0
- package/content-dist/fragments/references/rag-pipeline/ingestion.md +92 -0
- package/content-dist/fragments/references/rag-pipeline/retrieval-and-eval.md +148 -0
- package/content-dist/fragments/references/react-express-monolith/auth-and-client.md +110 -0
- package/content-dist/fragments/references/react-express-monolith/monorepo.md +71 -0
- package/content-dist/fragments/references/react-native-expo/native-patterns.md +103 -0
- package/content-dist/fragments/references/react-native-expo/navigation-and-auth.md +55 -0
- package/content-dist/fragments/references/react-ts-zustand-query/store-and-query.md +152 -0
- package/content-dist/fragments/references/react-typescript/feature-module.md +64 -0
- package/content-dist/fragments/references/react-typescript/forms-and-state.md +69 -0
- package/content-dist/fragments/references/react-typescript/recipes.md +37 -0
- package/content-dist/fragments/references/react-typescript/testing.md +40 -0
- package/content-dist/fragments/references/realtime-websockets/patterns.md +92 -0
- package/content-dist/fragments/references/relatorios-analytics/patterns.md +81 -0
- package/content-dist/fragments/references/remix-express-full/auth-and-uploads.md +88 -0
- package/content-dist/fragments/references/remix-express-full/express-server.md +54 -0
- package/content-dist/fragments/references/remix-typescript/auth-and-db.md +68 -0
- package/content-dist/fragments/references/remix-typescript/loaders-and-actions.md +98 -0
- package/content-dist/fragments/references/rust-axum/error-and-state.md +99 -0
- package/content-dist/fragments/references/rust-axum/handlers.md +87 -0
- package/content-dist/fragments/references/saas-stripe-billing/patterns.md +86 -0
- package/content-dist/fragments/references/serverless-lambda/handler-patterns.md +107 -0
- package/content-dist/fragments/references/sistema-pagamentos/pitfalls.md +54 -0
- package/content-dist/fragments/references/spring-boot/service-and-data.md +96 -0
- package/content-dist/fragments/references/spring-boot/web-layer.md +100 -0
- package/content-dist/fragments/references/supabase-nextjs/clients-and-middleware.md +102 -0
- package/content-dist/fragments/references/supabase-nextjs/rls-and-storage.md +86 -0
- package/content-dist/fragments/references/svelte-sveltekit/hooks-and-state.md +67 -0
- package/content-dist/fragments/references/svelte-sveltekit/load-and-actions.md +80 -0
- package/content-dist/fragments/references/t3-stack/routers-and-callers.md +75 -0
- package/content-dist/fragments/references/t3-stack/trpc-setup.md +60 -0
- package/content-dist/fragments/references/terraform-aws/modules-and-ci.md +114 -0
- package/content-dist/fragments/references/terraform-aws/state-and-workspaces.md +66 -0
- package/content-dist/fragments/references/turborepo-monorepo/pipeline-and-packages.md +84 -0
- package/content-dist/fragments/references/upload-midia/patterns.md +80 -0
- package/content-dist/fragments/references/vector-search-pinecone/client-and-upsert.md +98 -0
- package/content-dist/fragments/references/vector-search-pinecone/query-and-hybrid.md +81 -0
- package/content-dist/fragments/references/vps-deploy-producao/compose-prod.md +97 -0
- package/content-dist/fragments/references/vps-deploy-producao/proxy-and-operations.md +118 -0
- package/content-dist/fragments/references/vscode-extension/activation-and-tree.md +98 -0
- package/content-dist/fragments/references/vscode-extension/webview-csp.md +57 -0
- package/content-dist/fragments/references/vue3-pinia-vite/components-and-stores.md +73 -0
- package/content-dist/fragments/references/vue3-pinia-vite/queries-forms-testing.md +100 -0
- package/content-dist/fragments/references/whatsapp-business/patterns.md +107 -0
- package/content-dist/fragments/references/wordpress/hooks-and-security.md +92 -0
- package/content-dist/fragments/references/wordpress/wp-cli-gates.md +64 -0
- package/content-dist/fragments/stack/angular-ngrx.md +75 -0
- package/content-dist/fragments/stack/ansible-server-setup.md +69 -0
- package/content-dist/fragments/stack/astro-static.md +72 -0
- package/content-dist/fragments/stack/chrome-extension-mv3.md +66 -0
- package/content-dist/fragments/stack/cli-typescript-commander.md +66 -0
- package/content-dist/fragments/stack/cloud-run-gcp.md +63 -0
- package/content-dist/fragments/stack/computer-vision-yolo.md +62 -0
- package/content-dist/fragments/stack/convex-react.md +65 -0
- package/content-dist/fragments/stack/data-pipeline-airflow.md +64 -0
- package/content-dist/fragments/stack/delphi-object-pascal.md +63 -0
- package/content-dist/fragments/stack/django-drf-celery.md +63 -0
- package/content-dist/fragments/stack/docker-compose-dev.md +69 -0
- package/content-dist/fragments/stack/dotnet-aspnet.md +62 -0
- package/content-dist/fragments/stack/electron-app.md +70 -0
- package/content-dist/fragments/stack/elixir-phoenix.md +65 -0
- package/content-dist/fragments/stack/fine-tuning-huggingface.md +69 -0
- package/content-dist/fragments/stack/flutter.md +61 -0
- package/content-dist/fragments/stack/github-actions-cicd.md +73 -0
- package/content-dist/fragments/stack/go-chi-gorm.md +73 -0
- package/content-dist/fragments/stack/graphql-apollo.md +70 -0
- package/content-dist/fragments/stack/hono-bun.md +62 -0
- package/content-dist/fragments/stack/kubernetes-helm.md +67 -0
- package/content-dist/fragments/stack/langchain-python-agent.md +64 -0
- package/content-dist/fragments/stack/laravel.md +64 -0
- package/content-dist/fragments/stack/llm-ops-production.md +63 -0
- package/content-dist/fragments/stack/microservices-docker.md +70 -0
- package/content-dist/fragments/stack/ml-fastapi-serving.md +64 -0
- package/content-dist/fragments/stack/ml-training-pipeline.md +67 -0
- package/content-dist/fragments/stack/monitoring-observability.md +68 -0
- package/content-dist/fragments/stack/nestjs-typescript.md +68 -0
- package/content-dist/fragments/stack/nextjs-app-router.md +65 -0
- package/content-dist/fragments/stack/nextjs-prisma-postgres.md +61 -0
- package/content-dist/fragments/stack/nextjs-trpc-drizzle.md +63 -0
- package/content-dist/fragments/stack/nodejs-express-typescript.md +60 -0
- package/content-dist/fragments/stack/nuxt3-tailwind.md +62 -0
- package/content-dist/fragments/stack/openai-api-integration.md +58 -0
- package/content-dist/fragments/stack/python-fastapi.md +64 -0
- package/content-dist/fragments/stack/rag-pipeline.md +62 -0
- package/content-dist/fragments/stack/react-express-monolith.md +61 -0
- package/content-dist/fragments/stack/react-native-expo.md +68 -0
- package/content-dist/fragments/stack/react-ts-zustand-query.md +64 -0
- package/content-dist/fragments/stack/react-typescript.md +73 -0
- package/content-dist/fragments/stack/remix-express-full.md +63 -0
- package/content-dist/fragments/stack/remix-typescript.md +66 -0
- package/content-dist/fragments/stack/rust-axum.md +63 -0
- package/content-dist/fragments/stack/serverless-lambda.md +65 -0
- package/content-dist/fragments/stack/spring-boot.md +63 -0
- package/content-dist/fragments/stack/supabase-nextjs.md +64 -0
- package/content-dist/fragments/stack/svelte-sveltekit.md +67 -0
- package/content-dist/fragments/stack/t3-stack.md +63 -0
- package/content-dist/fragments/stack/terraform-aws.md +65 -0
- package/content-dist/fragments/stack/turborepo-monorepo.md +61 -0
- package/content-dist/fragments/stack/vector-search-pinecone.md +63 -0
- package/content-dist/fragments/stack/vps-deploy-producao.md +64 -0
- package/content-dist/fragments/stack/vscode-extension.md +64 -0
- package/content-dist/fragments/stack/vue3-pinia-vite.md +65 -0
- package/content-dist/fragments/stack/wordpress.md +63 -0
- package/content-dist/skills/invi-commit/SKILL.md +85 -0
- package/content-dist/skills/invi-journal/SKILL.md +67 -0
- package/content-dist/skills/invi-map/SKILL.md +118 -0
- package/content-dist/skills/invi-mode/SKILL.md +176 -0
- package/content-dist/skills/invi-pr/SKILL.md +142 -0
- package/content-dist/skills/invi-qa/SKILL.md +75 -0
- package/content-dist/skills/invi-refactor-legacy/SKILL.md +90 -0
- package/content-dist/skills/invi-review/SKILL.md +83 -0
- package/content-dist/skills/invi-security/SKILL.md +89 -0
- package/content-dist/skills/invi-status/SKILL.md +72 -0
- package/content-dist/skills/invi-task/SKILL.md +143 -0
- package/content-dist/skills/invi-test/SKILL.md +97 -0
- package/content-dist/skills/po-handoff/SKILL.md +130 -0
- package/content-dist/skills/po-intake/SKILL.md +115 -0
- package/content-dist/skills/po-lint/SKILL.md +82 -0
- package/content-dist/skills/po-spec/SKILL.md +138 -0
- package/content-dist/skills/po-status/SKILL.md +130 -0
- package/content-dist/skills/po-verify/SKILL.md +124 -0
- package/content-dist/templates/requirements/REQ-TEMPLATE.md +110 -0
- package/content-dist/templates/requirements/constitution-TEMPLATE.md +77 -0
- package/dist/baseline.d.ts +21 -0
- package/dist/baseline.d.ts.map +1 -0
- package/dist/baseline.js +43 -0
- package/dist/baseline.js.map +1 -0
- package/dist/cli.d.ts +15 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +345 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/doctor.d.ts +31 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +173 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/export.d.ts +49 -0
- package/dist/commands/export.d.ts.map +1 -0
- package/dist/commands/export.js +95 -0
- package/dist/commands/export.js.map +1 -0
- package/dist/commands/gate.d.ts +42 -0
- package/dist/commands/gate.d.ts.map +1 -0
- package/dist/commands/gate.js +97 -0
- package/dist/commands/gate.js.map +1 -0
- package/dist/commands/init.d.ts +88 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +540 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/journalCmd.d.ts +47 -0
- package/dist/commands/journalCmd.d.ts.map +1 -0
- package/dist/commands/journalCmd.js +89 -0
- package/dist/commands/journalCmd.js.map +1 -0
- package/dist/commands/keys.d.ts +68 -0
- package/dist/commands/keys.d.ts.map +1 -0
- package/dist/commands/keys.js +240 -0
- package/dist/commands/keys.js.map +1 -0
- package/dist/commands/map.d.ts +123 -0
- package/dist/commands/map.d.ts.map +1 -0
- package/dist/commands/map.js +383 -0
- package/dist/commands/map.js.map +1 -0
- package/dist/commands/plan.d.ts +28 -0
- package/dist/commands/plan.d.ts.map +1 -0
- package/dist/commands/plan.js +64 -0
- package/dist/commands/plan.js.map +1 -0
- package/dist/commands/req.d.ts +92 -0
- package/dist/commands/req.d.ts.map +1 -0
- package/dist/commands/req.js +270 -0
- package/dist/commands/req.js.map +1 -0
- package/dist/commands/review.d.ts +40 -0
- package/dist/commands/review.d.ts.map +1 -0
- package/dist/commands/review.js +101 -0
- package/dist/commands/review.js.map +1 -0
- package/dist/commands/run.d.ts +33 -0
- package/dist/commands/run.d.ts.map +1 -0
- package/dist/commands/run.js +151 -0
- package/dist/commands/run.js.map +1 -0
- package/dist/commands/ship.d.ts +45 -0
- package/dist/commands/ship.d.ts.map +1 -0
- package/dist/commands/ship.js +252 -0
- package/dist/commands/ship.js.map +1 -0
- package/dist/commands/status.d.ts +36 -0
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/status.js +152 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/commands/sync.d.ts +91 -0
- package/dist/commands/sync.d.ts.map +1 -0
- package/dist/commands/sync.js +331 -0
- package/dist/commands/sync.js.map +1 -0
- package/dist/commands/syncCommits.d.ts +56 -0
- package/dist/commands/syncCommits.d.ts.map +1 -0
- package/dist/commands/syncCommits.js +97 -0
- package/dist/commands/syncCommits.js.map +1 -0
- package/dist/commands/task.d.ts +108 -0
- package/dist/commands/task.d.ts.map +1 -0
- package/dist/commands/task.js +217 -0
- package/dist/commands/task.js.map +1 -0
- package/dist/commands/update.d.ts +92 -0
- package/dist/commands/update.d.ts.map +1 -0
- package/dist/commands/update.js +541 -0
- package/dist/commands/update.js.map +1 -0
- package/dist/commands/verifyTask.d.ts +50 -0
- package/dist/commands/verifyTask.d.ts.map +1 -0
- package/dist/commands/verifyTask.js +172 -0
- package/dist/commands/verifyTask.js.map +1 -0
- package/dist/content.d.ts +128 -0
- package/dist/content.d.ts.map +1 -0
- package/dist/content.js +177 -0
- package/dist/content.js.map +1 -0
- package/dist/detect.d.ts +122 -0
- package/dist/detect.d.ts.map +1 -0
- package/dist/detect.js +594 -0
- package/dist/detect.js.map +1 -0
- package/dist/events.d.ts +36 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +76 -0
- package/dist/events.js.map +1 -0
- package/dist/frontmatter.d.ts +15 -0
- package/dist/frontmatter.d.ts.map +1 -0
- package/dist/frontmatter.js +74 -0
- package/dist/frontmatter.js.map +1 -0
- package/dist/i18n/en.d.ts +421 -0
- package/dist/i18n/en.d.ts.map +1 -0
- package/dist/i18n/en.js +443 -0
- package/dist/i18n/en.js.map +1 -0
- package/dist/i18n/index.d.ts +40 -0
- package/dist/i18n/index.d.ts.map +1 -0
- package/dist/i18n/index.js +66 -0
- package/dist/i18n/index.js.map +1 -0
- package/dist/i18n/pt-BR.d.ts +11 -0
- package/dist/i18n/pt-BR.d.ts.map +1 -0
- package/dist/i18n/pt-BR.js +435 -0
- package/dist/i18n/pt-BR.js.map +1 -0
- package/dist/identity.d.ts +78 -0
- package/dist/identity.d.ts.map +1 -0
- package/dist/identity.js +152 -0
- package/dist/identity.js.map +1 -0
- package/dist/index.d.ts +79 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +48 -0
- package/dist/index.js.map +1 -0
- package/dist/insights.d.ts +86 -0
- package/dist/insights.d.ts.map +1 -0
- package/dist/insights.js +199 -0
- package/dist/insights.js.map +1 -0
- package/dist/interview.d.ts +81 -0
- package/dist/interview.d.ts.map +1 -0
- package/dist/interview.js +283 -0
- package/dist/interview.js.map +1 -0
- package/dist/inventory.d.ts +79 -0
- package/dist/inventory.d.ts.map +1 -0
- package/dist/inventory.js +86 -0
- package/dist/inventory.js.map +1 -0
- package/dist/journal.d.ts +22 -0
- package/dist/journal.d.ts.map +1 -0
- package/dist/journal.js +88 -0
- package/dist/journal.js.map +1 -0
- package/dist/migrations/legacyNames.d.ts +45 -0
- package/dist/migrations/legacyNames.d.ts.map +1 -0
- package/dist/migrations/legacyNames.js +118 -0
- package/dist/migrations/legacyNames.js.map +1 -0
- package/dist/plan.d.ts +42 -0
- package/dist/plan.d.ts.map +1 -0
- package/dist/plan.js +126 -0
- package/dist/plan.js.map +1 -0
- package/dist/render/agents.d.ts +327 -0
- package/dist/render/agents.d.ts.map +1 -0
- package/dist/render/agents.js +356 -0
- package/dist/render/agents.js.map +1 -0
- package/dist/render/claudeMd.d.ts +29 -0
- package/dist/render/claudeMd.d.ts.map +1 -0
- package/dist/render/claudeMd.js +110 -0
- package/dist/render/claudeMd.js.map +1 -0
- package/dist/render/githooks.d.ts +41 -0
- package/dist/render/githooks.d.ts.map +1 -0
- package/dist/render/githooks.js +168 -0
- package/dist/render/githooks.js.map +1 -0
- package/dist/render/markers.d.ts +13 -0
- package/dist/render/markers.d.ts.map +1 -0
- package/dist/render/markers.js +35 -0
- package/dist/render/markers.js.map +1 -0
- package/dist/render/requirements.d.ts +56 -0
- package/dist/render/requirements.d.ts.map +1 -0
- package/dist/render/requirements.js +86 -0
- package/dist/render/requirements.js.map +1 -0
- package/dist/render/settings.d.ts +43 -0
- package/dist/render/settings.d.ts.map +1 -0
- package/dist/render/settings.js +94 -0
- package/dist/render/settings.js.map +1 -0
- package/dist/render/transparency.d.ts +7 -0
- package/dist/render/transparency.d.ts.map +1 -0
- package/dist/render/transparency.js +164 -0
- package/dist/render/transparency.js.map +1 -0
- package/dist/requirements.d.ts +84 -0
- package/dist/requirements.d.ts.map +1 -0
- package/dist/requirements.js +229 -0
- package/dist/requirements.js.map +1 -0
- package/dist/sizing.d.ts +63 -0
- package/dist/sizing.d.ts.map +1 -0
- package/dist/sizing.js +104 -0
- package/dist/sizing.js.map +1 -0
- package/dist/tasks.d.ts +199 -0
- package/dist/tasks.d.ts.map +1 -0
- package/dist/tasks.js +320 -0
- package/dist/tasks.js.map +1 -0
- package/dist/util/diff3.d.ts +26 -0
- package/dist/util/diff3.d.ts.map +1 -0
- package/dist/util/diff3.js +112 -0
- package/dist/util/diff3.js.map +1 -0
- package/dist/util/fsx.d.ts +33 -0
- package/dist/util/fsx.d.ts.map +1 -0
- package/dist/util/fsx.js +153 -0
- package/dist/util/fsx.js.map +1 -0
- package/dist/util/git.d.ts +58 -0
- package/dist/util/git.d.ts.map +1 -0
- package/dist/util/git.js +171 -0
- package/dist/util/git.js.map +1 -0
- package/dist/util/merge.d.ts +27 -0
- package/dist/util/merge.d.ts.map +1 -0
- package/dist/util/merge.js +78 -0
- package/dist/util/merge.js.map +1 -0
- package/dist/util/out.d.ts +18 -0
- package/dist/util/out.d.ts.map +1 -0
- package/dist/util/out.js +23 -0
- package/dist/util/out.js.map +1 -0
- package/dist/util/proc.d.ts +12 -0
- package/dist/util/proc.d.ts.map +1 -0
- package/dist/util/proc.js +45 -0
- package/dist/util/proc.js.map +1 -0
- package/dist/util/registry.d.ts +58 -0
- package/dist/util/registry.d.ts.map +1 -0
- package/dist/util/registry.js +240 -0
- package/dist/util/registry.js.map +1 -0
- package/dist/verify.d.ts +52 -0
- package/dist/verify.d.ts.map +1 -0
- package/dist/verify.js +205 -0
- package/dist/verify.js.map +1 -0
- package/dist/version.d.ts +5 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +18 -0
- package/dist/version.js.map +1 -0
- package/package.json +63 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: stack/python-fastapi
|
|
3
|
+
version: 1.0.0
|
|
4
|
+
lang: en
|
|
5
|
+
summary: "FastAPI service discipline: router→service→repository layering, ORM/schema separation, async correctness, migration-gated model changes."
|
|
6
|
+
source: "backend/02-python-fastapi.md"
|
|
7
|
+
detect:
|
|
8
|
+
deps: { "fastapi": "*" }
|
|
9
|
+
files: ["pyproject.toml", "requirements.txt"]
|
|
10
|
+
score: 10
|
|
11
|
+
requires: []
|
|
12
|
+
conflicts: []
|
|
13
|
+
tokens: 814
|
|
14
|
+
migrated: true
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
# Python API (FastAPI)
|
|
18
|
+
|
|
19
|
+
Rules-only fragment; exemplar code is evicted to `references/python-fastapi/` and read on demand.
|
|
20
|
+
|
|
21
|
+
## Architecture rules
|
|
22
|
+
|
|
23
|
+
- Strict layering: router → service → repository. Never skip a layer.
|
|
24
|
+
- Routers hold only path declarations and dependency wiring. Services hold business logic and never import `Request`/`Response`. Repositories hold only SQLAlchemy queries — no branching logic.
|
|
25
|
+
- Each module lives in `app/modules/<name>/` as `router.py`, `service.py`, `repository.py`, `models.py`, `schemas.py`, `dependencies.py`; cross-cutting concerns (config, security, database, exceptions) live in `app/core/`.
|
|
26
|
+
- ORM models and Pydantic schemas are separate classes. Endpoints always serialize through schemas (`model_config = ConfigDict(from_attributes=True)`) and never return ORM objects.
|
|
27
|
+
- All route handlers are `async def`; blocking sync I/O goes through an executor or a worker queue, never inline.
|
|
28
|
+
- Configuration is one `Settings` object (pydantic-settings) sourced from the environment; nothing else reads `os.environ`.
|
|
29
|
+
- One DB session per request via `Depends(get_db)`; commit/rollback happen at the dependency boundary, not inside repositories.
|
|
30
|
+
- Every model change ships with a migration, tested in both directions before merge.
|
|
31
|
+
|
|
32
|
+
## Trigger → action
|
|
33
|
+
|
|
34
|
+
| Trigger | Action |
|
|
35
|
+
|---------|--------|
|
|
36
|
+
| New endpoint | router entry → service method → repository query → typed response schema |
|
|
37
|
+
| New module | scaffold the six-file module folder → register router in the app factory |
|
|
38
|
+
| Protected route | reuse `get_current_user` / role dependencies — never inline token parsing |
|
|
39
|
+
| Fire-and-forget work | `BackgroundTasks` only if loss-tolerable; otherwise a real queue (see `domain/filas-jobs`) |
|
|
40
|
+
| New config value | typed field on `Settings` — never a bare env read |
|
|
41
|
+
| Model change | generate migration → review it → test upgrade and downgrade |
|
|
42
|
+
|
|
43
|
+
## Quality gates (before any PR)
|
|
44
|
+
|
|
45
|
+
- Lint/format, static type check, and tests pass (exact commands come from PROJECT FACTS); no `type: ignore` without a justifying comment.
|
|
46
|
+
- Coverage on new service/repository code meets the project bar.
|
|
47
|
+
- Migration generated for any model change and tested up and down against a real database.
|
|
48
|
+
- No sync DB calls inside `async def`; no ORM instances in responses; response model annotated on every new endpoint.
|
|
49
|
+
- Secrets sourced from `Settings` only — never hardcoded.
|
|
50
|
+
|
|
51
|
+
## Forbidden
|
|
52
|
+
|
|
53
|
+
- NEVER execute raw SQL strings from handlers — use ORM expressions; hand-written SQL belongs in migrations.
|
|
54
|
+
- NEVER share one `AsyncSession` across requests or store it in module-level state.
|
|
55
|
+
- NEVER use `from __future__ import annotations` in schema modules — it breaks Pydantic's runtime type resolution.
|
|
56
|
+
- NEVER write `Union[X, None]` — use `X | None`.
|
|
57
|
+
- NEVER put business logic in Pydantic validators or routers — services own it.
|
|
58
|
+
- NEVER add python-jose or passlib — use PyJWT plus a maintained bcrypt/argon2 binding for tokens and hashing.
|
|
59
|
+
- NEVER use `global` mutable state — use dependency injection.
|
|
60
|
+
|
|
61
|
+
## References (read on demand)
|
|
62
|
+
|
|
63
|
+
- `references/python-fastapi/dependency-injection.md` — session/current-user/role dependencies, OAuth2 login flow.
|
|
64
|
+
- `references/python-fastapi/settings-and-tasks.md` — Settings pattern, background-task discipline.
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: stack/rag-pipeline
|
|
3
|
+
version: 1.0.0
|
|
4
|
+
lang: en
|
|
5
|
+
summary: "RAG pipeline discipline: deliberate chunking, batched embeddings, hybrid retrieval with reranking, mandatory chunk metadata, RAGAS-gated deployment."
|
|
6
|
+
source: "ai-ml/03-rag-pipeline.md"
|
|
7
|
+
detect:
|
|
8
|
+
deps: { "pgvector": "*" }
|
|
9
|
+
files: []
|
|
10
|
+
score: 5
|
|
11
|
+
requires: []
|
|
12
|
+
conflicts: []
|
|
13
|
+
tokens: 820
|
|
14
|
+
migrated: true
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
# RAG Pipeline (Python + pgvector)
|
|
18
|
+
|
|
19
|
+
Rules-only fragment; exemplar code is evicted to `references/rag-pipeline/` and read on demand.
|
|
20
|
+
|
|
21
|
+
## Architecture rules
|
|
22
|
+
|
|
23
|
+
- Pipeline stages are separate packages: `ingestion/` (load → chunk → embed → upsert), `retrieval/` (vector store, lexical index, hybrid fusion, reranker), `generation/` (chain + prompts), `evaluation/` (metrics + golden set), `api/`.
|
|
24
|
+
- Chunking strategy drives answer quality — the wrong chunk size is the top reason RAG fails. Profile against the golden set before deploying; every chunk must stand alone ("does this chunk answer a question by itself?").
|
|
25
|
+
- Embeddings are batched (100–500 chunks per batch, within the provider batch token limit) — never one document at a time. Max chunk length stays well under the embedding model's context window (≤60%).
|
|
26
|
+
- Hybrid search by default: dense (semantic) + sparse (BM25) fused with reciprocal rank fusion. Semantic-only misses exact keyword matches.
|
|
27
|
+
- Rerank after retrieval: retrieve wide (top-20), rerank narrow (top-5) with a cross-encoder/rerank service — far cheaper than a bigger LLM and better accuracy.
|
|
28
|
+
- Chunk metadata is non-negotiable: every chunk stores source id, position, timestamps, and doc type, enabling filtered retrieval; metadata columns are indexed.
|
|
29
|
+
- Ingestion is incremental: hash each document and skip re-embedding unchanged content.
|
|
30
|
+
- pgvector is the production store (the app already has Postgres) with an HNSW index; a lightweight local store is fine for dev only.
|
|
31
|
+
- Generation is grounded: the system prompt restricts answers to retrieved context, cites sources, and says "not enough information" rather than inventing.
|
|
32
|
+
|
|
33
|
+
## Chunking decision
|
|
34
|
+
|
|
35
|
+
| Content | Chunk size | Overlap |
|
|
36
|
+
|---------|-----------|---------|
|
|
37
|
+
| FAQ / dense technical docs | small (~256 tokens) | ~10% |
|
|
38
|
+
| General purpose (default) | medium (~512 tokens) | ~10% |
|
|
39
|
+
| Narrative / long-form | large (~1024 tokens) | ~10% |
|
|
40
|
+
| Legal/contracts | paragraph (semantic unit) | none |
|
|
41
|
+
| Markdown/code | recursive split on structure | auto |
|
|
42
|
+
|
|
43
|
+
## Quality gates (before any deploy)
|
|
44
|
+
|
|
45
|
+
- RAGAS evaluation on the golden set passes thresholds: faithfulness ≥ 0.90, answer relevancy ≥ 0.85, context precision ≥ 0.80, context recall ≥ 0.75 — a failing metric blocks the deploy.
|
|
46
|
+
- Vector table has an ANN index (HNSW) and metadata indexes; retrieval latency measured, not assumed.
|
|
47
|
+
- Ingestion idempotence proven: re-running on unchanged docs adds zero chunks.
|
|
48
|
+
- Grounding prompt verified: out-of-context questions produce a refusal, not a hallucination.
|
|
49
|
+
|
|
50
|
+
## Forbidden
|
|
51
|
+
|
|
52
|
+
- NEVER embed documents one at a time — batch.
|
|
53
|
+
- NEVER ship a chunking change without re-running the evaluation set.
|
|
54
|
+
- NEVER store chunks without source metadata.
|
|
55
|
+
- NEVER rely on semantic search alone when users query by exact names/codes — hybrid.
|
|
56
|
+
- NEVER let the generation step answer from model memory when context is required — grounded prompt only.
|
|
57
|
+
- NEVER re-embed unchanged documents — hash and skip.
|
|
58
|
+
|
|
59
|
+
## References (read on demand)
|
|
60
|
+
|
|
61
|
+
- `references/rag-pipeline/ingestion.md` — incremental ingest pipeline with hashing, batching, metadata enrichment; pgvector DDL with HNSW + metadata indexes.
|
|
62
|
+
- `references/rag-pipeline/retrieval-and-eval.md` — hybrid retriever with RRF, reranker wrapper, grounded RAG chain, RAGAS gate.
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: stack/react-express-monolith
|
|
3
|
+
version: 1.0.0
|
|
4
|
+
lang: en
|
|
5
|
+
summary: "React SPA + Express API monorepo discipline: shared types package, httpOnly-cookie JWT, origin-locked CORS, typed API client, prod SPA serving."
|
|
6
|
+
source: "fullstack/06-react-express-monolith.md"
|
|
7
|
+
detect:
|
|
8
|
+
deps: { "react": "*", "express": "*" }
|
|
9
|
+
files: []
|
|
10
|
+
score: 6
|
|
11
|
+
requires: []
|
|
12
|
+
conflicts: []
|
|
13
|
+
tokens: 788
|
|
14
|
+
migrated: true
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
# React + Express Monorepo (SPA + API)
|
|
18
|
+
|
|
19
|
+
Rules-only fragment; exemplar code is evicted to `references/react-express-monolith/` and read on demand.
|
|
20
|
+
|
|
21
|
+
## Architecture rules
|
|
22
|
+
|
|
23
|
+
- Workspace layout: `packages/shared` (types only, zero runtime dependencies), `apps/client` (Vite SPA), `apps/server` (Express API). Both apps depend on shared; nothing depends back — zero circular deps.
|
|
24
|
+
- API contracts live in the shared package: DTO interfaces plus an `ApiResponse<T>` / `ApiError` envelope every endpoint uses. DB-inferred types stay server-side; services map them to shared DTOs.
|
|
25
|
+
- Auth token travels in an `httpOnly + secure + sameSite=strict` cookie set by the server — never in `localStorage` or response bodies. Login compares passwords with bcrypt, strips the hash before responding, and the auth middleware verifies the cookie and attaches typed user info to the request.
|
|
26
|
+
- CORS is locked to the configured client origin with `credentials: true` — a wildcard origin with credentials is a security hole the browser will reject anyway.
|
|
27
|
+
- Dev: the Vite server proxies `/api` to Express (no CORS pain, cookies rewritten for localhost). Prod: Express serves the built SPA statically with an `index.html` fallback registered AFTER all API routes.
|
|
28
|
+
- The frontend talks to the API only through one typed client that sets `credentials: 'include'` and unwraps the response envelope — no raw `fetch` in components.
|
|
29
|
+
|
|
30
|
+
## Trigger → action
|
|
31
|
+
|
|
32
|
+
| Trigger | Action |
|
|
33
|
+
|---------|--------|
|
|
34
|
+
| New API resource | route + validation → service → shared DTO type → typed client method |
|
|
35
|
+
| New shared shape | add to `packages/shared` → both apps consume it |
|
|
36
|
+
| Auth-protected route | cookie-verifying middleware; role/ownership check in the handler |
|
|
37
|
+
| Frontend data need | hook wrapping the typed client — components never fetch directly |
|
|
38
|
+
| Deploy | build client + server; server serves `client/dist` with SPA fallback |
|
|
39
|
+
|
|
40
|
+
## Quality gates (before any PR)
|
|
41
|
+
|
|
42
|
+
- Typecheck passes for client, server, and shared; unit and e2e suites pass (login + a core CRUD flow covered end-to-end).
|
|
43
|
+
- CORS origin is a specific URL; auth cookie is `httpOnly` and `secure` in production.
|
|
44
|
+
- All API responses use the shared envelope types; `packages/shared` still has zero runtime dependencies.
|
|
45
|
+
- Production build produces both bundles and the server serves the SPA correctly.
|
|
46
|
+
|
|
47
|
+
## Forbidden
|
|
48
|
+
|
|
49
|
+
- NEVER store tokens in `localStorage`/`sessionStorage` — httpOnly cookies only.
|
|
50
|
+
- NEVER combine a wildcard CORS origin with credentials.
|
|
51
|
+
- NEVER import server modules into client code — shared types are the only bridge.
|
|
52
|
+
- NEVER send an error body without the proper HTTP status code.
|
|
53
|
+
- NEVER compare passwords with `===` — always the hashing library's compare.
|
|
54
|
+
- NEVER use raw `fetch` in React components — the typed API client.
|
|
55
|
+
- NEVER type `req.body` as `any` — parse with Zod first.
|
|
56
|
+
- NEVER register the SPA fallback before the API routes.
|
|
57
|
+
|
|
58
|
+
## References (read on demand)
|
|
59
|
+
|
|
60
|
+
- `references/react-express-monolith/monorepo.md` — shared types package, Vite dev proxy, production SPA serving.
|
|
61
|
+
- `references/react-express-monolith/auth-and-client.md` — cookie-JWT login/logout, auth middleware, typed API client.
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: stack/react-native-expo
|
|
3
|
+
version: 1.0.0
|
|
4
|
+
lang: en
|
|
5
|
+
summary: "React Native + Expo discipline: file-based routing with route groups, encrypted storage for secrets, virtualized lists, permission-gated native features."
|
|
6
|
+
source: "frontend/07-react-native-expo.md"
|
|
7
|
+
detect:
|
|
8
|
+
deps: { "expo": "*" }
|
|
9
|
+
files: ["app.json"]
|
|
10
|
+
score: 10
|
|
11
|
+
requires: []
|
|
12
|
+
conflicts: []
|
|
13
|
+
tokens: 792
|
|
14
|
+
migrated: true
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
# React Native (Expo)
|
|
18
|
+
|
|
19
|
+
Rules-only fragment; exemplar code is evicted to `references/react-native-expo/` and read on demand.
|
|
20
|
+
|
|
21
|
+
## Architecture rules
|
|
22
|
+
|
|
23
|
+
- Expo Router file-based routing: route groups like `(auth)` and `(tabs)`, one `_layout.tsx` per group, the root `_layout.tsx` owns providers and the auth redirect (segment check against the auth store).
|
|
24
|
+
- Server data flows through TanStack Query hooks (`hooks/use<Resource>.ts`); shared client state lives in Zustand stores; forms are schema-first (Zod + React Hook Form).
|
|
25
|
+
- Native primitives only: `View`/`Text`/`Pressable`. ALL text sits inside `<Text>`; press targets use `Pressable`, not TouchableOpacity.
|
|
26
|
+
- Storage split: SecureStore (encrypted) for tokens, keys, credentials; AsyncStorage (plaintext) for preferences only.
|
|
27
|
+
- Dynamic lists are virtualized: FlashList with `estimatedItemSize` for long lists; never ScrollView for dynamic content.
|
|
28
|
+
- Native capabilities: check the Expo SDK module first before reaching for a bare native module; request the permission before use and handle denial gracefully (explain + deep-link to Settings).
|
|
29
|
+
- Configuration comes from `Constants.expoConfig.extra` / typed env bindings — never hardcoded URLs.
|
|
30
|
+
|
|
31
|
+
## Trigger → action
|
|
32
|
+
|
|
33
|
+
| Trigger | Action |
|
|
34
|
+
|---------|--------|
|
|
35
|
+
| New screen | `app/(group)/screen.tsx` → register in the group `_layout.tsx` if tabbed |
|
|
36
|
+
| Auth flow | root `_layout.tsx` redirect driven by the auth store + segments |
|
|
37
|
+
| API call | TanStack Query hook in `hooks/use<Resource>.ts` |
|
|
38
|
+
| Native feature | Expo SDK module first → permission check → graceful denial path |
|
|
39
|
+
| Performance | FlashList, memoized render items, no inline functions in `renderItem` |
|
|
40
|
+
| Deep link | app scheme config → `expo-linking` |
|
|
41
|
+
| Push notifications | `expo-notifications` → register device token → send to API |
|
|
42
|
+
|
|
43
|
+
## Naming
|
|
44
|
+
|
|
45
|
+
Route files lowercase in `app/` · components `PascalCase.tsx` under `components/ui|features/` · hooks `use<Name>.ts` · stores `<name>.store.ts` · lib singletons in `lib/` (`api.ts`, `storage.ts`, `query-client.ts`).
|
|
46
|
+
|
|
47
|
+
## Quality gates (before any PR)
|
|
48
|
+
|
|
49
|
+
- Typecheck and tests pass with zero errors (exact commands come from PROJECT FACTS).
|
|
50
|
+
- No sensitive value in AsyncStorage — SecureStore only.
|
|
51
|
+
- Long dynamic lists render through FlashList with `estimatedItemSize` set.
|
|
52
|
+
- Verified on both an iOS simulator and an Android emulator.
|
|
53
|
+
- Offline state handled gracefully; every permission checked before use with a denial path.
|
|
54
|
+
|
|
55
|
+
## Forbidden
|
|
56
|
+
|
|
57
|
+
- NEVER store tokens or credentials in AsyncStorage — it is not encrypted.
|
|
58
|
+
- NEVER use TouchableOpacity — use `Pressable`.
|
|
59
|
+
- NEVER render long dynamic lists without virtualization (FlashList).
|
|
60
|
+
- NEVER put text outside a `<Text>` component.
|
|
61
|
+
- NEVER use CSS `vh`/`vw` units — use `useWindowDimensions`.
|
|
62
|
+
- NEVER hardcode the API URL — read it from the Expo config.
|
|
63
|
+
- NEVER access camera/location/photos without a prior permission check.
|
|
64
|
+
|
|
65
|
+
## References (read on demand)
|
|
66
|
+
|
|
67
|
+
- `references/react-native-expo/navigation-and-auth.md` — root layout, providers, segment-based auth redirect, route anatomy.
|
|
68
|
+
- `references/react-native-expo/native-patterns.md` — SecureStore wrapper, FlashList, permission-gated hook, screen test.
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: stack/react-ts-zustand-query
|
|
3
|
+
version: 1.0.0
|
|
4
|
+
lang: en
|
|
5
|
+
summary: "React + Zustand + TanStack Query discipline: strict server/client state split, query-key factories, selector-only store reads, interceptor-based auth."
|
|
6
|
+
source: "frontend/02-react-ts-zustand-query.md"
|
|
7
|
+
detect:
|
|
8
|
+
deps: { "react": ">=18", "zustand": "*", "@tanstack/react-query": ">=5" }
|
|
9
|
+
files: []
|
|
10
|
+
score: 7
|
|
11
|
+
requires: []
|
|
12
|
+
conflicts: []
|
|
13
|
+
tokens: 760
|
|
14
|
+
migrated: true
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
# React + Zustand + TanStack Query
|
|
18
|
+
|
|
19
|
+
Rules-only fragment; exemplar code is evicted to `references/react-ts-zustand-query/` and read on demand.
|
|
20
|
+
|
|
21
|
+
## Architecture rules
|
|
22
|
+
|
|
23
|
+
- Hard state split: server state (API responses, cached entities, pagination, optimistic mutations) lives ONLY in TanStack Query; client state (UI toggles, theme, wizard progress, drafts, notification queue) lives ONLY in Zustand. Never server data in a store, never UI toggles in the query cache.
|
|
24
|
+
- Feature colocation: each feature folder holds `components/`, `hooks/`, `api.ts` (HTTP + query keys), `store.ts` (client state only), `types.ts`, `index.ts` re-exports; cross-feature stores live in `src/stores/`.
|
|
25
|
+
- Query keys come from a per-entity factory (`<entity>Keys`) declared `as const`; mutations ALWAYS invalidate the related keys on success, never the whole cache.
|
|
26
|
+
- Every query sets an explicit `staleTime`; conditional queries use `enabled`; slow-feeling actions (toggles, likes) get optimistic updates via `onMutate`/`onError`/`onSettled`.
|
|
27
|
+
- Store reads go through selectors — a bare store call re-renders on every change. Use the immer middleware for nested state and persist middleware only for state that must survive a refresh.
|
|
28
|
+
- One configured HTTP client instance (`lib/axios.ts`) owns auth-token injection and 401 refresh/logout via interceptors; components never build requests by hand.
|
|
29
|
+
- Forms are schema-first: Zod schema → React Hook Form resolver → submit calls a mutation hook.
|
|
30
|
+
|
|
31
|
+
## Trigger → action
|
|
32
|
+
|
|
33
|
+
| Trigger | Action |
|
|
34
|
+
|---------|--------|
|
|
35
|
+
| New async data | query hook in `features/<name>/api.ts` with a key factory |
|
|
36
|
+
| Cross-feature state | store in `stores/<name>.store.ts` |
|
|
37
|
+
| Complex form | Zod schema → RHF → `useMutation` on submit |
|
|
38
|
+
| Re-render problem | check store selectors first, then missing `staleTime` |
|
|
39
|
+
| Cache invalidation | `invalidateQueries` with a specific key from the factory |
|
|
40
|
+
| Auth integration | interceptors in `lib/axios.ts` + `auth.store.ts` |
|
|
41
|
+
|
|
42
|
+
## Naming
|
|
43
|
+
|
|
44
|
+
Components `PascalCase.tsx` · hooks `use<Name>.ts` · stores `<name>.store.ts` · per-feature API files `api.ts` · key factories `<entity>Keys` · constants `SCREAMING_SNAKE`.
|
|
45
|
+
|
|
46
|
+
## Quality gates (before any PR)
|
|
47
|
+
|
|
48
|
+
- Typecheck, lint, and tests with coverage pass (exact commands come from PROJECT FACTS).
|
|
49
|
+
- No Zustand subscription without a selector.
|
|
50
|
+
- Every mutation surfaces a loading state; every error response gets user-facing feedback.
|
|
51
|
+
- List/table loads render skeletons, not spinners.
|
|
52
|
+
|
|
53
|
+
## Forbidden
|
|
54
|
+
|
|
55
|
+
- NEVER drill props more than two levels — promote to a store.
|
|
56
|
+
- NEVER call `invalidateQueries` without a specific query key.
|
|
57
|
+
- NEVER use `useEffect` to sync two pieces of state — derive instead.
|
|
58
|
+
- NEVER store derived data in Zustand — compute it in selectors.
|
|
59
|
+
- NEVER use `any` without a documented reason.
|
|
60
|
+
- NEVER use Context for data TanStack Query already handles.
|
|
61
|
+
|
|
62
|
+
## References (read on demand)
|
|
63
|
+
|
|
64
|
+
- `references/react-ts-zustand-query/store-and-query.md` — immer/persist store with selectors, query-key factory and hooks, axios interceptors, MSW hook test.
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: stack/react-typescript
|
|
3
|
+
version: 1.0.0
|
|
4
|
+
lang: en
|
|
5
|
+
summary: "React + TypeScript SPA discipline: feature-module colocation, server-state via query hooks, schema-first forms, selector-based client state."
|
|
6
|
+
source: "frontend/01-react-typescript-basic.md"
|
|
7
|
+
detect:
|
|
8
|
+
deps: { "react": ">=18", "vite": "*" }
|
|
9
|
+
files: ["src/main.tsx", "index.html"]
|
|
10
|
+
score: 5
|
|
11
|
+
requires: []
|
|
12
|
+
conflicts: []
|
|
13
|
+
tokens: 863
|
|
14
|
+
migrated: true
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
# React + TypeScript (Vite SPA)
|
|
18
|
+
|
|
19
|
+
Rules-only fragment; exemplar code is evicted to `references/react-typescript/` and read on demand, never preloaded.
|
|
20
|
+
|
|
21
|
+
## Architecture rules
|
|
22
|
+
|
|
23
|
+
- Feature-module colocation: everything a feature needs (components, hooks, `api.ts`, `types.ts`, `index.ts` re-export) lives in `src/features/<feature>/`. Deleting the folder must remove the feature with zero side effects.
|
|
24
|
+
- Shared UI primitives in `src/components/ui/`, layout shells in `src/components/layout/`, pure helpers in `src/lib/`, global stores in `src/stores/`.
|
|
25
|
+
- Functional components only. Props interface lives in the same file, named `<Component>Props`; use `React.ComponentPropsWithoutRef<'element'>` when wrapping native elements.
|
|
26
|
+
- Server data flows through TanStack Query hooks defined in the feature's `api.ts`, keyed by a query-key factory; components never call the HTTP client directly.
|
|
27
|
+
- Forms are schema-first: define the Zod schema, infer the form type from it, then wire React Hook Form with the resolver.
|
|
28
|
+
- Client-only shared state lives in a Zustand store consumed via selectors (a bare store call re-renders on every change).
|
|
29
|
+
|
|
30
|
+
## State decision tree
|
|
31
|
+
|
|
32
|
+
1. Data comes from the server → TanStack Query (`useQuery`/`useMutation`). NEVER copy it into a store or context.
|
|
33
|
+
2. Shared across components, not server data → Zustand store.
|
|
34
|
+
3. Local UI state → `useState`/`useReducer`.
|
|
35
|
+
4. Theme/locale/auth session → context at the app root.
|
|
36
|
+
|
|
37
|
+
## Trigger → action
|
|
38
|
+
|
|
39
|
+
| Trigger | Action |
|
|
40
|
+
|---------|--------|
|
|
41
|
+
| New page | page component → register route → back it with a feature folder |
|
|
42
|
+
| New form | Zod schema FIRST → RHF form → submit handler → success/error states |
|
|
43
|
+
| API integration | `features/<name>/api.ts` → query-key factory → query/mutation hooks |
|
|
44
|
+
| Global client state | `src/stores/<name>.store.ts` — never for server data |
|
|
45
|
+
| Performance issue | profile first; memoize only what measurement proves slow |
|
|
46
|
+
| Auth flow | token in httpOnly cookie → api-client interceptor → redirect on 401 |
|
|
47
|
+
|
|
48
|
+
## Naming
|
|
49
|
+
|
|
50
|
+
Components `PascalCase.tsx` · hooks `use<Name>.ts` · stores `<name>.store.ts` · feature API files `api.ts` · types `PascalCase` · constants `SCREAMING_SNAKE` in `src/lib/constants.ts` · tests `__tests__/<Name>.test.tsx`.
|
|
51
|
+
|
|
52
|
+
## Quality gates (before any PR)
|
|
53
|
+
|
|
54
|
+
- Typecheck, tests, and lint pass with zero errors (exact commands come from PROJECT FACTS).
|
|
55
|
+
- No `any` without a comment justifying it.
|
|
56
|
+
- Every async operation renders loading and error states; every query has error handling.
|
|
57
|
+
- Responsive at small viewports; no hardcoded user-facing strings (i18n or constants).
|
|
58
|
+
|
|
59
|
+
## Forbidden
|
|
60
|
+
|
|
61
|
+
- NEVER fetch in `useEffect` or in the component body — server data goes through query hooks.
|
|
62
|
+
- NEVER use `any` without a documented reason.
|
|
63
|
+
- NEVER use inline styles — use the project's styling-system classes.
|
|
64
|
+
- NEVER hardcode API URLs — read them from `VITE_*` env config.
|
|
65
|
+
- NEVER mutate state directly, and NEVER memoize (`useCallback`/`useMemo`) without a measured cause.
|
|
66
|
+
- NEVER add another state-management or data-fetching library — TanStack Query + Zustand cover it.
|
|
67
|
+
|
|
68
|
+
## References (read on demand)
|
|
69
|
+
|
|
70
|
+
- `references/react-typescript/feature-module.md` — feature anatomy, query-key factory, props typing.
|
|
71
|
+
- `references/react-typescript/forms-and-state.md` — schema-first form, selector-based store.
|
|
72
|
+
- `references/react-typescript/testing.md` — MSW + QueryClient test harness.
|
|
73
|
+
- `references/react-typescript/recipes.md` — protected route, optimistic update.
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: stack/remix-express-full
|
|
3
|
+
version: 1.0.0
|
|
4
|
+
lang: en
|
|
5
|
+
summary: "Remix on a custom Express server: server-only modules, Redis-backed sessions, progressive-enhancement forms, proxied validated uploads."
|
|
6
|
+
source: "fullstack/04-remix-express-full.md"
|
|
7
|
+
detect:
|
|
8
|
+
deps: { "@remix-run/express": "*", "express": "*" }
|
|
9
|
+
files: []
|
|
10
|
+
score: 12
|
|
11
|
+
requires: []
|
|
12
|
+
conflicts: []
|
|
13
|
+
tokens: 736
|
|
14
|
+
migrated: true
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
# Remix + Express (custom server, full stack)
|
|
18
|
+
|
|
19
|
+
Rules-only fragment; exemplar code is evicted to `references/remix-express-full/` and read on demand.
|
|
20
|
+
|
|
21
|
+
## Architecture rules
|
|
22
|
+
|
|
23
|
+
- All loaders/actions are server-only. Any module touching secrets or the database carries the `.server.ts` suffix and is never imported by client code.
|
|
24
|
+
- Sessions live in Redis; the cookie holds only the session id (`httpOnly`, `secure` in production). Never store session payloads in cookies.
|
|
25
|
+
- Progressive enhancement: forms work without JavaScript; actions handle both fetch and full-page submissions.
|
|
26
|
+
- The custom Express server owns cross-cutting middleware — security headers, compression, request logging, body limits, rate limiting — not Remix. Middleware order: security → compression → logging → parsers → static → session → rate limit → Remix catch-all.
|
|
27
|
+
- Uploads are server-side: authenticate, validate type and size, then put to object storage. Never hand presigned upload URLs to untrusted clients.
|
|
28
|
+
- Data loading goes through Remix loaders (`useLoaderData`/`useFetcher`); `useEffect` is for non-data side effects only.
|
|
29
|
+
- Every route exports an `ErrorBoundary` — unhandled loader errors otherwise crash the whole page.
|
|
30
|
+
|
|
31
|
+
## Trigger → action
|
|
32
|
+
|
|
33
|
+
| Trigger | Action |
|
|
34
|
+
|---------|--------|
|
|
35
|
+
| New page | route module with `loader` (+ `action` for mutations) + `ErrorBoundary` |
|
|
36
|
+
| Protected route | `requireUser(request)` as the first call in loader/action |
|
|
37
|
+
| New secret/DB access | `.server.ts` module under `app/lib/` |
|
|
38
|
+
| Cross-cutting concern | Express middleware in `server/middleware/` |
|
|
39
|
+
| File upload | resource route: auth → size/type validation → server-side storage put |
|
|
40
|
+
| Session data growth | store it in Redis under the session id, never in the cookie |
|
|
41
|
+
|
|
42
|
+
## Quality gates (before any PR)
|
|
43
|
+
|
|
44
|
+
- Typecheck, unit tests, and E2E (auth, mutation, upload flows) pass — exact commands come from PROJECT FACTS.
|
|
45
|
+
- The build confirms no `.server.ts` module leaks into the client bundle.
|
|
46
|
+
- Forms degrade gracefully without JavaScript.
|
|
47
|
+
- Session cookie is `httpOnly` and `secure` in production.
|
|
48
|
+
- Upload size and type validated server-side before the storage write.
|
|
49
|
+
- Every route has an `ErrorBoundary`.
|
|
50
|
+
|
|
51
|
+
## Forbidden
|
|
52
|
+
|
|
53
|
+
- NEVER `fetch('/api/...')` from `useEffect` — use loaders and `useFetcher`.
|
|
54
|
+
- NEVER import `.server.ts` modules from `entry.client.tsx` or UI components.
|
|
55
|
+
- NEVER store sessions in `document.cookie` — Redis-backed sessions only.
|
|
56
|
+
- NEVER give presigned upload URLs to untrusted input — validate and proxy.
|
|
57
|
+
- NEVER ship `unstable_*` APIs to production without accepting the breakage risk.
|
|
58
|
+
- NEVER pass large payloads via query strings — use form POST actions.
|
|
59
|
+
|
|
60
|
+
## References (read on demand)
|
|
61
|
+
|
|
62
|
+
- `references/remix-express-full/express-server.md` — Express bootstrap: Redis sessions, helmet/compression/rate-limit ordering.
|
|
63
|
+
- `references/remix-express-full/auth-and-uploads.md` — `getUser`/`requireUser`, protected loader, validated S3 upload route.
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: stack/remix-typescript
|
|
3
|
+
version: 1.0.0
|
|
4
|
+
lang: en
|
|
5
|
+
summary: "Remix + TypeScript discipline: read-only loaders, Zod-validated actions, auth-first protected routes, server-module isolation, mandatory error boundaries."
|
|
6
|
+
source: "frontend/09-remix-typescript.md"
|
|
7
|
+
detect:
|
|
8
|
+
deps: { "@remix-run/react": "*" }
|
|
9
|
+
files: []
|
|
10
|
+
score: 10
|
|
11
|
+
requires: []
|
|
12
|
+
conflicts: []
|
|
13
|
+
tokens: 809
|
|
14
|
+
migrated: true
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
# Remix + TypeScript
|
|
18
|
+
|
|
19
|
+
Rules-only fragment; exemplar code is evicted to `references/remix-typescript/` and read on demand.
|
|
20
|
+
|
|
21
|
+
## Architecture rules
|
|
22
|
+
|
|
23
|
+
- Loaders are read-only — they never mutate data. Actions own all mutations and return either `json()` with validation errors or a `redirect()`; never inline success payloads.
|
|
24
|
+
- Every action validates ALL input with Zod (`safeParse`) before touching the database.
|
|
25
|
+
- `requireUser(request)` is the FIRST call in every protected loader and action; sessions ride an `httpOnly`, `secure`-in-production cookie whose secret comes from the environment.
|
|
26
|
+
- `.server.ts` modules (DB client, auth, anything with secrets) are never imported from client code; business logic lives in loaders/actions, not components.
|
|
27
|
+
- Nested routing: exactly one `<Outlet />` per layout route; `root.tsx` holds only providers and the global `ErrorBoundary`; use `shouldRevalidate` to skip pointless re-fetches; `useMatches()` for breadcrumbs.
|
|
28
|
+
- `ErrorBoundary` is mandatory in `root.tsx` and in any route with external calls; log server-side, show a generic message — never a stack trace in production.
|
|
29
|
+
- ORM discipline: a single client singleton in `db.server.ts` (HMR-safe), explicit `select` on queries (never full ORM objects to the client), every migration named descriptively, no N+1 (use nested `select`/`include`).
|
|
30
|
+
- `throw new Response()` is reserved for 404/401/403 — business errors return `json()` with a status.
|
|
31
|
+
|
|
32
|
+
## Naming
|
|
33
|
+
|
|
34
|
+
Layout routes `_prefix.tsx` (pathless) · dynamic segments `$param` · resource routes export only `loader`/`action` with no default component · server-only modules `*.server.ts` · Zod schemas under `app/lib/validations/`.
|
|
35
|
+
|
|
36
|
+
## Trigger → action
|
|
37
|
+
|
|
38
|
+
| Trigger | Action |
|
|
39
|
+
|---------|--------|
|
|
40
|
+
| New page | route file with `loader`; mutations get an `action` in the same file |
|
|
41
|
+
| New form | Zod schema → Remix `<Form>` → action validates → redirect on success |
|
|
42
|
+
| Protected route | `requireUser()` first line of loader and action |
|
|
43
|
+
| Webhook/API | resource route (no default export) |
|
|
44
|
+
| Model change | named migration, reviewed before merge |
|
|
45
|
+
|
|
46
|
+
## Quality gates (before any PR)
|
|
47
|
+
|
|
48
|
+
- Typecheck, lint (zero warnings), and tests pass — exact commands come from PROJECT FACTS.
|
|
49
|
+
- Every action Zod-validates input; every protected route calls `requireUser()` first.
|
|
50
|
+
- No `.server.ts` import reachable from the client bundle; no N+1 queries.
|
|
51
|
+
- `ErrorBoundary` present in all layout routes; env vars validated at startup.
|
|
52
|
+
- No `console.log` in production paths — structured logger only.
|
|
53
|
+
|
|
54
|
+
## Forbidden
|
|
55
|
+
|
|
56
|
+
- NEVER import `db.server` (or any `.server.ts`) outside server modules.
|
|
57
|
+
- NEVER use a native `<form>` for mutations — use Remix `<Form>`.
|
|
58
|
+
- NEVER fetch app data client-side with `fetch()`/`useEffect` — loaders own it.
|
|
59
|
+
- NEVER return sensitive fields (password hashes, tokens) through `json()`.
|
|
60
|
+
- NEVER duplicate server data into local component state.
|
|
61
|
+
- NEVER use `any`; NEVER hardcode the session secret.
|
|
62
|
+
|
|
63
|
+
## References (read on demand)
|
|
64
|
+
|
|
65
|
+
- `references/remix-typescript/loaders-and-actions.md` — loader/action pair, Zod validation, `<Form>` pending state, error boundary.
|
|
66
|
+
- `references/remix-typescript/auth-and-db.md` — cookie session + `requireUser`, HMR-safe ORM singleton, nested-routing anatomy.
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: stack/rust-axum
|
|
3
|
+
version: 1.0.0
|
|
4
|
+
lang: en
|
|
5
|
+
summary: "Rust + Axum API discipline: typed AppError responses, Arc-cloned state, compile-time-checked SQL, instrumented handlers, no panics in request paths."
|
|
6
|
+
source: "backend/09-rust-axum.md"
|
|
7
|
+
detect:
|
|
8
|
+
deps: { "axum": "*" }
|
|
9
|
+
files: ["Cargo.toml"]
|
|
10
|
+
score: 10
|
|
11
|
+
requires: []
|
|
12
|
+
conflicts: []
|
|
13
|
+
tokens: 754
|
|
14
|
+
migrated: true
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
# Rust API (Axum)
|
|
18
|
+
|
|
19
|
+
Rules-only fragment; exemplar code is evicted to `references/rust-axum/` and read on demand.
|
|
20
|
+
|
|
21
|
+
## Architecture rules
|
|
22
|
+
|
|
23
|
+
- One `AppError` enum (thiserror) implements `IntoResponse`; handlers return `Result<impl IntoResponse, AppError>` only. Internal/database variants log the full error server-side and return a generic message — the client never sees internals.
|
|
24
|
+
- `AppState` derives `Clone` and wraps shared config in `Arc`. The SQLx pool is already `Clone + Send + Sync` — never wrap it in a `Mutex`; if writable shared state is unavoidable, prefer `RwLock` for read-heavy access.
|
|
25
|
+
- SQL goes through compile-time-checked macros (`sqlx::query_as!`) — not runtime-built query strings; hand-written SQL belongs in migration files.
|
|
26
|
+
- Migrations run at startup (`sqlx::migrate!().run(&pool)`) and are committed, idempotent files.
|
|
27
|
+
- Every public handler carries `#[tracing::instrument]` (skipping state/secrets); structured tracing is the only logging mechanism.
|
|
28
|
+
- Errors propagate with `?` — no `unwrap()`/`expect()` outside `main` and tests.
|
|
29
|
+
- Input types validate at the boundary (derive-based validation on request structs / validating extractors that map failures to `AppError`).
|
|
30
|
+
- Layering: routes assemble the router; handlers orchestrate; models hold DB rows plus request/response types. Config is one struct built from the environment at startup.
|
|
31
|
+
|
|
32
|
+
## Trigger → action
|
|
33
|
+
|
|
34
|
+
| Trigger | Action |
|
|
35
|
+
|---------|--------|
|
|
36
|
+
| New endpoint | model types → handler returning `Result<_, AppError>` → route registration |
|
|
37
|
+
| New error case | new `AppError` variant with an explicit status mapping |
|
|
38
|
+
| Schema change | new migration file → run at startup → re-verify checked queries |
|
|
39
|
+
| Shared resource | field on `AppState` (`Arc` for config-like data) |
|
|
40
|
+
| Slow/blocking work | async equivalents (`tokio::fs`, `tokio::time`) — never block the runtime |
|
|
41
|
+
|
|
42
|
+
## Quality gates (before any PR)
|
|
43
|
+
|
|
44
|
+
- Compile with zero warnings; lint clean with warnings denied; all tests pass; dependency audit clean (exact commands come from PROJECT FACTS).
|
|
45
|
+
- No `unwrap()`/`expect()` in request paths; every handler instrumented.
|
|
46
|
+
- Offline query metadata regenerated when checked queries change.
|
|
47
|
+
- Internal errors logged with full detail, returned to clients as generic messages.
|
|
48
|
+
- Migration files committed and idempotent.
|
|
49
|
+
|
|
50
|
+
## Forbidden
|
|
51
|
+
|
|
52
|
+
- NEVER `panic!()`/`unwrap()` in handler code paths.
|
|
53
|
+
- NEVER block inside async handlers (`std::fs`, `std::thread::sleep`).
|
|
54
|
+
- NEVER wrap the connection pool in a `Mutex`.
|
|
55
|
+
- NEVER return raw database errors to the client.
|
|
56
|
+
- NEVER build SQL from string concatenation outside the checked macros.
|
|
57
|
+
- NEVER skip startup migrations.
|
|
58
|
+
- NEVER `.clone()` large data structures in hot paths — restructure ownership instead.
|
|
59
|
+
|
|
60
|
+
## References (read on demand)
|
|
61
|
+
|
|
62
|
+
- `references/rust-axum/error-and-state.md` — `AppError` + `IntoResponse`, `AppState`, config-from-env, bootstrap with migrations.
|
|
63
|
+
- `references/rust-axum/handlers.md` — validated request models, instrumented handlers with `query_as!`, router assembly.
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: stack/serverless-lambda
|
|
3
|
+
version: 1.0.0
|
|
4
|
+
lang: en
|
|
5
|
+
summary: "AWS Lambda + TypeScript discipline: handler→service→repository layering, module-scope clients, Powertools observability, least-privilege IAM, SSM-backed secrets."
|
|
6
|
+
source: "backend/06-serverless-lambda.md"
|
|
7
|
+
detect:
|
|
8
|
+
deps: {}
|
|
9
|
+
files: ["serverless.yml", "template.yaml", "samconfig.toml"]
|
|
10
|
+
score: 6
|
|
11
|
+
requires: []
|
|
12
|
+
conflicts: []
|
|
13
|
+
tokens: 783
|
|
14
|
+
migrated: true
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
# Serverless API (AWS Lambda + TypeScript)
|
|
18
|
+
|
|
19
|
+
Rules-only fragment; exemplar code is evicted to `references/serverless-lambda/` and read on demand.
|
|
20
|
+
|
|
21
|
+
## Architecture rules
|
|
22
|
+
|
|
23
|
+
- Handler → service → repository, strictly, even in Lambda: handlers parse/validate input and shape responses; services hold business logic with no AWS SDK imports; repositories own ALL database access with no business logic.
|
|
24
|
+
- One handler file exports exactly one `handler`; shared code lives in a separate core package, never copy-pasted across functions.
|
|
25
|
+
- AWS clients (DynamoDB document client, etc.) are initialized at module scope — once per container, never inside the handler.
|
|
26
|
+
- Every handler is wrapped with Powertools middleware (structured Logger, Tracer, Metrics via middy); `console.log` is banned.
|
|
27
|
+
- Responses go through shared helpers (`ok`, `badRequest`, `notFound`, …) — no hand-built status/header objects.
|
|
28
|
+
- Input is Zod-validated at the handler boundary (path params, body, and `process.env` at startup).
|
|
29
|
+
- IAM is least-privilege per function: explicit actions on explicit resources, defined in the IaC stack.
|
|
30
|
+
- Secrets come from SSM-backed secret bindings (e.g. IaC secret constructs) — never plaintext environment variables.
|
|
31
|
+
- Import only the specific AWS SDK clients you use; mark runtime-provided SDKs external to the bundler; keep bundles small (no fonts/images/data files — use object storage).
|
|
32
|
+
|
|
33
|
+
## Trigger → action
|
|
34
|
+
|
|
35
|
+
| Trigger | Action |
|
|
36
|
+
|---------|--------|
|
|
37
|
+
| New endpoint | handler file → Zod schemas → service call → response helper |
|
|
38
|
+
| New table access | repository method — handlers never touch the SDK client |
|
|
39
|
+
| New secret | IaC secret binding (SSM) — never a plaintext env var |
|
|
40
|
+
| Slow cold starts | check module-scope init, bundle size, and unnecessary imports |
|
|
41
|
+
| New permission | add the minimal action/resource pair to that function only |
|
|
42
|
+
|
|
43
|
+
## Quality gates (before any PR)
|
|
44
|
+
|
|
45
|
+
- Typecheck and tests pass across all packages (exact commands come from PROJECT FACTS; Lambda tests often need serial execution).
|
|
46
|
+
- Bundle size per function within the project budget — verify with the bundler/IaC analyzer.
|
|
47
|
+
- No hardcoded secrets; env access validated at startup via Zod.
|
|
48
|
+
- Structured logs only; tracing enabled through the Powertools tracer.
|
|
49
|
+
- Each function's IAM policy reviewed for least privilege.
|
|
50
|
+
- Clients initialized at module scope; responses built via helpers.
|
|
51
|
+
|
|
52
|
+
## Forbidden
|
|
53
|
+
|
|
54
|
+
- NEVER attach `AdministratorAccess` or wildcard IAM policies.
|
|
55
|
+
- NEVER store secrets as plaintext Lambda environment variables.
|
|
56
|
+
- NEVER initialize AWS clients inside the handler body.
|
|
57
|
+
- NEVER `console.log` — use the Powertools Logger.
|
|
58
|
+
- NEVER import database clients directly in handlers — go through the repository layer.
|
|
59
|
+
- NEVER return raw AWS SDK error messages to clients.
|
|
60
|
+
- NEVER bundle test files into the deployment package.
|
|
61
|
+
- NEVER raise memory or timeout without benchmarking — API-gateway-fronted endpoints must stay under the gateway's integration timeout.
|
|
62
|
+
|
|
63
|
+
## References (read on demand)
|
|
64
|
+
|
|
65
|
+
- `references/serverless-lambda/handler-patterns.md` — module-scope init, Powertools + middy handler, response helpers, least-privilege IaC stack.
|