@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,81 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: domain/notificacoes-multicanal
|
|
3
|
+
version: 1.0.0
|
|
4
|
+
lang: en
|
|
5
|
+
summary: "Multi-channel notification discipline: preference-checked fan-out, idempotent deliveries, bounce and token hygiene, validated templates, quiet hours and frequency caps, alerting dead letters."
|
|
6
|
+
source: "dominio/08-notificacoes-multicanal.md"
|
|
7
|
+
detect:
|
|
8
|
+
deps: {}
|
|
9
|
+
files: []
|
|
10
|
+
score: 0
|
|
11
|
+
confirm: true
|
|
12
|
+
requires: []
|
|
13
|
+
conflicts: []
|
|
14
|
+
tokens: 996
|
|
15
|
+
migrated: true
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
# Domain: Multi-channel notifications (email, push, SMS, in-app)
|
|
19
|
+
|
|
20
|
+
Bad notification systems destroy the experience: duplicates, retry spam, no opt-out, a wrong message at 3 a.m. The technical challenge is reliable at-least-once delivery with no user-visible duplicates; the product challenge is honoring user preferences on every channel. Exemplar code lives in `references/notificacoes-multicanal/` — read on demand.
|
|
21
|
+
|
|
22
|
+
## Pipeline
|
|
23
|
+
|
|
24
|
+
- Event-driven: business event → resolve recipients → check preferences per user per channel → enqueue one delivery job per channel → channel workers send → track delivery.
|
|
25
|
+
- One delivery record per (notification × recipient × channel) is the idempotency anchor: before sending, check its status — a retry never sends twice.
|
|
26
|
+
- Retries use exponential backoff with a bounded attempt count; after that, dead-letter + ops alert carrying the message and the specific error. A silently dead notification is silently lost communication.
|
|
27
|
+
|
|
28
|
+
## Preferences and consent
|
|
29
|
+
|
|
30
|
+
- Preferences are granular: per event type AND per channel; global opt-out disables everything except mandatory transactional messages.
|
|
31
|
+
- Transactional notifications (password reset, purchase confirmation) bypass only marketing opt-outs — never bounce suppression.
|
|
32
|
+
- Quiet hours: no push/SMS during the user's night window, computed in the USER'S timezone.
|
|
33
|
+
- Frequency cap: count per type per user per day before delivering.
|
|
34
|
+
- Provider unsubscribe webhooks are honored immediately.
|
|
35
|
+
|
|
36
|
+
## Channel hygiene
|
|
37
|
+
|
|
38
|
+
- Hard bounce: mark the address invalid and never email it again without explicit user action; soft bounces get a bounded retry before temporary suspension.
|
|
39
|
+
- Invalid push token (rejected by the provider): delete it from the database immediately — devices rotate tokens.
|
|
40
|
+
- Track delivery states (queued → sending → sent → delivered | failed | bounced | unsubscribed) via provider webhooks (bounce, open, click, unsubscribe).
|
|
41
|
+
- Provider failover: switch providers when the error rate crosses the threshold; test the fallback in staging regularly.
|
|
42
|
+
|
|
43
|
+
## Templates
|
|
44
|
+
|
|
45
|
+
- Stored in the database (editable without deploy), with fallback: DB template → file template → hardcoded default.
|
|
46
|
+
- Per-locale templates with fallback to the default locale.
|
|
47
|
+
- Variables are validated before render — an undefined variable fails loudly; broken content is never sent.
|
|
48
|
+
- Admin preview renders templates with example variables.
|
|
49
|
+
|
|
50
|
+
## Trigger → action
|
|
51
|
+
|
|
52
|
+
| Trigger | Action |
|
|
53
|
+
|---------|--------|
|
|
54
|
+
| Business event | resolve recipients → preference/bounce/cap checks → create deliveries → enqueue per channel |
|
|
55
|
+
| Delivery job | idempotency check → render validated template → send → update delivery |
|
|
56
|
+
| Provider bounce webhook | mark hard/soft bounce → suppress if hard |
|
|
57
|
+
| Provider unsubscribe webhook | update preferences immediately |
|
|
58
|
+
| Invalid-token error | delete the stored token |
|
|
59
|
+
| Max retries exceeded | dead-letter + ops alert |
|
|
60
|
+
|
|
61
|
+
## Quality gates
|
|
62
|
+
|
|
63
|
+
- Opt-out (global and per type) respected on 100% of channels; transactional messages unaffected by marketing opt-out.
|
|
64
|
+
- Idempotency checked before every send attempt; duplicate-free under retry, proven by test.
|
|
65
|
+
- Hard bounces suppress the address immediately; invalid push tokens removed on provider error.
|
|
66
|
+
- Templates reject undefined variables before render.
|
|
67
|
+
- Quiet hours computed in the recipient's timezone; frequency caps enforced.
|
|
68
|
+
- Bounded retries with an alerting dead-letter queue; provider failover exercised in staging.
|
|
69
|
+
|
|
70
|
+
## Forbidden
|
|
71
|
+
|
|
72
|
+
- Sending without checking user preferences.
|
|
73
|
+
- Unlimited retries — bounded attempts, then dead-letter.
|
|
74
|
+
- Keeping invalid push tokens in the database.
|
|
75
|
+
- Templates that silently accept undefined variables.
|
|
76
|
+
- Non-transactional messages to opted-out users.
|
|
77
|
+
- Push/SMS in quiet hours without checking the recipient's timezone.
|
|
78
|
+
|
|
79
|
+
## References (read on demand)
|
|
80
|
+
|
|
81
|
+
- `references/notificacoes-multicanal/patterns.md` — idempotent delivery, preference-filtered fan-out, invalid-token cleanup, template validation discipline.
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: domain/pagamentos-brasil
|
|
3
|
+
version: 1.0.0
|
|
4
|
+
lang: en
|
|
5
|
+
summary: "Brazilian payment rails: Pix dynamic QR + webhook confirmation, boleto settlement accounting, double-credit-proof idempotent webhooks, gateway adapters, reconciliation discipline, PCI scope."
|
|
6
|
+
# Human-confirmed domain — detection only SUGGESTS (suggest-not-auto): weak file-name
|
|
7
|
+
# signals with a low score and confirm: true. deps are AND-matched by the detector, so
|
|
8
|
+
# alternative gateway SDKs cannot be ORed there; name-family file globs carry the OR.
|
|
9
|
+
detect:
|
|
10
|
+
deps: {}
|
|
11
|
+
files: ["**/*mercadopago*", "**/*pagarme*", "**/*asaas*", "**/pix/**", "**/*boleto*"]
|
|
12
|
+
score: 2
|
|
13
|
+
confirm: true
|
|
14
|
+
requires: []
|
|
15
|
+
conflicts: []
|
|
16
|
+
tokens: 1100
|
|
17
|
+
migrated: true
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
# Domain: Pagamentos Brasil (Pix, boleto, gateways)
|
|
21
|
+
|
|
22
|
+
Brazilian rails have timing and failure modes card rails don't: Pix settles in seconds, 24/7; boleto settles days after "paid"; every gateway retries webhooks. A double credit or a forged confirmation is a financial incident, not a bug. Exemplars live in `references/pagamentos-brasil/` — read on demand.
|
|
23
|
+
|
|
24
|
+
## Rails at a glance
|
|
25
|
+
|
|
26
|
+
| Rail | Confirmed by | Settlement | Expiry | Refund |
|
|
27
|
+
|------|--------------|------------|--------|--------|
|
|
28
|
+
| Pix (dynamic QR) | webhook, seconds | instant, 24/7 | explicit expiry, always | devolução by endToEndId; async, partial/full, window-bound |
|
|
29
|
+
| Boleto (bank-registered) | webhook or bank return file | D+1..D+3 business days | due date; late payment is bank-dependent — decide reject vs accept | no native rail — manual transfer, audited |
|
|
30
|
+
|
|
31
|
+
## Critical rules
|
|
32
|
+
|
|
33
|
+
1. A payment is confirmed ONLY by a signature-verified webhook or an authenticated status poll — never by a client-side "I paid" signal or a redirect page.
|
|
34
|
+
2. Verify the webhook signature (HMAC/mTLS, per provider) against the raw body BEFORE parsing; unsigned or invalid ⇒ reject and alert.
|
|
35
|
+
3. Double-credit prevention: persist the provider event id (and txid/endToEndId) under a unique constraint and credit the ledger in the SAME transaction — a duplicate insert aborts the credit. Webhooks arrive duplicated, out of order, or never.
|
|
36
|
+
4. Missing webhooks are reconciled by polling the provider; never assume delivery.
|
|
37
|
+
5. Every Pix charge carries an explicit expiry; an expired QR is regenerated with a new txid — never reused.
|
|
38
|
+
6. Money is integer centavos end to end; floats are forbidden.
|
|
39
|
+
7. Pix devolução references the original endToEndId and is async — confirmed by webhook under the same idempotency rules.
|
|
40
|
+
8. A boleto exists only after bank registration; "paid" is not money: release goods on "settled" only; accounting models the D+1..D+3 float explicitly.
|
|
41
|
+
9. One gateway adapter behind one port: provider families (Mercado Pago, Pagar.me, Asaas, Efí) differ in webhook shape, retry policy, and sandbox fidelity — provider types never leak outside it.
|
|
42
|
+
10. PCI scope stays at the gateway: card PAN/CVV never touches your servers, database, or logs — use gateway-hosted fields/tokenization. API keys and webhook secrets are still secrets.
|
|
43
|
+
|
|
44
|
+
## Reconciliation discipline
|
|
45
|
+
|
|
46
|
+
- A scheduled job diffs provider statement/API vs local ledger both ways; any diff alerts a human — never auto-corrected.
|
|
47
|
+
- Charge status is a state machine (created → waiting → confirmed → settled → refunded | expired | failed); illegal transitions are rejected and logged.
|
|
48
|
+
|
|
49
|
+
## Common pitfalls
|
|
50
|
+
|
|
51
|
+
- Crediting on webhook receipt without the unique event constraint — a retry storm becomes a double credit.
|
|
52
|
+
- Treating the boleto "paid" event as settled cash.
|
|
53
|
+
- Storing charge state only at the gateway — you can't reconcile what you didn't record.
|
|
54
|
+
|
|
55
|
+
## Trigger → action
|
|
56
|
+
|
|
57
|
+
| Trigger | Action |
|
|
58
|
+
|---------|--------|
|
|
59
|
+
| New charge | create dynamic QR with explicit expiry → persist txid BEFORE showing it |
|
|
60
|
+
| Webhook received | verify signature → dedupe by event id → apply state transition → 200 fast, heavy work async |
|
|
61
|
+
| Expiry reached, no webhook | poll provider → mark expired → regenerate with new txid |
|
|
62
|
+
| Refund request | Pix: devolução by endToEndId, confirm async; boleto: manual payout, audited |
|
|
63
|
+
| New gateway | new adapter behind the same port + contract tests replaying recorded webhooks |
|
|
64
|
+
|
|
65
|
+
## Quality gates
|
|
66
|
+
|
|
67
|
+
- Webhook handler tested for duplicate delivery, out-of-order events, invalid signature, unknown txid.
|
|
68
|
+
- Double-credit test: the same event delivered twice credits exactly once.
|
|
69
|
+
- Reconciliation job proven in staging with a seeded mismatch.
|
|
70
|
+
- Schema check: all money columns are integer centavos.
|
|
71
|
+
|
|
72
|
+
## Forbidden
|
|
73
|
+
|
|
74
|
+
- Confirming payment from anything the client controls.
|
|
75
|
+
- Processing an unverified webhook body.
|
|
76
|
+
- Credit paths without idempotency keys.
|
|
77
|
+
- Floats for money, anywhere.
|
|
78
|
+
- Card PAN/CVV in your database or logs.
|
|
79
|
+
- Releasing goods before settlement (boleto) or confirmation (Pix).
|
|
80
|
+
- Reusing an expired txid/QR.
|
|
81
|
+
|
|
82
|
+
## References (read on demand)
|
|
83
|
+
|
|
84
|
+
- `references/pagamentos-brasil/pix-boleto.md` — dynamic QR lifecycle, idempotent webhook handler, devolução flow, boleto settlement accounting.
|
|
85
|
+
- `references/pagamentos-brasil/gateways-reconciliation.md` — adapter port + contract tests, gateway family differences, reconciliation job, charge state machine.
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: domain/plataforma-conteudo
|
|
3
|
+
version: 1.0.0
|
|
4
|
+
lang: en
|
|
5
|
+
summary: "Content platform / CMS discipline: immutable published versions, slug redirects, editor-native JSON storage, SEO metadata gates, queued CDN invalidation."
|
|
6
|
+
source: "dominio/06-plataforma-conteudo.md"
|
|
7
|
+
detect:
|
|
8
|
+
deps: { "@tiptap/core": "*" }
|
|
9
|
+
files: []
|
|
10
|
+
score: 3
|
|
11
|
+
confirm: true
|
|
12
|
+
requires: []
|
|
13
|
+
conflicts: []
|
|
14
|
+
tokens: 1068
|
|
15
|
+
migrated: true
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
# Domain: Content platform (CMS / blog)
|
|
19
|
+
|
|
20
|
+
A CMS looks simple but hides SEO traps (a wrong canonical URL earns a duplicate-content penalty), performance traps (N+1 on post listings), and consistency traps (a draft published by a race condition). The rich-text storage format is the hardest decision to reverse. Exemplar schema and code live in `references/plataforma-conteudo/` — read on demand.
|
|
21
|
+
|
|
22
|
+
## Content model
|
|
23
|
+
|
|
24
|
+
- A post row holds identity, unique slug, status, and a pointer to its current version; every publication creates an immutable version snapshot (title, excerpt, content, SEO metadata). Rollback repoints the current-version pointer — history is never edited.
|
|
25
|
+
- Status flow: `draft → review → scheduled → published → archived`.
|
|
26
|
+
|
|
27
|
+
## Critical rules
|
|
28
|
+
|
|
29
|
+
1. A published slug never changes without a 301 redirect record from the old slug — and the old URL is invalidated too. Slugs are freely editable only before first publication; uniqueness is checked before save.
|
|
30
|
+
2. Published content is immutable history: every edit creates a new version; rollback repoints, never mutates.
|
|
31
|
+
3. Rich text is stored as the editor's native JSON (or Markdown) — never as generated HTML. HTML is produced at render time and sanitized; editor JSON can carry malicious links too.
|
|
32
|
+
4. Embedded media is referenced by asset ID, never by hardcoded URL. Media deletion is soft, checks references in published content first, and finishes via a cleanup job.
|
|
33
|
+
5. CDN invalidation is always asynchronous (queued, never inline in the publish request) and path-targeted: the post URL, listings, sitemap, feed. Wildcard invalidation is expensive and slow — last resort only.
|
|
34
|
+
6. Every published post ships with `canonical_url`, `meta_title`, and `meta_description` filled and length-validated (title ~60 chars, description ~160). Open Graph fields are separate from SEO meta.
|
|
35
|
+
7. The sitemap includes only published, indexable posts with lastmod = publication time; drafts, archives, and paginated/filtered pages carry `noindex`.
|
|
36
|
+
8. Scheduled publishing is a queued job that re-checks the post is still `scheduled` before publishing — it may have been cancelled.
|
|
37
|
+
9. Authors without publish permission submit to `review`; publishing is a permission-gated transition, not a client-side toggle.
|
|
38
|
+
10. Comments enter as `pending` and pass moderation before public display; media uploads validate MIME type server-side, never by extension alone.
|
|
39
|
+
|
|
40
|
+
## Common pitfalls
|
|
41
|
+
|
|
42
|
+
- Mutating a published slug 404s every indexed and externally linked URL — create the redirect first, then invalidate both old and new paths.
|
|
43
|
+
- Raw editor HTML in the database blocks any future editor migration and is a standing XSS risk.
|
|
44
|
+
- Synchronous CDN invalidation makes the publish request hang on the provider — queue it and respond immediately.
|
|
45
|
+
|
|
46
|
+
## Trigger → action
|
|
47
|
+
|
|
48
|
+
| Trigger | Action |
|
|
49
|
+
|---------|--------|
|
|
50
|
+
| Create post | draft + slug generated from title + uniqueness check |
|
|
51
|
+
| Publish | version snapshot → repoint current → queue CDN invalidation → reindex search |
|
|
52
|
+
| Unpublish | remove from delivery → queue invalidation → drop from sitemap |
|
|
53
|
+
| Slug change (published) | create 301 redirect → update slug → invalidate old and new URLs |
|
|
54
|
+
| Schedule | queue job for the publish time; job re-validates status |
|
|
55
|
+
| Media delete | reference check → soft delete → cleanup job |
|
|
56
|
+
|
|
57
|
+
## Quality gates
|
|
58
|
+
|
|
59
|
+
- Canonical/meta fields present and length-valid on 100% of published posts.
|
|
60
|
+
- Slug-change path proven to create a redirect (tested).
|
|
61
|
+
- Content stored as editor JSON; the render pipeline sanitizes output.
|
|
62
|
+
- CDN invalidation observed to be queued, never inline.
|
|
63
|
+
- Sitemap excludes drafts and `noindex` pages; version rollback exercised end-to-end.
|
|
64
|
+
- Comment moderation and server-side MIME validation covered by tests.
|
|
65
|
+
|
|
66
|
+
## Forbidden
|
|
67
|
+
|
|
68
|
+
- Storing editor-generated HTML in the database.
|
|
69
|
+
- Changing a published slug without creating a redirect.
|
|
70
|
+
- Synchronous CDN invalidation inside the publish request.
|
|
71
|
+
- Publishing without the required SEO metadata.
|
|
72
|
+
- Deleting media still referenced by published content.
|
|
73
|
+
- Public comments without a moderation flow on open platforms.
|
|
74
|
+
|
|
75
|
+
## References (read on demand)
|
|
76
|
+
|
|
77
|
+
- `references/plataforma-conteudo/patterns.md` — versioned content model, slug-redirect flow, editor-JSON storage, queued CDN invalidation.
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: domain/realtime-websockets
|
|
3
|
+
version: 1.0.0
|
|
4
|
+
lang: en
|
|
5
|
+
summary: "Realtime discipline: SSE vs WebSocket decision, handshake-only auth, per-room authorization, pub/sub adapter for multi-instance, TTL presence, REST-based reconnection."
|
|
6
|
+
source: "dominio/11-realtime-websockets.md"
|
|
7
|
+
detect:
|
|
8
|
+
deps: { "socket.io": "*" }
|
|
9
|
+
files: []
|
|
10
|
+
score: 4
|
|
11
|
+
confirm: true
|
|
12
|
+
requires: []
|
|
13
|
+
conflicts: []
|
|
14
|
+
tokens: 1045
|
|
15
|
+
migrated: true
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
# Domain: Realtime (WebSockets / SSE)
|
|
19
|
+
|
|
20
|
+
Realtime demos break in production: multiple instances split rooms, client reconnections duplicate messages, and backpressure takes the server down. The SSE-vs-WebSocket choice changes the whole architecture — decide it before writing code. Exemplar code lives in `references/realtime-websockets/` — read on demand.
|
|
21
|
+
|
|
22
|
+
## SSE vs WebSocket
|
|
23
|
+
|
|
24
|
+
| Criterion | SSE | WebSocket |
|
|
25
|
+
|-----------|-----|-----------|
|
|
26
|
+
| Direction | server → client only | bidirectional |
|
|
27
|
+
| Transport | plain HTTP | protocol upgrade |
|
|
28
|
+
| Reconnection | automatic (browser) | library/manual |
|
|
29
|
+
| Proxy/firewall | best compatibility | can be blocked |
|
|
30
|
+
| Complexity | low | high |
|
|
31
|
+
|
|
32
|
+
Use SSE for feeds, notifications, dashboards, and job progress. Use WebSocket for chat, realtime collaboration, games, and presence.
|
|
33
|
+
|
|
34
|
+
## Critical rules
|
|
35
|
+
|
|
36
|
+
1. Authenticate at the handshake, never per message; the resolved user rides on the connection for all handlers.
|
|
37
|
+
2. Authorize on every room join against the underlying resource — not only at connect time.
|
|
38
|
+
3. Multi-instance deployment requires a pub/sub adapter (e.g. Redis-backed); without it, rooms split-brain across instances.
|
|
39
|
+
4. Never run heavy synchronous work inside event handlers — it blocks the event loop for every connection.
|
|
40
|
+
5. Ephemeral signals (typing, cursors) are broadcast only, never persisted.
|
|
41
|
+
6. Reconnection never assumes prior state: recover missed messages via a REST history endpoint or an event cursor — never rebuild full state over the socket.
|
|
42
|
+
7. Presence lives in a store with TTL plus heartbeat renewal; without TTL, a crash with no disconnect event strands ghost users online forever.
|
|
43
|
+
8. Backpressure: cap the per-connection send buffer and close consistently slow consumers.
|
|
44
|
+
9. Heartbeat/ping-pong with an inactivity timeout reaps dead connections.
|
|
45
|
+
10. Emit to specific rooms only — global broadcasts are forbidden on production paths.
|
|
46
|
+
11. SSE events carry `event:`, `id:`, and `retry:` fields so clients can resume from a cursor (`Last-Event-ID`).
|
|
47
|
+
|
|
48
|
+
## Naming
|
|
49
|
+
|
|
50
|
+
Rooms follow `<resource_type>:<resource_id>` (e.g. `post:123`, `org:456`). Rooms are ephemeral: created on demand, never persisted to the database.
|
|
51
|
+
|
|
52
|
+
## Common pitfalls
|
|
53
|
+
|
|
54
|
+
- Presence without TTL: a server restart with no disconnect event leaves users "online" permanently — TTL plus periodic heartbeat renewal fixes it.
|
|
55
|
+
- Scaling without the pub/sub adapter: an event emitted on instance A never reaches sockets connected to instance B.
|
|
56
|
+
- Rebuilding full state over the socket at reconnect: use REST for history, the socket for live deltas only.
|
|
57
|
+
|
|
58
|
+
## Trigger → action
|
|
59
|
+
|
|
60
|
+
| Trigger | Action |
|
|
61
|
+
|---------|--------|
|
|
62
|
+
| Connect | verify token at handshake → attach user → confirm |
|
|
63
|
+
| Room join | authorize against the resource → join → update presence |
|
|
64
|
+
| Chat message | validate → persist → broadcast to the room |
|
|
65
|
+
| Ephemeral signal | broadcast to the room, no persistence |
|
|
66
|
+
| Disconnect | clear presence (if last connection of that user) → notify room if relevant |
|
|
67
|
+
| Reconnect | client fetches missed history via REST/cursor, then resumes deltas |
|
|
68
|
+
| Job progress | SSE stream subscribed to the pub/sub channel; close on completion |
|
|
69
|
+
|
|
70
|
+
## Quality gates
|
|
71
|
+
|
|
72
|
+
- Handshake auth rejects invalid tokens with a clear error; no per-message auth anywhere.
|
|
73
|
+
- Pub/sub adapter configured and tested before any multi-instance deploy.
|
|
74
|
+
- Room joins tested against unauthorized users.
|
|
75
|
+
- Presence TTL + heartbeat proven: no ghost users after a forced process kill.
|
|
76
|
+
- Reconnect path recovers history via REST/cursor in tests.
|
|
77
|
+
- Per-connection buffer limit enforced; dead connections reaped by heartbeat.
|
|
78
|
+
- SSE events carry `id:` so reconnection resumes from the cursor.
|
|
79
|
+
|
|
80
|
+
## Forbidden
|
|
81
|
+
|
|
82
|
+
- Per-message authentication.
|
|
83
|
+
- Multi-instance deployment without a pub/sub adapter.
|
|
84
|
+
- Heavy synchronous logic inside socket event handlers.
|
|
85
|
+
- Presence entries without TTL/heartbeat.
|
|
86
|
+
- Global broadcasts unscoped by room.
|
|
87
|
+
- Persisting ephemeral signals.
|
|
88
|
+
- Assuming connection state survived a reconnection.
|
|
89
|
+
|
|
90
|
+
## References (read on demand)
|
|
91
|
+
|
|
92
|
+
- `references/realtime-websockets/patterns.md` — handshake auth middleware, pub/sub adapter wiring, TTL presence, event-handler offloading, SSE cursor resume.
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: domain/relatorios-analytics
|
|
3
|
+
version: 1.0.0
|
|
4
|
+
lang: en
|
|
5
|
+
summary: "Reporting and analytics discipline: OLTP/OLAP split, read replicas and materialized views, explicit timezones, streaming exports, async report jobs."
|
|
6
|
+
source: "dominio/13-relatorios-analytics.md"
|
|
7
|
+
detect:
|
|
8
|
+
deps: {}
|
|
9
|
+
files: []
|
|
10
|
+
score: 0
|
|
11
|
+
confirm: true
|
|
12
|
+
requires: []
|
|
13
|
+
conflicts: []
|
|
14
|
+
tokens: 913
|
|
15
|
+
migrated: true
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
# Domain: Reports and analytics
|
|
19
|
+
|
|
20
|
+
Reports fail subtly: a five-table join that works on a hundred dev rows times out on millions of production rows; a large export OOMs the process; an implicit timezone puts yesterday's sales in today's report. The OLTP/OLAP split is a performance decision with real consequences, not an academic one. Exemplar SQL and code live in `references/relatorios-analytics/` — read on demand.
|
|
21
|
+
|
|
22
|
+
## Where a query runs
|
|
23
|
+
|
|
24
|
+
- Simple indexed query, small result: the primary OLTP database is fine.
|
|
25
|
+
- Aggregations with joins over large row counts: read replica or materialized view.
|
|
26
|
+
- Full-scan analytics beyond that: a dedicated analytical store / data warehouse.
|
|
27
|
+
- Recurring report with a fixed query: materialized view with scheduled refresh.
|
|
28
|
+
- Bulk export: always streaming, always asynchronous.
|
|
29
|
+
|
|
30
|
+
## Critical rules
|
|
31
|
+
|
|
32
|
+
1. Report and dashboard queries never run on the primary — read replica, materialized view, or warehouse.
|
|
33
|
+
2. Every date/range query states its timezone explicitly (the user's or tenant's) and converts before grouping — never the server default.
|
|
34
|
+
3. Exports beyond a trivial row count are async jobs: enqueue → worker streams to object storage → signed, expiring download link → notify the user.
|
|
35
|
+
4. CSV/Excel generation streams row by row; the full dataset never sits in memory.
|
|
36
|
+
5. Materialized views carry indexes and are refreshed concurrently (non-locking) in production.
|
|
37
|
+
6. Replica lag is monitored and alerted; when data may be stale, the UI says so.
|
|
38
|
+
7. Concurrent exports per user are capped; the excess queues.
|
|
39
|
+
8. Scheduled reports alert after consecutive failures.
|
|
40
|
+
9. Long exports expose progress or an estimate to the user.
|
|
41
|
+
10. User input never reaches SQL directly — filters and fields go through a whitelist, even "just for reports".
|
|
42
|
+
|
|
43
|
+
## Common pitfalls
|
|
44
|
+
|
|
45
|
+
- Grouping by day in server UTC shifts evening sales into "tomorrow" for the user's timezone — convert to the user's zone before grouping.
|
|
46
|
+
- An unindexed aggregate on the busy production table sequential-scans for seconds while checkout reads the same rows.
|
|
47
|
+
- Returning a huge result as one JSON response serializes the whole set in RAM and crashes the process — stream CSV to the client or to object storage.
|
|
48
|
+
|
|
49
|
+
## Trigger → action
|
|
50
|
+
|
|
51
|
+
| Trigger | Action |
|
|
52
|
+
|---------|--------|
|
|
53
|
+
| Dashboard widget | materialized view (bounded staleness, minutes) |
|
|
54
|
+
| Ad-hoc ranged report | read replica + explicit timezone conversion |
|
|
55
|
+
| Export request | async job → stream to storage → signed link + email |
|
|
56
|
+
| Job status poll | queued/processing/ready/failed + download URL |
|
|
57
|
+
| Recurring report | scheduler → same async pipeline → failure alerts |
|
|
58
|
+
| Real-time metric | primary with a short cache, scoped to a tiny window |
|
|
59
|
+
|
|
60
|
+
## Quality gates
|
|
61
|
+
|
|
62
|
+
- Zero report queries on the primary, verified by connection configuration review.
|
|
63
|
+
- Explicit timezone on every date/grouping query.
|
|
64
|
+
- Streaming proven for the largest supported export — memory stays flat.
|
|
65
|
+
- Materialized views indexed; refresh is concurrent.
|
|
66
|
+
- Replica-lag alerting live; download links expire.
|
|
67
|
+
- Per-user export cap enforced; scheduled-report failure alerts tested.
|
|
68
|
+
|
|
69
|
+
## Forbidden
|
|
70
|
+
|
|
71
|
+
- Heavy analytical queries on the primary OLTP database.
|
|
72
|
+
- Loading a full dataset into memory before export.
|
|
73
|
+
- Implicit server timezone in user-facing date ranges.
|
|
74
|
+
- Non-concurrent materialized-view refresh in production.
|
|
75
|
+
- SQL assembled from user input without a field whitelist.
|
|
76
|
+
- Synchronous large exports inside an HTTP request.
|
|
77
|
+
|
|
78
|
+
## References (read on demand)
|
|
79
|
+
|
|
80
|
+
- `references/relatorios-analytics/patterns.md` — materialized-view SQL with concurrent refresh, timezone-correct ranges, streaming export, async report-job pipeline.
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: domain/saas-stripe-billing
|
|
3
|
+
version: 1.0.0
|
|
4
|
+
lang: en
|
|
5
|
+
summary: "SaaS subscription billing discipline: verified async webhooks, Stripe as source of truth, status-based access gates, proration preview, safe cancellation, meter-event usage."
|
|
6
|
+
source: "dominio/01-saas-stripe-billing.md"
|
|
7
|
+
detect:
|
|
8
|
+
deps: { "stripe": "*" }
|
|
9
|
+
files: []
|
|
10
|
+
score: 6
|
|
11
|
+
confirm: true
|
|
12
|
+
requires: []
|
|
13
|
+
conflicts: []
|
|
14
|
+
tokens: 1071
|
|
15
|
+
migrated: true
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
# Domain: SaaS billing (Stripe subscriptions)
|
|
19
|
+
|
|
20
|
+
Billing is where silent bugs live: webhooks arrive out of order, trials expire unnoticed, proration surprises users. Treat billing as a distributed-systems problem, not a simple feature. Exemplar code lives in `references/saas-stripe-billing/` — read on demand.
|
|
21
|
+
|
|
22
|
+
## Critical rules
|
|
23
|
+
|
|
24
|
+
1. Verify the webhook signature before any parsing — processing unverified webhooks is a vulnerability, not a bug.
|
|
25
|
+
2. Never process webhooks inside the HTTP request: verify, enqueue, return 200 immediately. Slow handlers hit the provider timeout and trigger redelivery.
|
|
26
|
+
3. Handlers are idempotent: dedupe by event id against processed events before acting; reprocessing the same event must be a no-op.
|
|
27
|
+
4. Check the event type before touching the event payload object.
|
|
28
|
+
5. Stripe is the source of truth. The local database mirrors only what gating needs: customer id, subscription id, plan/price id, status, period end.
|
|
29
|
+
6. Access gates key on subscription status (`active`/`trialing`), never on period-end timestamps — `past_due` users are in a grace period, not cancelled.
|
|
30
|
+
7. Plan/feature gates are centralized middleware resolved from the plan (short-TTL cache, ~60s), never scattered if/else and never trusted from the client. Denials return 402 with a machine-readable upgrade code and the feature name.
|
|
31
|
+
8. Upgrades/downgrades show a proration preview (upcoming-invoice) before the user confirms.
|
|
32
|
+
9. Cancellation defaults to end-of-period, never immediate. Never delete the Stripe customer — cancel the subscription; the customer holds fiscal history.
|
|
33
|
+
10. Usage-based billing reports through Stripe's current metering API (meter events); the legacy usage-records API is deprecated. Always send the event's own timestamp, never server "now".
|
|
34
|
+
11. Card data never touches your systems — only Stripe payment-method tokens are stored.
|
|
35
|
+
12. Never call the Stripe API inside a database transaction (latency + deadlock risk).
|
|
36
|
+
13. Trial expiry is announced ahead of time by scheduled reminder emails; a trial without a payment method ends as `canceled`, not `past_due`.
|
|
37
|
+
14. Every Stripe write call carries an idempotency key; test and live modes use separate env-provided keys; every Stripe interaction is logged structurally.
|
|
38
|
+
|
|
39
|
+
## Common pitfalls
|
|
40
|
+
|
|
41
|
+
- Gating on `period end > now`: a `past_due` subscription still has a future period end — the status is the gate.
|
|
42
|
+
- Business logic in the webhook request: provider timeouts cause redelivery, and non-idempotent handlers then double-apply the change.
|
|
43
|
+
- Immediate cancellation: the user paid for the period — cancel at period end unless they explicitly demand otherwise.
|
|
44
|
+
|
|
45
|
+
## Trigger → action
|
|
46
|
+
|
|
47
|
+
| Trigger | Action |
|
|
48
|
+
|---------|--------|
|
|
49
|
+
| Webhook received | verify signature → dedupe by event id → enqueue → 200 |
|
|
50
|
+
| Payment failed | status `past_due` → dunning email → grace period starts |
|
|
51
|
+
| Payment succeeded | status `active` → extend the local period mirror |
|
|
52
|
+
| Subscription deleted | mark `canceled` → revoke access → notify |
|
|
53
|
+
| Trial ending soon | reminder email sequence |
|
|
54
|
+
| Upgrade request | proration preview → user confirms → update via API |
|
|
55
|
+
| Cancel request | cancel at period end → confirm to the user |
|
|
56
|
+
| Usage event | meter event with the original event timestamp |
|
|
57
|
+
|
|
58
|
+
## Quality gates
|
|
59
|
+
|
|
60
|
+
- Signature verification precedes parsing; tested with an invalid signature.
|
|
61
|
+
- Every webhook event deduped; a handler replay test proves idempotency.
|
|
62
|
+
- Gates centralized; the 402 body carries the upgrade code and feature.
|
|
63
|
+
- Proration preview shown before any plan change.
|
|
64
|
+
- Cancellation is end-of-period in tests; local webhook simulation (Stripe CLI listener) wired into development.
|
|
65
|
+
- Idempotency keys present on all Stripe write calls.
|
|
66
|
+
|
|
67
|
+
## Forbidden
|
|
68
|
+
|
|
69
|
+
- Storing card numbers (PAN) in any storage.
|
|
70
|
+
- Business logic inside the webhook HTTP handler.
|
|
71
|
+
- Using the event payload without checking the event type first.
|
|
72
|
+
- Stripe API calls inside database transactions.
|
|
73
|
+
- Immediate cancellation without explicit user confirmation.
|
|
74
|
+
- Trusting client-supplied plan or price identifiers.
|
|
75
|
+
- Gating access on period-end timestamps instead of status.
|
|
76
|
+
|
|
77
|
+
## References (read on demand)
|
|
78
|
+
|
|
79
|
+
- `references/saas-stripe-billing/patterns.md` — queued webhook handler, status-based gate, end-of-period cancellation, meter-event usage reporting.
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: domain/sistema-pagamentos
|
|
3
|
+
version: 1.0.0
|
|
4
|
+
lang: en
|
|
5
|
+
summary: "Payments discipline: PCI-safe card handling, idempotent gateway calls, webhook-confirmed 3DS, explicit payment state machine, refund ceilings, daily reconciliation."
|
|
6
|
+
source: "dominio/05-sistema-pagamentos.md"
|
|
7
|
+
detect:
|
|
8
|
+
deps: {}
|
|
9
|
+
files: []
|
|
10
|
+
score: 0
|
|
11
|
+
confirm: true
|
|
12
|
+
requires: []
|
|
13
|
+
conflicts: []
|
|
14
|
+
tokens: 1098
|
|
15
|
+
migrated: true
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
# Domain: Payments
|
|
19
|
+
|
|
20
|
+
A payments bug costs real money and can be a legal incident (PCI DSS). The complexity is not technical — it is flow: authorization vs capture, 3-D Secure, split payment, reconciliation. Teams ship the happy path and forget the failure states production actually exercises. Exemplar code lives in `references/sistema-pagamentos/` — read on demand.
|
|
21
|
+
|
|
22
|
+
## Payment state machine
|
|
23
|
+
|
|
24
|
+
Model the payment as an explicit state machine; transitions outside it are rejected in code.
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
created → processing → authorized → captured → succeeded
|
|
28
|
+
processing → failed
|
|
29
|
+
authorized → void/reversal | expired (capture window missed)
|
|
30
|
+
captured → partially_refunded → fully_refunded
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Critical rules
|
|
34
|
+
|
|
35
|
+
1. NEVER receive, transmit, store or log PAN, CVV or PIN. Card data is collected by the gateway's own SDK/hosted fields, so first-party servers stay out of PCI scope; all card traffic uses TLS 1.2 or newer.
|
|
36
|
+
2. Every payment-creation call carries an idempotency key, stored locally and checked before creating a new intent; a retry after a timeout reuses the SAME key — minting a new key per retry is how double charges happen.
|
|
37
|
+
3. Webhook signatures are verified before any processing; webhooks are enqueued and processed from a queue, never inline in the HTTP handler.
|
|
38
|
+
4. The 3-D Secure outcome is confirmed ONLY by the gateway webhook. The frontend merely redirects — it is never trusted to report authentication results.
|
|
39
|
+
5. Capture happens within the gateway's authorization window; expired authorizations are surfaced and handled, never silently dropped.
|
|
40
|
+
6. Refunds validate the maximum refundable amount (captured minus already refunded) in code before calling the gateway; refunds on split payments decrement each recipient proportionally.
|
|
41
|
+
7. Never process a payment for a blocked account or one with an active chargeback; alert automatically when the chargeback rate crosses the agreed risk threshold.
|
|
42
|
+
8. Daily reconciliation compares gateway transactions against local records in both directions, including amounts; every discrepancy creates a review record for a human — never auto-correct.
|
|
43
|
+
9. Payment logs carry reference ids only (payment intent id, idempotency key); request bodies of payment endpoints are never logged unsanitized.
|
|
44
|
+
10. Split payments (marketplace): recipients and percentages are fixed at intent creation, the platform fee is retained before splits, and every recipient account is KYC-verified with the gateway.
|
|
45
|
+
11. State is persisted before and after every gateway call — no fire-and-forget background processing without persisted intermediate state.
|
|
46
|
+
|
|
47
|
+
## Trigger → action
|
|
48
|
+
|
|
49
|
+
| Trigger | Action |
|
|
50
|
+
|---------|--------|
|
|
51
|
+
| Create payment | check idempotency key → create intent at gateway → persist with state |
|
|
52
|
+
| 3DS required | return client secret to the frontend → wait for the gateway webhook |
|
|
53
|
+
| Webhook received | verify signature → enqueue → apply state transition → notify |
|
|
54
|
+
| Refund request | compute max refundable → validate → gateway refund → transition state |
|
|
55
|
+
| Gateway timeout | retry with the SAME idempotency key |
|
|
56
|
+
| Daily reconciliation | diff gateway vs local both ways → discrepancy record + alert |
|
|
57
|
+
| Chargeback notice | pause the account → open the dispute workflow |
|
|
58
|
+
|
|
59
|
+
## Quality gates
|
|
60
|
+
|
|
61
|
+
- Zero occurrences of PAN/CVV in logs, database or error traces.
|
|
62
|
+
- Signature verification on 100% of payment webhooks.
|
|
63
|
+
- Idempotency key stored and checked before every intent creation; the retry path is tested.
|
|
64
|
+
- 3DS outcome driven exclusively by webhook (no frontend confirmation path exists).
|
|
65
|
+
- State machine transitions explicit; illegal transitions rejected and tested.
|
|
66
|
+
- Refund-ceiling validation covered by tests (full, partial, over-limit).
|
|
67
|
+
- Daily reconciliation running with alerting on divergence.
|
|
68
|
+
|
|
69
|
+
## Forbidden
|
|
70
|
+
|
|
71
|
+
- Storing or logging PAN, CVV or PIN under any circumstance.
|
|
72
|
+
- Accepting card data on first-party endpoints instead of the gateway SDK.
|
|
73
|
+
- Trusting the frontend for the 3DS outcome.
|
|
74
|
+
- Generating a new idempotency key when retrying a timed-out request.
|
|
75
|
+
- Refunding beyond the captured amount (missing code-side ceiling check).
|
|
76
|
+
- Manually "fixing" reconciliation discrepancies without a review record.
|
|
77
|
+
- Processing payments in background jobs without persisted intermediate state.
|
|
78
|
+
|
|
79
|
+
## References (read on demand)
|
|
80
|
+
|
|
81
|
+
- `references/sistema-pagamentos/pitfalls.md` — webhook-confirmed 3DS, refund ceiling, idempotent retry (wrong vs right).
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: domain/upload-midia
|
|
3
|
+
version: 1.0.0
|
|
4
|
+
lang: en
|
|
5
|
+
summary: "Media upload discipline: direct-to-storage presigned uploads, magic-byte validation, quarantine plus virus scan, EXIF stripping, async processing, signed CDN delivery."
|
|
6
|
+
source: "dominio/09-upload-midia.md"
|
|
7
|
+
detect:
|
|
8
|
+
deps: { "sharp": "*" }
|
|
9
|
+
files: []
|
|
10
|
+
score: 2
|
|
11
|
+
confirm: true
|
|
12
|
+
requires: []
|
|
13
|
+
conflicts: []
|
|
14
|
+
tokens: 1032
|
|
15
|
+
migrated: true
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
# Domain: Media upload and processing
|
|
19
|
+
|
|
20
|
+
File upload looks trivial until the first multi-GB video lands in the app server's RAM, or the first malicious file bypasses an extension check. The correct flow is direct-to-storage upload via presigned URLs, content-level validation, asynchronous processing, and CDN delivery. Exemplar code lives in `references/upload-midia/` — read on demand.
|
|
21
|
+
|
|
22
|
+
## Upload flow (direct to object storage)
|
|
23
|
+
|
|
24
|
+
1. Client requests an upload → API creates a media record (`pending`) and returns a presigned upload URL.
|
|
25
|
+
2. Client uploads straight to object storage — bytes never pass through the app server.
|
|
26
|
+
3. Client confirms → API verifies the object exists and enqueues validation + processing jobs.
|
|
27
|
+
4. Worker validates real MIME (magic bytes), virus-scans, processes; the record moves to `ready` or `failed`.
|
|
28
|
+
5. Client polls status; delivery is always a CDN URL, never the raw storage object.
|
|
29
|
+
|
|
30
|
+
## Critical rules
|
|
31
|
+
|
|
32
|
+
1. Uploads go directly to object storage via presigned URLs with a short TTL — the app server never buffers file bytes.
|
|
33
|
+
2. File type is verified server-side from magic bytes; the extension and the client's `Content-Type` header are untrusted input.
|
|
34
|
+
3. Per-context allowlist of types and size caps (e.g. avatars accept images only) — deny by default.
|
|
35
|
+
4. Virus scan before any file becomes available; unscanned files wait in a private quarantine bucket and move out only after approval.
|
|
36
|
+
5. Storage keys are unguessable (UUID in the path) and never contain the user's filename (path traversal, enumeration).
|
|
37
|
+
6. EXIF metadata is stripped from every image before serving — GPS and device info are personal data.
|
|
38
|
+
7. Private content is served through signed CDN URLs with a TTL — never permanent or direct storage URLs.
|
|
39
|
+
8. Processing runs in async workers with status tracking; transcoding tools (FFmpeg-class) run in an isolated process with CPU/memory limits.
|
|
40
|
+
9. Multipart upload for large files (single-PUT limits of the storage provider); serve processed variants, never the original object.
|
|
41
|
+
10. Deletion is soft: mark in the database, purge from storage via lifecycle policy after a retention window.
|
|
42
|
+
|
|
43
|
+
## Processing pipeline
|
|
44
|
+
|
|
45
|
+
- Images: thumbnail eagerly; larger variants and compressed original async. Output a modern efficient format with a broadly compatible fallback; watermark after resize, not before.
|
|
46
|
+
- Video: probe codec/metadata before transcoding; output one maximum-compatibility progressive file plus a streaming (HLS) rendition; thumbnail from an early frame; progress via job status.
|
|
47
|
+
|
|
48
|
+
## Trigger → action
|
|
49
|
+
|
|
50
|
+
| Trigger | Action |
|
|
51
|
+
|---------|--------|
|
|
52
|
+
| Upload request | create `pending` record → presign → return URL |
|
|
53
|
+
| Upload confirmed | verify object exists → enqueue validation + processing |
|
|
54
|
+
| Scan verdict | approve → move out of quarantine · reject → notify + delete |
|
|
55
|
+
| Delete request | soft delete → schedule storage purge via lifecycle policy |
|
|
56
|
+
| Private asset view | issue signed CDN URL with TTL |
|
|
57
|
+
| New media context | define its type allowlist and size cap first |
|
|
58
|
+
|
|
59
|
+
## Quality gates
|
|
60
|
+
|
|
61
|
+
- Zero file buffers pass through the app server — presign path only.
|
|
62
|
+
- Magic-byte MIME validation tested, including a spoofed Content-Type case.
|
|
63
|
+
- Virus-scan gate proven: nothing reaches `ready`/public without a scan verdict.
|
|
64
|
+
- EXIF stripping verified on served images.
|
|
65
|
+
- Storage keys UUID-based; no user filename appears in any key.
|
|
66
|
+
- Signed-URL TTL enforced for private content; direct storage URLs absent from responses.
|
|
67
|
+
- Pipeline async with observable status; sandbox resource limits configured.
|
|
68
|
+
|
|
69
|
+
## Forbidden
|
|
70
|
+
|
|
71
|
+
- Receiving files as multipart/form-data on the app server.
|
|
72
|
+
- Trusting the client's Content-Type header or the file extension.
|
|
73
|
+
- Serving raw storage URLs, or permanent URLs to private content.
|
|
74
|
+
- Making a file available without a virus-scan verdict.
|
|
75
|
+
- Processing images or video on the request thread.
|
|
76
|
+
- Using the user's filename in storage keys.
|
|
77
|
+
- Hard-deleting media without the retention window.
|
|
78
|
+
|
|
79
|
+
## References (read on demand)
|
|
80
|
+
|
|
81
|
+
- `references/upload-midia/patterns.md` — presigned upload, magic-byte validation, signed delivery URLs, magic-byte table (wrong vs right).
|