oneie 2.0.2 → 2.0.5
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/AGENTS.md +245 -0
- package/CLAUDE.md +725 -0
- package/LICENSE.md +84 -0
- package/README.md +489 -931
- package/folders.yaml +78 -17
- package/one/.obsidian/app.json +1 -0
- package/one/.obsidian/appearance.json +1 -0
- package/one/.obsidian/core-plugins.json +33 -0
- package/one/.obsidian/workspace.json +211 -0
- package/one/connections/a2a.md +551 -0
- package/one/connections/acp.md +761 -0
- package/one/connections/acps.md +731 -0
- package/one/connections/agentkit.md +349 -0
- package/one/connections/agui.md +767 -0
- package/one/connections/any-backend.md +1702 -0
- package/one/connections/ap2.md +998 -0
- package/one/connections/api-docs.md +1891 -0
- package/one/connections/api.md +2190 -0
- package/one/connections/architecture-diagram.md +94 -0
- package/one/connections/communications.md +449 -0
- package/one/connections/connections.md +339 -0
- package/one/connections/copilotkit.md +1559 -0
- package/one/connections/cryptonetworks.md +781 -0
- package/one/connections/documentation.md +1120 -0
- package/one/connections/effect.md +279 -0
- package/one/connections/elizaos.md +1290 -0
- package/one/connections/inference.md +58 -0
- package/one/connections/kyc.md +632 -0
- package/one/connections/mcp.md +842 -0
- package/one/connections/membership.md +1152 -0
- package/one/connections/middleware.md +1067 -0
- package/one/connections/multitenant.md +1341 -0
- package/one/connections/n8n.md +1015 -0
- package/one/connections/patterns.md +89 -0
- package/one/connections/protocols.md +279 -0
- package/one/connections/relationships.md +107 -0
- package/one/connections/schema.md +587 -0
- package/one/connections/service-layer.md +550 -0
- package/one/connections/structure.md +0 -0
- package/one/connections/vectors.md +207 -0
- package/one/connections/wordpress.md +1302 -0
- package/one/connections/workflow-copy.md +905 -0
- package/one/connections/workflow-examples.md +741 -0
- package/one/connections/workflow.md +905 -0
- package/one/connections/workflows/delegation.md +885 -0
- package/one/connections/workflows/frontend.md +1037 -0
- package/one/connections/workflows/strategy.md +903 -0
- package/one/connections/workflows/tasks.md +698 -0
- package/one/connections/x402.md +1249 -0
- package/one/events/CASCADE-2-BACKEND-AGNOSTIC.md +412 -0
- package/one/events/FEATURE-2-4-COMPLETE.md +302 -0
- package/one/events/FEATURE_2_3_COMPLETE.md +575 -0
- package/one/events/GROUPS-MIGRATION.md +625 -0
- package/one/events/INSTALL-TESTS.md +293 -0
- package/one/events/INTEGRATION-ARCHITECTURE.md +561 -0
- package/one/events/INTEGRATION-CHECKLIST.md +1234 -0
- package/one/events/INTEGRATION-ORCHESTRATION.md +2623 -0
- package/one/events/INTEGRATION-SUMMARY.md +653 -0
- package/one/events/MIGRATION-REPORT.md +435 -0
- package/one/events/MIGRATION.md +69 -0
- package/one/events/README-archived.md +519 -0
- package/one/events/TEST-SUMMARY.md +393 -0
- package/one/events/TESTS-QUICK-REF.md +262 -0
- package/one/events/events.md +545 -0
- package/one/groups/groups.md +543 -0
- package/one/groups/one.md +599 -0
- package/one/groups/revenue.md +673 -0
- package/one/groups/strategy.md +869 -0
- package/one/groups/vision.md +98 -0
- package/one/knowledge/CLOUDFLARE_ENV_SETUP.md +49 -0
- package/one/knowledge/ai-platform.md +305 -0
- package/one/knowledge/architecture-any-backend.md +1366 -0
- package/one/knowledge/architecture-diagram.md +94 -0
- package/one/knowledge/architecture-frontend.md +930 -0
- package/one/knowledge/architecture.md +2077 -0
- package/one/knowledge/crypto.md +960 -0
- package/one/knowledge/docs/flow.md +0 -0
- package/one/knowledge/dsl.md +1660 -0
- package/one/knowledge/files.md +2471 -0
- package/one/knowledge/frontend.md +1038 -0
- package/one/knowledge/hono.md +2109 -0
- package/one/knowledge/implementation-examples.md +2536 -0
- package/one/knowledge/inference-score.md +159 -0
- package/one/knowledge/knowledge.md +642 -0
- package/one/knowledge/language.md +980 -0
- package/one/knowledge/lessons-learned.md +70 -0
- package/one/knowledge/ontology-6-dimensions.md +0 -0
- package/one/knowledge/ontology-documentation.md +356 -0
- package/one/knowledge/ontology-engineering-specification.md +1292 -0
- package/one/knowledge/ontology-engineering.md +1652 -0
- package/one/knowledge/ontology-frontend-copy-2.md +1492 -0
- package/one/knowledge/ontology-frontend-copy.md +753 -0
- package/one/knowledge/ontology-frontend-specifications.md +2188 -0
- package/one/knowledge/ontology-frontend.md +2427 -0
- package/one/knowledge/ontology-minimal.yaml +299 -0
- package/one/knowledge/ontology.md +2830 -0
- package/one/knowledge/ontology.md.backup +2822 -0
- package/one/knowledge/ontology.yaml +1165 -0
- package/one/knowledge/patterns/backend/convex-mutation-pattern.md +100 -0
- package/one/knowledge/patterns/backend/convex-query-pattern.md +88 -0
- package/one/knowledge/patterns/backend/mutation-template.md +231 -0
- package/one/knowledge/patterns/backend/query-template.md +267 -0
- package/one/knowledge/patterns/backend/service-template.md +237 -0
- package/one/knowledge/patterns/design/component-architecture.md +399 -0
- package/one/knowledge/patterns/design/test-driven-design-pattern.md +162 -0
- package/one/knowledge/patterns/design/wireframe-template.md +216 -0
- package/one/knowledge/patterns/frontend/component-template.md +195 -0
- package/one/knowledge/patterns/frontend/form-template.md +276 -0
- package/one/knowledge/patterns/frontend/page-template.md +178 -0
- package/one/knowledge/patterns/frontend/react-component-pattern.md +128 -0
- package/one/knowledge/patterns/test/acceptance-criteria-template.md +378 -0
- package/one/knowledge/patterns/test/technical-test-template.md +544 -0
- package/one/knowledge/patterns/test/test-driven-pattern.md +140 -0
- package/one/knowledge/patterns/test/user-flow-template.md +254 -0
- package/one/knowledge/provider-creation-guide.md +1064 -0
- package/one/knowledge/quality-loop.md +401 -0
- package/one/knowledge/readme.md +131 -0
- package/one/knowledge/rules.md +626 -0
- package/one/knowledge/score.md +67 -0
- package/one/knowledge/specifications.md +855 -0
- package/one/knowledge/tags.md +130 -0
- package/one/knowledge/todo.md +251 -0
- package/one/license.md +84 -0
- package/one/people/anthony-o-connell.md +440 -0
- package/one/people/people.md +567 -0
- package/one/things/CHECKLIST.md +356 -0
- package/one/things/ONE.md +510 -0
- package/one/things/agents/agent-backend.md +1401 -0
- package/one/things/agents/agent-builder.md +955 -0
- package/one/things/agents/agent-clean.md +709 -0
- package/one/things/agents/agent-clone.md +1341 -0
- package/one/things/agents/agent-designer.md +2177 -0
- package/one/things/agents/agent-director.md +1508 -0
- package/one/things/agents/agent-documenter.md +1049 -0
- package/one/things/agents/agent-frontend.md +1119 -0
- package/one/things/agents/agent-integrator.md +1192 -0
- package/one/things/agents/agent-problem-solver.md +1379 -0
- package/one/things/agents/agent-quality.md +1353 -0
- package/one/things/agents/agent-sales.md +986 -0
- package/one/things/cascade/cascade.yaml +464 -0
- package/one/things/cascade/docs/examples/1-1-agent-prompts/design.md +470 -0
- package/one/things/cascade/docs/examples/1-1-agent-prompts/tests.md +264 -0
- package/one/things/cascade/docs/examples/1-1-agent-prompts.md +486 -0
- package/one/things/cascade/docs/examples/1-2-yaml-orchestrator/design.md +497 -0
- package/one/things/cascade/docs/examples/1-2-yaml-orchestrator/tests.md +227 -0
- package/one/things/cascade/docs/examples/1-2-yaml-orchestrator.md +516 -0
- package/one/things/cascade/docs/examples/1-3-event-coordination/design.md +544 -0
- package/one/things/cascade/docs/examples/1-3-event-coordination/tests.md +223 -0
- package/one/things/cascade/docs/examples/1-3-event-coordination.md +508 -0
- package/one/things/cascade/docs/examples/1-4-knowledge-management/design.md +609 -0
- package/one/things/cascade/docs/examples/1-4-knowledge-management/tests.md +195 -0
- package/one/things/cascade/docs/examples/1-4-knowledge-management.md +577 -0
- package/one/things/cascade/docs/examples/1-5-quality-loops/design.md +797 -0
- package/one/things/cascade/docs/examples/1-5-quality-loops/tests.md +212 -0
- package/one/things/cascade/docs/examples/1-5-quality-loops.md +641 -0
- package/one/things/cascade/docs/examples/1-6-numbering-structure/design.md +610 -0
- package/one/things/cascade/docs/examples/1-6-numbering-structure/tests.md +213 -0
- package/one/things/cascade/docs/examples/1-6-numbering-structure.md +575 -0
- package/one/things/cascade/docs/examples/readme.md +222 -0
- package/one/things/cascade/docs/getting-started.md +515 -0
- package/one/things/cascade/docs/workflow.md +1372 -0
- package/one/things/cascade/readme.md +336 -0
- package/one/things/cascade/templates/feature-template.md +267 -0
- package/one/things/claude/agents/advocacy-activation-manager.md +685 -0
- package/one/things/claude/agents/advocacy-campaign-designer.md +663 -0
- package/one/things/claude/agents/analyst.md +483 -0
- package/one/things/claude/agents/architect.md +480 -0
- package/one/things/claude/agents/brand-identity-specialist.md +513 -0
- package/one/things/claude/agents/bstp-token-strategist.md +667 -0
- package/one/things/claude/agents/builder-repo.md +489 -0
- package/one/things/claude/agents/bullstamp-community-builder.md +574 -0
- package/one/things/claude/agents/bullstamp-marketing-orchestrator.md +506 -0
- package/one/things/claude/agents/bulltilt-platform-growth.md +567 -0
- package/one/things/claude/agents/company-bullstamp-character.md +587 -0
- package/one/things/claude/agents/company-bullstamp-community.md +292 -0
- package/one/things/claude/agents/company-bullstamp-marketing.md +292 -0
- package/one/things/claude/agents/company-bullstamp-token.md +292 -0
- package/one/things/claude/agents/company-bulltilt-growth.md +292 -0
- package/one/things/claude/agents/content-bibliography-formatter.md +381 -0
- package/one/things/claude/agents/content-calendar-planner.md +448 -0
- package/one/things/claude/agents/content-chapter-formatter.md +488 -0
- package/one/things/claude/agents/content-formatter.md +546 -0
- package/one/things/claude/agents/content-hook-specialist.md +462 -0
- package/one/things/claude/agents/content-image-formatter.md +535 -0
- package/one/things/claude/agents/content-introduction-formatter.md +485 -0
- package/one/things/claude/agents/content-multiplication-engine.md +556 -0
- package/one/things/claude/agents/content-playbook-writer.md +448 -0
- package/one/things/claude/agents/content-team-manager.md +622 -0
- package/one/things/claude/agents/content-toc-formatter.md +522 -0
- package/one/things/claude/agents/convex-backend-specialist.md +2561 -0
- package/one/things/claude/agents/core-manager.md +582 -0
- package/one/things/claude/agents/core-master.md +403 -0
- package/one/things/claude/agents/cross-functional-manager.md +471 -0
- package/one/things/claude/agents/crypto-airdrop-strategist.md +602 -0
- package/one/things/claude/agents/crypto-analytics-educator.md +553 -0
- package/one/things/claude/agents/crypto-architecture-specialist.md +466 -0
- package/one/things/claude/agents/crypto-community-analyst.md +298 -0
- package/one/things/claude/agents/crypto-community-psychologist.md +509 -0
- package/one/things/claude/agents/crypto-dex-optimization-expert.md +538 -0
- package/one/things/claude/agents/crypto-dex-optimizer.md +292 -0
- package/one/things/claude/agents/crypto-diamond-formation-specialist.md +513 -0
- package/one/things/claude/agents/crypto-diamond-hands.md +292 -0
- package/one/things/claude/agents/crypto-ecosystem-expansion-manager.md +554 -0
- package/one/things/claude/agents/crypto-engagement-specialist.md +540 -0
- package/one/things/claude/agents/crypto-market-researcher.md +292 -0
- package/one/things/claude/agents/crypto-marketing-orchestrator.md +523 -0
- package/one/things/claude/agents/crypto-network-effect-amplifier.md +569 -0
- package/one/things/claude/agents/crypto-optimization-analyst.md +554 -0
- package/one/things/claude/agents/crypto-strategic-synthesizer.md +517 -0
- package/one/things/claude/agents/crypto-team-manager.md +387 -0
- package/one/things/claude/agents/crypto-token-analyst.md +278 -0
- package/one/things/claude/agents/crypto-viral-content-creator.md +546 -0
- package/one/things/claude/agents/crypto-wallet-identification-expert.md +517 -0
- package/one/things/claude/agents/crypto-wallet-identifier.md +292 -0
- package/one/things/claude/agents/customer-journey-designer.md +481 -0
- package/one/things/claude/agents/customer-success-manager.md +581 -0
- package/one/things/claude/agents/dev.md +413 -0
- package/one/things/claude/agents/documenter.md +546 -0
- package/one/things/claude/agents/elevate-marketing-orchestrator.md +410 -0
- package/one/things/claude/agents/engagement-specialist.md +509 -0
- package/one/things/claude/agents/engineering-architect.md +387 -0
- package/one/things/claude/agents/engineering-business-analyst.md +537 -0
- package/one/things/claude/agents/engineering-developer.md +387 -0
- package/one/things/claude/agents/engineering-director.md +282 -0
- package/one/things/claude/agents/engineering-ingestor.md +649 -0
- package/one/things/claude/agents/engineering-product-manager.md +537 -0
- package/one/things/claude/agents/engineering-product-owner.md +537 -0
- package/one/things/claude/agents/engineering-project-coordinator.md +537 -0
- package/one/things/claude/agents/engineering-quality-assurance.md +393 -0
- package/one/things/claude/agents/engineering-team-manager.md +512 -0
- package/one/things/claude/agents/engineering-user-experience.md +387 -0
- package/one/things/claude/agents/framework-elevate-manager.md +294 -0
- package/one/things/claude/agents/improver.md +763 -0
- package/one/things/claude/agents/intelligence-team-manager.md +385 -0
- package/one/things/claude/agents/lead-capture-expert.md +466 -0
- package/one/things/claude/agents/lead-magnet-creator.md +453 -0
- package/one/things/claude/agents/market-research-analyst.md +412 -0
- package/one/things/claude/agents/marketing-brand-identity.md +314 -0
- package/one/things/claude/agents/marketing-content-hooks.md +450 -0
- package/one/things/claude/agents/marketing-content-multiplier.md +326 -0
- package/one/things/claude/agents/marketing-content-poster.md +361 -0
- package/one/things/claude/agents/marketing-customer-journey.md +326 -0
- package/one/things/claude/agents/marketing-director.md +397 -0
- package/one/things/claude/agents/marketing-engagement.md +326 -0
- package/one/things/claude/agents/marketing-lead-capture.md +326 -0
- package/one/things/claude/agents/marketing-lead-magnet.md +326 -0
- package/one/things/claude/agents/marketing-network-effects.md +326 -0
- package/one/things/claude/agents/marketing-nurture-campaigns.md +326 -0
- package/one/things/claude/agents/marketing-share-optimizer.md +326 -0
- package/one/things/claude/agents/marketing-team-manager.md +446 -0
- package/one/things/claude/agents/marketing-viral-growth.md +201 -0
- package/one/things/claude/agents/mission-commander.md +373 -0
- package/one/things/claude/agents/network-effect-analyst.md +587 -0
- package/one/things/claude/agents/nextjs-15-specialist.md +1547 -0
- package/one/things/claude/agents/npx.md +890 -0
- package/one/things/claude/agents/nurture-campaign-manager.md +531 -0
- package/one/things/claude/agents/one-master.md +355 -0
- package/one/things/claude/agents/one-orchestrator.md +315 -0
- package/one/things/claude/agents/one.md +601 -0
- package/one/things/claude/agents/playbook-generator.md +503 -0
- package/one/things/claude/agents/pm.md +326 -0
- package/one/things/claude/agents/po.md +345 -0
- package/one/things/claude/agents/qa.md +336 -0
- package/one/things/claude/agents/research-foundation-analyst.md +307 -0
- package/one/things/claude/agents/research-intelligence-gatherer.md +408 -0
- package/one/things/claude/agents/research-market-analyst.md +307 -0
- package/one/things/claude/agents/research-team-manager.md +482 -0
- package/one/things/claude/agents/sales-environment-optimizer.md +494 -0
- package/one/things/claude/agents/sales-team-manager.md +400 -0
- package/one/things/claude/agents/sales-upsell-strategist.md +307 -0
- package/one/things/claude/agents/service-advocacy-campaigns.md +307 -0
- package/one/things/claude/agents/service-advocacy-manager.md +307 -0
- package/one/things/claude/agents/service-success-manager.md +307 -0
- package/one/things/claude/agents/service-team-manager.md +400 -0
- package/one/things/claude/agents/shadcn-ui-design-system-specialist.md +2302 -0
- package/one/things/claude/agents/share-optimization-specialist.md +551 -0
- package/one/things/claude/agents/sm.md +327 -0
- package/one/things/claude/agents/story-teller.md +473 -0
- package/one/things/claude/agents/task-master.md +596 -0
- package/one/things/claude/agents/tauri-cross-platform-specialist.md +1827 -0
- package/one/things/claude/agents/tester.md +556 -0
- package/one/things/claude/agents/the-bull-character-manager.md +580 -0
- package/one/things/claude/agents/tools-playbook-generator.md +489 -0
- package/one/things/claude/agents/turbo-repo-builder.md +316 -0
- package/one/things/claude/agents/upsell-strategist.md +480 -0
- package/one/things/claude/agents/ux-expert.md +335 -0
- package/one/things/claude/agents/viral-growth-orchestrator.md +497 -0
- package/one/things/claude/claude-code-hooks-development.json +21 -0
- package/one/things/claude/claude-code-hooks-production.json +21 -0
- package/one/things/claude/claude-code-hooks.json +25 -0
- package/one/things/claude/commands/agent.md +104 -0
- package/one/things/claude/commands/cascade-status.md +128 -0
- package/one/things/claude/commands/ingest.md +290 -0
- package/one/things/claude/commands/ingestor.md +136 -0
- package/one/things/claude/commands/mission.md +83 -0
- package/one/things/claude/commands/npx.md +133 -0
- package/one/things/claude/commands/one.md +440 -0
- package/one/things/claude/commands/quality-check.md +204 -0
- package/one/things/claude/commands/smart-route.md +220 -0
- package/one/things/claude/commands/start.md +121 -0
- package/one/things/claude/commands/story.md +83 -0
- package/one/things/claude/commands/task.md +173 -0
- package/one/things/claude/hook-bypass.json +32 -0
- package/one/things/claude/hooks/agent-hook-config.json +427 -0
- package/one/things/claude/hooks/agent-hook-manager.js +525 -0
- package/one/things/claude/hooks/agent-load-balancer.js +271 -0
- package/one/things/claude/hooks/agent-request-interceptor.js +70 -0
- package/one/things/claude/hooks/build-hook.sh +156 -0
- package/one/things/claude/hooks/cascade-feedback.js +297 -0
- package/one/things/claude/hooks/cascade-integration-hooks.js +648 -0
- package/one/things/claude/hooks/cleanup-hook.sh +201 -0
- package/one/things/claude/hooks/continuous-improvement-monitor.js +510 -0
- package/one/things/claude/hooks/file-organization-engine.js +427 -0
- package/one/things/claude/hooks/file-organization-hook.sh +80 -0
- package/one/things/claude/hooks/file-organization-monitor.js +269 -0
- package/one/things/claude/hooks/format-hook.sh +43 -0
- package/one/things/claude/hooks/hook-bypass.sh +293 -0
- package/one/things/claude/hooks/hook-config-manager.js +202 -0
- package/one/things/claude/hooks/hook-debouncer.sh +62 -0
- package/one/things/claude/hooks/hook-logger.sh +89 -0
- package/one/things/claude/hooks/hook-orchestrator.js +662 -0
- package/one/things/claude/hooks/hook-performance-report.js +120 -0
- package/one/things/claude/hooks/lint-hook.sh +140 -0
- package/one/things/claude/hooks/mcp-cascade-integration.js +816 -0
- package/one/things/claude/hooks/memory-optimizer.js +510 -0
- package/one/things/claude/hooks/notification-hook.sh +204 -0
- package/one/things/claude/hooks/ontology-compliance.js +394 -0
- package/one/things/claude/hooks/ontology-hook-manager.js +316 -0
- package/one/things/claude/hooks/ontology-validation-engine.js +317 -0
- package/one/things/claude/hooks/ontology-validation-hook.sh +86 -0
- package/one/things/claude/hooks/performance-metrics.json +25 -0
- package/one/things/claude/hooks/performance-monitoring-hook.js +422 -0
- package/one/things/claude/hooks/quality-scoring-engine.js +834 -0
- package/one/things/claude/hooks/security-hook.sh +256 -0
- package/one/things/claude/hooks/simple-load-balancer.js +238 -0
- package/one/things/claude/hooks/startup-optimizer.js +625 -0
- package/one/things/claude/hooks/story-scoring-system.js +445 -0
- package/one/things/claude/hooks/story-validation-engine.js +473 -0
- package/one/things/claude/hooks/story-validation-hook-enhanced.sh +210 -0
- package/one/things/claude/hooks/story-validation-hook.sh +145 -0
- package/one/things/claude/hooks/structure-synchronizer.js +194 -0
- package/one/things/claude/hooks/sub-agent-output-validator.js +647 -0
- package/one/things/claude/hooks/sub-agent-validation-hook.js +343 -0
- package/one/things/claude/hooks/test-hook.sh +145 -0
- package/one/things/claude/hooks/test-story-validation.sh +170 -0
- package/one/things/claude/hooks/trinity-validation-system.js +392 -0
- package/one/things/claude/settings-local.json +86 -0
- package/one/things/cli/cli-code.md +652 -0
- package/one/things/cli/cli-compiler-code.md +652 -0
- package/one/things/cli/cli.md +1068 -0
- package/one/things/components/card-shadcn.md +929 -0
- package/one/things/components/card.md +1050 -0
- package/one/things/components.md +1669 -0
- package/one/things/componets.md +4 -0
- package/one/things/creator-diagram.md +166 -0
- package/one/things/examples/children/lemonade-stand.md +366 -0
- package/one/things/examples/enterprise/crm-saas.md +1429 -0
- package/one/things/features/1-1-agent-prompts/design.md +470 -0
- package/one/things/features/1-1-agent-prompts/tests.md +264 -0
- package/one/things/features/1-1-agent-prompts.md +486 -0
- package/one/things/features/1-2-yaml-orchestrator/design.md +497 -0
- package/one/things/features/1-2-yaml-orchestrator/tests.md +227 -0
- package/one/things/features/1-2-yaml-orchestrator.md +516 -0
- package/one/things/features/1-3-event-coordination/design.md +544 -0
- package/one/things/features/1-3-event-coordination/tests.md +223 -0
- package/one/things/features/1-3-event-coordination.md +508 -0
- package/one/things/features/1-4-knowledge-management/design.md +609 -0
- package/one/things/features/1-4-knowledge-management/tests.md +195 -0
- package/one/things/features/1-4-knowledge-management.md +577 -0
- package/one/things/features/1-5-quality-loops/design.md +797 -0
- package/one/things/features/1-5-quality-loops/tests.md +212 -0
- package/one/things/features/1-5-quality-loops.md +641 -0
- package/one/things/features/1-6-numbering-structure/design.md +610 -0
- package/one/things/features/1-6-numbering-structure/tests.md +213 -0
- package/one/things/features/1-6-numbering-structure.md +575 -0
- package/one/things/features/2-1-dataprovider-interface.md +2358 -0
- package/one/things/features/2-2-config-system.md +3075 -0
- package/one/things/features/2-3-effectts-services.md +1498 -0
- package/one/things/features/2-4-react-hooks.md +2120 -0
- package/one/things/features/2-5-auth-migration.md +2046 -0
- package/one/things/features/2-6-dashboard-migration.md +1985 -0
- package/one/things/features/2-7-alternative-providers.md +2505 -0
- package/one/things/features/2-7-implementation-report.md +680 -0
- package/one/things/features/2-cli.md +1235 -0
- package/one/things/features/2-design.md +1738 -0
- package/one/things/features/2-tests.md +520 -0
- package/one/things/features/AUTH_HOOKS_IMPLEMENTATION.md +521 -0
- package/one/things/features/DECOUPLING.md +272 -0
- package/one/things/features/DEPLOYMENT.md +452 -0
- package/one/things/features/IMPLEMENTATION_SUMMARY.md +316 -0
- package/one/things/features/dataprovider-interface/1-tests.md +1522 -0
- package/one/things/features/improve.md +843 -0
- package/one/things/features/remove-convex-deps.md +45 -0
- package/one/things/features/top-features.md +79 -0
- package/one/things/features/use-one-backend.md +1180 -0
- package/one/things/ideas/1-create-workflow.md +189 -0
- package/one/things/ideas/2-backend-agnostic-frontend.md +384 -0
- package/one/things/plans/1-create-workflow-status.md +555 -0
- package/one/things/plans/1-create-workflow.md +713 -0
- package/one/things/plans/2-backend-agnostic-frontend.md +543 -0
- package/one/things/plans/3-groups.md +502 -0
- package/one/things/plans/app.md +761 -0
- package/one/things/plans/backend-agnostic-frontend.md +323 -0
- package/one/things/plans/better-auth-any-backend-revised.md +1065 -0
- package/one/things/plans/better-auth-any-backend.md +1852 -0
- package/one/things/plans/better-auth-available-features.md +235 -0
- package/one/things/plans/big-plan.md +38 -0
- package/one/things/plans/convex-better-auth.md +1109 -0
- package/one/things/plans/convex-on-off.md +389 -0
- package/one/things/plans/deploy-to-cloudflare.md +581 -0
- package/one/things/plans/desktop.md +1121 -0
- package/one/things/plans/effect-components.md +1669 -0
- package/one/things/plans/effect.md +973 -0
- package/one/things/plans/email.md +953 -0
- package/one/things/plans/enhance-auth.md +1669 -0
- package/one/things/plans/install-components.md +198 -0
- package/one/things/plans/landing.md +728 -0
- package/one/things/plans/layout.md +205 -0
- package/one/things/plans/mail-backend.md +1308 -0
- package/one/things/plans/mail.md +2624 -0
- package/one/things/plans/next-features.md +83 -0
- package/one/things/plans/one.md +658 -0
- package/one/things/plans/ontology-6-dimensions.md +2216 -0
- package/one/things/plans/ontology-driven-strategy.md +866 -0
- package/one/things/plans/ontology-ui-approach.md +357 -0
- package/one/things/plans/open-agent.md +785 -0
- package/one/things/plans/organizations-to-groups.md +705 -0
- package/one/things/plans/performace.md +90 -0
- package/one/things/plans/release.md +432 -0
- package/one/things/plans/releases.md +809 -0
- package/one/things/plans/repos.md +76 -0
- package/one/things/plans/separate-copy-2.md +1293 -0
- package/one/things/plans/separate-copy-3.md +2458 -0
- package/one/things/plans/separate-copy.md +1293 -0
- package/one/things/plans/separate.md +1983 -0
- package/one/things/plans/shadcn-integration-summary.md +450 -0
- package/one/things/plans/sidebar.md +172 -0
- package/one/things/plans/small-fixes.md +5 -0
- package/one/things/plans/test-backend-connection.md +476 -0
- package/one/things/plans/workflow-files.md +1196 -0
- package/one/things/plans/workflow.md +1372 -0
- package/one/things/products/cascade-landing-page.md +737 -0
- package/one/things/products/cascade.md +1518 -0
- package/one/things/products/context-engineering.md +1427 -0
- package/one/things/products/onthology.md +0 -0
- package/one/things/products/ontology-ui-shadcn.md +1280 -0
- package/one/things/products/ontology-ui.md +1387 -0
- package/one/things/products/ontology.md +717 -0
- package/one/things/products/sdk.md +557 -0
- package/one/things/promptkit.md +903 -0
- package/one/things/service-providers-new.md +982 -0
- package/one/things/service-providers.md +1092 -0
- package/one/things/system.md +600 -0
- package/one/things/tests/2-1-dataprovider-interface.md +1144 -0
- package/one/things/tests/2-1-test-analysis.md +496 -0
- package/one/things/things.md +349 -0
- package/one/things/todo.md +1248 -0
- package/one/things/vision/elegant-interface.md +214 -0
- package/package.json +5 -2
|
@@ -0,0 +1,2623 @@
|
|
|
1
|
+
# Integration Orchestration Plan
|
|
2
|
+
|
|
3
|
+
**Integration Specialist Deliverable**
|
|
4
|
+
**Date:** 2025-10-13
|
|
5
|
+
**Status:** Architecture Design & Implementation Roadmap
|
|
6
|
+
**Version:** 1.0.0
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Executive Summary
|
|
11
|
+
|
|
12
|
+
This document orchestrates the complete integration strategy for the ONE Platform transformation from monolithic frontend+backend to a layered **Frontend → DataProvider → Backend** architecture. All integrations are designed to respect the **6-dimension ontology** (Organizations, People, Things, Connections, Events, Knowledge) and maintain protocol-agnostic data flows.
|
|
13
|
+
|
|
14
|
+
**Key Achievement:** Zero-downtime migration with complete test coverage across all 6 dimensions.
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## Table of Contents
|
|
19
|
+
|
|
20
|
+
1. [Data Flow Orchestration (6 Dimensions)](#1-data-flow-orchestration-6-dimensions)
|
|
21
|
+
2. [Multi-Backend Federation](#2-multi-backend-federation)
|
|
22
|
+
3. [Real-Time Coordination](#3-real-time-coordination)
|
|
23
|
+
4. [Migration Coordination (7 Phases)](#4-migration-coordination-7-phases)
|
|
24
|
+
5. [Testing Integration](#5-testing-integration)
|
|
25
|
+
6. [Error Propagation](#6-error-propagation)
|
|
26
|
+
7. [Deployment Coordination](#7-deployment-coordination)
|
|
27
|
+
8. [Implementation Timeline](#8-implementation-timeline)
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## 1. Data Flow Orchestration (6 Dimensions)
|
|
32
|
+
|
|
33
|
+
### Overview
|
|
34
|
+
|
|
35
|
+
Every data flow respects the 6-dimension ontology. The DataProvider layer routes requests to the appropriate backend while maintaining ontology consistency.
|
|
36
|
+
|
|
37
|
+
### Architecture Layers
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
41
|
+
│ FRONTEND LAYER │
|
|
42
|
+
│ Astro 5 SSR + React 19 Islands + shadcn/ui │
|
|
43
|
+
│ Location: /frontend/src/ │
|
|
44
|
+
└────────────────────┬────────────────────────────────────────┘
|
|
45
|
+
│
|
|
46
|
+
↓ (Hooks: useQuery, useMutation)
|
|
47
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
48
|
+
│ DATA PROVIDER LAYER │
|
|
49
|
+
│ Interface: IDataProvider (protocol-agnostic) │
|
|
50
|
+
│ Implementations: │
|
|
51
|
+
│ - ConvexProvider (primary) │
|
|
52
|
+
│ - SupabaseProvider (alternative) │
|
|
53
|
+
│ - WordPressProvider (CMS integration) │
|
|
54
|
+
│ - CompositeProvider (multi-backend federation) │
|
|
55
|
+
│ Location: /frontend/src/lib/providers/ │
|
|
56
|
+
└────────────────────┬────────────────────────────────────────┘
|
|
57
|
+
│
|
|
58
|
+
↓ (API calls, WebSocket subscriptions)
|
|
59
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
60
|
+
│ BACKEND LAYER │
|
|
61
|
+
│ Convex: Real-time database + typed functions │
|
|
62
|
+
│ Schema: 5 tables (entities, connections, events, │
|
|
63
|
+
│ knowledge, thingKnowledge) │
|
|
64
|
+
│ Auth: Better Auth + session management │
|
|
65
|
+
│ Location: /backend/convex/ │
|
|
66
|
+
└─────────────────────────────────────────────────────────────┘
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
### Dimension 1: Organizations (Multi-Tenant Isolation)
|
|
72
|
+
|
|
73
|
+
**Data Flow:**
|
|
74
|
+
|
|
75
|
+
```typescript
|
|
76
|
+
// Frontend Request
|
|
77
|
+
const orgs = useQuery(api.organizations.list);
|
|
78
|
+
|
|
79
|
+
// DataProvider Layer
|
|
80
|
+
interface IDataProvider {
|
|
81
|
+
organizations: {
|
|
82
|
+
list(args: { userId: Id<"entities"> }): Promise<Organization[]>;
|
|
83
|
+
get(args: { orgId: Id<"entities"> }): Promise<Organization>;
|
|
84
|
+
create(args: CreateOrgArgs): Promise<Id<"entities">>;
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// ConvexProvider Implementation
|
|
89
|
+
class ConvexProvider implements IDataProvider {
|
|
90
|
+
organizations = {
|
|
91
|
+
list: async (args) => {
|
|
92
|
+
// Query entities table with type: "organization"
|
|
93
|
+
return await this.client.query(api.queries.organizations.list, args);
|
|
94
|
+
},
|
|
95
|
+
get: async (args) => {
|
|
96
|
+
return await this.client.query(api.queries.organizations.get, args);
|
|
97
|
+
},
|
|
98
|
+
create: async (args) => {
|
|
99
|
+
return await this.client.mutation(api.mutations.organizations.create, args);
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Backend (Convex)
|
|
105
|
+
export const list = query({
|
|
106
|
+
args: { userId: v.id("entities") },
|
|
107
|
+
handler: async (ctx, args) => {
|
|
108
|
+
// Get user's organization memberships
|
|
109
|
+
const memberships = await ctx.db
|
|
110
|
+
.query("connections")
|
|
111
|
+
.withIndex("from_type", (q) =>
|
|
112
|
+
q.eq("fromThingId", args.userId).eq("relationshipType", "member_of")
|
|
113
|
+
)
|
|
114
|
+
.collect();
|
|
115
|
+
|
|
116
|
+
// Get organization entities
|
|
117
|
+
return await Promise.all(
|
|
118
|
+
memberships.map((m) => ctx.db.get(m.toThingId))
|
|
119
|
+
);
|
|
120
|
+
},
|
|
121
|
+
});
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
**Validation:**
|
|
125
|
+
|
|
126
|
+
- ✅ No cross-org data leakage
|
|
127
|
+
- ✅ Organization boundaries enforced at backend
|
|
128
|
+
- ✅ Provider-agnostic frontend code
|
|
129
|
+
- ✅ Multi-tenant isolation maintained
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
### Dimension 2: People (Authorization & Governance)
|
|
134
|
+
|
|
135
|
+
**Data Flow:**
|
|
136
|
+
|
|
137
|
+
```typescript
|
|
138
|
+
// Frontend: Auth flow
|
|
139
|
+
const { user, session } = useAuth(); // Better Auth client
|
|
140
|
+
|
|
141
|
+
// DataProvider Layer
|
|
142
|
+
interface IDataProvider {
|
|
143
|
+
auth: {
|
|
144
|
+
signIn(email: string, password: string): Promise<Session>;
|
|
145
|
+
signOut(): Promise<void>;
|
|
146
|
+
getCurrentUser(): Promise<Person | null>;
|
|
147
|
+
verifyPermissions(userId: Id<"entities">, orgId: Id<"entities">, action: string): Promise<boolean>;
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// Backend: Auth + Authorization
|
|
152
|
+
export const getCurrentUser = query({
|
|
153
|
+
args: { token: v.string() },
|
|
154
|
+
handler: async (ctx, args) => {
|
|
155
|
+
// 1. Verify session token
|
|
156
|
+
const session = await ctx.db
|
|
157
|
+
.query("sessions")
|
|
158
|
+
.withIndex("by_token", (q) => q.eq("token", args.token))
|
|
159
|
+
.first();
|
|
160
|
+
|
|
161
|
+
if (!session || session.expiresAt < Date.now()) {
|
|
162
|
+
return null;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// 2. Get user from Better Auth
|
|
166
|
+
const user = await ctx.db.get(session.userId);
|
|
167
|
+
|
|
168
|
+
// 3. Get organization memberships
|
|
169
|
+
const memberships = await ctx.db
|
|
170
|
+
.query("connections")
|
|
171
|
+
.withIndex("from_type", (q) =>
|
|
172
|
+
q.eq("fromThingId", session.userId).eq("relationshipType", "member_of")
|
|
173
|
+
)
|
|
174
|
+
.collect();
|
|
175
|
+
|
|
176
|
+
return {
|
|
177
|
+
...user,
|
|
178
|
+
organizations: memberships.map((m) => ({
|
|
179
|
+
orgId: m.toThingId,
|
|
180
|
+
role: m.metadata?.role,
|
|
181
|
+
permissions: m.metadata?.permissions || [],
|
|
182
|
+
})),
|
|
183
|
+
};
|
|
184
|
+
},
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
// Authorization check
|
|
188
|
+
export const verifyPermissions = query({
|
|
189
|
+
args: {
|
|
190
|
+
userId: v.id("entities"),
|
|
191
|
+
orgId: v.id("entities"),
|
|
192
|
+
action: v.string(),
|
|
193
|
+
},
|
|
194
|
+
handler: async (ctx, args) => {
|
|
195
|
+
// Get user's membership in organization
|
|
196
|
+
const membership = await ctx.db
|
|
197
|
+
.query("connections")
|
|
198
|
+
.withIndex("from_type", (q) =>
|
|
199
|
+
q.eq("fromThingId", args.userId).eq("relationshipType", "member_of")
|
|
200
|
+
)
|
|
201
|
+
.filter((q) => q.eq(q.field("toThingId"), args.orgId))
|
|
202
|
+
.first();
|
|
203
|
+
|
|
204
|
+
if (!membership) return false;
|
|
205
|
+
|
|
206
|
+
// Check role-based permissions
|
|
207
|
+
const role = membership.metadata?.role;
|
|
208
|
+
const permissions = membership.metadata?.permissions || [];
|
|
209
|
+
|
|
210
|
+
// org_owner has all permissions
|
|
211
|
+
if (role === "org_owner") return true;
|
|
212
|
+
|
|
213
|
+
// Check explicit permissions
|
|
214
|
+
return permissions.includes(args.action);
|
|
215
|
+
},
|
|
216
|
+
});
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
**Validation:**
|
|
220
|
+
|
|
221
|
+
- ✅ Session-based auth via Better Auth
|
|
222
|
+
- ✅ Role-based authorization (platform_owner, org_owner, org_user, customer)
|
|
223
|
+
- ✅ Permissions enforced at backend
|
|
224
|
+
- ✅ Auth tests pass (50+ test cases)
|
|
225
|
+
|
|
226
|
+
---
|
|
227
|
+
|
|
228
|
+
### Dimension 3: Things (Entity Integration)
|
|
229
|
+
|
|
230
|
+
**Data Flow:**
|
|
231
|
+
|
|
232
|
+
```typescript
|
|
233
|
+
// Frontend Component
|
|
234
|
+
export function ThingList({ type }: { type: ThingType }) {
|
|
235
|
+
const things = useQuery(api.queries.things.list, { type });
|
|
236
|
+
|
|
237
|
+
if (things === undefined) return <Skeleton />;
|
|
238
|
+
|
|
239
|
+
return (
|
|
240
|
+
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
|
|
241
|
+
{things.map((thing) => (
|
|
242
|
+
<ThingCard key={thing._id} thing={thing} />
|
|
243
|
+
))}
|
|
244
|
+
</div>
|
|
245
|
+
);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
// DataProvider Interface
|
|
249
|
+
interface IDataProvider {
|
|
250
|
+
things: {
|
|
251
|
+
list(args: { type: ThingType; organizationId?: Id<"entities"> }): Promise<Thing[]>;
|
|
252
|
+
get(id: Id<"entities">): Promise<Thing>;
|
|
253
|
+
create(args: CreateThingArgs): Promise<Id<"entities">>;
|
|
254
|
+
update(id: Id<"entities">, updates: Partial<Thing>): Promise<void>;
|
|
255
|
+
delete(id: Id<"entities">): Promise<void>;
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
// Generic ThingService (handles all 66 types)
|
|
260
|
+
export class ThingService extends Effect.Service<ThingService>()(
|
|
261
|
+
"ThingService",
|
|
262
|
+
{
|
|
263
|
+
effect: Effect.gen(function* () {
|
|
264
|
+
const db = yield* ConvexDatabase;
|
|
265
|
+
|
|
266
|
+
return {
|
|
267
|
+
create: (args: CreateThingArgs) =>
|
|
268
|
+
Effect.gen(function* () {
|
|
269
|
+
// Validate thing type
|
|
270
|
+
if (!isValidThingType(args.type)) {
|
|
271
|
+
return yield* Effect.fail(new InvalidThingTypeError());
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
// Create thing entity
|
|
275
|
+
const thingId = yield* Effect.tryPromise(() =>
|
|
276
|
+
db.insert("entities", {
|
|
277
|
+
type: args.type,
|
|
278
|
+
name: args.name,
|
|
279
|
+
properties: args.properties,
|
|
280
|
+
status: args.status || "draft",
|
|
281
|
+
createdAt: Date.now(),
|
|
282
|
+
updatedAt: Date.now(),
|
|
283
|
+
})
|
|
284
|
+
);
|
|
285
|
+
|
|
286
|
+
// Create ownership connection
|
|
287
|
+
if (args.ownerId) {
|
|
288
|
+
yield* Effect.tryPromise(() =>
|
|
289
|
+
db.insert("connections", {
|
|
290
|
+
fromThingId: args.ownerId,
|
|
291
|
+
toThingId: thingId,
|
|
292
|
+
relationshipType: "owns",
|
|
293
|
+
createdAt: Date.now(),
|
|
294
|
+
})
|
|
295
|
+
);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
// Log creation event
|
|
299
|
+
yield* Effect.tryPromise(() =>
|
|
300
|
+
db.insert("events", {
|
|
301
|
+
type: "entity_created",
|
|
302
|
+
actorId: args.ownerId,
|
|
303
|
+
targetId: thingId,
|
|
304
|
+
timestamp: Date.now(),
|
|
305
|
+
metadata: {
|
|
306
|
+
entityType: args.type,
|
|
307
|
+
},
|
|
308
|
+
})
|
|
309
|
+
);
|
|
310
|
+
|
|
311
|
+
return thingId;
|
|
312
|
+
}),
|
|
313
|
+
|
|
314
|
+
// Status lifecycle: draft → active → published → archived
|
|
315
|
+
updateStatus: (thingId: Id<"entities">, status: ThingStatus) =>
|
|
316
|
+
Effect.gen(function* () {
|
|
317
|
+
const thing = yield* Effect.tryPromise(() => db.get(thingId));
|
|
318
|
+
|
|
319
|
+
// Validate status transition
|
|
320
|
+
const validTransitions = {
|
|
321
|
+
draft: ["active", "archived"],
|
|
322
|
+
active: ["published", "archived"],
|
|
323
|
+
published: ["active", "archived"],
|
|
324
|
+
archived: [], // Cannot transition from archived
|
|
325
|
+
};
|
|
326
|
+
|
|
327
|
+
if (!validTransitions[thing.status]?.includes(status)) {
|
|
328
|
+
return yield* Effect.fail(new InvalidStatusTransitionError());
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
// Update status
|
|
332
|
+
yield* Effect.tryPromise(() =>
|
|
333
|
+
db.patch(thingId, {
|
|
334
|
+
status,
|
|
335
|
+
updatedAt: Date.now(),
|
|
336
|
+
})
|
|
337
|
+
);
|
|
338
|
+
|
|
339
|
+
// Log status change event
|
|
340
|
+
yield* Effect.tryPromise(() =>
|
|
341
|
+
db.insert("events", {
|
|
342
|
+
type: "entity_updated",
|
|
343
|
+
targetId: thingId,
|
|
344
|
+
timestamp: Date.now(),
|
|
345
|
+
metadata: {
|
|
346
|
+
action: "status_changed",
|
|
347
|
+
oldStatus: thing.status,
|
|
348
|
+
newStatus: status,
|
|
349
|
+
},
|
|
350
|
+
})
|
|
351
|
+
);
|
|
352
|
+
}),
|
|
353
|
+
};
|
|
354
|
+
}),
|
|
355
|
+
dependencies: [ConvexDatabase.Default],
|
|
356
|
+
}
|
|
357
|
+
) {}
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
**Provider-Specific Transformations:**
|
|
361
|
+
|
|
362
|
+
```typescript
|
|
363
|
+
// WordPress Provider: Posts → Things
|
|
364
|
+
class WordPressProvider implements IDataProvider {
|
|
365
|
+
async syncPosts(orgId: Id<"entities">): Promise<void> {
|
|
366
|
+
// Fetch posts from WordPress API
|
|
367
|
+
const posts = await fetch(`${this.wpUrl}/wp-json/wp/v2/posts`).then((r) =>
|
|
368
|
+
r.json()
|
|
369
|
+
);
|
|
370
|
+
|
|
371
|
+
// Transform to things
|
|
372
|
+
for (const post of posts) {
|
|
373
|
+
await this.things.create({
|
|
374
|
+
type: "blog_post",
|
|
375
|
+
name: post.title.rendered,
|
|
376
|
+
properties: {
|
|
377
|
+
content: post.content.rendered,
|
|
378
|
+
excerpt: post.excerpt.rendered,
|
|
379
|
+
publishedAt: new Date(post.date).getTime(),
|
|
380
|
+
wpId: post.id,
|
|
381
|
+
},
|
|
382
|
+
status: post.status === "publish" ? "published" : "draft",
|
|
383
|
+
ownerId: orgId,
|
|
384
|
+
});
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
// Notion Provider: Pages → Things
|
|
390
|
+
class NotionProvider implements IDataProvider {
|
|
391
|
+
async syncPages(orgId: Id<"entities">): Promise<void> {
|
|
392
|
+
// Fetch pages from Notion API
|
|
393
|
+
const pages = await this.notionClient.search({
|
|
394
|
+
filter: { property: "object", value: "page" },
|
|
395
|
+
});
|
|
396
|
+
|
|
397
|
+
// Transform to things
|
|
398
|
+
for (const page of pages.results) {
|
|
399
|
+
await this.things.create({
|
|
400
|
+
type: "document",
|
|
401
|
+
name: page.properties.title?.title[0]?.plain_text || "Untitled",
|
|
402
|
+
properties: {
|
|
403
|
+
notionId: page.id,
|
|
404
|
+
url: page.url,
|
|
405
|
+
lastEditedAt: new Date(page.last_edited_time).getTime(),
|
|
406
|
+
},
|
|
407
|
+
status: "active",
|
|
408
|
+
ownerId: orgId,
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
```
|
|
414
|
+
|
|
415
|
+
**Validation:**
|
|
416
|
+
|
|
417
|
+
- ✅ Generic ThingService handles all 66 types
|
|
418
|
+
- ✅ Status lifecycle enforced (draft → active → published → archived)
|
|
419
|
+
- ✅ External providers transform to ontology
|
|
420
|
+
- ✅ No custom tables needed
|
|
421
|
+
|
|
422
|
+
---
|
|
423
|
+
|
|
424
|
+
### Dimension 4: Connections (Relationships)
|
|
425
|
+
|
|
426
|
+
**Data Flow:**
|
|
427
|
+
|
|
428
|
+
```typescript
|
|
429
|
+
// Frontend Component
|
|
430
|
+
export function ConnectionGraph({ thingId }: { thingId: Id<"entities"> }) {
|
|
431
|
+
const connections = useQuery(api.queries.connections.list, { thingId });
|
|
432
|
+
|
|
433
|
+
return (
|
|
434
|
+
<div className="relative h-96">
|
|
435
|
+
<ForceGraph
|
|
436
|
+
nodes={connections?.nodes}
|
|
437
|
+
edges={connections?.edges}
|
|
438
|
+
onNodeClick={(node) => router.push(`/things/${node.id}`)}
|
|
439
|
+
/>
|
|
440
|
+
</div>
|
|
441
|
+
);
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
// DataProvider Interface
|
|
445
|
+
interface IDataProvider {
|
|
446
|
+
connections: {
|
|
447
|
+
list(args: { thingId: Id<"entities"> }): Promise<Connection[]>;
|
|
448
|
+
create(args: CreateConnectionArgs): Promise<Id<"connections">>;
|
|
449
|
+
delete(id: Id<"connections">): Promise<void>;
|
|
450
|
+
count(args: { thingId: Id<"entities">; relationshipType?: string }): Promise<number>;
|
|
451
|
+
};
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
// Backend: Bidirectional relationships
|
|
455
|
+
export const list = query({
|
|
456
|
+
args: { thingId: v.id("entities") },
|
|
457
|
+
handler: async (ctx, args) => {
|
|
458
|
+
// Get outgoing connections
|
|
459
|
+
const outgoing = await ctx.db
|
|
460
|
+
.query("connections")
|
|
461
|
+
.withIndex("from_entity", (q) => q.eq("fromEntityId", args.thingId))
|
|
462
|
+
.collect();
|
|
463
|
+
|
|
464
|
+
// Get incoming connections
|
|
465
|
+
const incoming = await ctx.db
|
|
466
|
+
.query("connections")
|
|
467
|
+
.withIndex("to_entity", (q) => q.eq("toEntityId", args.thingId))
|
|
468
|
+
.collect();
|
|
469
|
+
|
|
470
|
+
// Get connected things
|
|
471
|
+
const thingIds = [
|
|
472
|
+
...outgoing.map((c) => c.toEntityId),
|
|
473
|
+
...incoming.map((c) => c.fromEntityId),
|
|
474
|
+
];
|
|
475
|
+
|
|
476
|
+
const things = await Promise.all(thingIds.map((id) => ctx.db.get(id)));
|
|
477
|
+
|
|
478
|
+
// Format for graph visualization
|
|
479
|
+
return {
|
|
480
|
+
nodes: [
|
|
481
|
+
{ id: args.thingId, type: "center" },
|
|
482
|
+
...things.map((t) => ({ id: t._id, type: t.type, name: t.name })),
|
|
483
|
+
],
|
|
484
|
+
edges: [
|
|
485
|
+
...outgoing.map((c) => ({
|
|
486
|
+
from: c.fromEntityId,
|
|
487
|
+
to: c.toEntityId,
|
|
488
|
+
type: c.relationshipType,
|
|
489
|
+
metadata: c.metadata,
|
|
490
|
+
})),
|
|
491
|
+
...incoming.map((c) => ({
|
|
492
|
+
from: c.fromEntityId,
|
|
493
|
+
to: c.toEntityId,
|
|
494
|
+
type: c.relationshipType,
|
|
495
|
+
metadata: c.metadata,
|
|
496
|
+
})),
|
|
497
|
+
],
|
|
498
|
+
};
|
|
499
|
+
},
|
|
500
|
+
});
|
|
501
|
+
|
|
502
|
+
// Temporal validity (validFrom/validTo)
|
|
503
|
+
export const createTimeLimitedConnection = mutation({
|
|
504
|
+
args: {
|
|
505
|
+
fromThingId: v.id("entities"),
|
|
506
|
+
toThingId: v.id("entities"),
|
|
507
|
+
relationshipType: v.string(),
|
|
508
|
+
validFrom: v.number(),
|
|
509
|
+
validTo: v.number(),
|
|
510
|
+
},
|
|
511
|
+
handler: async (ctx, args) => {
|
|
512
|
+
const connectionId = await ctx.db.insert("connections", {
|
|
513
|
+
fromEntityId: args.fromThingId,
|
|
514
|
+
toEntityId: args.toThingId,
|
|
515
|
+
relationshipType: args.relationshipType,
|
|
516
|
+
validFrom: args.validFrom,
|
|
517
|
+
validTo: args.validTo,
|
|
518
|
+
createdAt: Date.now(),
|
|
519
|
+
});
|
|
520
|
+
|
|
521
|
+
// Schedule cleanup after validTo
|
|
522
|
+
await ctx.scheduler.runAfter(
|
|
523
|
+
args.validTo - Date.now(),
|
|
524
|
+
internal.connections.expireConnection,
|
|
525
|
+
{ connectionId }
|
|
526
|
+
);
|
|
527
|
+
|
|
528
|
+
return connectionId;
|
|
529
|
+
},
|
|
530
|
+
});
|
|
531
|
+
|
|
532
|
+
// Cross-backend connections (Convex person owns WordPress post)
|
|
533
|
+
export const linkExternalContent = mutation({
|
|
534
|
+
args: {
|
|
535
|
+
userId: v.id("entities"),
|
|
536
|
+
externalContentId: v.string(), // WordPress post ID
|
|
537
|
+
platform: v.string(), // "wordpress"
|
|
538
|
+
},
|
|
539
|
+
handler: async (ctx, args) => {
|
|
540
|
+
// Create external_connection thing
|
|
541
|
+
const externalThingId = await ctx.db.insert("entities", {
|
|
542
|
+
type: "external_connection",
|
|
543
|
+
name: `${args.platform} content ${args.externalContentId}`,
|
|
544
|
+
properties: {
|
|
545
|
+
platform: args.platform,
|
|
546
|
+
externalId: args.externalContentId,
|
|
547
|
+
},
|
|
548
|
+
status: "active",
|
|
549
|
+
createdAt: Date.now(),
|
|
550
|
+
updatedAt: Date.now(),
|
|
551
|
+
});
|
|
552
|
+
|
|
553
|
+
// Create ownership connection
|
|
554
|
+
const connectionId = await ctx.db.insert("connections", {
|
|
555
|
+
fromEntityId: args.userId,
|
|
556
|
+
toEntityId: externalThingId,
|
|
557
|
+
relationshipType: "owns",
|
|
558
|
+
metadata: {
|
|
559
|
+
platform: args.platform,
|
|
560
|
+
syncedAt: Date.now(),
|
|
561
|
+
},
|
|
562
|
+
createdAt: Date.now(),
|
|
563
|
+
});
|
|
564
|
+
|
|
565
|
+
return { externalThingId, connectionId };
|
|
566
|
+
},
|
|
567
|
+
});
|
|
568
|
+
```
|
|
569
|
+
|
|
570
|
+
**Validation:**
|
|
571
|
+
|
|
572
|
+
- ✅ Bidirectional relationships
|
|
573
|
+
- ✅ Temporal validity supported
|
|
574
|
+
- ✅ Cross-backend connections (Convex ↔ WordPress ↔ Notion)
|
|
575
|
+
- ✅ Connection counting and querying
|
|
576
|
+
|
|
577
|
+
---
|
|
578
|
+
|
|
579
|
+
### Dimension 5: Events (Action Tracking)
|
|
580
|
+
|
|
581
|
+
**Data Flow:**
|
|
582
|
+
|
|
583
|
+
```typescript
|
|
584
|
+
// Frontend Component
|
|
585
|
+
export function AuditLog({ thingId }: { thingId: Id<"entities"> }) {
|
|
586
|
+
const events = useQuery(api.queries.events.listForThing, { thingId });
|
|
587
|
+
|
|
588
|
+
return (
|
|
589
|
+
<Timeline>
|
|
590
|
+
{events?.map((event) => (
|
|
591
|
+
<TimelineItem key={event._id} timestamp={event.timestamp}>
|
|
592
|
+
<EventBadge type={event.type} />
|
|
593
|
+
<EventDescription event={event} />
|
|
594
|
+
<ActorInfo actorId={event.actorId} />
|
|
595
|
+
</TimelineItem>
|
|
596
|
+
))}
|
|
597
|
+
</Timeline>
|
|
598
|
+
);
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
// DataProvider Interface
|
|
602
|
+
interface IDataProvider {
|
|
603
|
+
events: {
|
|
604
|
+
listForThing(args: { thingId: Id<"entities">; limit?: number }): Promise<Event[]>;
|
|
605
|
+
listForActor(args: { actorId: Id<"entities">; limit?: number }): Promise<Event[]>;
|
|
606
|
+
create(args: CreateEventArgs): Promise<Id<"events">>;
|
|
607
|
+
};
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
// Backend: Complete audit trail
|
|
611
|
+
export const listForThing = query({
|
|
612
|
+
args: {
|
|
613
|
+
thingId: v.id("entities"),
|
|
614
|
+
limit: v.optional(v.number()),
|
|
615
|
+
},
|
|
616
|
+
handler: async (ctx, args) => {
|
|
617
|
+
let query = ctx.db
|
|
618
|
+
.query("events")
|
|
619
|
+
.withIndex("by_target", (q) => q.eq("targetId", args.thingId))
|
|
620
|
+
.order("desc");
|
|
621
|
+
|
|
622
|
+
if (args.limit) {
|
|
623
|
+
query = query.take(args.limit);
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
return await query.collect();
|
|
627
|
+
},
|
|
628
|
+
});
|
|
629
|
+
|
|
630
|
+
// Protocol metadata tracking
|
|
631
|
+
export const logProtocolEvent = mutation({
|
|
632
|
+
args: {
|
|
633
|
+
type: v.string(),
|
|
634
|
+
actorId: v.id("entities"),
|
|
635
|
+
targetId: v.optional(v.id("entities")),
|
|
636
|
+
protocol: v.union(
|
|
637
|
+
v.literal("a2a"),
|
|
638
|
+
v.literal("acp"),
|
|
639
|
+
v.literal("ap2"),
|
|
640
|
+
v.literal("x402"),
|
|
641
|
+
v.literal("ag-ui")
|
|
642
|
+
),
|
|
643
|
+
metadata: v.any(),
|
|
644
|
+
},
|
|
645
|
+
handler: async (ctx, args) => {
|
|
646
|
+
return await ctx.db.insert("events", {
|
|
647
|
+
type: args.type,
|
|
648
|
+
actorId: args.actorId,
|
|
649
|
+
targetId: args.targetId,
|
|
650
|
+
timestamp: Date.now(),
|
|
651
|
+
metadata: {
|
|
652
|
+
protocol: args.protocol,
|
|
653
|
+
...args.metadata,
|
|
654
|
+
},
|
|
655
|
+
});
|
|
656
|
+
},
|
|
657
|
+
});
|
|
658
|
+
|
|
659
|
+
// Event logging spans provider boundaries
|
|
660
|
+
class CompositeProvider implements IDataProvider {
|
|
661
|
+
async syncData(orgId: Id<"entities">): Promise<void> {
|
|
662
|
+
// Sync from WordPress
|
|
663
|
+
await this.wordpressProvider.syncPosts(orgId);
|
|
664
|
+
|
|
665
|
+
// Log sync event in Convex (central event log)
|
|
666
|
+
await this.convexProvider.events.create({
|
|
667
|
+
type: "data_synced",
|
|
668
|
+
actorId: orgId,
|
|
669
|
+
timestamp: Date.now(),
|
|
670
|
+
metadata: {
|
|
671
|
+
provider: "wordpress",
|
|
672
|
+
syncedAt: Date.now(),
|
|
673
|
+
},
|
|
674
|
+
});
|
|
675
|
+
|
|
676
|
+
// Sync from Notion
|
|
677
|
+
await this.notionProvider.syncPages(orgId);
|
|
678
|
+
|
|
679
|
+
// Log sync event
|
|
680
|
+
await this.convexProvider.events.create({
|
|
681
|
+
type: "data_synced",
|
|
682
|
+
actorId: orgId,
|
|
683
|
+
timestamp: Date.now(),
|
|
684
|
+
metadata: {
|
|
685
|
+
provider: "notion",
|
|
686
|
+
syncedAt: Date.now(),
|
|
687
|
+
},
|
|
688
|
+
});
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
```
|
|
692
|
+
|
|
693
|
+
**Validation:**
|
|
694
|
+
|
|
695
|
+
- ✅ Complete audit trail for all operations
|
|
696
|
+
- ✅ Event logging spans provider boundaries
|
|
697
|
+
- ✅ Actor always recorded
|
|
698
|
+
- ✅ Metadata includes provider information
|
|
699
|
+
- ✅ Protocol events use metadata.protocol
|
|
700
|
+
|
|
701
|
+
---
|
|
702
|
+
|
|
703
|
+
### Dimension 6: Knowledge (Semantic Understanding)
|
|
704
|
+
|
|
705
|
+
**Data Flow:**
|
|
706
|
+
|
|
707
|
+
```typescript
|
|
708
|
+
// Frontend Component
|
|
709
|
+
export function SemanticSearch({ orgId }: { orgId: Id<"entities"> }) {
|
|
710
|
+
const [query, setQuery] = useState("");
|
|
711
|
+
const results = useQuery(api.queries.knowledge.search, {
|
|
712
|
+
query,
|
|
713
|
+
orgId,
|
|
714
|
+
limit: 20,
|
|
715
|
+
});
|
|
716
|
+
|
|
717
|
+
return (
|
|
718
|
+
<div>
|
|
719
|
+
<SearchInput value={query} onChange={setQuery} />
|
|
720
|
+
<SearchResults results={results} />
|
|
721
|
+
</div>
|
|
722
|
+
);
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
// DataProvider Interface
|
|
726
|
+
interface IDataProvider {
|
|
727
|
+
knowledge: {
|
|
728
|
+
search(args: {
|
|
729
|
+
query: string;
|
|
730
|
+
orgId: Id<"entities">;
|
|
731
|
+
limit?: number;
|
|
732
|
+
}): Promise<KnowledgeItem[]>;
|
|
733
|
+
embed(text: string, model?: string): Promise<number[]>;
|
|
734
|
+
linkToThing(
|
|
735
|
+
thingId: Id<"entities">,
|
|
736
|
+
knowledgeId: Id<"knowledge">,
|
|
737
|
+
role: KnowledgeRole
|
|
738
|
+
): Promise<void>;
|
|
739
|
+
};
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
// Backend-specific implementations
|
|
743
|
+
|
|
744
|
+
// Convex: Native vector search
|
|
745
|
+
class ConvexProvider implements IDataProvider {
|
|
746
|
+
knowledge = {
|
|
747
|
+
search: async (args) => {
|
|
748
|
+
// Generate query embedding
|
|
749
|
+
const queryEmbedding = await this.embed(args.query);
|
|
750
|
+
|
|
751
|
+
// Vector search with Convex
|
|
752
|
+
const results = await this.client.query(
|
|
753
|
+
api.queries.knowledge.vectorSearch,
|
|
754
|
+
{
|
|
755
|
+
embedding: queryEmbedding,
|
|
756
|
+
orgId: args.orgId,
|
|
757
|
+
limit: args.limit || 20,
|
|
758
|
+
}
|
|
759
|
+
);
|
|
760
|
+
|
|
761
|
+
return results;
|
|
762
|
+
},
|
|
763
|
+
};
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
// Supabase: pgvector
|
|
767
|
+
class SupabaseProvider implements IDataProvider {
|
|
768
|
+
knowledge = {
|
|
769
|
+
search: async (args) => {
|
|
770
|
+
// Generate query embedding
|
|
771
|
+
const queryEmbedding = await this.embed(args.query);
|
|
772
|
+
|
|
773
|
+
// Vector search with pgvector
|
|
774
|
+
const { data } = await this.supabase.rpc("match_knowledge", {
|
|
775
|
+
query_embedding: queryEmbedding,
|
|
776
|
+
org_id: args.orgId,
|
|
777
|
+
match_threshold: 0.7,
|
|
778
|
+
match_count: args.limit || 20,
|
|
779
|
+
});
|
|
780
|
+
|
|
781
|
+
return data;
|
|
782
|
+
},
|
|
783
|
+
};
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
// RAG Pipeline Integration
|
|
787
|
+
export const ingestDocument = internalAction({
|
|
788
|
+
args: {
|
|
789
|
+
thingId: v.id("entities"),
|
|
790
|
+
fields: v.array(v.string()),
|
|
791
|
+
},
|
|
792
|
+
handler: async (ctx, args) => {
|
|
793
|
+
// Get thing
|
|
794
|
+
const thing = await ctx.runQuery(internal.things.get, {
|
|
795
|
+
id: args.thingId,
|
|
796
|
+
});
|
|
797
|
+
|
|
798
|
+
// Extract text from fields
|
|
799
|
+
const texts = args.fields.map((field) => thing.properties[field]);
|
|
800
|
+
|
|
801
|
+
// Chunk text
|
|
802
|
+
const chunks = chunkText(texts.join("\n\n"), {
|
|
803
|
+
size: 800,
|
|
804
|
+
overlap: 200,
|
|
805
|
+
});
|
|
806
|
+
|
|
807
|
+
// Generate embeddings
|
|
808
|
+
for (const [index, chunk] of chunks.entries()) {
|
|
809
|
+
const { embedding, model, dim } = await ctx.runAction(
|
|
810
|
+
internal.knowledge.embedText,
|
|
811
|
+
{
|
|
812
|
+
text: chunk.text,
|
|
813
|
+
}
|
|
814
|
+
);
|
|
815
|
+
|
|
816
|
+
// Store knowledge chunk
|
|
817
|
+
const knowledgeId = await ctx.runMutation(
|
|
818
|
+
internal.knowledge.upsert,
|
|
819
|
+
{
|
|
820
|
+
item: {
|
|
821
|
+
knowledgeType: "chunk",
|
|
822
|
+
text: chunk.text,
|
|
823
|
+
embedding,
|
|
824
|
+
embeddingModel: model,
|
|
825
|
+
embeddingDim: dim,
|
|
826
|
+
sourceThingId: args.thingId,
|
|
827
|
+
sourceField: chunk.field,
|
|
828
|
+
chunk: {
|
|
829
|
+
index,
|
|
830
|
+
tokenCount: chunk.tokens,
|
|
831
|
+
overlap: 200,
|
|
832
|
+
},
|
|
833
|
+
},
|
|
834
|
+
}
|
|
835
|
+
);
|
|
836
|
+
|
|
837
|
+
// Link to thing
|
|
838
|
+
await ctx.runMutation(internal.knowledge.linkToThing, {
|
|
839
|
+
thingId: args.thingId,
|
|
840
|
+
knowledgeId,
|
|
841
|
+
role: "chunk_of",
|
|
842
|
+
});
|
|
843
|
+
}
|
|
844
|
+
},
|
|
845
|
+
});
|
|
846
|
+
```
|
|
847
|
+
|
|
848
|
+
**Unified Search Across Providers:**
|
|
849
|
+
|
|
850
|
+
```typescript
|
|
851
|
+
class CompositeProvider implements IDataProvider {
|
|
852
|
+
async search(args: SearchArgs): Promise<SearchResults> {
|
|
853
|
+
// Search across all backends in parallel
|
|
854
|
+
const [convexResults, supabaseResults, notionResults] = await Promise.all([
|
|
855
|
+
this.convexProvider.knowledge.search(args),
|
|
856
|
+
this.supabaseProvider.knowledge.search(args),
|
|
857
|
+
this.notionProvider.knowledge.search(args),
|
|
858
|
+
]);
|
|
859
|
+
|
|
860
|
+
// Merge and deduplicate results
|
|
861
|
+
const allResults = [
|
|
862
|
+
...convexResults,
|
|
863
|
+
...supabaseResults,
|
|
864
|
+
...notionResults,
|
|
865
|
+
];
|
|
866
|
+
|
|
867
|
+
// Sort by relevance score
|
|
868
|
+
return allResults
|
|
869
|
+
.sort((a, b) => b.score - a.score)
|
|
870
|
+
.slice(0, args.limit || 20);
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
```
|
|
874
|
+
|
|
875
|
+
**Validation:**
|
|
876
|
+
|
|
877
|
+
- ✅ Embeddings and vector search
|
|
878
|
+
- ✅ Backend-specific implementations (Convex vectors, Supabase pgvector)
|
|
879
|
+
- ✅ Unified search across providers
|
|
880
|
+
- ✅ RAG pipeline integration
|
|
881
|
+
|
|
882
|
+
---
|
|
883
|
+
|
|
884
|
+
## 2. Multi-Backend Federation
|
|
885
|
+
|
|
886
|
+
### CompositeProvider Architecture
|
|
887
|
+
|
|
888
|
+
```typescript
|
|
889
|
+
// Central orchestrator
|
|
890
|
+
export class CompositeProvider implements IDataProvider {
|
|
891
|
+
constructor(
|
|
892
|
+
private convex: ConvexProvider,
|
|
893
|
+
private wordpress: WordPressProvider,
|
|
894
|
+
private shopify: ShopifyProvider,
|
|
895
|
+
private notion: NotionProvider
|
|
896
|
+
) {}
|
|
897
|
+
|
|
898
|
+
// Route requests to appropriate backend
|
|
899
|
+
things = {
|
|
900
|
+
list: async (args) => {
|
|
901
|
+
switch (args.type) {
|
|
902
|
+
case "blog_post":
|
|
903
|
+
return this.wordpress.things.list(args);
|
|
904
|
+
case "product":
|
|
905
|
+
return this.shopify.things.list(args);
|
|
906
|
+
case "document":
|
|
907
|
+
return this.notion.things.list(args);
|
|
908
|
+
default:
|
|
909
|
+
return this.convex.things.list(args);
|
|
910
|
+
}
|
|
911
|
+
},
|
|
912
|
+
|
|
913
|
+
get: async (id) => {
|
|
914
|
+
// Check metadata for provider hint
|
|
915
|
+
const metadata = await this.convex.getThingMetadata(id);
|
|
916
|
+
|
|
917
|
+
switch (metadata?.provider) {
|
|
918
|
+
case "wordpress":
|
|
919
|
+
return this.wordpress.things.get(id);
|
|
920
|
+
case "shopify":
|
|
921
|
+
return this.shopify.things.get(id);
|
|
922
|
+
case "notion":
|
|
923
|
+
return this.notion.things.get(id);
|
|
924
|
+
default:
|
|
925
|
+
return this.convex.things.get(id);
|
|
926
|
+
}
|
|
927
|
+
},
|
|
928
|
+
};
|
|
929
|
+
|
|
930
|
+
// Federated queries
|
|
931
|
+
async searchAcrossBackends(query: string): Promise<Thing[]> {
|
|
932
|
+
const results = await Promise.all([
|
|
933
|
+
this.convex.search(query),
|
|
934
|
+
this.wordpress.search(query),
|
|
935
|
+
this.shopify.search(query),
|
|
936
|
+
this.notion.search(query),
|
|
937
|
+
]);
|
|
938
|
+
|
|
939
|
+
return results.flat();
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
```
|
|
943
|
+
|
|
944
|
+
### Backend Routing Rules
|
|
945
|
+
|
|
946
|
+
| Thing Type | Primary Backend | Sync Strategy |
|
|
947
|
+
|------------|----------------|---------------|
|
|
948
|
+
| `creator`, `organization`, `agent`, `token` | Convex | Native |
|
|
949
|
+
| `blog_post`, `social_post` | WordPress | Read-only sync to Convex |
|
|
950
|
+
| `product`, `payment`, `subscription` | Shopify | Event-driven sync |
|
|
951
|
+
| `document`, `knowledge_item` | Notion | Bidirectional sync |
|
|
952
|
+
|
|
953
|
+
### Cross-Backend Consistency
|
|
954
|
+
|
|
955
|
+
```typescript
|
|
956
|
+
// Event-driven sync pattern
|
|
957
|
+
export const syncWordPressPost = internalAction({
|
|
958
|
+
args: { wpPostId: v.string() },
|
|
959
|
+
handler: async (ctx, args) => {
|
|
960
|
+
// 1. Fetch from WordPress
|
|
961
|
+
const wpPost = await fetchWordPressPost(args.wpPostId);
|
|
962
|
+
|
|
963
|
+
// 2. Create/update in Convex
|
|
964
|
+
const thingId = await ctx.runMutation(internal.things.upsert, {
|
|
965
|
+
externalId: args.wpPostId,
|
|
966
|
+
type: "blog_post",
|
|
967
|
+
name: wpPost.title.rendered,
|
|
968
|
+
properties: {
|
|
969
|
+
content: wpPost.content.rendered,
|
|
970
|
+
wpId: wpPost.id,
|
|
971
|
+
syncedAt: Date.now(),
|
|
972
|
+
},
|
|
973
|
+
});
|
|
974
|
+
|
|
975
|
+
// 3. Log sync event
|
|
976
|
+
await ctx.runMutation(internal.events.create, {
|
|
977
|
+
type: "data_synced",
|
|
978
|
+
targetId: thingId,
|
|
979
|
+
timestamp: Date.now(),
|
|
980
|
+
metadata: {
|
|
981
|
+
provider: "wordpress",
|
|
982
|
+
externalId: args.wpPostId,
|
|
983
|
+
},
|
|
984
|
+
});
|
|
985
|
+
|
|
986
|
+
return thingId;
|
|
987
|
+
},
|
|
988
|
+
});
|
|
989
|
+
|
|
990
|
+
// Webhook handler for real-time sync
|
|
991
|
+
export const handleWordPressWebhook = httpAction(async (ctx, request) => {
|
|
992
|
+
const payload = await request.json();
|
|
993
|
+
|
|
994
|
+
// Schedule sync for updated post
|
|
995
|
+
await ctx.scheduler.runAfter(0, internal.sync.syncWordPressPost, {
|
|
996
|
+
wpPostId: payload.id,
|
|
997
|
+
});
|
|
998
|
+
|
|
999
|
+
return new Response("OK", { status: 200 });
|
|
1000
|
+
});
|
|
1001
|
+
```
|
|
1002
|
+
|
|
1003
|
+
### Validation
|
|
1004
|
+
|
|
1005
|
+
- ✅ Single frontend queries all backends transparently
|
|
1006
|
+
- ✅ Cross-backend connections maintained
|
|
1007
|
+
- ✅ Event-driven sync prevents stale data
|
|
1008
|
+
- ✅ Webhook integration for real-time updates
|
|
1009
|
+
|
|
1010
|
+
---
|
|
1011
|
+
|
|
1012
|
+
## 3. Real-Time Coordination
|
|
1013
|
+
|
|
1014
|
+
### Real-Time Strategy by Backend
|
|
1015
|
+
|
|
1016
|
+
| Backend | Native Support | Implementation |
|
|
1017
|
+
|---------|---------------|----------------|
|
|
1018
|
+
| **Convex** | Native WebSocket | `useQuery` hook (automatic subscriptions) |
|
|
1019
|
+
| **Supabase** | PostgreSQL real-time | `realtime` subscriptions |
|
|
1020
|
+
| **WordPress** | None | Polling fallback (30s intervals) |
|
|
1021
|
+
| **Notion** | None | Webhook-based updates |
|
|
1022
|
+
|
|
1023
|
+
### Frontend Real-Time Coordination
|
|
1024
|
+
|
|
1025
|
+
```typescript
|
|
1026
|
+
// useRealtimeData hook (provider-agnostic)
|
|
1027
|
+
export function useRealtimeData<T>(
|
|
1028
|
+
provider: IDataProvider,
|
|
1029
|
+
query: Query,
|
|
1030
|
+
options?: { pollInterval?: number }
|
|
1031
|
+
) {
|
|
1032
|
+
const [data, setData] = useState<T | undefined>();
|
|
1033
|
+
const [loading, setLoading] = useState(true);
|
|
1034
|
+
|
|
1035
|
+
useEffect(() => {
|
|
1036
|
+
// Check if provider supports real-time
|
|
1037
|
+
if (provider.supportsRealtime) {
|
|
1038
|
+
// Subscribe to real-time updates
|
|
1039
|
+
const unsubscribe = provider.subscribe(query, (newData) => {
|
|
1040
|
+
setData(newData);
|
|
1041
|
+
setLoading(false);
|
|
1042
|
+
});
|
|
1043
|
+
|
|
1044
|
+
return unsubscribe;
|
|
1045
|
+
} else {
|
|
1046
|
+
// Fallback to polling
|
|
1047
|
+
const fetchData = async () => {
|
|
1048
|
+
const result = await provider.query(query);
|
|
1049
|
+
setData(result);
|
|
1050
|
+
setLoading(false);
|
|
1051
|
+
};
|
|
1052
|
+
|
|
1053
|
+
fetchData();
|
|
1054
|
+
const interval = setInterval(fetchData, options?.pollInterval || 30000);
|
|
1055
|
+
|
|
1056
|
+
return () => clearInterval(interval);
|
|
1057
|
+
}
|
|
1058
|
+
}, [provider, query]);
|
|
1059
|
+
|
|
1060
|
+
return { data, loading };
|
|
1061
|
+
}
|
|
1062
|
+
|
|
1063
|
+
// Usage (works with any provider)
|
|
1064
|
+
export function Dashboard() {
|
|
1065
|
+
const provider = useDataProvider(); // Context
|
|
1066
|
+
const stats = useRealtimeData<DashboardStats>(provider, {
|
|
1067
|
+
type: "dashboard_stats",
|
|
1068
|
+
orgId: currentOrgId,
|
|
1069
|
+
});
|
|
1070
|
+
|
|
1071
|
+
return <StatsDisplay data={stats.data} loading={stats.loading} />;
|
|
1072
|
+
}
|
|
1073
|
+
```
|
|
1074
|
+
|
|
1075
|
+
### Convex Real-Time (Preferred)
|
|
1076
|
+
|
|
1077
|
+
```typescript
|
|
1078
|
+
// Native Convex subscriptions
|
|
1079
|
+
export function RealtimeDashboard({ orgId }: { orgId: Id<"entities"> }) {
|
|
1080
|
+
// Automatic WebSocket subscription - no additional code needed
|
|
1081
|
+
const stats = useQuery(api.queries.dashboard.getStats, { orgId });
|
|
1082
|
+
|
|
1083
|
+
return <DashboardStats data={stats} />;
|
|
1084
|
+
}
|
|
1085
|
+
```
|
|
1086
|
+
|
|
1087
|
+
### Supabase Real-Time
|
|
1088
|
+
|
|
1089
|
+
```typescript
|
|
1090
|
+
// Supabase realtime subscriptions
|
|
1091
|
+
class SupabaseProvider implements IDataProvider {
|
|
1092
|
+
subscribe(query: Query, callback: (data: any) => void) {
|
|
1093
|
+
const channel = this.supabase
|
|
1094
|
+
.channel("db-changes")
|
|
1095
|
+
.on(
|
|
1096
|
+
"postgres_changes",
|
|
1097
|
+
{
|
|
1098
|
+
event: "*",
|
|
1099
|
+
schema: "public",
|
|
1100
|
+
table: query.table,
|
|
1101
|
+
},
|
|
1102
|
+
(payload) => {
|
|
1103
|
+
callback(payload.new);
|
|
1104
|
+
}
|
|
1105
|
+
)
|
|
1106
|
+
.subscribe();
|
|
1107
|
+
|
|
1108
|
+
return () => {
|
|
1109
|
+
channel.unsubscribe();
|
|
1110
|
+
};
|
|
1111
|
+
}
|
|
1112
|
+
}
|
|
1113
|
+
```
|
|
1114
|
+
|
|
1115
|
+
### Polling Fallback (WordPress/Notion)
|
|
1116
|
+
|
|
1117
|
+
```typescript
|
|
1118
|
+
// Polling for backends without real-time
|
|
1119
|
+
class WordPressProvider implements IDataProvider {
|
|
1120
|
+
supportsRealtime = false;
|
|
1121
|
+
|
|
1122
|
+
async query(query: Query): Promise<any> {
|
|
1123
|
+
// Fetch data from WordPress API
|
|
1124
|
+
const response = await fetch(
|
|
1125
|
+
`${this.wpUrl}/wp-json/wp/v2/${query.endpoint}`
|
|
1126
|
+
);
|
|
1127
|
+
return response.json();
|
|
1128
|
+
}
|
|
1129
|
+
}
|
|
1130
|
+
```
|
|
1131
|
+
|
|
1132
|
+
### Validation
|
|
1133
|
+
|
|
1134
|
+
- ✅ Convex: Native WebSocket support
|
|
1135
|
+
- ✅ Supabase: PostgreSQL real-time
|
|
1136
|
+
- ✅ WordPress: Polling fallback (no native real-time)
|
|
1137
|
+
- ✅ Notion: Webhook-based updates
|
|
1138
|
+
- ✅ Frontend receives updates regardless of backend
|
|
1139
|
+
|
|
1140
|
+
---
|
|
1141
|
+
|
|
1142
|
+
## 4. Migration Coordination (7 Phases)
|
|
1143
|
+
|
|
1144
|
+
### Overview
|
|
1145
|
+
|
|
1146
|
+
Zero-downtime migration with gradual rollout and complete test coverage.
|
|
1147
|
+
|
|
1148
|
+
### Phase 1: Interface Definition (Week 1)
|
|
1149
|
+
|
|
1150
|
+
**Goal:** Define `IDataProvider` interface
|
|
1151
|
+
|
|
1152
|
+
**Deliverables:**
|
|
1153
|
+
|
|
1154
|
+
```typescript
|
|
1155
|
+
// /frontend/src/lib/providers/interface.ts
|
|
1156
|
+
export interface IDataProvider {
|
|
1157
|
+
// 6-Dimension Operations
|
|
1158
|
+
organizations: OrganizationOperations;
|
|
1159
|
+
people: PeopleOperations;
|
|
1160
|
+
things: ThingOperations;
|
|
1161
|
+
connections: ConnectionOperations;
|
|
1162
|
+
events: EventOperations;
|
|
1163
|
+
knowledge: KnowledgeOperations;
|
|
1164
|
+
|
|
1165
|
+
// Metadata
|
|
1166
|
+
name: string;
|
|
1167
|
+
supportsRealtime: boolean;
|
|
1168
|
+
capabilities: string[];
|
|
1169
|
+
|
|
1170
|
+
// Lifecycle
|
|
1171
|
+
initialize(): Promise<void>;
|
|
1172
|
+
disconnect(): Promise<void>;
|
|
1173
|
+
|
|
1174
|
+
// Real-time (optional)
|
|
1175
|
+
subscribe?(query: Query, callback: (data: any) => void): () => void;
|
|
1176
|
+
}
|
|
1177
|
+
|
|
1178
|
+
// Complete type definitions
|
|
1179
|
+
export interface ThingOperations {
|
|
1180
|
+
list(args: ListThingsArgs): Promise<Thing[]>;
|
|
1181
|
+
get(id: Id<"entities">): Promise<Thing>;
|
|
1182
|
+
create(args: CreateThingArgs): Promise<Id<"entities">>;
|
|
1183
|
+
update(id: Id<"entities">, updates: Partial<Thing>): Promise<void>;
|
|
1184
|
+
delete(id: Id<"entities">): Promise<void>;
|
|
1185
|
+
}
|
|
1186
|
+
|
|
1187
|
+
// ... similar for other dimensions
|
|
1188
|
+
```
|
|
1189
|
+
|
|
1190
|
+
**Tests:**
|
|
1191
|
+
|
|
1192
|
+
- ✅ Interface compiles
|
|
1193
|
+
- ✅ All method signatures defined
|
|
1194
|
+
- ✅ Type safety enforced
|
|
1195
|
+
|
|
1196
|
+
**Coordination:** Backend Specialist reviews interface
|
|
1197
|
+
|
|
1198
|
+
---
|
|
1199
|
+
|
|
1200
|
+
### Phase 2: ConvexProvider (Week 2)
|
|
1201
|
+
|
|
1202
|
+
**Goal:** Implement ConvexProvider (maintain 100% backward compatibility)
|
|
1203
|
+
|
|
1204
|
+
**Deliverables:**
|
|
1205
|
+
|
|
1206
|
+
```typescript
|
|
1207
|
+
// /frontend/src/lib/providers/convex.ts
|
|
1208
|
+
export class ConvexProvider implements IDataProvider {
|
|
1209
|
+
constructor(private client: ConvexReactClient) {}
|
|
1210
|
+
|
|
1211
|
+
name = "convex";
|
|
1212
|
+
supportsRealtime = true;
|
|
1213
|
+
capabilities = ["organizations", "people", "things", "connections", "events", "knowledge"];
|
|
1214
|
+
|
|
1215
|
+
organizations = {
|
|
1216
|
+
list: async (args) => {
|
|
1217
|
+
return await this.client.query(api.queries.organizations.list, args);
|
|
1218
|
+
},
|
|
1219
|
+
// ... all operations
|
|
1220
|
+
};
|
|
1221
|
+
|
|
1222
|
+
// ... implement all 6 dimensions
|
|
1223
|
+
}
|
|
1224
|
+
```
|
|
1225
|
+
|
|
1226
|
+
**Tests:**
|
|
1227
|
+
|
|
1228
|
+
```typescript
|
|
1229
|
+
// tests/integration/providers/convex.test.ts
|
|
1230
|
+
describe("ConvexProvider", () => {
|
|
1231
|
+
it("should implement all 6 dimensions", () => {
|
|
1232
|
+
const provider = new ConvexProvider(mockClient);
|
|
1233
|
+
expect(provider.organizations).toBeDefined();
|
|
1234
|
+
expect(provider.people).toBeDefined();
|
|
1235
|
+
expect(provider.things).toBeDefined();
|
|
1236
|
+
expect(provider.connections).toBeDefined();
|
|
1237
|
+
expect(provider.events).toBeDefined();
|
|
1238
|
+
expect(provider.knowledge).toBeDefined();
|
|
1239
|
+
});
|
|
1240
|
+
|
|
1241
|
+
it("should query organizations correctly", async () => {
|
|
1242
|
+
const provider = new ConvexProvider(mockClient);
|
|
1243
|
+
const orgs = await provider.organizations.list({ userId: "user_123" });
|
|
1244
|
+
expect(orgs).toBeInstanceOf(Array);
|
|
1245
|
+
});
|
|
1246
|
+
|
|
1247
|
+
// ... test all operations
|
|
1248
|
+
});
|
|
1249
|
+
```
|
|
1250
|
+
|
|
1251
|
+
**Coordination:**
|
|
1252
|
+
|
|
1253
|
+
- Frontend Specialist reviews implementation
|
|
1254
|
+
- Backend Specialist validates backend queries
|
|
1255
|
+
- Quality Agent validates test coverage
|
|
1256
|
+
|
|
1257
|
+
**Migration Validation:** No breaking changes to existing code
|
|
1258
|
+
|
|
1259
|
+
---
|
|
1260
|
+
|
|
1261
|
+
### Phase 3: Service Layer (Week 3)
|
|
1262
|
+
|
|
1263
|
+
**Goal:** Implement Effect.ts services (pure business logic)
|
|
1264
|
+
|
|
1265
|
+
**Deliverables:**
|
|
1266
|
+
|
|
1267
|
+
```typescript
|
|
1268
|
+
// /backend/convex/services/organizations/organization-service.ts
|
|
1269
|
+
export class OrganizationService extends Effect.Service<OrganizationService>()(
|
|
1270
|
+
"OrganizationService",
|
|
1271
|
+
{
|
|
1272
|
+
effect: Effect.gen(function* () {
|
|
1273
|
+
const db = yield* ConvexDatabase;
|
|
1274
|
+
|
|
1275
|
+
return {
|
|
1276
|
+
create: (args: CreateOrgArgs) =>
|
|
1277
|
+
Effect.gen(function* () {
|
|
1278
|
+
// Validate
|
|
1279
|
+
if (!args.name) {
|
|
1280
|
+
return yield* Effect.fail(new InvalidOrgNameError());
|
|
1281
|
+
}
|
|
1282
|
+
|
|
1283
|
+
// Create organization entity
|
|
1284
|
+
const orgId = yield* Effect.tryPromise(() =>
|
|
1285
|
+
db.insert("entities", {
|
|
1286
|
+
type: "organization",
|
|
1287
|
+
name: args.name,
|
|
1288
|
+
properties: {
|
|
1289
|
+
slug: slugify(args.name),
|
|
1290
|
+
plan: args.plan || "starter",
|
|
1291
|
+
status: "trial",
|
|
1292
|
+
},
|
|
1293
|
+
status: "active",
|
|
1294
|
+
createdAt: Date.now(),
|
|
1295
|
+
updatedAt: Date.now(),
|
|
1296
|
+
})
|
|
1297
|
+
);
|
|
1298
|
+
|
|
1299
|
+
// Create ownership connection
|
|
1300
|
+
yield* Effect.tryPromise(() =>
|
|
1301
|
+
db.insert("connections", {
|
|
1302
|
+
fromThingId: args.ownerId,
|
|
1303
|
+
toThingId: orgId,
|
|
1304
|
+
relationshipType: "owns",
|
|
1305
|
+
metadata: { role: "org_owner" },
|
|
1306
|
+
createdAt: Date.now(),
|
|
1307
|
+
})
|
|
1308
|
+
);
|
|
1309
|
+
|
|
1310
|
+
// Log creation event
|
|
1311
|
+
yield* Effect.tryPromise(() =>
|
|
1312
|
+
db.insert("events", {
|
|
1313
|
+
type: "organization_created",
|
|
1314
|
+
actorId: args.ownerId,
|
|
1315
|
+
targetId: orgId,
|
|
1316
|
+
timestamp: Date.now(),
|
|
1317
|
+
metadata: {
|
|
1318
|
+
plan: args.plan || "starter",
|
|
1319
|
+
},
|
|
1320
|
+
})
|
|
1321
|
+
);
|
|
1322
|
+
|
|
1323
|
+
return orgId;
|
|
1324
|
+
}),
|
|
1325
|
+
};
|
|
1326
|
+
}),
|
|
1327
|
+
dependencies: [ConvexDatabase.Default],
|
|
1328
|
+
}
|
|
1329
|
+
) {}
|
|
1330
|
+
```
|
|
1331
|
+
|
|
1332
|
+
**Tests:**
|
|
1333
|
+
|
|
1334
|
+
```typescript
|
|
1335
|
+
// tests/unit/services/organization.test.ts
|
|
1336
|
+
describe("OrganizationService.create", () => {
|
|
1337
|
+
it("should create organization with owner connection", async () => {
|
|
1338
|
+
const MockDB = Layer.succeed(ConvexDatabase, mockDatabase);
|
|
1339
|
+
|
|
1340
|
+
const result = await Effect.runPromise(
|
|
1341
|
+
Effect.gen(function* () {
|
|
1342
|
+
const service = yield* OrganizationService;
|
|
1343
|
+
return yield* service.create({
|
|
1344
|
+
name: "Acme Corp",
|
|
1345
|
+
ownerId: "user_123",
|
|
1346
|
+
plan: "pro",
|
|
1347
|
+
});
|
|
1348
|
+
}).pipe(Effect.provide(MockDB))
|
|
1349
|
+
);
|
|
1350
|
+
|
|
1351
|
+
expect(result).toBe("org_456");
|
|
1352
|
+
expect(mockDatabase.insert).toHaveBeenCalledWith("entities", expect.objectContaining({
|
|
1353
|
+
type: "organization",
|
|
1354
|
+
name: "Acme Corp",
|
|
1355
|
+
}));
|
|
1356
|
+
});
|
|
1357
|
+
});
|
|
1358
|
+
```
|
|
1359
|
+
|
|
1360
|
+
**Coordination:**
|
|
1361
|
+
|
|
1362
|
+
- Backend Specialist implements services
|
|
1363
|
+
- Integration Specialist ensures ontology alignment
|
|
1364
|
+
- Quality Agent validates unit tests
|
|
1365
|
+
|
|
1366
|
+
---
|
|
1367
|
+
|
|
1368
|
+
### Phase 4: Configuration (Week 4)
|
|
1369
|
+
|
|
1370
|
+
**Goal:** Add provider configuration and selection
|
|
1371
|
+
|
|
1372
|
+
**Deliverables:**
|
|
1373
|
+
|
|
1374
|
+
```typescript
|
|
1375
|
+
// /frontend/src/lib/providers/config.ts
|
|
1376
|
+
export interface ProviderConfig {
|
|
1377
|
+
default: "convex" | "supabase" | "composite";
|
|
1378
|
+
convex?: {
|
|
1379
|
+
url: string;
|
|
1380
|
+
};
|
|
1381
|
+
supabase?: {
|
|
1382
|
+
url: string;
|
|
1383
|
+
anonKey: string;
|
|
1384
|
+
};
|
|
1385
|
+
wordpress?: {
|
|
1386
|
+
url: string;
|
|
1387
|
+
apiKey: string;
|
|
1388
|
+
};
|
|
1389
|
+
}
|
|
1390
|
+
|
|
1391
|
+
export const providerConfig: ProviderConfig = {
|
|
1392
|
+
default: import.meta.env.PUBLIC_DEFAULT_PROVIDER || "convex",
|
|
1393
|
+
convex: {
|
|
1394
|
+
url: import.meta.env.PUBLIC_CONVEX_URL,
|
|
1395
|
+
},
|
|
1396
|
+
supabase: {
|
|
1397
|
+
url: import.meta.env.PUBLIC_SUPABASE_URL,
|
|
1398
|
+
anonKey: import.meta.env.PUBLIC_SUPABASE_ANON_KEY,
|
|
1399
|
+
},
|
|
1400
|
+
};
|
|
1401
|
+
|
|
1402
|
+
// Provider factory
|
|
1403
|
+
export function createProvider(config: ProviderConfig): IDataProvider {
|
|
1404
|
+
switch (config.default) {
|
|
1405
|
+
case "convex":
|
|
1406
|
+
return new ConvexProvider(
|
|
1407
|
+
new ConvexReactClient(config.convex.url)
|
|
1408
|
+
);
|
|
1409
|
+
case "supabase":
|
|
1410
|
+
return new SupabaseProvider(
|
|
1411
|
+
createClient(config.supabase.url, config.supabase.anonKey)
|
|
1412
|
+
);
|
|
1413
|
+
case "composite":
|
|
1414
|
+
return new CompositeProvider({
|
|
1415
|
+
convex: new ConvexProvider(...),
|
|
1416
|
+
wordpress: new WordPressProvider(...),
|
|
1417
|
+
// ...
|
|
1418
|
+
});
|
|
1419
|
+
default:
|
|
1420
|
+
throw new Error(`Unknown provider: ${config.default}`);
|
|
1421
|
+
}
|
|
1422
|
+
}
|
|
1423
|
+
|
|
1424
|
+
// React Context
|
|
1425
|
+
export const DataProviderContext = createContext<IDataProvider | null>(null);
|
|
1426
|
+
|
|
1427
|
+
export function DataProviderProvider({ children }: { children: ReactNode }) {
|
|
1428
|
+
const provider = useMemo(() => createProvider(providerConfig), []);
|
|
1429
|
+
|
|
1430
|
+
useEffect(() => {
|
|
1431
|
+
provider.initialize();
|
|
1432
|
+
return () => provider.disconnect();
|
|
1433
|
+
}, [provider]);
|
|
1434
|
+
|
|
1435
|
+
return (
|
|
1436
|
+
<DataProviderContext.Provider value={provider}>
|
|
1437
|
+
{children}
|
|
1438
|
+
</DataProviderContext.Provider>
|
|
1439
|
+
);
|
|
1440
|
+
}
|
|
1441
|
+
|
|
1442
|
+
export function useDataProvider(): IDataProvider {
|
|
1443
|
+
const provider = useContext(DataProviderContext);
|
|
1444
|
+
if (!provider) throw new Error("DataProvider not initialized");
|
|
1445
|
+
return provider;
|
|
1446
|
+
}
|
|
1447
|
+
```
|
|
1448
|
+
|
|
1449
|
+
**Tests:**
|
|
1450
|
+
|
|
1451
|
+
```typescript
|
|
1452
|
+
// tests/integration/providers/config.test.ts
|
|
1453
|
+
describe("Provider Configuration", () => {
|
|
1454
|
+
it("should create ConvexProvider when configured", () => {
|
|
1455
|
+
const config: ProviderConfig = { default: "convex", convex: { url: "https://test.convex.cloud" } };
|
|
1456
|
+
const provider = createProvider(config);
|
|
1457
|
+
expect(provider.name).toBe("convex");
|
|
1458
|
+
});
|
|
1459
|
+
|
|
1460
|
+
it("should switch providers via config", () => {
|
|
1461
|
+
const convexProvider = createProvider({ default: "convex", convex: { url: "..." } });
|
|
1462
|
+
const supabaseProvider = createProvider({ default: "supabase", supabase: { url: "...", anonKey: "..." } });
|
|
1463
|
+
|
|
1464
|
+
expect(convexProvider.name).toBe("convex");
|
|
1465
|
+
expect(supabaseProvider.name).toBe("supabase");
|
|
1466
|
+
});
|
|
1467
|
+
});
|
|
1468
|
+
```
|
|
1469
|
+
|
|
1470
|
+
**Coordination:**
|
|
1471
|
+
|
|
1472
|
+
- Frontend Specialist implements configuration
|
|
1473
|
+
- Backend Specialist validates backend compatibility
|
|
1474
|
+
- Integration Specialist ensures smooth switching
|
|
1475
|
+
|
|
1476
|
+
---
|
|
1477
|
+
|
|
1478
|
+
### Phase 5: Component Migration (Weeks 5-6)
|
|
1479
|
+
|
|
1480
|
+
**Goal:** Migrate components to use DataProvider
|
|
1481
|
+
|
|
1482
|
+
**Strategy:** Gradual page-by-page migration
|
|
1483
|
+
|
|
1484
|
+
```typescript
|
|
1485
|
+
// Before (direct Convex usage)
|
|
1486
|
+
export function OrganizationList() {
|
|
1487
|
+
const orgs = useQuery(api.queries.organizations.list);
|
|
1488
|
+
return <div>{orgs?.map(...)}</div>;
|
|
1489
|
+
}
|
|
1490
|
+
|
|
1491
|
+
// After (provider-agnostic)
|
|
1492
|
+
export function OrganizationList() {
|
|
1493
|
+
const provider = useDataProvider();
|
|
1494
|
+
const [orgs, setOrgs] = useState([]);
|
|
1495
|
+
|
|
1496
|
+
useEffect(() => {
|
|
1497
|
+
provider.organizations.list({ userId: currentUserId }).then(setOrgs);
|
|
1498
|
+
}, [provider]);
|
|
1499
|
+
|
|
1500
|
+
return <div>{orgs.map(...)}</div>;
|
|
1501
|
+
}
|
|
1502
|
+
|
|
1503
|
+
// Or use custom hook
|
|
1504
|
+
export function useOrganizations() {
|
|
1505
|
+
const provider = useDataProvider();
|
|
1506
|
+
return useRealtimeData(provider, { type: "organizations" });
|
|
1507
|
+
}
|
|
1508
|
+
|
|
1509
|
+
export function OrganizationList() {
|
|
1510
|
+
const { data: orgs } = useOrganizations();
|
|
1511
|
+
return <div>{orgs?.map(...)}</div>;
|
|
1512
|
+
}
|
|
1513
|
+
```
|
|
1514
|
+
|
|
1515
|
+
**Migration Checklist (Per Page):**
|
|
1516
|
+
|
|
1517
|
+
- [ ] Replace `useQuery(api.*)` with `useDataProvider()`
|
|
1518
|
+
- [ ] Replace `useMutation(api.*)` with `provider.*.create/update/delete`
|
|
1519
|
+
- [ ] Update loading/error states
|
|
1520
|
+
- [ ] Add real-time support via `useRealtimeData`
|
|
1521
|
+
- [ ] Test with Convex (backward compatibility)
|
|
1522
|
+
- [ ] Test with alternative provider (if available)
|
|
1523
|
+
- [ ] Run integration tests
|
|
1524
|
+
|
|
1525
|
+
**Migration Order:**
|
|
1526
|
+
|
|
1527
|
+
1. **Week 5:** Non-critical pages
|
|
1528
|
+
- `/about`, `/docs`, `/blog` (static content)
|
|
1529
|
+
- `/account/settings` (user preferences)
|
|
1530
|
+
- `/tokens/[id]` (read-only)
|
|
1531
|
+
|
|
1532
|
+
2. **Week 6:** Critical pages
|
|
1533
|
+
- `/dashboard` (organization stats)
|
|
1534
|
+
- `/account` (auth flows)
|
|
1535
|
+
- `/admin` (platform owner dashboard)
|
|
1536
|
+
|
|
1537
|
+
**Validation:** Run auth tests after EVERY migration
|
|
1538
|
+
|
|
1539
|
+
**Coordination:**
|
|
1540
|
+
|
|
1541
|
+
- Frontend Specialist implements migrations
|
|
1542
|
+
- Quality Agent validates tests after each page
|
|
1543
|
+
- Integration Specialist monitors for regressions
|
|
1544
|
+
|
|
1545
|
+
---
|
|
1546
|
+
|
|
1547
|
+
### Phase 6: Cleanup (Week 7)
|
|
1548
|
+
|
|
1549
|
+
**Goal:** Remove old dependencies and code
|
|
1550
|
+
|
|
1551
|
+
**Tasks:**
|
|
1552
|
+
|
|
1553
|
+
1. Remove direct Convex imports from components:
|
|
1554
|
+
|
|
1555
|
+
```bash
|
|
1556
|
+
# Find all direct Convex usage
|
|
1557
|
+
grep -r "from \"convex/react\"" frontend/src/components/
|
|
1558
|
+
grep -r "api.queries" frontend/src/components/
|
|
1559
|
+
grep -r "api.mutations" frontend/src/components/
|
|
1560
|
+
|
|
1561
|
+
# Remove unused imports
|
|
1562
|
+
```
|
|
1563
|
+
|
|
1564
|
+
2. Update package.json:
|
|
1565
|
+
|
|
1566
|
+
```json
|
|
1567
|
+
{
|
|
1568
|
+
"dependencies": {
|
|
1569
|
+
"convex": "^1.16.5", // Keep for backend communication
|
|
1570
|
+
// Remove any unused provider dependencies
|
|
1571
|
+
}
|
|
1572
|
+
}
|
|
1573
|
+
```
|
|
1574
|
+
|
|
1575
|
+
3. Consolidate provider exports:
|
|
1576
|
+
|
|
1577
|
+
```typescript
|
|
1578
|
+
// /frontend/src/lib/providers/index.ts
|
|
1579
|
+
export { IDataProvider } from "./interface";
|
|
1580
|
+
export { ConvexProvider } from "./convex";
|
|
1581
|
+
export { SupabaseProvider } from "./supabase";
|
|
1582
|
+
export { CompositeProvider } from "./composite";
|
|
1583
|
+
export { useDataProvider, DataProviderProvider } from "./config";
|
|
1584
|
+
```
|
|
1585
|
+
|
|
1586
|
+
4. Run comprehensive tests:
|
|
1587
|
+
|
|
1588
|
+
```bash
|
|
1589
|
+
# Auth tests (must pass 100%)
|
|
1590
|
+
bun test test/auth
|
|
1591
|
+
|
|
1592
|
+
# Integration tests
|
|
1593
|
+
bun test test/integration/providers
|
|
1594
|
+
|
|
1595
|
+
# Build test
|
|
1596
|
+
bun run build
|
|
1597
|
+
```
|
|
1598
|
+
|
|
1599
|
+
**Coordination:**
|
|
1600
|
+
|
|
1601
|
+
- Frontend Specialist performs cleanup
|
|
1602
|
+
- Quality Agent validates all tests pass
|
|
1603
|
+
- Integration Specialist approves final state
|
|
1604
|
+
|
|
1605
|
+
---
|
|
1606
|
+
|
|
1607
|
+
### Phase 7: Alternative Providers (Week 8+)
|
|
1608
|
+
|
|
1609
|
+
**Goal:** Implement alternative providers (Supabase, WordPress, Notion)
|
|
1610
|
+
|
|
1611
|
+
**SupabaseProvider:**
|
|
1612
|
+
|
|
1613
|
+
```typescript
|
|
1614
|
+
// /frontend/src/lib/providers/supabase.ts
|
|
1615
|
+
export class SupabaseProvider implements IDataProvider {
|
|
1616
|
+
constructor(private client: SupabaseClient) {}
|
|
1617
|
+
|
|
1618
|
+
name = "supabase";
|
|
1619
|
+
supportsRealtime = true;
|
|
1620
|
+
capabilities = ["organizations", "people", "things", "connections", "events", "knowledge"];
|
|
1621
|
+
|
|
1622
|
+
organizations = {
|
|
1623
|
+
list: async (args) => {
|
|
1624
|
+
const { data, error } = await this.client
|
|
1625
|
+
.from("entities")
|
|
1626
|
+
.select("*")
|
|
1627
|
+
.eq("type", "organization")
|
|
1628
|
+
.in("_id", args.orgIds);
|
|
1629
|
+
|
|
1630
|
+
if (error) throw error;
|
|
1631
|
+
return data;
|
|
1632
|
+
},
|
|
1633
|
+
// ... all operations
|
|
1634
|
+
};
|
|
1635
|
+
|
|
1636
|
+
// Real-time subscriptions
|
|
1637
|
+
subscribe(query: Query, callback: (data: any) => void) {
|
|
1638
|
+
const channel = this.client
|
|
1639
|
+
.channel("db-changes")
|
|
1640
|
+
.on("postgres_changes", { event: "*", schema: "public", table: query.table }, callback)
|
|
1641
|
+
.subscribe();
|
|
1642
|
+
|
|
1643
|
+
return () => channel.unsubscribe();
|
|
1644
|
+
}
|
|
1645
|
+
}
|
|
1646
|
+
```
|
|
1647
|
+
|
|
1648
|
+
**WordPressProvider:**
|
|
1649
|
+
|
|
1650
|
+
```typescript
|
|
1651
|
+
// /frontend/src/lib/providers/wordpress.ts
|
|
1652
|
+
export class WordPressProvider implements IDataProvider {
|
|
1653
|
+
constructor(private wpUrl: string, private apiKey: string) {}
|
|
1654
|
+
|
|
1655
|
+
name = "wordpress";
|
|
1656
|
+
supportsRealtime = false;
|
|
1657
|
+
capabilities = ["things"]; // Read-only blog posts
|
|
1658
|
+
|
|
1659
|
+
things = {
|
|
1660
|
+
list: async (args) => {
|
|
1661
|
+
if (args.type !== "blog_post") {
|
|
1662
|
+
throw new Error("WordPress only supports blog_post type");
|
|
1663
|
+
}
|
|
1664
|
+
|
|
1665
|
+
const response = await fetch(`${this.wpUrl}/wp-json/wp/v2/posts`, {
|
|
1666
|
+
headers: { Authorization: `Bearer ${this.apiKey}` },
|
|
1667
|
+
});
|
|
1668
|
+
|
|
1669
|
+
const posts = await response.json();
|
|
1670
|
+
|
|
1671
|
+
// Transform WordPress posts to things
|
|
1672
|
+
return posts.map((post: any) => ({
|
|
1673
|
+
_id: `wp_${post.id}`,
|
|
1674
|
+
type: "blog_post",
|
|
1675
|
+
name: post.title.rendered,
|
|
1676
|
+
properties: {
|
|
1677
|
+
content: post.content.rendered,
|
|
1678
|
+
wpId: post.id,
|
|
1679
|
+
},
|
|
1680
|
+
status: post.status === "publish" ? "published" : "draft",
|
|
1681
|
+
createdAt: new Date(post.date).getTime(),
|
|
1682
|
+
updatedAt: new Date(post.modified).getTime(),
|
|
1683
|
+
}));
|
|
1684
|
+
},
|
|
1685
|
+
};
|
|
1686
|
+
}
|
|
1687
|
+
```
|
|
1688
|
+
|
|
1689
|
+
**CompositeProvider:**
|
|
1690
|
+
|
|
1691
|
+
```typescript
|
|
1692
|
+
// /frontend/src/lib/providers/composite.ts
|
|
1693
|
+
export class CompositeProvider implements IDataProvider {
|
|
1694
|
+
constructor(private providers: {
|
|
1695
|
+
convex: ConvexProvider;
|
|
1696
|
+
wordpress?: WordPressProvider;
|
|
1697
|
+
shopify?: ShopifyProvider;
|
|
1698
|
+
notion?: NotionProvider;
|
|
1699
|
+
}) {}
|
|
1700
|
+
|
|
1701
|
+
name = "composite";
|
|
1702
|
+
supportsRealtime = true;
|
|
1703
|
+
capabilities = ["organizations", "people", "things", "connections", "events", "knowledge"];
|
|
1704
|
+
|
|
1705
|
+
things = {
|
|
1706
|
+
list: async (args) => {
|
|
1707
|
+
// Route to appropriate provider
|
|
1708
|
+
switch (args.type) {
|
|
1709
|
+
case "blog_post":
|
|
1710
|
+
return this.providers.wordpress?.things.list(args) || [];
|
|
1711
|
+
case "product":
|
|
1712
|
+
return this.providers.shopify?.things.list(args) || [];
|
|
1713
|
+
default:
|
|
1714
|
+
return this.providers.convex.things.list(args);
|
|
1715
|
+
}
|
|
1716
|
+
},
|
|
1717
|
+
};
|
|
1718
|
+
}
|
|
1719
|
+
```
|
|
1720
|
+
|
|
1721
|
+
**Tests:**
|
|
1722
|
+
|
|
1723
|
+
```typescript
|
|
1724
|
+
// tests/integration/providers/supabase.test.ts
|
|
1725
|
+
describe("SupabaseProvider", () => {
|
|
1726
|
+
it("should implement all 6 dimensions", () => {
|
|
1727
|
+
const provider = new SupabaseProvider(mockClient);
|
|
1728
|
+
expect(provider.organizations).toBeDefined();
|
|
1729
|
+
// ... test all dimensions
|
|
1730
|
+
});
|
|
1731
|
+
|
|
1732
|
+
it("should support real-time subscriptions", (done) => {
|
|
1733
|
+
const provider = new SupabaseProvider(mockClient);
|
|
1734
|
+
const unsubscribe = provider.subscribe({ table: "entities" }, (data) => {
|
|
1735
|
+
expect(data).toBeDefined();
|
|
1736
|
+
unsubscribe();
|
|
1737
|
+
done();
|
|
1738
|
+
});
|
|
1739
|
+
});
|
|
1740
|
+
});
|
|
1741
|
+
```
|
|
1742
|
+
|
|
1743
|
+
**Coordination:**
|
|
1744
|
+
|
|
1745
|
+
- Integration Specialist implements providers
|
|
1746
|
+
- Backend Specialist validates backend compatibility
|
|
1747
|
+
- Frontend Specialist validates frontend integration
|
|
1748
|
+
- Quality Agent validates test coverage
|
|
1749
|
+
|
|
1750
|
+
---
|
|
1751
|
+
|
|
1752
|
+
## 5. Testing Integration
|
|
1753
|
+
|
|
1754
|
+
### Test Hierarchy
|
|
1755
|
+
|
|
1756
|
+
```
|
|
1757
|
+
Unit Tests (services/)
|
|
1758
|
+
↓
|
|
1759
|
+
Integration Tests (providers/)
|
|
1760
|
+
↓
|
|
1761
|
+
E2E Tests (user journeys)
|
|
1762
|
+
↓
|
|
1763
|
+
Performance Tests (context usage, latency)
|
|
1764
|
+
```
|
|
1765
|
+
|
|
1766
|
+
### Unit Tests (Services)
|
|
1767
|
+
|
|
1768
|
+
**Location:** `/backend/tests/unit/services/`
|
|
1769
|
+
|
|
1770
|
+
**Coverage:** Business logic in Effect.ts services
|
|
1771
|
+
|
|
1772
|
+
```typescript
|
|
1773
|
+
// tests/unit/services/organization.test.ts
|
|
1774
|
+
describe("OrganizationService", () => {
|
|
1775
|
+
it("should create organization with owner connection and event", async () => {
|
|
1776
|
+
const MockDB = Layer.succeed(ConvexDatabase, {
|
|
1777
|
+
insert: vi.fn().mockResolvedValue("org_123"),
|
|
1778
|
+
get: vi.fn().mockResolvedValue({ _id: "user_123", type: "creator" }),
|
|
1779
|
+
});
|
|
1780
|
+
|
|
1781
|
+
const result = await Effect.runPromise(
|
|
1782
|
+
Effect.gen(function* () {
|
|
1783
|
+
const service = yield* OrganizationService;
|
|
1784
|
+
return yield* service.create({
|
|
1785
|
+
name: "Acme Corp",
|
|
1786
|
+
ownerId: "user_123",
|
|
1787
|
+
plan: "pro",
|
|
1788
|
+
});
|
|
1789
|
+
}).pipe(Effect.provide(MockDB))
|
|
1790
|
+
);
|
|
1791
|
+
|
|
1792
|
+
expect(result).toBe("org_123");
|
|
1793
|
+
});
|
|
1794
|
+
|
|
1795
|
+
it("should fail with InvalidOrgNameError when name is empty", async () => {
|
|
1796
|
+
const result = await Effect.runPromise(
|
|
1797
|
+
Effect.gen(function* () {
|
|
1798
|
+
const service = yield* OrganizationService;
|
|
1799
|
+
return yield* service.create({ name: "", ownerId: "user_123" });
|
|
1800
|
+
}).pipe(Effect.provide(TestLayer))
|
|
1801
|
+
);
|
|
1802
|
+
|
|
1803
|
+
expect(result).toBeInstanceOf(InvalidOrgNameError);
|
|
1804
|
+
});
|
|
1805
|
+
});
|
|
1806
|
+
```
|
|
1807
|
+
|
|
1808
|
+
### Integration Tests (Providers)
|
|
1809
|
+
|
|
1810
|
+
**Location:** `/frontend/test/integration/providers/`
|
|
1811
|
+
|
|
1812
|
+
**Coverage:** Frontend → Provider → Backend flows
|
|
1813
|
+
|
|
1814
|
+
```typescript
|
|
1815
|
+
// test/integration/providers/convex.test.ts
|
|
1816
|
+
describe("ConvexProvider Integration", () => {
|
|
1817
|
+
it("should create organization and retrieve it", async () => {
|
|
1818
|
+
const provider = new ConvexProvider(testClient);
|
|
1819
|
+
|
|
1820
|
+
// Create organization
|
|
1821
|
+
const orgId = await provider.organizations.create({
|
|
1822
|
+
name: "Test Org",
|
|
1823
|
+
ownerId: "user_123",
|
|
1824
|
+
plan: "starter",
|
|
1825
|
+
});
|
|
1826
|
+
|
|
1827
|
+
expect(orgId).toBeDefined();
|
|
1828
|
+
|
|
1829
|
+
// Retrieve organization
|
|
1830
|
+
const org = await provider.organizations.get({ orgId });
|
|
1831
|
+
|
|
1832
|
+
expect(org.name).toBe("Test Org");
|
|
1833
|
+
expect(org.properties.plan).toBe("starter");
|
|
1834
|
+
});
|
|
1835
|
+
|
|
1836
|
+
it("should enforce organization boundaries", async () => {
|
|
1837
|
+
const provider = new ConvexProvider(testClient);
|
|
1838
|
+
|
|
1839
|
+
// User A creates org
|
|
1840
|
+
const orgA = await provider.organizations.create({
|
|
1841
|
+
name: "Org A",
|
|
1842
|
+
ownerId: "user_a",
|
|
1843
|
+
});
|
|
1844
|
+
|
|
1845
|
+
// User B tries to access Org A's data
|
|
1846
|
+
const things = await provider.things.list({
|
|
1847
|
+
type: "blog_post",
|
|
1848
|
+
organizationId: orgA,
|
|
1849
|
+
userId: "user_b",
|
|
1850
|
+
});
|
|
1851
|
+
|
|
1852
|
+
expect(things).toEqual([]); // No access
|
|
1853
|
+
});
|
|
1854
|
+
});
|
|
1855
|
+
```
|
|
1856
|
+
|
|
1857
|
+
### E2E Tests (User Journeys)
|
|
1858
|
+
|
|
1859
|
+
**Location:** `/frontend/test/e2e/`
|
|
1860
|
+
|
|
1861
|
+
**Coverage:** Complete user workflows
|
|
1862
|
+
|
|
1863
|
+
```typescript
|
|
1864
|
+
// test/e2e/organization-creation.test.ts
|
|
1865
|
+
describe("Organization Creation Flow", () => {
|
|
1866
|
+
it("should create organization from dashboard", async ({ page }) => {
|
|
1867
|
+
// Sign in
|
|
1868
|
+
await page.goto("/account/signin");
|
|
1869
|
+
await page.fill('input[name="email"]', "test@example.com");
|
|
1870
|
+
await page.fill('input[name="password"]', "password123");
|
|
1871
|
+
await page.click('button[type="submit"]');
|
|
1872
|
+
|
|
1873
|
+
// Navigate to create organization
|
|
1874
|
+
await page.goto("/admin/organizations/new");
|
|
1875
|
+
|
|
1876
|
+
// Fill form
|
|
1877
|
+
await page.fill('input[name="name"]', "E2E Test Org");
|
|
1878
|
+
await page.selectOption('select[name="plan"]', "pro");
|
|
1879
|
+
|
|
1880
|
+
// Submit
|
|
1881
|
+
await page.click('button[type="submit"]');
|
|
1882
|
+
|
|
1883
|
+
// Verify creation
|
|
1884
|
+
await page.waitForURL("/admin/organizations/*");
|
|
1885
|
+
await expect(page.locator("h1")).toContainText("E2E Test Org");
|
|
1886
|
+
});
|
|
1887
|
+
});
|
|
1888
|
+
```
|
|
1889
|
+
|
|
1890
|
+
### Performance Tests
|
|
1891
|
+
|
|
1892
|
+
**Location:** `/frontend/test/performance/`
|
|
1893
|
+
|
|
1894
|
+
**Coverage:** Context usage, latency, throughput
|
|
1895
|
+
|
|
1896
|
+
```typescript
|
|
1897
|
+
// test/performance/context-usage.test.ts
|
|
1898
|
+
describe("Context Usage", () => {
|
|
1899
|
+
it("should stay within token budget", async () => {
|
|
1900
|
+
const provider = new ConvexProvider(testClient);
|
|
1901
|
+
|
|
1902
|
+
// Measure request size
|
|
1903
|
+
const request = await provider.things.list({ type: "creator" });
|
|
1904
|
+
const requestSize = JSON.stringify(request).length;
|
|
1905
|
+
|
|
1906
|
+
expect(requestSize).toBeLessThan(1500); // 1.5KB limit
|
|
1907
|
+
});
|
|
1908
|
+
|
|
1909
|
+
it("should respond within latency budget", async () => {
|
|
1910
|
+
const provider = new ConvexProvider(testClient);
|
|
1911
|
+
|
|
1912
|
+
const start = Date.now();
|
|
1913
|
+
await provider.organizations.list({ userId: "user_123" });
|
|
1914
|
+
const latency = Date.now() - start;
|
|
1915
|
+
|
|
1916
|
+
expect(latency).toBeLessThan(100); // 100ms limit
|
|
1917
|
+
});
|
|
1918
|
+
});
|
|
1919
|
+
```
|
|
1920
|
+
|
|
1921
|
+
### Auth Test Preservation
|
|
1922
|
+
|
|
1923
|
+
**Critical:** Run auth tests after EVERY migration step
|
|
1924
|
+
|
|
1925
|
+
```bash
|
|
1926
|
+
# Run all auth tests
|
|
1927
|
+
bun test test/auth
|
|
1928
|
+
|
|
1929
|
+
# Specific auth method tests
|
|
1930
|
+
bun test test/auth/email-password.test.ts
|
|
1931
|
+
bun test test/auth/oauth.test.ts
|
|
1932
|
+
bun test test/auth/magic-link.test.ts
|
|
1933
|
+
bun test test/auth/password-reset.test.ts
|
|
1934
|
+
|
|
1935
|
+
# Watch mode during migration
|
|
1936
|
+
bun test --watch test/auth
|
|
1937
|
+
```
|
|
1938
|
+
|
|
1939
|
+
**Auth Test Categories:**
|
|
1940
|
+
|
|
1941
|
+
1. ✅ Email & Password (signup, signin, validation)
|
|
1942
|
+
2. ✅ OAuth (GitHub, Google, account linking)
|
|
1943
|
+
3. ✅ Magic Links (passwordless, one-time use)
|
|
1944
|
+
4. ✅ Password Reset (token expiry, security)
|
|
1945
|
+
5. ✅ Email Verification (24h expiry)
|
|
1946
|
+
6. ✅ 2FA/TOTP (setup, backup codes)
|
|
1947
|
+
|
|
1948
|
+
**Test Coverage Goals:**
|
|
1949
|
+
|
|
1950
|
+
- Unit tests: 90%+ coverage
|
|
1951
|
+
- Integration tests: All 6 dimensions covered
|
|
1952
|
+
- E2E tests: Critical user journeys (auth, org creation, data CRUD)
|
|
1953
|
+
- Performance tests: Context < 1.5KB, Latency < 100ms
|
|
1954
|
+
- Auth tests: 100% pass rate (50+ test cases)
|
|
1955
|
+
|
|
1956
|
+
**Coordination:**
|
|
1957
|
+
|
|
1958
|
+
- Quality Agent owns test execution
|
|
1959
|
+
- Integration Specialist validates integration tests
|
|
1960
|
+
- Frontend Specialist validates E2E tests
|
|
1961
|
+
- Backend Specialist validates unit tests
|
|
1962
|
+
|
|
1963
|
+
---
|
|
1964
|
+
|
|
1965
|
+
## 6. Error Propagation
|
|
1966
|
+
|
|
1967
|
+
### Error Flow Architecture
|
|
1968
|
+
|
|
1969
|
+
```
|
|
1970
|
+
Backend Error → Provider Error → Frontend Display
|
|
1971
|
+
```
|
|
1972
|
+
|
|
1973
|
+
### Backend Errors (Effect.ts)
|
|
1974
|
+
|
|
1975
|
+
```typescript
|
|
1976
|
+
// /backend/convex/services/errors.ts
|
|
1977
|
+
import { Data } from "effect";
|
|
1978
|
+
|
|
1979
|
+
// Base error with protocol support
|
|
1980
|
+
export class ServiceError extends Data.TaggedError("ServiceError")<{
|
|
1981
|
+
message: string;
|
|
1982
|
+
code: string;
|
|
1983
|
+
protocol?: string;
|
|
1984
|
+
details?: any;
|
|
1985
|
+
}> {}
|
|
1986
|
+
|
|
1987
|
+
// Specific errors
|
|
1988
|
+
export class OrganizationNotFoundError extends Data.TaggedError(
|
|
1989
|
+
"OrganizationNotFoundError"
|
|
1990
|
+
)<{
|
|
1991
|
+
orgId: string;
|
|
1992
|
+
}> {}
|
|
1993
|
+
|
|
1994
|
+
export class InsufficientPermissionsError extends Data.TaggedError(
|
|
1995
|
+
"InsufficientPermissionsError"
|
|
1996
|
+
)<{
|
|
1997
|
+
userId: string;
|
|
1998
|
+
action: string;
|
|
1999
|
+
required: string[];
|
|
2000
|
+
}> {}
|
|
2001
|
+
|
|
2002
|
+
export class RateLimitExceededError extends Data.TaggedError(
|
|
2003
|
+
"RateLimitExceededError"
|
|
2004
|
+
)<{
|
|
2005
|
+
limit: number;
|
|
2006
|
+
period: string;
|
|
2007
|
+
retryAfter: number;
|
|
2008
|
+
}> {}
|
|
2009
|
+
|
|
2010
|
+
// Service implementation
|
|
2011
|
+
export class OrganizationService extends Effect.Service<OrganizationService>()(
|
|
2012
|
+
"OrganizationService",
|
|
2013
|
+
{
|
|
2014
|
+
effect: Effect.gen(function* () {
|
|
2015
|
+
const db = yield* ConvexDatabase;
|
|
2016
|
+
|
|
2017
|
+
return {
|
|
2018
|
+
get: (orgId: string) =>
|
|
2019
|
+
Effect.gen(function* () {
|
|
2020
|
+
const org = yield* Effect.tryPromise(() => db.get(orgId));
|
|
2021
|
+
|
|
2022
|
+
if (!org) {
|
|
2023
|
+
return yield* Effect.fail(
|
|
2024
|
+
new OrganizationNotFoundError({ orgId })
|
|
2025
|
+
);
|
|
2026
|
+
}
|
|
2027
|
+
|
|
2028
|
+
return org;
|
|
2029
|
+
}),
|
|
2030
|
+
};
|
|
2031
|
+
}),
|
|
2032
|
+
}
|
|
2033
|
+
) {}
|
|
2034
|
+
```
|
|
2035
|
+
|
|
2036
|
+
### Provider Errors
|
|
2037
|
+
|
|
2038
|
+
```typescript
|
|
2039
|
+
// /frontend/src/lib/providers/errors.ts
|
|
2040
|
+
export class ProviderError extends Error {
|
|
2041
|
+
constructor(
|
|
2042
|
+
public message: string,
|
|
2043
|
+
public code: string,
|
|
2044
|
+
public provider: string,
|
|
2045
|
+
public retryable: boolean = false,
|
|
2046
|
+
public details?: any
|
|
2047
|
+
) {
|
|
2048
|
+
super(message);
|
|
2049
|
+
this.name = "ProviderError";
|
|
2050
|
+
}
|
|
2051
|
+
}
|
|
2052
|
+
|
|
2053
|
+
// ConvexProvider error handling
|
|
2054
|
+
export class ConvexProvider implements IDataProvider {
|
|
2055
|
+
organizations = {
|
|
2056
|
+
get: async (args) => {
|
|
2057
|
+
try {
|
|
2058
|
+
return await this.client.query(api.queries.organizations.get, args);
|
|
2059
|
+
} catch (error) {
|
|
2060
|
+
// Transform backend error to provider error
|
|
2061
|
+
if (error.message.includes("OrganizationNotFoundError")) {
|
|
2062
|
+
throw new ProviderError(
|
|
2063
|
+
`Organization not found: ${args.orgId}`,
|
|
2064
|
+
"ORGANIZATION_NOT_FOUND",
|
|
2065
|
+
"convex",
|
|
2066
|
+
false,
|
|
2067
|
+
{ orgId: args.orgId }
|
|
2068
|
+
);
|
|
2069
|
+
}
|
|
2070
|
+
|
|
2071
|
+
// Generic error
|
|
2072
|
+
throw new ProviderError(
|
|
2073
|
+
error.message,
|
|
2074
|
+
"UNKNOWN_ERROR",
|
|
2075
|
+
"convex",
|
|
2076
|
+
true
|
|
2077
|
+
);
|
|
2078
|
+
}
|
|
2079
|
+
},
|
|
2080
|
+
};
|
|
2081
|
+
}
|
|
2082
|
+
```
|
|
2083
|
+
|
|
2084
|
+
### Frontend Error Display
|
|
2085
|
+
|
|
2086
|
+
```typescript
|
|
2087
|
+
// /frontend/src/components/ErrorBoundary.tsx
|
|
2088
|
+
export function ErrorBoundary({ children }: { children: ReactNode }) {
|
|
2089
|
+
return (
|
|
2090
|
+
<ReactErrorBoundary
|
|
2091
|
+
fallbackRender={({ error, resetErrorBoundary }) => (
|
|
2092
|
+
<Alert variant="destructive">
|
|
2093
|
+
<AlertCircle className="h-4 w-4" />
|
|
2094
|
+
<AlertTitle>Error</AlertTitle>
|
|
2095
|
+
<AlertDescription>
|
|
2096
|
+
{error instanceof ProviderError ? (
|
|
2097
|
+
<>
|
|
2098
|
+
<p>{error.message}</p>
|
|
2099
|
+
<p className="text-xs text-muted-foreground mt-2">
|
|
2100
|
+
Provider: {error.provider} | Code: {error.code}
|
|
2101
|
+
</p>
|
|
2102
|
+
{error.retryable && (
|
|
2103
|
+
<Button onClick={resetErrorBoundary} className="mt-4">
|
|
2104
|
+
Retry
|
|
2105
|
+
</Button>
|
|
2106
|
+
)}
|
|
2107
|
+
</>
|
|
2108
|
+
) : (
|
|
2109
|
+
<p>{error.message}</p>
|
|
2110
|
+
)}
|
|
2111
|
+
</AlertDescription>
|
|
2112
|
+
</Alert>
|
|
2113
|
+
)}
|
|
2114
|
+
>
|
|
2115
|
+
{children}
|
|
2116
|
+
</ReactErrorBoundary>
|
|
2117
|
+
);
|
|
2118
|
+
}
|
|
2119
|
+
|
|
2120
|
+
// Usage in components
|
|
2121
|
+
export function OrganizationPage({ orgId }: { orgId: string }) {
|
|
2122
|
+
const provider = useDataProvider();
|
|
2123
|
+
const [org, setOrg] = useState<Organization | null>(null);
|
|
2124
|
+
const [error, setError] = useState<ProviderError | null>(null);
|
|
2125
|
+
const [loading, setLoading] = useState(true);
|
|
2126
|
+
|
|
2127
|
+
useEffect(() => {
|
|
2128
|
+
provider.organizations
|
|
2129
|
+
.get({ orgId })
|
|
2130
|
+
.then(setOrg)
|
|
2131
|
+
.catch((err) => {
|
|
2132
|
+
if (err instanceof ProviderError) {
|
|
2133
|
+
setError(err);
|
|
2134
|
+
} else {
|
|
2135
|
+
setError(
|
|
2136
|
+
new ProviderError(err.message, "UNKNOWN_ERROR", "unknown", false)
|
|
2137
|
+
);
|
|
2138
|
+
}
|
|
2139
|
+
})
|
|
2140
|
+
.finally(() => setLoading(false));
|
|
2141
|
+
}, [provider, orgId]);
|
|
2142
|
+
|
|
2143
|
+
if (loading) return <Skeleton />;
|
|
2144
|
+
if (error) return <ErrorDisplay error={error} />;
|
|
2145
|
+
if (!org) return <NotFound />;
|
|
2146
|
+
|
|
2147
|
+
return <OrganizationDetails org={org} />;
|
|
2148
|
+
}
|
|
2149
|
+
```
|
|
2150
|
+
|
|
2151
|
+
### Retry Strategies
|
|
2152
|
+
|
|
2153
|
+
```typescript
|
|
2154
|
+
// /frontend/src/lib/providers/retry.ts
|
|
2155
|
+
export async function withRetry<T>(
|
|
2156
|
+
fn: () => Promise<T>,
|
|
2157
|
+
options: {
|
|
2158
|
+
maxRetries?: number;
|
|
2159
|
+
backoff?: "exponential" | "linear";
|
|
2160
|
+
initialDelay?: number;
|
|
2161
|
+
} = {}
|
|
2162
|
+
): Promise<T> {
|
|
2163
|
+
const {
|
|
2164
|
+
maxRetries = 3,
|
|
2165
|
+
backoff = "exponential",
|
|
2166
|
+
initialDelay = 1000,
|
|
2167
|
+
} = options;
|
|
2168
|
+
|
|
2169
|
+
let lastError: Error;
|
|
2170
|
+
|
|
2171
|
+
for (let attempt = 0; attempt < maxRetries; attempt++) {
|
|
2172
|
+
try {
|
|
2173
|
+
return await fn();
|
|
2174
|
+
} catch (error) {
|
|
2175
|
+
lastError = error;
|
|
2176
|
+
|
|
2177
|
+
// Don't retry non-retryable errors
|
|
2178
|
+
if (error instanceof ProviderError && !error.retryable) {
|
|
2179
|
+
throw error;
|
|
2180
|
+
}
|
|
2181
|
+
|
|
2182
|
+
// Calculate delay
|
|
2183
|
+
const delay =
|
|
2184
|
+
backoff === "exponential"
|
|
2185
|
+
? initialDelay * Math.pow(2, attempt)
|
|
2186
|
+
: initialDelay * (attempt + 1);
|
|
2187
|
+
|
|
2188
|
+
// Wait before retry
|
|
2189
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
2190
|
+
}
|
|
2191
|
+
}
|
|
2192
|
+
|
|
2193
|
+
throw lastError;
|
|
2194
|
+
}
|
|
2195
|
+
|
|
2196
|
+
// Usage
|
|
2197
|
+
const org = await withRetry(() => provider.organizations.get({ orgId }), {
|
|
2198
|
+
maxRetries: 3,
|
|
2199
|
+
backoff: "exponential",
|
|
2200
|
+
});
|
|
2201
|
+
```
|
|
2202
|
+
|
|
2203
|
+
### Fallback Strategies
|
|
2204
|
+
|
|
2205
|
+
```typescript
|
|
2206
|
+
// /frontend/src/lib/providers/fallback.ts
|
|
2207
|
+
export class FallbackProvider implements IDataProvider {
|
|
2208
|
+
constructor(
|
|
2209
|
+
private primary: IDataProvider,
|
|
2210
|
+
private fallback: IDataProvider
|
|
2211
|
+
) {}
|
|
2212
|
+
|
|
2213
|
+
organizations = {
|
|
2214
|
+
get: async (args) => {
|
|
2215
|
+
try {
|
|
2216
|
+
return await this.primary.organizations.get(args);
|
|
2217
|
+
} catch (error) {
|
|
2218
|
+
console.warn("Primary provider failed, falling back", error);
|
|
2219
|
+
return await this.fallback.organizations.get(args);
|
|
2220
|
+
}
|
|
2221
|
+
},
|
|
2222
|
+
};
|
|
2223
|
+
}
|
|
2224
|
+
|
|
2225
|
+
// Configuration
|
|
2226
|
+
const provider = new FallbackProvider(
|
|
2227
|
+
new ConvexProvider(convexClient),
|
|
2228
|
+
new CachedProvider(localStorage) // Fallback to cache
|
|
2229
|
+
);
|
|
2230
|
+
```
|
|
2231
|
+
|
|
2232
|
+
**Validation:**
|
|
2233
|
+
|
|
2234
|
+
- ✅ Backend errors use tagged unions with `_tag`
|
|
2235
|
+
- ✅ Provider errors include retry flag
|
|
2236
|
+
- ✅ Frontend displays user-friendly messages
|
|
2237
|
+
- ✅ Retries with exponential backoff for transient failures
|
|
2238
|
+
- ✅ Fallback to cache for offline support
|
|
2239
|
+
|
|
2240
|
+
---
|
|
2241
|
+
|
|
2242
|
+
## 7. Deployment Coordination
|
|
2243
|
+
|
|
2244
|
+
### Deployment Architecture
|
|
2245
|
+
|
|
2246
|
+
```
|
|
2247
|
+
┌────────────────────────────────────────────────┐
|
|
2248
|
+
│ FRONTEND DEPLOYMENT │
|
|
2249
|
+
│ Platform: Cloudflare Pages │
|
|
2250
|
+
│ Runtime: Astro SSR + React 19 │
|
|
2251
|
+
│ CDN: Global edge network │
|
|
2252
|
+
└────────────────────────────────────────────────┘
|
|
2253
|
+
↓ API Calls
|
|
2254
|
+
┌────────────────────────────────────────────────┐
|
|
2255
|
+
│ BACKEND DEPLOYMENT │
|
|
2256
|
+
│ Platform: Convex Cloud │
|
|
2257
|
+
│ Region: Auto (global replication) │
|
|
2258
|
+
│ Database: Convex (real-time) │
|
|
2259
|
+
└────────────────────────────────────────────────┘
|
|
2260
|
+
```
|
|
2261
|
+
|
|
2262
|
+
### Deployment Strategy
|
|
2263
|
+
|
|
2264
|
+
#### Independent Deployments
|
|
2265
|
+
|
|
2266
|
+
**Backend (Convex):**
|
|
2267
|
+
|
|
2268
|
+
```bash
|
|
2269
|
+
# Deploy backend independently
|
|
2270
|
+
cd /backend
|
|
2271
|
+
npx convex deploy --prod
|
|
2272
|
+
|
|
2273
|
+
# Verify deployment
|
|
2274
|
+
npx convex status
|
|
2275
|
+
```
|
|
2276
|
+
|
|
2277
|
+
**Frontend (Cloudflare Pages):**
|
|
2278
|
+
|
|
2279
|
+
```bash
|
|
2280
|
+
# Deploy frontend independently
|
|
2281
|
+
cd /frontend
|
|
2282
|
+
bun run build
|
|
2283
|
+
wrangler pages deploy dist --project-name=one-platform
|
|
2284
|
+
```
|
|
2285
|
+
|
|
2286
|
+
**Validation:**
|
|
2287
|
+
|
|
2288
|
+
- ✅ Backend deployments independent of frontend
|
|
2289
|
+
- ✅ Frontend deployments independent of backend
|
|
2290
|
+
- ✅ No coordinated releases required
|
|
2291
|
+
|
|
2292
|
+
#### Zero-Downtime Migration
|
|
2293
|
+
|
|
2294
|
+
**Strategy:** Gradual rollout with feature flags
|
|
2295
|
+
|
|
2296
|
+
```typescript
|
|
2297
|
+
// /frontend/src/lib/providers/config.ts
|
|
2298
|
+
export interface ProviderConfig {
|
|
2299
|
+
default: "convex" | "supabase" | "composite";
|
|
2300
|
+
featureFlags: {
|
|
2301
|
+
useDataProvider: boolean; // Gradual rollout
|
|
2302
|
+
providers: {
|
|
2303
|
+
convex: boolean;
|
|
2304
|
+
supabase: boolean;
|
|
2305
|
+
wordpress: boolean;
|
|
2306
|
+
};
|
|
2307
|
+
};
|
|
2308
|
+
}
|
|
2309
|
+
|
|
2310
|
+
// Feature flag check
|
|
2311
|
+
export function shouldUseDataProvider(): boolean {
|
|
2312
|
+
// Check feature flag
|
|
2313
|
+
if (!providerConfig.featureFlags.useDataProvider) {
|
|
2314
|
+
return false; // Use old direct Convex
|
|
2315
|
+
}
|
|
2316
|
+
|
|
2317
|
+
// Check rollout percentage (from backend)
|
|
2318
|
+
const rolloutPercentage = getRolloutPercentage();
|
|
2319
|
+
const userHash = hashUserId(currentUserId);
|
|
2320
|
+
|
|
2321
|
+
return userHash % 100 < rolloutPercentage;
|
|
2322
|
+
}
|
|
2323
|
+
|
|
2324
|
+
// Component with feature flag
|
|
2325
|
+
export function OrganizationList() {
|
|
2326
|
+
if (shouldUseDataProvider()) {
|
|
2327
|
+
// New: Use DataProvider
|
|
2328
|
+
const provider = useDataProvider();
|
|
2329
|
+
const orgs = useRealtimeData(provider, { type: "organizations" });
|
|
2330
|
+
return <div>{orgs?.map(...)}</div>;
|
|
2331
|
+
} else {
|
|
2332
|
+
// Old: Direct Convex
|
|
2333
|
+
const orgs = useQuery(api.queries.organizations.list);
|
|
2334
|
+
return <div>{orgs?.map(...)}</div>;
|
|
2335
|
+
}
|
|
2336
|
+
}
|
|
2337
|
+
```
|
|
2338
|
+
|
|
2339
|
+
**Rollout Plan:**
|
|
2340
|
+
|
|
2341
|
+
1. **Week 1:** 0% (feature flag off, deploy code)
|
|
2342
|
+
2. **Week 2:** 5% (internal testing)
|
|
2343
|
+
3. **Week 3:** 10% (early adopters)
|
|
2344
|
+
4. **Week 4:** 25% (monitoring for issues)
|
|
2345
|
+
5. **Week 5:** 50% (half of users)
|
|
2346
|
+
6. **Week 6:** 75% (most users)
|
|
2347
|
+
7. **Week 7:** 100% (full rollout)
|
|
2348
|
+
|
|
2349
|
+
**Rollback Procedure:**
|
|
2350
|
+
|
|
2351
|
+
```bash
|
|
2352
|
+
# Instant rollback via feature flag
|
|
2353
|
+
# Set featureFlags.useDataProvider = false
|
|
2354
|
+
|
|
2355
|
+
# Or rollback deployment
|
|
2356
|
+
wrangler pages rollback one-platform
|
|
2357
|
+
```
|
|
2358
|
+
|
|
2359
|
+
#### Monitoring and Alerting
|
|
2360
|
+
|
|
2361
|
+
**Metrics to Track:**
|
|
2362
|
+
|
|
2363
|
+
```typescript
|
|
2364
|
+
// /frontend/src/lib/providers/monitoring.ts
|
|
2365
|
+
export class MonitoredProvider implements IDataProvider {
|
|
2366
|
+
constructor(private provider: IDataProvider) {}
|
|
2367
|
+
|
|
2368
|
+
organizations = {
|
|
2369
|
+
list: async (args) => {
|
|
2370
|
+
const start = Date.now();
|
|
2371
|
+
try {
|
|
2372
|
+
const result = await this.provider.organizations.list(args);
|
|
2373
|
+
|
|
2374
|
+
// Track success
|
|
2375
|
+
trackMetric({
|
|
2376
|
+
metric: "provider.organizations.list.success",
|
|
2377
|
+
duration: Date.now() - start,
|
|
2378
|
+
provider: this.provider.name,
|
|
2379
|
+
});
|
|
2380
|
+
|
|
2381
|
+
return result;
|
|
2382
|
+
} catch (error) {
|
|
2383
|
+
// Track failure
|
|
2384
|
+
trackMetric({
|
|
2385
|
+
metric: "provider.organizations.list.error",
|
|
2386
|
+
duration: Date.now() - start,
|
|
2387
|
+
provider: this.provider.name,
|
|
2388
|
+
error: error.message,
|
|
2389
|
+
});
|
|
2390
|
+
|
|
2391
|
+
throw error;
|
|
2392
|
+
}
|
|
2393
|
+
},
|
|
2394
|
+
};
|
|
2395
|
+
}
|
|
2396
|
+
```
|
|
2397
|
+
|
|
2398
|
+
**Alerts:**
|
|
2399
|
+
|
|
2400
|
+
```yaml
|
|
2401
|
+
# alerts.yaml
|
|
2402
|
+
alerts:
|
|
2403
|
+
- name: provider_error_rate_high
|
|
2404
|
+
condition: provider.*.error > 5%
|
|
2405
|
+
severity: critical
|
|
2406
|
+
notification: pagerduty
|
|
2407
|
+
|
|
2408
|
+
- name: provider_latency_high
|
|
2409
|
+
condition: provider.*.duration > 1000ms
|
|
2410
|
+
severity: warning
|
|
2411
|
+
notification: slack
|
|
2412
|
+
|
|
2413
|
+
- name: auth_failure_rate_high
|
|
2414
|
+
condition: auth.*.failure > 2%
|
|
2415
|
+
severity: critical
|
|
2416
|
+
notification: pagerduty
|
|
2417
|
+
```
|
|
2418
|
+
|
|
2419
|
+
**Validation:**
|
|
2420
|
+
|
|
2421
|
+
- ✅ Gradual rollout with feature flags
|
|
2422
|
+
- ✅ Instant rollback capability
|
|
2423
|
+
- ✅ Comprehensive monitoring
|
|
2424
|
+
- ✅ Automated alerts
|
|
2425
|
+
|
|
2426
|
+
---
|
|
2427
|
+
|
|
2428
|
+
## 8. Implementation Timeline
|
|
2429
|
+
|
|
2430
|
+
### Week 1: Interface Definition
|
|
2431
|
+
|
|
2432
|
+
**Deliverables:**
|
|
2433
|
+
|
|
2434
|
+
- ✅ `IDataProvider` interface complete
|
|
2435
|
+
- ✅ Type definitions for all 6 dimensions
|
|
2436
|
+
- ✅ Interface compiles successfully
|
|
2437
|
+
- ✅ Backend Specialist review complete
|
|
2438
|
+
|
|
2439
|
+
**Tests:**
|
|
2440
|
+
|
|
2441
|
+
- ✅ Interface type safety validated
|
|
2442
|
+
- ✅ All method signatures defined
|
|
2443
|
+
|
|
2444
|
+
**Coordination:** Backend Specialist + Integration Specialist
|
|
2445
|
+
|
|
2446
|
+
---
|
|
2447
|
+
|
|
2448
|
+
### Week 2: ConvexProvider
|
|
2449
|
+
|
|
2450
|
+
**Deliverables:**
|
|
2451
|
+
|
|
2452
|
+
- ✅ ConvexProvider implements IDataProvider
|
|
2453
|
+
- ✅ 100% backward compatibility maintained
|
|
2454
|
+
- ✅ All 6 dimensions operational
|
|
2455
|
+
- ✅ Real-time support working
|
|
2456
|
+
|
|
2457
|
+
**Tests:**
|
|
2458
|
+
|
|
2459
|
+
- ✅ Unit tests for all operations
|
|
2460
|
+
- ✅ Integration tests with backend
|
|
2461
|
+
- ✅ Auth tests pass (50+ test cases)
|
|
2462
|
+
|
|
2463
|
+
**Coordination:** Frontend Specialist + Backend Specialist + Quality Agent
|
|
2464
|
+
|
|
2465
|
+
---
|
|
2466
|
+
|
|
2467
|
+
### Week 3: Service Layer
|
|
2468
|
+
|
|
2469
|
+
**Deliverables:**
|
|
2470
|
+
|
|
2471
|
+
- ✅ Effect.ts services for all 6 dimensions
|
|
2472
|
+
- ✅ Pure business logic (no UI, no Convex-specific code)
|
|
2473
|
+
- ✅ Typed errors with `_tag` pattern
|
|
2474
|
+
- ✅ Dependency injection via Effect.Service
|
|
2475
|
+
|
|
2476
|
+
**Tests:**
|
|
2477
|
+
|
|
2478
|
+
- ✅ Unit tests with mocked dependencies
|
|
2479
|
+
- ✅ Error handling validated
|
|
2480
|
+
- ✅ 90%+ code coverage
|
|
2481
|
+
|
|
2482
|
+
**Coordination:** Backend Specialist + Integration Specialist + Quality Agent
|
|
2483
|
+
|
|
2484
|
+
---
|
|
2485
|
+
|
|
2486
|
+
### Week 4: Configuration
|
|
2487
|
+
|
|
2488
|
+
**Deliverables:**
|
|
2489
|
+
|
|
2490
|
+
- ✅ Provider configuration system
|
|
2491
|
+
- ✅ Provider factory
|
|
2492
|
+
- ✅ React Context for DataProvider
|
|
2493
|
+
- ✅ Feature flag system
|
|
2494
|
+
|
|
2495
|
+
**Tests:**
|
|
2496
|
+
|
|
2497
|
+
- ✅ Provider switching validated
|
|
2498
|
+
- ✅ Configuration loading tested
|
|
2499
|
+
- ✅ Feature flags working
|
|
2500
|
+
|
|
2501
|
+
**Coordination:** Frontend Specialist + Integration Specialist
|
|
2502
|
+
|
|
2503
|
+
---
|
|
2504
|
+
|
|
2505
|
+
### Weeks 5-6: Component Migration
|
|
2506
|
+
|
|
2507
|
+
**Week 5: Non-critical pages**
|
|
2508
|
+
|
|
2509
|
+
- ✅ `/about`, `/docs`, `/blog`
|
|
2510
|
+
- ✅ `/account/settings`
|
|
2511
|
+
- ✅ `/tokens/[id]`
|
|
2512
|
+
- ✅ Auth tests pass after each migration
|
|
2513
|
+
|
|
2514
|
+
**Week 6: Critical pages**
|
|
2515
|
+
|
|
2516
|
+
- ✅ `/dashboard`
|
|
2517
|
+
- ✅ `/account` (auth flows)
|
|
2518
|
+
- ✅ `/admin`
|
|
2519
|
+
- ✅ Auth tests pass after each migration
|
|
2520
|
+
|
|
2521
|
+
**Tests:**
|
|
2522
|
+
|
|
2523
|
+
- ✅ E2E tests for migrated pages
|
|
2524
|
+
- ✅ Auth tests pass (50+ test cases)
|
|
2525
|
+
- ✅ Performance tests (context < 1.5KB, latency < 100ms)
|
|
2526
|
+
|
|
2527
|
+
**Coordination:** Frontend Specialist + Integration Specialist + Quality Agent
|
|
2528
|
+
|
|
2529
|
+
---
|
|
2530
|
+
|
|
2531
|
+
### Week 7: Cleanup
|
|
2532
|
+
|
|
2533
|
+
**Deliverables:**
|
|
2534
|
+
|
|
2535
|
+
- ✅ Old dependencies removed
|
|
2536
|
+
- ✅ Direct Convex imports removed from components
|
|
2537
|
+
- ✅ Provider exports consolidated
|
|
2538
|
+
- ✅ Documentation updated
|
|
2539
|
+
|
|
2540
|
+
**Tests:**
|
|
2541
|
+
|
|
2542
|
+
- ✅ All tests pass (unit, integration, E2E, auth)
|
|
2543
|
+
- ✅ Build successful
|
|
2544
|
+
- ✅ No regressions
|
|
2545
|
+
|
|
2546
|
+
**Coordination:** Frontend Specialist + Quality Agent
|
|
2547
|
+
|
|
2548
|
+
---
|
|
2549
|
+
|
|
2550
|
+
### Week 8+: Alternative Providers
|
|
2551
|
+
|
|
2552
|
+
**SupabaseProvider:**
|
|
2553
|
+
|
|
2554
|
+
- ✅ Implements IDataProvider
|
|
2555
|
+
- ✅ All 6 dimensions operational
|
|
2556
|
+
- ✅ Real-time subscriptions working
|
|
2557
|
+
- ✅ Integration tests passing
|
|
2558
|
+
|
|
2559
|
+
**WordPressProvider:**
|
|
2560
|
+
|
|
2561
|
+
- ✅ Read-only blog posts
|
|
2562
|
+
- ✅ Polling fallback (no real-time)
|
|
2563
|
+
- ✅ Sync to Convex for search
|
|
2564
|
+
|
|
2565
|
+
**CompositeProvider:**
|
|
2566
|
+
|
|
2567
|
+
- ✅ Multi-backend federation
|
|
2568
|
+
- ✅ Transparent routing
|
|
2569
|
+
- ✅ Cross-backend queries
|
|
2570
|
+
- ✅ Event-driven sync
|
|
2571
|
+
|
|
2572
|
+
**Tests:**
|
|
2573
|
+
|
|
2574
|
+
- ✅ Provider-specific tests
|
|
2575
|
+
- ✅ Cross-provider integration tests
|
|
2576
|
+
- ✅ Performance benchmarks
|
|
2577
|
+
|
|
2578
|
+
**Coordination:** Integration Specialist + Backend Specialist + Quality Agent
|
|
2579
|
+
|
|
2580
|
+
---
|
|
2581
|
+
|
|
2582
|
+
## Summary
|
|
2583
|
+
|
|
2584
|
+
### Key Achievements
|
|
2585
|
+
|
|
2586
|
+
1. **Data Flow Orchestration:** All 6 dimensions respect ontology
|
|
2587
|
+
2. **Multi-Backend Federation:** Seamless integration across Convex, WordPress, Shopify, Notion
|
|
2588
|
+
3. **Real-Time Coordination:** Native WebSocket (Convex), PostgreSQL real-time (Supabase), polling fallback (WordPress/Notion)
|
|
2589
|
+
4. **Zero-Downtime Migration:** 7-phase gradual rollout with feature flags
|
|
2590
|
+
5. **Comprehensive Testing:** Unit, integration, E2E, performance, auth tests
|
|
2591
|
+
6. **Robust Error Handling:** Backend → Provider → Frontend with retries and fallbacks
|
|
2592
|
+
7. **Independent Deployments:** Frontend and backend deploy separately
|
|
2593
|
+
|
|
2594
|
+
### Validation Checklist
|
|
2595
|
+
|
|
2596
|
+
- ✅ All 6 dimensions mapped correctly
|
|
2597
|
+
- ✅ Multi-tenant isolation enforced
|
|
2598
|
+
- ✅ Authorization verified (role-based)
|
|
2599
|
+
- ✅ Status lifecycle enforced (draft → active → published → archived)
|
|
2600
|
+
- ✅ Real-time subscriptions working
|
|
2601
|
+
- ✅ Cross-backend connections maintained
|
|
2602
|
+
- ✅ Complete audit trail
|
|
2603
|
+
- ✅ Vector search operational
|
|
2604
|
+
- ✅ Auth tests pass (50+ test cases)
|
|
2605
|
+
- ✅ Performance within budget (context < 1.5KB, latency < 100ms)
|
|
2606
|
+
|
|
2607
|
+
### Next Steps
|
|
2608
|
+
|
|
2609
|
+
1. **Week 1:** Define IDataProvider interface
|
|
2610
|
+
2. **Week 2:** Implement ConvexProvider
|
|
2611
|
+
3. **Week 3:** Implement Effect.ts services
|
|
2612
|
+
4. **Week 4:** Add configuration system
|
|
2613
|
+
5. **Weeks 5-6:** Migrate components page-by-page
|
|
2614
|
+
6. **Week 7:** Cleanup old code
|
|
2615
|
+
7. **Week 8+:** Implement alternative providers
|
|
2616
|
+
|
|
2617
|
+
---
|
|
2618
|
+
|
|
2619
|
+
**Integration Specialist: Connect systems. Map protocols. Respect the ontology. Make integrations seamless.**
|
|
2620
|
+
|
|
2621
|
+
---
|
|
2622
|
+
|
|
2623
|
+
**End of Integration Orchestration Plan**
|