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,1983 @@
|
|
|
1
|
+
# Frontend-Backend Separation Plan
|
|
2
|
+
|
|
3
|
+
## Executive Summary
|
|
4
|
+
|
|
5
|
+
**Goal:** Transform the current tightly-coupled architecture into a fully headless, **backend-agnostic** architecture where:
|
|
6
|
+
|
|
7
|
+
- **Frontend:** Pure Astro/React UI with DataProvider interface (no backend dependency)
|
|
8
|
+
- **Backend:** ANY backend that implements the 6-dimension ontology (Convex, WordPress, Notion, Supabase, etc.)
|
|
9
|
+
- **Connection:** DataProvider interface - swap backends by changing ONE line
|
|
10
|
+
|
|
11
|
+
**Current State:**
|
|
12
|
+
|
|
13
|
+
- ✅ Frontend is **working** and connected to Convex backend
|
|
14
|
+
- ✅ Auth is functional with tests in `frontend/tests/auth/*`
|
|
15
|
+
- ✅ Direct Convex integration (using `useQuery`, `useMutation`, Convex hooks)
|
|
16
|
+
- ⚠️ Tightly coupled to Convex - can't swap to WordPress/Notion/Supabase
|
|
17
|
+
|
|
18
|
+
**Target State:**
|
|
19
|
+
|
|
20
|
+
- Frontend uses DataProvider interface
|
|
21
|
+
- Backend is pluggable - organizations can use Convex, their existing WordPress site, Notion databases, or any other backend
|
|
22
|
+
- Existing auth tests continue to pass
|
|
23
|
+
- All current functionality preserved while adding flexibility
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## Important Context
|
|
28
|
+
|
|
29
|
+
**This is NOT a bug fix - this is a strategic enhancement.**
|
|
30
|
+
|
|
31
|
+
✅ **Current System Works:**
|
|
32
|
+
|
|
33
|
+
- Frontend successfully talks to Convex backend
|
|
34
|
+
- Auth is functional with passing tests
|
|
35
|
+
- All features operational
|
|
36
|
+
- No critical issues requiring immediate changes
|
|
37
|
+
|
|
38
|
+
⚠️ **Why Separate Now:**
|
|
39
|
+
|
|
40
|
+
- Add backend flexibility (support WordPress, Notion, Shopify, etc.)
|
|
41
|
+
- Enable multi-backend federation (auth in Convex, blog in WordPress, products in Shopify)
|
|
42
|
+
- Allow organizations to use existing infrastructure
|
|
43
|
+
- Remove Convex lock-in
|
|
44
|
+
|
|
45
|
+
**Migration Approach:**
|
|
46
|
+
|
|
47
|
+
- Zero downtime - wrap existing working functionality
|
|
48
|
+
- Preserve all existing tests (especially auth tests)
|
|
49
|
+
- Gradual page-by-page migration
|
|
50
|
+
- Can rollback at any phase
|
|
51
|
+
- No data migration required
|
|
52
|
+
|
|
53
|
+
**Priority:** Medium (strategic, not urgent)
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## Table of Contents
|
|
58
|
+
|
|
59
|
+
1. [Architecture Comparison](#architecture-comparison)
|
|
60
|
+
2. [Backend Options](#backend-options)
|
|
61
|
+
3. [Benefits of Separation](#benefits-of-separation)
|
|
62
|
+
4. [Migration Strategy](#migration-strategy)
|
|
63
|
+
5. [Backend Implementations](#backend-implementations)
|
|
64
|
+
6. [Testing Strategy](#testing-strategy)
|
|
65
|
+
7. [Deployment](#deployment)
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## Architecture Comparison
|
|
70
|
+
|
|
71
|
+
### Current Architecture (Working, but Coupled)
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
┌─────────────────────────────────────────────────────────┐
|
|
75
|
+
│ FRONTEND (Astro + React) │
|
|
76
|
+
│ ┌──────────────────────────────────────────────────┐ │
|
|
77
|
+
│ │ Pages & Components │ │
|
|
78
|
+
│ │ ├─ import { useQuery } from 'convex/react' │ │
|
|
79
|
+
│ │ ├─ import { api } from 'convex/_generated/api' │ │
|
|
80
|
+
│ │ └─ const data = useQuery(api.things.get) │ │
|
|
81
|
+
│ └──────────────────────────────────────────────────┘ │
|
|
82
|
+
│ │
|
|
83
|
+
│ frontend/convex/* (schema, mutations, queries) │
|
|
84
|
+
│ ↓ Direct WebSocket Connection (WORKING) │
|
|
85
|
+
│ │
|
|
86
|
+
│ frontend/tests/auth/* (Auth tests passing) │
|
|
87
|
+
└─────────────────────────────────────────────────────────┘
|
|
88
|
+
│
|
|
89
|
+
▼
|
|
90
|
+
┌───────────────────────┐
|
|
91
|
+
│ CONVEX BACKEND │
|
|
92
|
+
│ (Real-time DB) │
|
|
93
|
+
│ 6-Dimension Ontology │
|
|
94
|
+
└───────────────────────┘
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
**Status:** ✅ Working - Auth functional, tests passing
|
|
98
|
+
|
|
99
|
+
**Limitations (Not Bugs):**
|
|
100
|
+
|
|
101
|
+
- ⚠️ Frontend tightly coupled to Convex (works, but inflexible)
|
|
102
|
+
- ⚠️ Can't swap backend without rewriting frontend
|
|
103
|
+
- ⚠️ Organizations must use Convex (can't use existing WordPress/Notion)
|
|
104
|
+
- ⚠️ Hard to add mobile/desktop apps without Convex SDK
|
|
105
|
+
- ⚠️ No multi-backend support (can't federate data from Shopify/WordPress)
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
### Target Architecture (Backend-Agnostic with 6-Dimension Ontology)
|
|
110
|
+
|
|
111
|
+
```
|
|
112
|
+
┌──────────────────────────────────────────────────────────┐
|
|
113
|
+
│ FRONTEND (Backend-Agnostic) │
|
|
114
|
+
│ ┌────────────────────────────────────────────────────┐ │
|
|
115
|
+
│ │ Astro Pages + React Components │ │
|
|
116
|
+
│ │ - Renders UI from data │ │
|
|
117
|
+
│ │ - Calls DataProvider methods │ │
|
|
118
|
+
│ │ - NO backend-specific code │ │
|
|
119
|
+
│ └────────────────────────────────────────────────────┘ │
|
|
120
|
+
│ │
|
|
121
|
+
│ ┌────────────────────────────────────────────────────┐ │
|
|
122
|
+
│ │ Effect.ts Services (Backend-Agnostic) │ │
|
|
123
|
+
│ │ - ThingService │ │
|
|
124
|
+
│ │ - ConnectionService │ │
|
|
125
|
+
│ │ - Uses DataProvider interface │ │
|
|
126
|
+
│ └────────────────────────────────────────────────────┘ │
|
|
127
|
+
│ │
|
|
128
|
+
│ ┌────────────────────────────────────────────────────┐ │
|
|
129
|
+
│ │ DataProvider Interface (Universal API) │ │
|
|
130
|
+
│ │ organizations: { get, list, update } │ │
|
|
131
|
+
│ │ people: { get, list, create, update } │ │
|
|
132
|
+
│ │ things: { get, list, create, update, delete } │ │
|
|
133
|
+
│ │ connections: { create, getRelated, getCount } │ │
|
|
134
|
+
│ │ events: { log, query } │ │
|
|
135
|
+
│ │ knowledge: { embed, search } │ │
|
|
136
|
+
│ └────────────────────────────────────────────────────┘ │
|
|
137
|
+
└──────────────────────────────────────────────────────────┘
|
|
138
|
+
│
|
|
139
|
+
↓ Provider Implementation
|
|
140
|
+
┌──────────────────────────────────────────────────────────┐
|
|
141
|
+
│ BACKEND PROVIDERS (Choose One - ONE Line!) │
|
|
142
|
+
│ │
|
|
143
|
+
│ ┌─────────────────────────────────────────────┐ │
|
|
144
|
+
│ │ Option 1: ConvexProvider │ │
|
|
145
|
+
│ │ → Convex backend (real-time, serverless) │ │
|
|
146
|
+
│ └─────────────────────────────────────────────┘ │
|
|
147
|
+
│ │
|
|
148
|
+
│ ┌─────────────────────────────────────────────┐ │
|
|
149
|
+
│ │ Option 2: WordPressProvider │ │
|
|
150
|
+
│ │ → WordPress + WooCommerce (existing CMS) │ │
|
|
151
|
+
│ └─────────────────────────────────────────────┘ │
|
|
152
|
+
│ │
|
|
153
|
+
│ ┌─────────────────────────────────────────────┐ │
|
|
154
|
+
│ │ Option 3: NotionProvider │ │
|
|
155
|
+
│ │ → Notion databases as backend │ │
|
|
156
|
+
│ └─────────────────────────────────────────────┘ │
|
|
157
|
+
│ │
|
|
158
|
+
│ ┌─────────────────────────────────────────────┐ │
|
|
159
|
+
│ │ Option 4: SupabaseProvider │ │
|
|
160
|
+
│ │ → PostgreSQL + real-time (pgvector) │ │
|
|
161
|
+
│ └─────────────────────────────────────────────┘ │
|
|
162
|
+
│ │
|
|
163
|
+
│ ┌─────────────────────────────────────────────┐ │
|
|
164
|
+
│ │ Option 5: CustomProvider │ │
|
|
165
|
+
│ │ → Your own API/database │ │
|
|
166
|
+
│ └─────────────────────────────────────────────┘ │
|
|
167
|
+
│ │
|
|
168
|
+
│ All implement the same DataProvider interface │
|
|
169
|
+
└──────────────────────────────────────────────────────────┘
|
|
170
|
+
│
|
|
171
|
+
↓ Backend-Specific Implementation
|
|
172
|
+
┌──────────────────────────────────────────────────────────┐
|
|
173
|
+
│ ACTUAL BACKENDS (Examples) │
|
|
174
|
+
│ │
|
|
175
|
+
│ Convex: │
|
|
176
|
+
│ 6 tables → organizations, people, things, │
|
|
177
|
+
│ connections, events, knowledge │
|
|
178
|
+
│ │
|
|
179
|
+
│ WordPress: │
|
|
180
|
+
│ wp_posts, wp_users, wp_postmeta, wp_terms, etc. │
|
|
181
|
+
│ │
|
|
182
|
+
│ Notion: │
|
|
183
|
+
│ Databases, Pages, Relations │
|
|
184
|
+
│ │
|
|
185
|
+
│ Supabase: │
|
|
186
|
+
│ PostgreSQL tables with pgvector for knowledge │
|
|
187
|
+
│ │
|
|
188
|
+
│ Custom: │
|
|
189
|
+
│ Your own database schema │
|
|
190
|
+
└──────────────────────────────────────────────────────────┘
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
**Benefits:**
|
|
194
|
+
|
|
195
|
+
- ✅ **Backend-Agnostic:** Change backend by editing ONE line in config
|
|
196
|
+
- ✅ **Multi-Backend Support:** Organizations can use existing infrastructure (WordPress, Notion, etc.)
|
|
197
|
+
- ✅ **No Lock-In:** Not tied to Convex, any backend works
|
|
198
|
+
- ✅ **Progressive Migration:** Keep existing WordPress site, add ONE frontend gradually
|
|
199
|
+
- ✅ **Frontend Independence:** Rebuild UI without touching backend
|
|
200
|
+
- ✅ **6-Dimension Ontology:** Universal data model works with any backend
|
|
201
|
+
- ✅ **Effect.ts Services:** Type-safe, composable, testable operations
|
|
202
|
+
- ✅ **Multi-Platform:** Same backend serves web, mobile, desktop, CLI
|
|
203
|
+
- ✅ **Developer Choice:** Use the best backend for your organization's needs
|
|
204
|
+
|
|
205
|
+
---
|
|
206
|
+
|
|
207
|
+
## Understanding the 6-Dimension Ontology
|
|
208
|
+
|
|
209
|
+
**The ONE ontology models reality in six core dimensions:**
|
|
210
|
+
|
|
211
|
+
```
|
|
212
|
+
┌──────────────────────────────────────────────────────┐
|
|
213
|
+
│ 1. ORGANIZATIONS → Who owns this space? │
|
|
214
|
+
│ Multi-tenant isolation, perfect data boundaries │
|
|
215
|
+
└──────────────────────────────────────────────────────┘
|
|
216
|
+
↓
|
|
217
|
+
┌──────────────────────────────────────────────────────┐
|
|
218
|
+
│ 2. PEOPLE → Who can do what? │
|
|
219
|
+
│ Authorization, governance, human intent │
|
|
220
|
+
└──────────────────────────────────────────────────────┘
|
|
221
|
+
↓
|
|
222
|
+
┌──────────────────────────────────────────────────────┐
|
|
223
|
+
│ 3. THINGS → What exists? │
|
|
224
|
+
│ Domain entities (66 types) │
|
|
225
|
+
└──────────────────────────────────────────────────────┘
|
|
226
|
+
↓
|
|
227
|
+
┌──────────────────────────────────────────────────────┐
|
|
228
|
+
│ 4. CONNECTIONS → How do things relate? │
|
|
229
|
+
│ Relationships (25 types) │
|
|
230
|
+
└──────────────────────────────────────────────────────┘
|
|
231
|
+
↓
|
|
232
|
+
┌──────────────────────────────────────────────────────┐
|
|
233
|
+
│ 5. EVENTS → What happened? │
|
|
234
|
+
│ Audit trail, complete history (67 types) │
|
|
235
|
+
└──────────────────────────────────────────────────────┘
|
|
236
|
+
↓
|
|
237
|
+
┌──────────────────────────────────────────────────────┐
|
|
238
|
+
│ 6. KNOWLEDGE → What does it mean? │
|
|
239
|
+
│ AI intelligence, embeddings, RAG │
|
|
240
|
+
└──────────────────────────────────────────────────────┘
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
**Key Principle:** Every feature maps to these 6 dimensions. If you can't map it, you're thinking about it wrong.
|
|
244
|
+
|
|
245
|
+
### Example: User Creates a Course
|
|
246
|
+
|
|
247
|
+
**Organizations (Dimension 1):**
|
|
248
|
+
|
|
249
|
+
```typescript
|
|
250
|
+
organizationId: "fitnesspro_123"; // All operations scoped here
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
**People (Dimension 2):**
|
|
254
|
+
|
|
255
|
+
```typescript
|
|
256
|
+
// Separate people table (NOT things!)
|
|
257
|
+
{
|
|
258
|
+
_id: Id<'people'>,
|
|
259
|
+
email: "sarah@fitnesspro.com",
|
|
260
|
+
role: "org_owner", // Authorization level
|
|
261
|
+
organizationId: "fitnesspro_123"
|
|
262
|
+
}
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
**Things (Dimension 3):**
|
|
266
|
+
|
|
267
|
+
```typescript
|
|
268
|
+
// Course is a thing
|
|
269
|
+
{
|
|
270
|
+
_id: Id<'things'>,
|
|
271
|
+
thingType: "course",
|
|
272
|
+
name: "Fitness Fundamentals",
|
|
273
|
+
organizationId: "fitnesspro_123",
|
|
274
|
+
properties: {
|
|
275
|
+
description: "...",
|
|
276
|
+
price: 99,
|
|
277
|
+
duration: "8 weeks"
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
**Connections (Dimension 4):**
|
|
283
|
+
|
|
284
|
+
```typescript
|
|
285
|
+
// Sarah owns the course
|
|
286
|
+
{
|
|
287
|
+
_id: Id<'connections'>,
|
|
288
|
+
fromPersonId: sarah_person_id, // Person ID (Dimension 2)!
|
|
289
|
+
toThingId: course_thing_id, // Thing ID (Dimension 3)
|
|
290
|
+
relationshipType: "owns",
|
|
291
|
+
organizationId: "fitnesspro_123"
|
|
292
|
+
}
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
**Events (Dimension 5):**
|
|
296
|
+
|
|
297
|
+
```typescript
|
|
298
|
+
// Log the creation
|
|
299
|
+
{
|
|
300
|
+
_id: Id<'events'>,
|
|
301
|
+
eventType: "course_created",
|
|
302
|
+
actorId: sarah_person_id, // Person who did it (REQUIRED)
|
|
303
|
+
targetId: course_thing_id, // What was created
|
|
304
|
+
organizationId: "fitnesspro_123",
|
|
305
|
+
timestamp: Date.now()
|
|
306
|
+
}
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
**Knowledge (Dimension 6):**
|
|
310
|
+
|
|
311
|
+
```typescript
|
|
312
|
+
// Embed course content for AI
|
|
313
|
+
{
|
|
314
|
+
_id: Id<'knowledge'>,
|
|
315
|
+
knowledgeType: "document",
|
|
316
|
+
text: "Fitness Fundamentals...",
|
|
317
|
+
embedding: [...], // 768-dim vector
|
|
318
|
+
sourceThingId: course_thing_id,
|
|
319
|
+
organizationId: "fitnesspro_123",
|
|
320
|
+
labels: ["course", "fitness", "beginner"]
|
|
321
|
+
}
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
**Result:** One operation touches all 6 dimensions → complete context for AI agents.
|
|
325
|
+
|
|
326
|
+
---
|
|
327
|
+
|
|
328
|
+
## Effect.ts + DataProvider Pattern
|
|
329
|
+
|
|
330
|
+
**The separation uses Effect.ts for type-safety and DataProvider for backend-agnosticism.**
|
|
331
|
+
|
|
332
|
+
### DataProvider Interface (Backend-Agnostic)
|
|
333
|
+
|
|
334
|
+
```typescript
|
|
335
|
+
// frontend/src/providers/DataProvider.ts
|
|
336
|
+
import { Effect, Context } from "effect";
|
|
337
|
+
|
|
338
|
+
// Universal interface ALL backends implement
|
|
339
|
+
export interface DataProvider {
|
|
340
|
+
// Dimension 1: Organizations
|
|
341
|
+
organizations: {
|
|
342
|
+
get: (id: string) => Effect.Effect<Organization, OrganizationNotFoundError>;
|
|
343
|
+
list: (params?: {
|
|
344
|
+
status?: string;
|
|
345
|
+
}) => Effect.Effect<Organization[], Error>;
|
|
346
|
+
};
|
|
347
|
+
|
|
348
|
+
// Dimension 2: People (separate from things!)
|
|
349
|
+
people: {
|
|
350
|
+
get: (id: string) => Effect.Effect<Person, PersonNotFoundError>;
|
|
351
|
+
list: (params: {
|
|
352
|
+
organizationId?: string;
|
|
353
|
+
role?: string;
|
|
354
|
+
}) => Effect.Effect<Person[], Error>;
|
|
355
|
+
create: (input: {
|
|
356
|
+
email: string;
|
|
357
|
+
displayName: string;
|
|
358
|
+
role: string;
|
|
359
|
+
organizationId: string;
|
|
360
|
+
}) => Effect.Effect<string, Error>;
|
|
361
|
+
};
|
|
362
|
+
|
|
363
|
+
// Dimension 3: Things
|
|
364
|
+
things: {
|
|
365
|
+
get: (id: string) => Effect.Effect<Thing, ThingNotFoundError>;
|
|
366
|
+
list: (params: {
|
|
367
|
+
type: ThingType;
|
|
368
|
+
organizationId?: string;
|
|
369
|
+
}) => Effect.Effect<Thing[], Error>;
|
|
370
|
+
create: (input: {
|
|
371
|
+
type: ThingType;
|
|
372
|
+
name: string;
|
|
373
|
+
organizationId: string;
|
|
374
|
+
properties: any;
|
|
375
|
+
}) => Effect.Effect<string, Error>;
|
|
376
|
+
};
|
|
377
|
+
|
|
378
|
+
// Dimension 4: Connections
|
|
379
|
+
connections: {
|
|
380
|
+
create: (input: {
|
|
381
|
+
fromPersonId?: string; // Can connect people
|
|
382
|
+
fromThingId?: string; // OR things
|
|
383
|
+
toThingId: string;
|
|
384
|
+
relationshipType: ConnectionType;
|
|
385
|
+
organizationId: string;
|
|
386
|
+
metadata?: any;
|
|
387
|
+
}) => Effect.Effect<string, Error>;
|
|
388
|
+
};
|
|
389
|
+
|
|
390
|
+
// Dimension 5: Events
|
|
391
|
+
events: {
|
|
392
|
+
log: (event: {
|
|
393
|
+
type: EventType;
|
|
394
|
+
actorId: string; // Always a Person ID!
|
|
395
|
+
targetId?: string;
|
|
396
|
+
organizationId: string;
|
|
397
|
+
metadata?: any;
|
|
398
|
+
}) => Effect.Effect<void, Error>;
|
|
399
|
+
};
|
|
400
|
+
|
|
401
|
+
// Dimension 6: Knowledge
|
|
402
|
+
knowledge: {
|
|
403
|
+
search: (params: {
|
|
404
|
+
query: string;
|
|
405
|
+
organizationId: string;
|
|
406
|
+
k?: number;
|
|
407
|
+
}) => Effect.Effect<KnowledgeChunk[], Error>;
|
|
408
|
+
};
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
export const DataProvider = Context.GenericTag<DataProvider>("DataProvider");
|
|
412
|
+
```
|
|
413
|
+
|
|
414
|
+
### Effect.ts Service Example
|
|
415
|
+
|
|
416
|
+
```typescript
|
|
417
|
+
// backend/services/CourseService.ts
|
|
418
|
+
import { Effect } from "effect";
|
|
419
|
+
import { DataProvider } from "@/providers/DataProvider";
|
|
420
|
+
|
|
421
|
+
export class CourseService extends Effect.Service<CourseService>()(
|
|
422
|
+
"CourseService",
|
|
423
|
+
{
|
|
424
|
+
effect: Effect.gen(function* () {
|
|
425
|
+
const provider = yield* DataProvider;
|
|
426
|
+
|
|
427
|
+
return {
|
|
428
|
+
// Create course → touches all 6 dimensions
|
|
429
|
+
create: (params: {
|
|
430
|
+
name: string;
|
|
431
|
+
creatorId: string;
|
|
432
|
+
organizationId: string;
|
|
433
|
+
properties: any;
|
|
434
|
+
}) =>
|
|
435
|
+
Effect.gen(function* () {
|
|
436
|
+
// 3. Create thing (course)
|
|
437
|
+
const courseId = yield* provider.things.create({
|
|
438
|
+
type: "course",
|
|
439
|
+
name: params.name,
|
|
440
|
+
organizationId: params.organizationId,
|
|
441
|
+
properties: params.properties,
|
|
442
|
+
});
|
|
443
|
+
|
|
444
|
+
// 4. Create connection (person owns course)
|
|
445
|
+
yield* provider.connections.create({
|
|
446
|
+
fromPersonId: params.creatorId, // Person ID!
|
|
447
|
+
toThingId: courseId,
|
|
448
|
+
relationshipType: "owns",
|
|
449
|
+
organizationId: params.organizationId,
|
|
450
|
+
});
|
|
451
|
+
|
|
452
|
+
// 5. Log event (course created)
|
|
453
|
+
yield* provider.events.log({
|
|
454
|
+
type: "course_created",
|
|
455
|
+
actorId: params.creatorId, // Person who did it
|
|
456
|
+
targetId: courseId,
|
|
457
|
+
organizationId: params.organizationId,
|
|
458
|
+
metadata: {
|
|
459
|
+
courseName: params.name,
|
|
460
|
+
creatorEmail: "sarah@fitnesspro.com",
|
|
461
|
+
},
|
|
462
|
+
});
|
|
463
|
+
|
|
464
|
+
// 6. Embed for knowledge (AI can find it)
|
|
465
|
+
// (handled by background job)
|
|
466
|
+
|
|
467
|
+
return courseId;
|
|
468
|
+
}),
|
|
469
|
+
};
|
|
470
|
+
}),
|
|
471
|
+
dependencies: [DataProvider],
|
|
472
|
+
}
|
|
473
|
+
) {}
|
|
474
|
+
```
|
|
475
|
+
|
|
476
|
+
### Frontend Usage (Backend-Agnostic)
|
|
477
|
+
|
|
478
|
+
```tsx
|
|
479
|
+
// frontend/src/components/CreateCourse.tsx
|
|
480
|
+
import { useEffectRunner } from "@/hooks/useEffectRunner";
|
|
481
|
+
import { CourseService } from "@/services/CourseService";
|
|
482
|
+
import { Effect } from "effect";
|
|
483
|
+
|
|
484
|
+
export function CreateCourseForm() {
|
|
485
|
+
const { run, loading } = useEffectRunner();
|
|
486
|
+
|
|
487
|
+
const handleSubmit = async (formData: CourseFormData) => {
|
|
488
|
+
// Define Effect program using CourseService
|
|
489
|
+
const program = Effect.gen(function* () {
|
|
490
|
+
const courseService = yield* CourseService;
|
|
491
|
+
|
|
492
|
+
// Create course → touches all 6 dimensions automatically
|
|
493
|
+
const courseId = yield* courseService.create({
|
|
494
|
+
name: formData.name,
|
|
495
|
+
creatorId: currentUser.id,
|
|
496
|
+
organizationId: currentOrg.id,
|
|
497
|
+
properties: {
|
|
498
|
+
description: formData.description,
|
|
499
|
+
price: formData.price,
|
|
500
|
+
},
|
|
501
|
+
});
|
|
502
|
+
|
|
503
|
+
return courseId;
|
|
504
|
+
});
|
|
505
|
+
|
|
506
|
+
// Run program (frontend uses DataProvider)
|
|
507
|
+
const courseId = await run(program);
|
|
508
|
+
|
|
509
|
+
// Redirect to course page
|
|
510
|
+
navigate(`/courses/${courseId}`);
|
|
511
|
+
};
|
|
512
|
+
|
|
513
|
+
return <form onSubmit={handleSubmit}>...</form>;
|
|
514
|
+
}
|
|
515
|
+
```
|
|
516
|
+
|
|
517
|
+
### Backend Provider Implementations
|
|
518
|
+
|
|
519
|
+
**Convex Provider:**
|
|
520
|
+
|
|
521
|
+
```typescript
|
|
522
|
+
// frontend/src/providers/convex/ConvexProvider.ts
|
|
523
|
+
import { Effect, Layer } from "effect";
|
|
524
|
+
import { ConvexHttpClient } from "convex/browser";
|
|
525
|
+
import { DataProvider } from "../DataProvider";
|
|
526
|
+
|
|
527
|
+
export class ConvexProvider implements DataProvider {
|
|
528
|
+
constructor(private client: ConvexHttpClient) {}
|
|
529
|
+
|
|
530
|
+
things = {
|
|
531
|
+
create: (input) =>
|
|
532
|
+
Effect.tryPromise({
|
|
533
|
+
try: () => this.client.mutation(api.things.create, input),
|
|
534
|
+
catch: (error) => new Error(String(error)),
|
|
535
|
+
}),
|
|
536
|
+
};
|
|
537
|
+
|
|
538
|
+
people = {
|
|
539
|
+
create: (input) =>
|
|
540
|
+
Effect.tryPromise({
|
|
541
|
+
try: () => this.client.mutation(api.people.create, input),
|
|
542
|
+
catch: (error) => new Error(String(error)),
|
|
543
|
+
}),
|
|
544
|
+
};
|
|
545
|
+
|
|
546
|
+
// ... other dimensions
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
export const convexProvider = (config: { url: string }) =>
|
|
550
|
+
Layer.succeed(
|
|
551
|
+
DataProvider,
|
|
552
|
+
new ConvexProvider(new ConvexHttpClient(config.url))
|
|
553
|
+
);
|
|
554
|
+
```
|
|
555
|
+
|
|
556
|
+
**Composite Provider (Multi-Backend):**
|
|
557
|
+
|
|
558
|
+
```typescript
|
|
559
|
+
// frontend/src/providers/composite/CompositeProvider.ts
|
|
560
|
+
import { Effect, Layer } from "effect";
|
|
561
|
+
import { DataProvider } from "../DataProvider";
|
|
562
|
+
|
|
563
|
+
export class CompositeProvider implements DataProvider {
|
|
564
|
+
constructor(
|
|
565
|
+
private defaultProvider: DataProvider,
|
|
566
|
+
private routes: Map<ThingType, DataProvider>
|
|
567
|
+
) {}
|
|
568
|
+
|
|
569
|
+
// Route to appropriate provider based on thing type
|
|
570
|
+
private getProvider(type?: ThingType): DataProvider {
|
|
571
|
+
if (type && this.routes.has(type)) {
|
|
572
|
+
return this.routes.get(type)!;
|
|
573
|
+
}
|
|
574
|
+
return this.defaultProvider;
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
things = {
|
|
578
|
+
get: (id: string) =>
|
|
579
|
+
Effect.gen(function* () {
|
|
580
|
+
// Fetch thing to determine type
|
|
581
|
+
const thing = yield* this.defaultProvider.things.get(id);
|
|
582
|
+
|
|
583
|
+
// Route to appropriate provider
|
|
584
|
+
const provider = this.getProvider(thing.type);
|
|
585
|
+
if (provider !== this.defaultProvider) {
|
|
586
|
+
return yield* provider.things.get(id);
|
|
587
|
+
}
|
|
588
|
+
return thing;
|
|
589
|
+
}),
|
|
590
|
+
|
|
591
|
+
list: (params: { type: ThingType; organizationId?: string }) =>
|
|
592
|
+
Effect.gen(function* () {
|
|
593
|
+
// Route based on thing type
|
|
594
|
+
const provider = this.getProvider(params.type);
|
|
595
|
+
return yield* provider.things.list(params);
|
|
596
|
+
}),
|
|
597
|
+
|
|
598
|
+
create: (input: {
|
|
599
|
+
type: ThingType;
|
|
600
|
+
name: string;
|
|
601
|
+
organizationId: string;
|
|
602
|
+
properties: any;
|
|
603
|
+
}) =>
|
|
604
|
+
Effect.gen(function* () {
|
|
605
|
+
// Route based on thing type
|
|
606
|
+
const provider = this.getProvider(input.type);
|
|
607
|
+
return yield* provider.things.create(input);
|
|
608
|
+
}),
|
|
609
|
+
};
|
|
610
|
+
|
|
611
|
+
// Organizations, People, Events, Knowledge → always use default provider
|
|
612
|
+
organizations = this.defaultProvider.organizations;
|
|
613
|
+
people = this.defaultProvider.people;
|
|
614
|
+
connections = this.defaultProvider.connections;
|
|
615
|
+
events = this.defaultProvider.events;
|
|
616
|
+
knowledge = this.defaultProvider.knowledge;
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
export function compositeProvider(config: {
|
|
620
|
+
default: Layer<DataProvider>;
|
|
621
|
+
routes: Record<string, Layer<DataProvider> | "default">;
|
|
622
|
+
}) {
|
|
623
|
+
return Effect.gen(function* () {
|
|
624
|
+
// Resolve default provider
|
|
625
|
+
const defaultProvider = yield* Effect.provide(DataProvider, config.default);
|
|
626
|
+
|
|
627
|
+
// Resolve route providers
|
|
628
|
+
const routes = new Map<ThingType, DataProvider>();
|
|
629
|
+
for (const [type, providerConfig] of Object.entries(config.routes)) {
|
|
630
|
+
if (providerConfig === "default") {
|
|
631
|
+
routes.set(type as ThingType, defaultProvider);
|
|
632
|
+
} else {
|
|
633
|
+
const provider = yield* Effect.provide(DataProvider, providerConfig);
|
|
634
|
+
routes.set(type as ThingType, provider);
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
return new CompositeProvider(defaultProvider, routes);
|
|
639
|
+
}).pipe(Effect.map((provider) => Layer.succeed(DataProvider, provider)));
|
|
640
|
+
}
|
|
641
|
+
```
|
|
642
|
+
|
|
643
|
+
**Real-World Example:**
|
|
644
|
+
|
|
645
|
+
```typescript
|
|
646
|
+
// Auth & courses in Convex, blog in WordPress, products in Shopify
|
|
647
|
+
export default defineConfig({
|
|
648
|
+
integrations: [
|
|
649
|
+
one({
|
|
650
|
+
provider: compositeProvider({
|
|
651
|
+
default: convexProvider({ url: env.PUBLIC_CONVEX_URL }),
|
|
652
|
+
routes: {
|
|
653
|
+
blog_post: wordpressProvider({
|
|
654
|
+
url: "https://blog.yoursite.com",
|
|
655
|
+
apiKey: env.WP_API_KEY,
|
|
656
|
+
}),
|
|
657
|
+
product: shopifyProvider({
|
|
658
|
+
store: "yourstore.myshopify.com",
|
|
659
|
+
accessToken: env.SHOPIFY_ACCESS_TOKEN,
|
|
660
|
+
}),
|
|
661
|
+
},
|
|
662
|
+
}),
|
|
663
|
+
}),
|
|
664
|
+
],
|
|
665
|
+
});
|
|
666
|
+
```
|
|
667
|
+
|
|
668
|
+
**Benefits:**
|
|
669
|
+
|
|
670
|
+
- ✅ **Type-safe**: Compiler enforces all dimensions
|
|
671
|
+
- ✅ **Composable**: Services build on each other
|
|
672
|
+
- ✅ **Testable**: Mock layers, not databases
|
|
673
|
+
- ✅ **Backend-agnostic**: Change provider, not code
|
|
674
|
+
- ✅ **Multi-backend**: Use best backend for each data type
|
|
675
|
+
- ✅ **6-dimension aware**: Every operation properly scoped
|
|
676
|
+
|
|
677
|
+
---
|
|
678
|
+
|
|
679
|
+
## Backend Options
|
|
680
|
+
|
|
681
|
+
Once your frontend is backend-agnostic (using the DataProvider interface), you have **two paths**:
|
|
682
|
+
|
|
683
|
+
### Option 1: Self-Hosted Backend
|
|
684
|
+
|
|
685
|
+
**You own and operate the backend.**
|
|
686
|
+
|
|
687
|
+
```
|
|
688
|
+
Your Frontend → DataProvider → Your Backend Choice
|
|
689
|
+
├─ Convex (current)
|
|
690
|
+
├─ Supabase
|
|
691
|
+
├─ WordPress
|
|
692
|
+
├─ Notion
|
|
693
|
+
├─ Custom API
|
|
694
|
+
└─ Any backend
|
|
695
|
+
```
|
|
696
|
+
|
|
697
|
+
**When to choose:**
|
|
698
|
+
|
|
699
|
+
- ✅ Full control over data
|
|
700
|
+
- ✅ Custom backend logic
|
|
701
|
+
- ✅ Existing infrastructure (WordPress, Supabase, etc.)
|
|
702
|
+
- ✅ Enterprise security requirements
|
|
703
|
+
- ✅ No external dependencies
|
|
704
|
+
|
|
705
|
+
**What you maintain:**
|
|
706
|
+
|
|
707
|
+
- Backend infrastructure
|
|
708
|
+
- Database management
|
|
709
|
+
- Auth system setup
|
|
710
|
+
- API deployment
|
|
711
|
+
- Monitoring & scaling
|
|
712
|
+
|
|
713
|
+
### Option 2: Use ONE Backend (BaaS)
|
|
714
|
+
|
|
715
|
+
**ONE hosts and operates the backend for you.**
|
|
716
|
+
|
|
717
|
+
```
|
|
718
|
+
Your Frontend → DataProvider → ONE Backend (BaaS)
|
|
719
|
+
└─ https://api.one.ie
|
|
720
|
+
├─ Auth (6 methods)
|
|
721
|
+
├─ Database (6 dimensions)
|
|
722
|
+
├─ Real-time sync
|
|
723
|
+
├─ Multi-tenancy
|
|
724
|
+
└─ Free tier
|
|
725
|
+
```
|
|
726
|
+
|
|
727
|
+
**When to choose:**
|
|
728
|
+
|
|
729
|
+
- ✅ **Zero backend work** - focus on frontend only
|
|
730
|
+
- ✅ **Instant auth** - 6 methods (email, Google, GitHub, etc.)
|
|
731
|
+
- ✅ **Instant database** - 6-dimension ontology ready
|
|
732
|
+
- ✅ **Free tier** - Start with 10K API calls/month
|
|
733
|
+
- ✅ **Real-time included** - Convex-powered subscriptions
|
|
734
|
+
- ✅ **Fast MVP** - Ship in hours, not weeks
|
|
735
|
+
|
|
736
|
+
**Setup (3 steps):**
|
|
737
|
+
|
|
738
|
+
```bash
|
|
739
|
+
# 1. Sign up at one.ie → Get API key
|
|
740
|
+
# 2. Install SDK
|
|
741
|
+
npm install @oneie/sdk
|
|
742
|
+
|
|
743
|
+
# 3. Configure
|
|
744
|
+
USE_ONE_BACKEND=true
|
|
745
|
+
PUBLIC_ONE_API_KEY=ok_live_abc123
|
|
746
|
+
PUBLIC_ONE_ORG_ID=org_abc123
|
|
747
|
+
```
|
|
748
|
+
|
|
749
|
+
**Pricing:**
|
|
750
|
+
|
|
751
|
+
- **Starter:** Free (10K API calls/month, 100 users, 1K things)
|
|
752
|
+
- **Pro:** $29/month (100K calls, 1K users, 10K things)
|
|
753
|
+
- **Enterprise:** Custom (unlimited everything)
|
|
754
|
+
|
|
755
|
+
**No lock-in:** Switch between self-hosted and ONE Backend by changing ONE environment variable.
|
|
756
|
+
|
|
757
|
+
### Comparison
|
|
758
|
+
|
|
759
|
+
| Feature | Self-Hosted | ONE Backend (BaaS) |
|
|
760
|
+
| ------------------ | -------------- | ----------------------- |
|
|
761
|
+
| **Setup time** | Days-Weeks | Minutes |
|
|
762
|
+
| **Auth** | You build | Included (6 methods) |
|
|
763
|
+
| **Database** | You design | Included (6 dimensions) |
|
|
764
|
+
| **Real-time** | You configure | Included (Convex) |
|
|
765
|
+
| **Multi-tenancy** | You implement | Included |
|
|
766
|
+
| **Cost** | Infrastructure | Free tier / $29/mo |
|
|
767
|
+
| **Control** | Full | Managed service |
|
|
768
|
+
| **Data ownership** | You own | You own |
|
|
769
|
+
| **Migration** | N/A | Export anytime |
|
|
770
|
+
|
|
771
|
+
### Hybrid Approach
|
|
772
|
+
|
|
773
|
+
**Use both!** Self-host some backends, use ONE Backend for others:
|
|
774
|
+
|
|
775
|
+
```typescript
|
|
776
|
+
// astro.config.ts
|
|
777
|
+
provider: compositeProvider({
|
|
778
|
+
default: oneBackendProvider({
|
|
779
|
+
apiKey: env.PUBLIC_ONE_API_KEY, // ONE Backend for core data
|
|
780
|
+
}),
|
|
781
|
+
routes: {
|
|
782
|
+
// Blog from your WordPress
|
|
783
|
+
blog_post: wordpressProvider({ url: env.WP_URL }),
|
|
784
|
+
|
|
785
|
+
// Products from Shopify
|
|
786
|
+
product: shopifyProvider({ store: env.SHOPIFY_STORE }),
|
|
787
|
+
},
|
|
788
|
+
});
|
|
789
|
+
```
|
|
790
|
+
|
|
791
|
+
**Best of both worlds:**
|
|
792
|
+
|
|
793
|
+
- ✅ ONE Backend for auth, users, core features (managed)
|
|
794
|
+
- ✅ Self-hosted backends for specific data sources (control)
|
|
795
|
+
- ✅ Mix and match based on needs
|
|
796
|
+
|
|
797
|
+
---
|
|
798
|
+
|
|
799
|
+
## Benefits of Separation
|
|
800
|
+
|
|
801
|
+
### 1. Multi-Tenancy Support
|
|
802
|
+
|
|
803
|
+
**Before:**
|
|
804
|
+
|
|
805
|
+
```
|
|
806
|
+
Org A → Frontend A → Convex Deployment A
|
|
807
|
+
Org B → Frontend B → Convex Deployment B
|
|
808
|
+
Org C → Frontend C → Convex Deployment C
|
|
809
|
+
|
|
810
|
+
❌ 3 orgs = 3 Convex deployments (expensive, hard to manage)
|
|
811
|
+
```
|
|
812
|
+
|
|
813
|
+
**After:**
|
|
814
|
+
|
|
815
|
+
```
|
|
816
|
+
Org A → Frontend A ──┐
|
|
817
|
+
├→ Single Backend API → Single Convex Deployment
|
|
818
|
+
Org B → Frontend B ──┤ (with API key isolation)
|
|
819
|
+
│
|
|
820
|
+
Org C → Frontend C ──┘
|
|
821
|
+
|
|
822
|
+
✅ 3 orgs = 1 Convex deployment (cheap, centralized)
|
|
823
|
+
```
|
|
824
|
+
|
|
825
|
+
### 2. Backend Independence
|
|
826
|
+
|
|
827
|
+
**Before:**
|
|
828
|
+
|
|
829
|
+
- Frontend tightly coupled to Convex
|
|
830
|
+
- Can't switch to WordPress, Notion, Supabase, etc.
|
|
831
|
+
- Organizations must use Convex even if they have existing systems
|
|
832
|
+
- Must learn Convex SDK for every platform
|
|
833
|
+
|
|
834
|
+
❌ Locked into Convex
|
|
835
|
+
|
|
836
|
+
**After (Backend-Agnostic):**
|
|
837
|
+
|
|
838
|
+
- Frontend uses DataProvider interface
|
|
839
|
+
- Organizations can use:
|
|
840
|
+
- **Convex** (real-time, serverless)
|
|
841
|
+
- **WordPress** (existing CMS)
|
|
842
|
+
- **Notion** (databases as backend)
|
|
843
|
+
- **Supabase** (PostgreSQL + real-time)
|
|
844
|
+
- **Custom backend** (your own API)
|
|
845
|
+
- Change backend by editing ONE line in `astro.config.ts`
|
|
846
|
+
|
|
847
|
+
```typescript
|
|
848
|
+
// Swap backends - frontend code unchanged!
|
|
849
|
+
provider: convexProvider({ url: "..." });
|
|
850
|
+
// OR
|
|
851
|
+
provider: wordpressProvider({ url: "...", apiKey: "..." });
|
|
852
|
+
// OR
|
|
853
|
+
provider: notionProvider({ apiKey: "...", databaseId: "..." });
|
|
854
|
+
```
|
|
855
|
+
|
|
856
|
+
✅ Organizations use their existing infrastructure
|
|
857
|
+
|
|
858
|
+
### 3. Team Organization
|
|
859
|
+
|
|
860
|
+
**Before:**
|
|
861
|
+
|
|
862
|
+
```
|
|
863
|
+
Full-stack developer needs to know:
|
|
864
|
+
- Astro + React
|
|
865
|
+
- Convex-specific hooks and patterns
|
|
866
|
+
- Convex schema + queries/mutations/actions
|
|
867
|
+
- Effect.ts
|
|
868
|
+
- Business logic
|
|
869
|
+
```
|
|
870
|
+
|
|
871
|
+
**After (Backend-Agnostic):**
|
|
872
|
+
|
|
873
|
+
```
|
|
874
|
+
Frontend developer needs to know:
|
|
875
|
+
- Astro + React
|
|
876
|
+
- DataProvider interface (universal)
|
|
877
|
+
- Effect.ts services
|
|
878
|
+
|
|
879
|
+
Backend developer needs to know:
|
|
880
|
+
- Their chosen backend (WordPress, Convex, Notion, etc.)
|
|
881
|
+
- How to implement DataProvider for that backend
|
|
882
|
+
- 6-dimension ontology mapping
|
|
883
|
+
```
|
|
884
|
+
|
|
885
|
+
✅ Frontend devs don't learn backend-specific details
|
|
886
|
+
✅ Organizations can hire developers with their existing tech stack
|
|
887
|
+
✅ Clear separation of concerns
|
|
888
|
+
|
|
889
|
+
### 4. Progressive Migration & Flexibility
|
|
890
|
+
|
|
891
|
+
**Before:**
|
|
892
|
+
|
|
893
|
+
```
|
|
894
|
+
Organization has WordPress site with 10,000 posts
|
|
895
|
+
Want to use ONE frontend
|
|
896
|
+
Must migrate ALL data to Convex first
|
|
897
|
+
|
|
898
|
+
❌ Big-bang migration required
|
|
899
|
+
❌ Can't test gradually
|
|
900
|
+
❌ Risk losing SEO, existing integrations
|
|
901
|
+
```
|
|
902
|
+
|
|
903
|
+
**After (Backend-Agnostic):**
|
|
904
|
+
|
|
905
|
+
```
|
|
906
|
+
Organization keeps WordPress backend
|
|
907
|
+
Implements WordPressProvider (maps WP → 6-dimension ontology)
|
|
908
|
+
Deploys ONE frontend
|
|
909
|
+
Frontend talks to WordPress via DataProvider
|
|
910
|
+
|
|
911
|
+
✅ Zero data migration needed
|
|
912
|
+
✅ Keep existing WordPress admin, plugins, integrations
|
|
913
|
+
✅ Progressive: Start with one page, migrate gradually
|
|
914
|
+
✅ Test ONE frontend without touching backend
|
|
915
|
+
```
|
|
916
|
+
|
|
917
|
+
**Real-World Example:**
|
|
918
|
+
|
|
919
|
+
```typescript
|
|
920
|
+
// Week 1: Deploy ONE frontend with WordPress backend
|
|
921
|
+
provider: wordpressProvider({
|
|
922
|
+
url: "https://existing-site.com",
|
|
923
|
+
apiKey: env.WP_API_KEY,
|
|
924
|
+
});
|
|
925
|
+
|
|
926
|
+
// Week 50: Migrate to Convex when ready (ONE line change)
|
|
927
|
+
provider: convexProvider({
|
|
928
|
+
url: env.CONVEX_URL,
|
|
929
|
+
});
|
|
930
|
+
|
|
931
|
+
// Frontend code? UNCHANGED. No rewrite needed.
|
|
932
|
+
```
|
|
933
|
+
|
|
934
|
+
✅ Organizations control their migration timeline
|
|
935
|
+
✅ No forced backend choice
|
|
936
|
+
✅ Test frontend without backend risk
|
|
937
|
+
|
|
938
|
+
---
|
|
939
|
+
|
|
940
|
+
## Migration Strategy
|
|
941
|
+
|
|
942
|
+
### Phase 1: Create DataProvider Interface (Universal API)
|
|
943
|
+
|
|
944
|
+
**Goal:** Define the backend-agnostic interface that ALL providers must implement
|
|
945
|
+
|
|
946
|
+
**Tasks:**
|
|
947
|
+
|
|
948
|
+
1. Create `/frontend/src/providers/DataProvider.ts`
|
|
949
|
+
2. Define interfaces for 6 dimensions:
|
|
950
|
+
- `organizations: { get, list, update }`
|
|
951
|
+
- `people: { get, list, create, update, delete }`
|
|
952
|
+
- `things: { get, list, create, update, delete }`
|
|
953
|
+
- `connections: { create, getRelated, getCount, delete }`
|
|
954
|
+
- `events: { log, query }`
|
|
955
|
+
- `knowledge: { embed, search }`
|
|
956
|
+
3. Define error types (ThingNotFoundError, ConnectionCreateError, etc.)
|
|
957
|
+
4. Document interface with TypeScript types
|
|
958
|
+
|
|
959
|
+
**Timeline:** 2-3 days
|
|
960
|
+
|
|
961
|
+
**Risk:** None (just interface definition)
|
|
962
|
+
|
|
963
|
+
**Reference:** See `one/knowledge/ontology-frontend.md` for complete DataProvider interface
|
|
964
|
+
|
|
965
|
+
---
|
|
966
|
+
|
|
967
|
+
### Phase 2: Implement ConvexProvider (Wrap Existing Working Backend)
|
|
968
|
+
|
|
969
|
+
**Goal:** Wrap existing **working** Convex backend with DataProvider interface (NO functionality changes)
|
|
970
|
+
|
|
971
|
+
**Tasks:**
|
|
972
|
+
|
|
973
|
+
1. Create `/frontend/src/providers/convex/ConvexProvider.ts`
|
|
974
|
+
2. Implement DataProvider interface using Convex client:
|
|
975
|
+
```typescript
|
|
976
|
+
things.get(id) => client.query(api.queries.things.get, { id })
|
|
977
|
+
things.create(input) => client.mutation(api.mutations.things.create, input)
|
|
978
|
+
// etc. for all methods
|
|
979
|
+
```
|
|
980
|
+
3. Wrap Convex calls in Effect.ts for error handling
|
|
981
|
+
4. Create factory function: `convexProvider(config)`
|
|
982
|
+
5. Test provider in isolation
|
|
983
|
+
6. **Critical:** Run `frontend/tests/auth/*` - all tests must pass
|
|
984
|
+
|
|
985
|
+
**Timeline:** 3-5 days
|
|
986
|
+
|
|
987
|
+
**Risk:** Very Low (just wraps existing working Convex calls, no logic changes)
|
|
988
|
+
|
|
989
|
+
**Success Criteria:**
|
|
990
|
+
|
|
991
|
+
- ✅ ConvexProvider implements DataProvider interface fully
|
|
992
|
+
- ✅ All existing auth tests pass
|
|
993
|
+
- ✅ No functionality changes - just adds abstraction layer
|
|
994
|
+
|
|
995
|
+
---
|
|
996
|
+
|
|
997
|
+
### Phase 3: Create Effect.ts Service Layer
|
|
998
|
+
|
|
999
|
+
**Goal:** Build generic services that use DataProvider (backend-agnostic)
|
|
1000
|
+
|
|
1001
|
+
**Tasks:**
|
|
1002
|
+
|
|
1003
|
+
1. Create `/frontend/src/services/ThingService.ts` (generic, handles all 66 types)
|
|
1004
|
+
2. Create `/frontend/src/services/ConnectionService.ts`
|
|
1005
|
+
3. Create `/frontend/src/services/ClientLayer.ts` (dependency injection)
|
|
1006
|
+
4. Services delegate to DataProvider:
|
|
1007
|
+
```typescript
|
|
1008
|
+
export class ThingService extends Effect.Service<ThingService>()({
|
|
1009
|
+
effect: Effect.gen(function* () {
|
|
1010
|
+
const provider = yield* DataProvider // Backend-agnostic!
|
|
1011
|
+
return {
|
|
1012
|
+
get: (id: string) => provider.things.get(id),
|
|
1013
|
+
list: (type, orgId) => provider.things.list({ type, organizationId: orgId })
|
|
1014
|
+
}
|
|
1015
|
+
})
|
|
1016
|
+
})
|
|
1017
|
+
```
|
|
1018
|
+
5. Create `useEffectRunner` hook for React integration
|
|
1019
|
+
|
|
1020
|
+
**Timeline:** 3-5 days
|
|
1021
|
+
|
|
1022
|
+
**Risk:** Low (services just delegate to provider)
|
|
1023
|
+
|
|
1024
|
+
---
|
|
1025
|
+
|
|
1026
|
+
### Phase 4: Configure Provider in astro.config.ts
|
|
1027
|
+
|
|
1028
|
+
**Goal:** Wire up ConvexProvider as the active backend
|
|
1029
|
+
|
|
1030
|
+
**Tasks:**
|
|
1031
|
+
|
|
1032
|
+
1. Update `astro.config.ts`:
|
|
1033
|
+
|
|
1034
|
+
```typescript
|
|
1035
|
+
import { convexProvider } from "./src/providers/convex";
|
|
1036
|
+
|
|
1037
|
+
export default defineConfig({
|
|
1038
|
+
integrations: [
|
|
1039
|
+
react(),
|
|
1040
|
+
one({
|
|
1041
|
+
provider: convexProvider({
|
|
1042
|
+
url: import.meta.env.PUBLIC_CONVEX_URL,
|
|
1043
|
+
}),
|
|
1044
|
+
}),
|
|
1045
|
+
],
|
|
1046
|
+
});
|
|
1047
|
+
```
|
|
1048
|
+
|
|
1049
|
+
2. Test that services can access provider via Effect.ts layers
|
|
1050
|
+
|
|
1051
|
+
**Timeline:** 1 day
|
|
1052
|
+
|
|
1053
|
+
**Risk:** Low (configuration only)
|
|
1054
|
+
|
|
1055
|
+
---
|
|
1056
|
+
|
|
1057
|
+
### Phase 5: Migrate Frontend Components Gradually
|
|
1058
|
+
|
|
1059
|
+
**Goal:** Replace Convex hooks with Effect.ts services (page by page)
|
|
1060
|
+
|
|
1061
|
+
**Before:**
|
|
1062
|
+
|
|
1063
|
+
```tsx
|
|
1064
|
+
import { useQuery } from "convex/react";
|
|
1065
|
+
import { api } from "@/convex/_generated/api";
|
|
1066
|
+
|
|
1067
|
+
const courses = useQuery(api.queries.things.list, { type: "course" });
|
|
1068
|
+
```
|
|
1069
|
+
|
|
1070
|
+
**After:**
|
|
1071
|
+
|
|
1072
|
+
```tsx
|
|
1073
|
+
import { useEffectRunner } from "@/hooks/useEffectRunner";
|
|
1074
|
+
import { ThingService } from "@/services/ThingService";
|
|
1075
|
+
|
|
1076
|
+
const { run, loading } = useEffectRunner();
|
|
1077
|
+
const [courses, setCourses] = useState([]);
|
|
1078
|
+
|
|
1079
|
+
useEffect(() => {
|
|
1080
|
+
const program = Effect.gen(function* () {
|
|
1081
|
+
const thingService = yield* ThingService;
|
|
1082
|
+
return yield* thingService.list("course", orgId);
|
|
1083
|
+
});
|
|
1084
|
+
run(program, { onSuccess: setCourses });
|
|
1085
|
+
}, []);
|
|
1086
|
+
```
|
|
1087
|
+
|
|
1088
|
+
**Migration Order:**
|
|
1089
|
+
|
|
1090
|
+
1. Low-traffic pages first (`/about`, `/blog`)
|
|
1091
|
+
2. Medium-traffic pages (`/courses`, `/products`)
|
|
1092
|
+
3. High-traffic pages (`/`, `/dashboard`)
|
|
1093
|
+
4. Authentication pages last (highest risk)
|
|
1094
|
+
|
|
1095
|
+
**Critical - Auth Test Validation:**
|
|
1096
|
+
|
|
1097
|
+
```bash
|
|
1098
|
+
# After migrating ANY page that touches auth
|
|
1099
|
+
npm test frontend/tests/auth/
|
|
1100
|
+
|
|
1101
|
+
# If tests fail:
|
|
1102
|
+
# 1. STOP migration
|
|
1103
|
+
# 2. Debug the issue
|
|
1104
|
+
# 3. Fix before continuing
|
|
1105
|
+
# 4. Re-run tests until all pass
|
|
1106
|
+
```
|
|
1107
|
+
|
|
1108
|
+
**Timeline:** 2-4 weeks (gradual, page by page)
|
|
1109
|
+
|
|
1110
|
+
**Risk:** Medium (test each page thoroughly before deploying)
|
|
1111
|
+
|
|
1112
|
+
**Safety Net:** Existing auth tests catch regressions immediately
|
|
1113
|
+
|
|
1114
|
+
---
|
|
1115
|
+
|
|
1116
|
+
### Phase 6: Remove Convex Dependencies from Frontend
|
|
1117
|
+
|
|
1118
|
+
**Goal:** Clean up frontend - no more direct Convex imports
|
|
1119
|
+
|
|
1120
|
+
**Tasks:**
|
|
1121
|
+
|
|
1122
|
+
1. Verify all pages use Effect.ts services (no direct Convex hooks)
|
|
1123
|
+
2. Remove `convex` from `frontend/package.json`
|
|
1124
|
+
3. Delete `frontend/convex/` directory (no longer needed)
|
|
1125
|
+
4. Update build process (no Convex codegen)
|
|
1126
|
+
5. Frontend is now backend-agnostic!
|
|
1127
|
+
|
|
1128
|
+
**Timeline:** 1-2 days
|
|
1129
|
+
|
|
1130
|
+
**Risk:** Low (if Phase 5 complete)
|
|
1131
|
+
|
|
1132
|
+
---
|
|
1133
|
+
|
|
1134
|
+
### Phase 7 (Optional): Add Alternative Backend Providers
|
|
1135
|
+
|
|
1136
|
+
**Goal:** Demonstrate backend flexibility - add WordPress, Notion, Supabase providers
|
|
1137
|
+
|
|
1138
|
+
**Example - WordPress Provider:**
|
|
1139
|
+
|
|
1140
|
+
```typescript
|
|
1141
|
+
// /frontend/src/providers/wordpress/WordPressProvider.ts
|
|
1142
|
+
export class WordPressProvider implements DataProvider {
|
|
1143
|
+
things = {
|
|
1144
|
+
get: (id) =>
|
|
1145
|
+
Effect.gen(function* () {
|
|
1146
|
+
const response = yield* Effect.tryPromise({
|
|
1147
|
+
try: () => fetch(`${this.baseUrl}/wp-json/wp/v2/posts/${id}`),
|
|
1148
|
+
catch: (error) => new Error(String(error)),
|
|
1149
|
+
});
|
|
1150
|
+
const post = yield* Effect.tryPromise({
|
|
1151
|
+
try: () => response.json(),
|
|
1152
|
+
catch: (error) => new Error(String(error)),
|
|
1153
|
+
});
|
|
1154
|
+
// Transform WordPress post → ONE thing
|
|
1155
|
+
return {
|
|
1156
|
+
_id: post.id.toString(),
|
|
1157
|
+
type: "post",
|
|
1158
|
+
name: post.title.rendered,
|
|
1159
|
+
properties: {
|
|
1160
|
+
content: post.content.rendered,
|
|
1161
|
+
publishedAt: post.date,
|
|
1162
|
+
},
|
|
1163
|
+
status: post.status,
|
|
1164
|
+
createdAt: new Date(post.date).getTime(),
|
|
1165
|
+
updatedAt: new Date(post.modified).getTime(),
|
|
1166
|
+
};
|
|
1167
|
+
}),
|
|
1168
|
+
};
|
|
1169
|
+
// ... implement other methods
|
|
1170
|
+
}
|
|
1171
|
+
```
|
|
1172
|
+
|
|
1173
|
+
**Swap backends in config:**
|
|
1174
|
+
|
|
1175
|
+
```typescript
|
|
1176
|
+
// Change from Convex to WordPress - ONE line!
|
|
1177
|
+
export default defineConfig({
|
|
1178
|
+
integrations: [
|
|
1179
|
+
one({
|
|
1180
|
+
// provider: convexProvider({ url: "..." }) // OLD
|
|
1181
|
+
provider: wordpressProvider({
|
|
1182
|
+
// NEW
|
|
1183
|
+
url: "https://existing-site.com",
|
|
1184
|
+
apiKey: env.WP_API_KEY,
|
|
1185
|
+
}),
|
|
1186
|
+
}),
|
|
1187
|
+
],
|
|
1188
|
+
});
|
|
1189
|
+
```
|
|
1190
|
+
|
|
1191
|
+
**Timeline:** 1-2 weeks per provider
|
|
1192
|
+
|
|
1193
|
+
**Risk:** Low (doesn't affect existing Convex setup)
|
|
1194
|
+
|
|
1195
|
+
**Value:** Demonstrates TRUE backend-agnosticism
|
|
1196
|
+
|
|
1197
|
+
---
|
|
1198
|
+
|
|
1199
|
+
## Backend Implementations
|
|
1200
|
+
|
|
1201
|
+
Once you have the DataProvider interface, implementing it for ANY backend follows similar patterns.
|
|
1202
|
+
|
|
1203
|
+
### Implementation Patterns
|
|
1204
|
+
|
|
1205
|
+
**Pattern 1: REST API**
|
|
1206
|
+
|
|
1207
|
+
- Fetch-based requests
|
|
1208
|
+
- Transform responses to ONE types
|
|
1209
|
+
- Handle auth headers
|
|
1210
|
+
|
|
1211
|
+
**Pattern 2: GraphQL**
|
|
1212
|
+
|
|
1213
|
+
- Query/mutation-based
|
|
1214
|
+
- Parse GraphQL responses
|
|
1215
|
+
- Map to ONE ontology
|
|
1216
|
+
|
|
1217
|
+
**Pattern 3: Direct Database**
|
|
1218
|
+
|
|
1219
|
+
- SQL/NoSQL queries
|
|
1220
|
+
- Row/document mapping
|
|
1221
|
+
- Connection pooling
|
|
1222
|
+
|
|
1223
|
+
**Pattern 4: CMS API**
|
|
1224
|
+
|
|
1225
|
+
- Platform-specific SDKs
|
|
1226
|
+
- Content type mapping
|
|
1227
|
+
- Read-only or full CRUD
|
|
1228
|
+
|
|
1229
|
+
### Supported Backends
|
|
1230
|
+
|
|
1231
|
+
**Databases:**
|
|
1232
|
+
|
|
1233
|
+
- ✅ Convex (current - real-time, serverless)
|
|
1234
|
+
- ✅ Supabase (PostgreSQL + real-time)
|
|
1235
|
+
- ✅ Neon (serverless Postgres)
|
|
1236
|
+
- ✅ PlanetScale (MySQL)
|
|
1237
|
+
- ✅ MongoDB
|
|
1238
|
+
- ✅ PostgreSQL
|
|
1239
|
+
- ✅ MySQL
|
|
1240
|
+
|
|
1241
|
+
**CMS Platforms:**
|
|
1242
|
+
|
|
1243
|
+
- ✅ WordPress + WooCommerce
|
|
1244
|
+
- ✅ Strapi
|
|
1245
|
+
- ✅ Contentful
|
|
1246
|
+
- ✅ Sanity
|
|
1247
|
+
- ✅ Ghost
|
|
1248
|
+
- ✅ Prismic
|
|
1249
|
+
|
|
1250
|
+
**SaaS/Headless:**
|
|
1251
|
+
|
|
1252
|
+
- ✅ Notion (databases as backend)
|
|
1253
|
+
- ✅ Airtable
|
|
1254
|
+
- ✅ Google Sheets
|
|
1255
|
+
- ✅ Salesforce
|
|
1256
|
+
- ✅ HubSpot
|
|
1257
|
+
- ✅ Shopify
|
|
1258
|
+
|
|
1259
|
+
**Custom:**
|
|
1260
|
+
|
|
1261
|
+
- ✅ Your own REST/GraphQL API
|
|
1262
|
+
- ✅ Legacy systems
|
|
1263
|
+
- ✅ Enterprise backends
|
|
1264
|
+
|
|
1265
|
+
### Quick Example: Supabase Provider
|
|
1266
|
+
|
|
1267
|
+
```typescript
|
|
1268
|
+
// frontend/src/providers/supabase/SupabaseProvider.ts
|
|
1269
|
+
import { createClient } from "@supabase/supabase-js";
|
|
1270
|
+
import { Effect } from "effect";
|
|
1271
|
+
import { DataProvider } from "../DataProvider";
|
|
1272
|
+
|
|
1273
|
+
export class SupabaseProvider implements DataProvider {
|
|
1274
|
+
private supabase;
|
|
1275
|
+
|
|
1276
|
+
constructor(url: string, anonKey: string) {
|
|
1277
|
+
this.supabase = createClient(url, anonKey);
|
|
1278
|
+
}
|
|
1279
|
+
|
|
1280
|
+
things = {
|
|
1281
|
+
get: (id: string) =>
|
|
1282
|
+
Effect.gen(this, function* () {
|
|
1283
|
+
const { data, error } = yield* Effect.tryPromise({
|
|
1284
|
+
try: () =>
|
|
1285
|
+
this.supabase.from("things").select("*").eq("id", id).single(),
|
|
1286
|
+
catch: (err) => new Error(String(err)),
|
|
1287
|
+
});
|
|
1288
|
+
|
|
1289
|
+
if (error) {
|
|
1290
|
+
return yield* Effect.fail(new ThingNotFoundError(id));
|
|
1291
|
+
}
|
|
1292
|
+
|
|
1293
|
+
// Transform Supabase row → ONE Thing
|
|
1294
|
+
return {
|
|
1295
|
+
_id: data.id,
|
|
1296
|
+
type: data.type,
|
|
1297
|
+
name: data.name,
|
|
1298
|
+
properties: data.properties,
|
|
1299
|
+
status: data.status,
|
|
1300
|
+
createdAt: new Date(data.created_at).getTime(),
|
|
1301
|
+
updatedAt: new Date(data.updated_at).getTime(),
|
|
1302
|
+
organizationId: data.organization_id,
|
|
1303
|
+
};
|
|
1304
|
+
}),
|
|
1305
|
+
|
|
1306
|
+
list: (params) =>
|
|
1307
|
+
Effect.gen(this, function* () {
|
|
1308
|
+
let query = this.supabase
|
|
1309
|
+
.from("things")
|
|
1310
|
+
.select("*")
|
|
1311
|
+
.eq("type", params.type);
|
|
1312
|
+
|
|
1313
|
+
if (params.organizationId) {
|
|
1314
|
+
query = query.eq("organization_id", params.organizationId);
|
|
1315
|
+
}
|
|
1316
|
+
|
|
1317
|
+
const { data, error } = yield* Effect.tryPromise({
|
|
1318
|
+
try: () => query.limit(params.limit || 10),
|
|
1319
|
+
catch: (err) => new Error(String(err)),
|
|
1320
|
+
});
|
|
1321
|
+
|
|
1322
|
+
if (error) {
|
|
1323
|
+
return yield* Effect.fail(new Error(error.message));
|
|
1324
|
+
}
|
|
1325
|
+
|
|
1326
|
+
return data.map((row) => ({
|
|
1327
|
+
_id: row.id,
|
|
1328
|
+
type: row.type,
|
|
1329
|
+
name: row.name,
|
|
1330
|
+
properties: row.properties,
|
|
1331
|
+
status: row.status,
|
|
1332
|
+
createdAt: new Date(row.created_at).getTime(),
|
|
1333
|
+
updatedAt: new Date(row.updated_at).getTime(),
|
|
1334
|
+
organizationId: row.organization_id,
|
|
1335
|
+
}));
|
|
1336
|
+
}),
|
|
1337
|
+
|
|
1338
|
+
create: (input) =>
|
|
1339
|
+
Effect.gen(this, function* () {
|
|
1340
|
+
const { data, error } = yield* Effect.tryPromise({
|
|
1341
|
+
try: () =>
|
|
1342
|
+
this.supabase
|
|
1343
|
+
.from("things")
|
|
1344
|
+
.insert({
|
|
1345
|
+
type: input.type,
|
|
1346
|
+
name: input.name,
|
|
1347
|
+
properties: input.properties,
|
|
1348
|
+
organization_id: input.organizationId,
|
|
1349
|
+
status: "active",
|
|
1350
|
+
created_at: new Date().toISOString(),
|
|
1351
|
+
updated_at: new Date().toISOString(),
|
|
1352
|
+
})
|
|
1353
|
+
.select()
|
|
1354
|
+
.single(),
|
|
1355
|
+
catch: (err) => new Error(String(err)),
|
|
1356
|
+
});
|
|
1357
|
+
|
|
1358
|
+
if (error) {
|
|
1359
|
+
return yield* Effect.fail(new Error(error.message));
|
|
1360
|
+
}
|
|
1361
|
+
|
|
1362
|
+
return data.id;
|
|
1363
|
+
}),
|
|
1364
|
+
|
|
1365
|
+
update: (id, updates) => {
|
|
1366
|
+
/* ... */
|
|
1367
|
+
},
|
|
1368
|
+
delete: (id) => {
|
|
1369
|
+
/* ... */
|
|
1370
|
+
},
|
|
1371
|
+
};
|
|
1372
|
+
|
|
1373
|
+
connections = {
|
|
1374
|
+
/* ... */
|
|
1375
|
+
};
|
|
1376
|
+
events = {
|
|
1377
|
+
/* ... */
|
|
1378
|
+
};
|
|
1379
|
+
knowledge = {
|
|
1380
|
+
/* ... */
|
|
1381
|
+
};
|
|
1382
|
+
|
|
1383
|
+
// ✅ Supabase supports real-time!
|
|
1384
|
+
subscriptions = {
|
|
1385
|
+
watchThing: (id: string) =>
|
|
1386
|
+
Effect.gen(this, function* () {
|
|
1387
|
+
const channel = this.supabase.channel(`thing:${id}`).on(
|
|
1388
|
+
"postgres_changes",
|
|
1389
|
+
{
|
|
1390
|
+
event: "*",
|
|
1391
|
+
schema: "public",
|
|
1392
|
+
table: "things",
|
|
1393
|
+
filter: `id=eq.${id}`,
|
|
1394
|
+
},
|
|
1395
|
+
(payload) => {
|
|
1396
|
+
// Emit updates via Observable
|
|
1397
|
+
}
|
|
1398
|
+
);
|
|
1399
|
+
|
|
1400
|
+
yield* Effect.tryPromise({
|
|
1401
|
+
try: () => channel.subscribe(),
|
|
1402
|
+
catch: (err) => new Error(String(err)),
|
|
1403
|
+
});
|
|
1404
|
+
|
|
1405
|
+
// Return observable
|
|
1406
|
+
}),
|
|
1407
|
+
};
|
|
1408
|
+
}
|
|
1409
|
+
|
|
1410
|
+
export function supabaseProvider(config: { url: string; anonKey: string }) {
|
|
1411
|
+
return Layer.succeed(
|
|
1412
|
+
DataProvider,
|
|
1413
|
+
new SupabaseProvider(config.url, config.anonKey)
|
|
1414
|
+
);
|
|
1415
|
+
}
|
|
1416
|
+
```
|
|
1417
|
+
|
|
1418
|
+
**Key Points:**
|
|
1419
|
+
|
|
1420
|
+
1. Implement `DataProvider` interface
|
|
1421
|
+
2. Transform backend data → ONE types (Thing, Connection, Event, Knowledge)
|
|
1422
|
+
3. Handle errors with Effect.ts
|
|
1423
|
+
4. Map backend fields → ONE ontology fields
|
|
1424
|
+
5. Done! Frontend works unchanged.
|
|
1425
|
+
|
|
1426
|
+
### Complete Implementation Guide
|
|
1427
|
+
|
|
1428
|
+
For detailed implementation examples of all supported backends:
|
|
1429
|
+
|
|
1430
|
+
- **Databases**: See `one/connections/any-backend.md` (sections: Supabase, Neon, PlanetScale, MongoDB)
|
|
1431
|
+
- **CMS**: See `one/connections/any-backend.md` (sections: WordPress, Strapi, Contentful)
|
|
1432
|
+
- **SaaS**: See `one/connections/any-backend.md` (sections: Notion, Airtable, Shopify)
|
|
1433
|
+
- **Custom**: See `one/connections/any-backend.md` (section: Custom Backends)
|
|
1434
|
+
|
|
1435
|
+
### Authentication by Backend
|
|
1436
|
+
|
|
1437
|
+
**Each backend handles auth differently:**
|
|
1438
|
+
|
|
1439
|
+
| Backend | Auth Method |
|
|
1440
|
+
| ---------------------- | ---------------------------------------- |
|
|
1441
|
+
| **Convex** | Better Auth sessions + JWT validation |
|
|
1442
|
+
| **Supabase** | Row Level Security (RLS) + Supabase Auth |
|
|
1443
|
+
| **WordPress** | Application Passwords or OAuth |
|
|
1444
|
+
| **Notion** | Integration tokens (server-side only) |
|
|
1445
|
+
| **ONE Backend (BaaS)** | API keys + Better Auth (6 methods) |
|
|
1446
|
+
| **Custom API** | Your auth system |
|
|
1447
|
+
|
|
1448
|
+
**Frontend:** Uses provider's auth configuration, not backend-specific code.
|
|
1449
|
+
|
|
1450
|
+
---
|
|
1451
|
+
|
|
1452
|
+
## Testing Strategy
|
|
1453
|
+
|
|
1454
|
+
### 0. Preserve Existing Auth Tests (Critical)
|
|
1455
|
+
|
|
1456
|
+
**REQUIREMENT:** All tests in `frontend/tests/auth/*` must continue to pass throughout migration.
|
|
1457
|
+
|
|
1458
|
+
**Strategy:**
|
|
1459
|
+
|
|
1460
|
+
```typescript
|
|
1461
|
+
// Run existing auth tests after each phase
|
|
1462
|
+
npm test frontend/tests/auth/
|
|
1463
|
+
|
|
1464
|
+
// Tests must pass:
|
|
1465
|
+
// ✅ Signup flow
|
|
1466
|
+
// ✅ Signin flow
|
|
1467
|
+
// ✅ Session management
|
|
1468
|
+
// ✅ Password reset
|
|
1469
|
+
// ✅ Email verification
|
|
1470
|
+
// ✅ Role-based authorization
|
|
1471
|
+
```
|
|
1472
|
+
|
|
1473
|
+
**Migration Safety:**
|
|
1474
|
+
|
|
1475
|
+
1. **Phase 2 (ConvexProvider):** Run auth tests - should pass unchanged
|
|
1476
|
+
2. **Phase 3 (Service Layer):** Run auth tests - should pass with new services
|
|
1477
|
+
3. **Phase 5 (Component Migration):** Run auth tests after each page migration
|
|
1478
|
+
4. **Phase 6 (Remove Convex):** Run auth tests - final verification
|
|
1479
|
+
|
|
1480
|
+
**If auth tests fail at any phase:** STOP, investigate, fix before continuing.
|
|
1481
|
+
|
|
1482
|
+
---
|
|
1483
|
+
|
|
1484
|
+
### Mock Provider for Testing
|
|
1485
|
+
|
|
1486
|
+
```typescript
|
|
1487
|
+
// backend/api/__tests__/tokens.test.ts
|
|
1488
|
+
import { describe, it, expect } from "vitest";
|
|
1489
|
+
import app from "../index";
|
|
1490
|
+
|
|
1491
|
+
describe("Tokens API", () => {
|
|
1492
|
+
it("should require API key", async () => {
|
|
1493
|
+
const res = await app.request("/api/v1/tokens/123");
|
|
1494
|
+
expect(res.status).toBe(401);
|
|
1495
|
+
});
|
|
1496
|
+
|
|
1497
|
+
it("should fetch token with valid key", async () => {
|
|
1498
|
+
const res = await app.request("/api/v1/tokens/123", {
|
|
1499
|
+
headers: {
|
|
1500
|
+
Authorization: `Bearer ${process.env.TEST_API_KEY}`,
|
|
1501
|
+
},
|
|
1502
|
+
});
|
|
1503
|
+
expect(res.status).toBe(200);
|
|
1504
|
+
});
|
|
1505
|
+
|
|
1506
|
+
it("should enforce org isolation", async () => {
|
|
1507
|
+
const res = await app.request("/api/v1/tokens/org-b-token", {
|
|
1508
|
+
headers: {
|
|
1509
|
+
Authorization: `Bearer ${process.env.ORG_A_API_KEY}`,
|
|
1510
|
+
},
|
|
1511
|
+
});
|
|
1512
|
+
expect(res.status).toBe(403);
|
|
1513
|
+
});
|
|
1514
|
+
});
|
|
1515
|
+
```
|
|
1516
|
+
|
|
1517
|
+
### 2. Frontend Integration Tests
|
|
1518
|
+
|
|
1519
|
+
```typescript
|
|
1520
|
+
// frontend/src/lib/api/__tests__/client.test.ts
|
|
1521
|
+
import { describe, it, expect, vi } from "vitest";
|
|
1522
|
+
import { ApiClient } from "../client";
|
|
1523
|
+
|
|
1524
|
+
describe("ApiClient", () => {
|
|
1525
|
+
it("should add Authorization header", async () => {
|
|
1526
|
+
const fetchMock = vi.fn().mockResolvedValue({
|
|
1527
|
+
ok: true,
|
|
1528
|
+
json: async () => ({ id: "123" }),
|
|
1529
|
+
});
|
|
1530
|
+
global.fetch = fetchMock;
|
|
1531
|
+
|
|
1532
|
+
const client = new ApiClient("sk_test_123");
|
|
1533
|
+
await client.tokens.get("123");
|
|
1534
|
+
|
|
1535
|
+
expect(fetchMock).toHaveBeenCalledWith(
|
|
1536
|
+
expect.any(String),
|
|
1537
|
+
expect.objectContaining({
|
|
1538
|
+
headers: expect.objectContaining({
|
|
1539
|
+
Authorization: "Bearer sk_test_123",
|
|
1540
|
+
}),
|
|
1541
|
+
})
|
|
1542
|
+
);
|
|
1543
|
+
});
|
|
1544
|
+
|
|
1545
|
+
it("should throw ApiError on failure", async () => {
|
|
1546
|
+
global.fetch = vi.fn().mockResolvedValue({
|
|
1547
|
+
ok: false,
|
|
1548
|
+
status: 404,
|
|
1549
|
+
json: async () => ({ error: "Not found" }),
|
|
1550
|
+
});
|
|
1551
|
+
|
|
1552
|
+
const client = new ApiClient("sk_test_123");
|
|
1553
|
+
await expect(client.tokens.get("999")).rejects.toThrow("Not found");
|
|
1554
|
+
});
|
|
1555
|
+
});
|
|
1556
|
+
```
|
|
1557
|
+
|
|
1558
|
+
---
|
|
1559
|
+
|
|
1560
|
+
## Deployment
|
|
1561
|
+
|
|
1562
|
+
### Option 1: Self-Hosted Backend
|
|
1563
|
+
|
|
1564
|
+
**Example: Deploy with Convex Provider**
|
|
1565
|
+
|
|
1566
|
+
```bash
|
|
1567
|
+
# 1. Deploy backend (Convex)
|
|
1568
|
+
cd backend
|
|
1569
|
+
convex deploy
|
|
1570
|
+
# Output: https://your-deployment.convex.cloud
|
|
1571
|
+
|
|
1572
|
+
# 2. Deploy frontend
|
|
1573
|
+
cd frontend
|
|
1574
|
+
# Set environment variables:
|
|
1575
|
+
# PUBLIC_CONVEX_URL=https://your-deployment.convex.cloud
|
|
1576
|
+
npm run build
|
|
1577
|
+
# Deploy to Vercel/Netlify/Cloudflare Pages
|
|
1578
|
+
```
|
|
1579
|
+
|
|
1580
|
+
**Example: Deploy with Supabase Provider**
|
|
1581
|
+
|
|
1582
|
+
```bash
|
|
1583
|
+
# 1. Setup Supabase (already deployed)
|
|
1584
|
+
# Get URL and anon key from Supabase dashboard
|
|
1585
|
+
|
|
1586
|
+
# 2. Deploy frontend
|
|
1587
|
+
cd frontend
|
|
1588
|
+
# Set environment variables:
|
|
1589
|
+
# PUBLIC_SUPABASE_URL=https://your-project.supabase.co
|
|
1590
|
+
# PUBLIC_SUPABASE_ANON_KEY=your-anon-key
|
|
1591
|
+
npm run build
|
|
1592
|
+
# Deploy to Vercel/Netlify/Cloudflare Pages
|
|
1593
|
+
```
|
|
1594
|
+
|
|
1595
|
+
### Option 2: Use ONE Backend (BaaS)
|
|
1596
|
+
|
|
1597
|
+
```bash
|
|
1598
|
+
# 1. Sign up at one.ie → Get API key
|
|
1599
|
+
|
|
1600
|
+
# 2. Deploy frontend
|
|
1601
|
+
cd frontend
|
|
1602
|
+
# Set environment variables:
|
|
1603
|
+
# USE_ONE_BACKEND=true
|
|
1604
|
+
# PUBLIC_ONE_API_KEY=ok_live_abc123
|
|
1605
|
+
# PUBLIC_ONE_ORG_ID=org_abc123
|
|
1606
|
+
npm run build
|
|
1607
|
+
# Deploy to Vercel/Netlify/Cloudflare Pages
|
|
1608
|
+
```
|
|
1609
|
+
|
|
1610
|
+
**Done!** Backend is managed by ONE, you only deploy frontend.
|
|
1611
|
+
|
|
1612
|
+
### Environment Variables by Provider
|
|
1613
|
+
|
|
1614
|
+
**Convex Provider:**
|
|
1615
|
+
|
|
1616
|
+
```env
|
|
1617
|
+
PUBLIC_CONVEX_URL=https://your-deployment.convex.cloud
|
|
1618
|
+
CONVEX_DEPLOYMENT=prod:your-deployment
|
|
1619
|
+
```
|
|
1620
|
+
|
|
1621
|
+
**Supabase Provider:**
|
|
1622
|
+
|
|
1623
|
+
```env
|
|
1624
|
+
PUBLIC_SUPABASE_URL=https://your-project.supabase.co
|
|
1625
|
+
PUBLIC_SUPABASE_ANON_KEY=your-anon-key
|
|
1626
|
+
```
|
|
1627
|
+
|
|
1628
|
+
**WordPress Provider:**
|
|
1629
|
+
|
|
1630
|
+
```env
|
|
1631
|
+
WORDPRESS_URL=https://yoursite.com
|
|
1632
|
+
WORDPRESS_API_KEY=your-app-password
|
|
1633
|
+
```
|
|
1634
|
+
|
|
1635
|
+
**ONE Backend (BaaS):**
|
|
1636
|
+
|
|
1637
|
+
```env
|
|
1638
|
+
USE_ONE_BACKEND=true
|
|
1639
|
+
PUBLIC_ONE_API_KEY=ok_live_abc123
|
|
1640
|
+
PUBLIC_ONE_ORG_ID=org_abc123
|
|
1641
|
+
```
|
|
1642
|
+
|
|
1643
|
+
---
|
|
1644
|
+
|
|
1645
|
+
## Summary
|
|
1646
|
+
|
|
1647
|
+
### What This Migration Achieves
|
|
1648
|
+
|
|
1649
|
+
**Before:**
|
|
1650
|
+
|
|
1651
|
+
- ❌ Frontend tightly coupled to Convex
|
|
1652
|
+
- ❌ Can't swap backends without rewriting code
|
|
1653
|
+
- ❌ Organizations must use Convex (no alternatives)
|
|
1654
|
+
- ❌ No multi-backend support
|
|
1655
|
+
|
|
1656
|
+
**After:**
|
|
1657
|
+
|
|
1658
|
+
- ✅ Frontend backend-agnostic (uses DataProvider)
|
|
1659
|
+
- ✅ Swap backends by changing ONE line
|
|
1660
|
+
- ✅ Support ANY backend (Convex, WordPress, Supabase, Notion, etc.)
|
|
1661
|
+
- ✅ Use multiple backends simultaneously
|
|
1662
|
+
- ✅ Option to use ONE Backend (BaaS) - zero backend work
|
|
1663
|
+
- ✅ All existing auth tests pass
|
|
1664
|
+
- ✅ Zero downtime migration
|
|
1665
|
+
- ✅ Can rollback at any phase
|
|
1666
|
+
|
|
1667
|
+
### Three Paths Forward
|
|
1668
|
+
|
|
1669
|
+
**Path 1: Keep Current Convex (No Migration)**
|
|
1670
|
+
|
|
1671
|
+
- Current system works
|
|
1672
|
+
- No changes needed
|
|
1673
|
+
- Wait for business justification
|
|
1674
|
+
|
|
1675
|
+
**Path 2: Migrate to Backend-Agnostic (Self-Hosted)**
|
|
1676
|
+
|
|
1677
|
+
- 4-6 weeks migration
|
|
1678
|
+
- Wrap Convex in DataProvider
|
|
1679
|
+
- Enable future backend swaps
|
|
1680
|
+
- Keep full control
|
|
1681
|
+
|
|
1682
|
+
**Path 3: Use ONE Backend (BaaS)**
|
|
1683
|
+
|
|
1684
|
+
- 1 hour setup
|
|
1685
|
+
- No backend to maintain
|
|
1686
|
+
- Free tier available
|
|
1687
|
+
- Focus on frontend only
|
|
1688
|
+
|
|
1689
|
+
### References
|
|
1690
|
+
|
|
1691
|
+
**Detailed Implementation Guides:**
|
|
1692
|
+
|
|
1693
|
+
- **Any Backend**: See `one/connections/any-backend.md`
|
|
1694
|
+
|
|
1695
|
+
- Databases: Convex, Supabase, Neon, PlanetScale, MongoDB, PostgreSQL
|
|
1696
|
+
- CMS: WordPress, Strapi, Contentful, Sanity, Ghost
|
|
1697
|
+
- SaaS: Notion, Airtable, Shopify, Salesforce
|
|
1698
|
+
- Custom: Your own REST/GraphQL API
|
|
1699
|
+
|
|
1700
|
+
- **ONE Backend (BaaS)**: See `one/features/use-one-backend.md`
|
|
1701
|
+
|
|
1702
|
+
- Setup & onboarding
|
|
1703
|
+
- API key management
|
|
1704
|
+
- Pricing tiers
|
|
1705
|
+
- Migration guide
|
|
1706
|
+
|
|
1707
|
+
- **6-Dimension Ontology**: See `one/knowledge/ontology.md`
|
|
1708
|
+
- Complete data model
|
|
1709
|
+
- All 66 thing types
|
|
1710
|
+
- All 25 connection types
|
|
1711
|
+
- All 67 event types
|
|
1712
|
+
|
|
1713
|
+
---
|
|
1714
|
+
|
|
1715
|
+
## Rollback Plan
|
|
1716
|
+
|
|
1717
|
+
**Key Safety:** We're wrapping a working system, so rollback just means removing the wrapper.
|
|
1718
|
+
|
|
1719
|
+
If migration encounters issues, rollback is straightforward:
|
|
1720
|
+
|
|
1721
|
+
**Option 1: Gradual Rollback (Keep Both)**
|
|
1722
|
+
|
|
1723
|
+
```typescript
|
|
1724
|
+
// Keep both Convex hooks and Effect.ts services temporarily
|
|
1725
|
+
// Migrate page by page, test thoroughly
|
|
1726
|
+
|
|
1727
|
+
// Old page (still works)
|
|
1728
|
+
const courses = useQuery(api.queries.things.list, { type: "course" });
|
|
1729
|
+
|
|
1730
|
+
// New page (backend-agnostic)
|
|
1731
|
+
const program = Effect.gen(function* () {
|
|
1732
|
+
const thingService = yield* ThingService;
|
|
1733
|
+
return yield* thingService.list("course", orgId);
|
|
1734
|
+
});
|
|
1735
|
+
```
|
|
1736
|
+
|
|
1737
|
+
**Option 2: Quick Rollback (Revert Provider)**
|
|
1738
|
+
|
|
1739
|
+
```typescript
|
|
1740
|
+
// Change provider back to direct Convex hooks if needed
|
|
1741
|
+
// In astro.config.ts:
|
|
1742
|
+
provider: convexProvider({ url: env.PUBLIC_CONVEX_URL }); // Keep this working
|
|
1743
|
+
|
|
1744
|
+
// Frontend components still work with ConvexProvider
|
|
1745
|
+
// Just wraps the same Convex queries/mutations
|
|
1746
|
+
```
|
|
1747
|
+
|
|
1748
|
+
**Key Safety:**
|
|
1749
|
+
|
|
1750
|
+
- ConvexProvider just wraps existing Convex backend
|
|
1751
|
+
- No data migration needed
|
|
1752
|
+
- No backend changes required
|
|
1753
|
+
- Worst case: remove DataProvider layer, use Convex directly again
|
|
1754
|
+
|
|
1755
|
+
---
|
|
1756
|
+
|
|
1757
|
+
## Success Metrics
|
|
1758
|
+
|
|
1759
|
+
**Critical Requirements (Must Pass):**
|
|
1760
|
+
|
|
1761
|
+
- [ ] All existing auth tests in `frontend/tests/auth/*` pass
|
|
1762
|
+
- [ ] Auth functionality unchanged (signup, signin, sessions, password reset, etc.)
|
|
1763
|
+
- [ ] No regressions in user-facing features
|
|
1764
|
+
- [ ] Zero downtime during migration
|
|
1765
|
+
|
|
1766
|
+
**Technical Goals:**
|
|
1767
|
+
|
|
1768
|
+
- [ ] Frontend uses DataProvider interface (backend-agnostic)
|
|
1769
|
+
- [ ] Can swap from Convex → WordPress by changing ONE line
|
|
1770
|
+
- [ ] Can swap from WordPress → Notion by changing ONE line
|
|
1771
|
+
- [ ] Effect.ts services handle all 66 thing types generically
|
|
1772
|
+
- [ ] No direct backend imports in frontend components
|
|
1773
|
+
- [ ] Full type safety maintained with Effect.ts
|
|
1774
|
+
|
|
1775
|
+
**Backend Flexibility:**
|
|
1776
|
+
|
|
1777
|
+
- [ ] ConvexProvider fully implements DataProvider interface
|
|
1778
|
+
- [ ] Organizations can choose their preferred backend
|
|
1779
|
+
- [ ] At least 2 provider implementations working (e.g., Convex + WordPress)
|
|
1780
|
+
- [ ] Multi-tenancy works across all providers
|
|
1781
|
+
- [ ] Authorization enforced by backend (not frontend)
|
|
1782
|
+
|
|
1783
|
+
**Developer Experience:**
|
|
1784
|
+
|
|
1785
|
+
- [ ] Frontend developers don't need backend-specific knowledge
|
|
1786
|
+
- [ ] Adding new provider takes 1-2 weeks (not months)
|
|
1787
|
+
- [ ] Frontend components work unchanged when backend swaps
|
|
1788
|
+
- [ ] Clear documentation for implementing new providers
|
|
1789
|
+
- [ ] Effect.ts patterns are consistent and learnable
|
|
1790
|
+
|
|
1791
|
+
---
|
|
1792
|
+
|
|
1793
|
+
## Timeline
|
|
1794
|
+
|
|
1795
|
+
**Total Duration:** 4-6 weeks (Backend-Agnostic Approach)
|
|
1796
|
+
|
|
1797
|
+
**Week 1:** Define DataProvider interface + Implement ConvexProvider wrapper
|
|
1798
|
+
**Week 2:** Create Effect.ts service layer + useEffectRunner hook
|
|
1799
|
+
**Week 3-4:** Migrate frontend components to use services (page by page)
|
|
1800
|
+
**Week 5:** Remove direct Convex imports + Test thoroughly
|
|
1801
|
+
**Week 6 (Optional):** Add alternative provider (WordPress, Notion, etc.) to prove flexibility
|
|
1802
|
+
|
|
1803
|
+
**Comparison to Old Plan:**
|
|
1804
|
+
|
|
1805
|
+
- ✅ Faster (4-6 weeks vs 6-8 weeks)
|
|
1806
|
+
- ✅ Less risky (no REST API to build)
|
|
1807
|
+
- ✅ More value (true backend flexibility, not just REST)
|
|
1808
|
+
- ✅ Organizations can use existing infrastructure immediately
|
|
1809
|
+
|
|
1810
|
+
---
|
|
1811
|
+
|
|
1812
|
+
## Next Steps
|
|
1813
|
+
|
|
1814
|
+
1. **Review this plan** with team - focus on DataProvider pattern benefits
|
|
1815
|
+
2. **Study references:**
|
|
1816
|
+
- Read `one/knowledge/ontology-frontend.md` (DataProvider architecture)
|
|
1817
|
+
- Review Astro's content layer pattern (inspiration for DataProvider)
|
|
1818
|
+
- Understand Effect.ts basics (type-safe composable services)
|
|
1819
|
+
3. **Begin Phase 1:** Create DataProvider interface
|
|
1820
|
+
- Define the 6-dimension interface
|
|
1821
|
+
- Document expected behavior for each method
|
|
1822
|
+
- Define error types (ThingNotFoundError, etc.)
|
|
1823
|
+
4. **Begin Phase 2:** Implement ConvexProvider
|
|
1824
|
+
- Wrap existing Convex queries/mutations
|
|
1825
|
+
- Test provider in isolation
|
|
1826
|
+
- Verify no functionality lost
|
|
1827
|
+
|
|
1828
|
+
---
|
|
1829
|
+
|
|
1830
|
+
## When to Implement This Plan
|
|
1831
|
+
|
|
1832
|
+
**DO migrate when:**
|
|
1833
|
+
|
|
1834
|
+
- ✅ You need to support organizations with existing WordPress/Notion/Supabase infrastructure
|
|
1835
|
+
- ✅ You want to enable multi-backend federation (e.g., auth in Convex + blog in WordPress)
|
|
1836
|
+
- ✅ You're building mobile/desktop apps and want backend flexibility
|
|
1837
|
+
- ✅ You want to reduce Convex lock-in for customer acquisition
|
|
1838
|
+
- ✅ You have 4-6 weeks for strategic enhancement work
|
|
1839
|
+
|
|
1840
|
+
**DON'T migrate yet if:**
|
|
1841
|
+
|
|
1842
|
+
- ❌ You need to ship urgent features (migration is strategic, not urgent)
|
|
1843
|
+
- ❌ Current Convex integration is causing actual problems (it's not - it works)
|
|
1844
|
+
- ❌ You have less than 4 weeks available (rushed migration = bugs)
|
|
1845
|
+
- ❌ Auth tests aren't stable yet (fix tests first, then migrate)
|
|
1846
|
+
|
|
1847
|
+
**Current Recommendation:** Keep existing Convex integration until you have:
|
|
1848
|
+
|
|
1849
|
+
1. A concrete customer requesting WordPress/Notion/Supabase support
|
|
1850
|
+
2. 4-6 weeks of uninterrupted development time
|
|
1851
|
+
3. All existing auth tests passing reliably
|
|
1852
|
+
4. Clear business value from backend flexibility
|
|
1853
|
+
|
|
1854
|
+
**The current system works. Don't fix what isn't broken unless the strategic value justifies the effort.**
|
|
1855
|
+
|
|
1856
|
+
---
|
|
1857
|
+
|
|
1858
|
+
## Questions to Resolve
|
|
1859
|
+
|
|
1860
|
+
1. **Real-Time Support:** Should DataProvider interface include `subscriptions` methods? (Optional - not all backends support it)
|
|
1861
|
+
2. **Provider Discovery:** Should providers register themselves, or explicit imports?
|
|
1862
|
+
3. **Error Handling:** Standardize error types across all providers, or allow provider-specific errors?
|
|
1863
|
+
4. **Provider Versioning:** How to handle breaking changes in provider implementations?
|
|
1864
|
+
5. **Performance:** Should DataProvider support caching/batching at interface level?
|
|
1865
|
+
|
|
1866
|
+
---
|
|
1867
|
+
|
|
1868
|
+
## Conclusion
|
|
1869
|
+
|
|
1870
|
+
### Starting Point: Working System
|
|
1871
|
+
|
|
1872
|
+
**What we have today:**
|
|
1873
|
+
|
|
1874
|
+
- ✅ Frontend connected to Convex backend (working)
|
|
1875
|
+
- ✅ Auth fully functional with passing tests
|
|
1876
|
+
- ✅ Real-time updates via Convex WebSockets
|
|
1877
|
+
- ✅ 6-dimension ontology implemented
|
|
1878
|
+
- ✅ All features operational
|
|
1879
|
+
|
|
1880
|
+
**This is a solid foundation.** We're not fixing broken code - we're adding strategic capabilities.
|
|
1881
|
+
|
|
1882
|
+
### The Transformation
|
|
1883
|
+
|
|
1884
|
+
This **backend-agnostic separation** transforms ONE from a tightly-coupled (but working) monolith into a truly flexible platform where:
|
|
1885
|
+
|
|
1886
|
+
### Key Wins
|
|
1887
|
+
|
|
1888
|
+
**🎯 For Organizations:**
|
|
1889
|
+
|
|
1890
|
+
- ✅ Use your existing infrastructure (WordPress, Notion, Supabase, etc.)
|
|
1891
|
+
- ✅ No forced migration to Convex
|
|
1892
|
+
- ✅ Keep your existing admin tools, plugins, workflows
|
|
1893
|
+
- ✅ Test ONE frontend without backend risk
|
|
1894
|
+
- ✅ Migrate backend later if/when you want
|
|
1895
|
+
|
|
1896
|
+
**🎯 For Developers:**
|
|
1897
|
+
|
|
1898
|
+
- ✅ Frontend devs learn DataProvider interface once, work with any backend
|
|
1899
|
+
- ✅ Backend devs can use their preferred stack
|
|
1900
|
+
- ✅ No vendor lock-in
|
|
1901
|
+
- ✅ Effect.ts provides type-safe, composable operations
|
|
1902
|
+
- ✅ Clear separation: frontend renders, backend manages data
|
|
1903
|
+
|
|
1904
|
+
**🎯 For ONE Platform:**
|
|
1905
|
+
|
|
1906
|
+
- ✅ Serve organizations with diverse infrastructure needs
|
|
1907
|
+
- ✅ Prove the 6-dimension ontology is universal (works with ANY backend)
|
|
1908
|
+
- ✅ Attract organizations who would never adopt Convex
|
|
1909
|
+
- ✅ Position as frontend layer, not full-stack lock-in
|
|
1910
|
+
|
|
1911
|
+
### The Breakthrough
|
|
1912
|
+
|
|
1913
|
+
**Universal data interface** that works with ANY backend:
|
|
1914
|
+
|
|
1915
|
+
```
|
|
1916
|
+
Your Frontend → DataProvider → Your Choice:
|
|
1917
|
+
├─ Self-Hosted (Convex, Supabase, WordPress, etc.)
|
|
1918
|
+
├─ ONE Backend (BaaS - managed service)
|
|
1919
|
+
└─ Hybrid (mix multiple backends)
|
|
1920
|
+
|
|
1921
|
+
✅ Change backends with ONE line
|
|
1922
|
+
✅ No rewrite needed
|
|
1923
|
+
✅ Organizations choose their infrastructure
|
|
1924
|
+
```
|
|
1925
|
+
|
|
1926
|
+
### Three Options
|
|
1927
|
+
|
|
1928
|
+
**Option 1: Keep Current Setup (Convex)**
|
|
1929
|
+
|
|
1930
|
+
- Works today
|
|
1931
|
+
- No changes needed
|
|
1932
|
+
- Revisit when business needs backend flexibility
|
|
1933
|
+
|
|
1934
|
+
**Option 2: Backend-Agnostic (Self-Hosted)**
|
|
1935
|
+
|
|
1936
|
+
- 4-6 weeks migration
|
|
1937
|
+
- Support ANY backend (Convex, WordPress, Supabase, Notion, etc.)
|
|
1938
|
+
- Full control, full flexibility
|
|
1939
|
+
|
|
1940
|
+
**Option 3: ONE Backend (BaaS)**
|
|
1941
|
+
|
|
1942
|
+
- 1 hour setup
|
|
1943
|
+
- Zero backend maintenance
|
|
1944
|
+
- Free tier available
|
|
1945
|
+
- Focus on frontend only
|
|
1946
|
+
|
|
1947
|
+
### Implementation Strategy
|
|
1948
|
+
|
|
1949
|
+
The key is **gradual migration** with **zero risk**:
|
|
1950
|
+
|
|
1951
|
+
1. **Week 1-2:** Create abstraction layer (DataProvider + ConvexProvider)
|
|
1952
|
+
2. **Week 3-4:** Migrate frontend page by page to use services
|
|
1953
|
+
3. **Week 5:** Remove direct backend imports
|
|
1954
|
+
4. **Week 6+:** Add alternative providers to prove flexibility
|
|
1955
|
+
|
|
1956
|
+
At every step, frontend still works. At every step, we can rollback. At every step, we add value.
|
|
1957
|
+
|
|
1958
|
+
### Resources
|
|
1959
|
+
|
|
1960
|
+
**Within This Document:**
|
|
1961
|
+
|
|
1962
|
+
- [Backend Options](#backend-options) - Self-hosted vs ONE Backend (BaaS) vs Hybrid
|
|
1963
|
+
- [Backend Implementations](#backend-implementations) - How to implement providers for ANY backend
|
|
1964
|
+
- [Migration Strategy](#migration-strategy) - 7-phase gradual migration plan
|
|
1965
|
+
- [Testing Strategy](#testing-strategy) - Preserve auth tests throughout migration
|
|
1966
|
+
|
|
1967
|
+
**External References:**
|
|
1968
|
+
|
|
1969
|
+
- **Any Backend Guide:** `one/connections/any-backend.md`
|
|
1970
|
+
- Complete implementation examples for 20+ backends
|
|
1971
|
+
- REST, GraphQL, SQL, CMS, SaaS patterns
|
|
1972
|
+
- **ONE Backend (BaaS):** `one/features/use-one-backend.md`
|
|
1973
|
+
- Managed backend service details
|
|
1974
|
+
- API key management, pricing, setup
|
|
1975
|
+
- **6-Dimension Ontology:** `one/knowledge/ontology.md`
|
|
1976
|
+
- Complete data model (66 thing types, 25 connection types, 67 event types)
|
|
1977
|
+
- **Frontend Architecture:** `one/knowledge/ontology-frontend.md`
|
|
1978
|
+
- DataProvider interface specification
|
|
1979
|
+
- Effect.ts patterns and examples
|
|
1980
|
+
|
|
1981
|
+
---
|
|
1982
|
+
|
|
1983
|
+
**ONE platform: Backend-agnostic by design. Your infrastructure, your choice.**
|