oneie 2.0.1 → 2.0.3
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 +534 -0
- package/README.md +61 -4
- 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/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/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/events.md +545 -0
- package/one/knowledge/ai-platform.md +305 -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/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 +2819 -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/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/organisation/one.md +599 -0
- package/one/organisation/organisation.md +438 -0
- package/one/organisation/revenue.md +673 -0
- package/one/organisation/strategy.md +869 -0
- package/one/organisation/vision.md +98 -0
- package/one/people/anthony-o-connell.md +440 -0
- package/one/people/people.md +567 -0
- package/one/repomix-output.md +92634 -0
- package/one/things/agentkit.md +349 -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-code.md +652 -0
- package/one/things/cli-compiler-code.md +652 -0
- package/one/things/cli.md +1045 -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/copilotkit.md +1559 -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-cli.md +1235 -0
- package/one/things/features/use-one-backend.md +1180 -0
- package/one/things/ideas/1-create-workflow.md +189 -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/app.md +761 -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/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/performace.md +90 -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/things.md +349 -0
- package/one/things/todo.md +1248 -0
- package/package.json +5 -2
|
@@ -0,0 +1,1492 @@
|
|
|
1
|
+
# ONE Ontology: Frontend Implementation Guide
|
|
2
|
+
|
|
3
|
+
**Building /frontend/* - The Rendering Layer**
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Executive Summary
|
|
8
|
+
|
|
9
|
+
The frontend is **purely a rendering and interaction layer**. It has ZERO business logic, ZERO database access, ZERO data validation. It only:
|
|
10
|
+
|
|
11
|
+
1. **Renders UI** from data
|
|
12
|
+
2. **Calls backend APIs** to get/modify data
|
|
13
|
+
3. **Manages local UI state** (loading, errors, forms)
|
|
14
|
+
4. **Displays real-time updates** via subscriptions
|
|
15
|
+
|
|
16
|
+
**Clear Separation:**
|
|
17
|
+
```
|
|
18
|
+
┌──────────────────────────────────────┐
|
|
19
|
+
│ FRONTEND (Astro + React) │
|
|
20
|
+
│ ✅ Renders HTML/React components │
|
|
21
|
+
│ ✅ Calls backend APIs │
|
|
22
|
+
│ ✅ Manages UI state only │
|
|
23
|
+
│ ✅ Displays data from backend │
|
|
24
|
+
│ ❌ NO database access │
|
|
25
|
+
│ ❌ NO business logic │
|
|
26
|
+
│ ❌ NO data validation │
|
|
27
|
+
│ ❌ NO event logging │
|
|
28
|
+
└──────────────┬───────────────────────┘
|
|
29
|
+
│ HTTP/WebSocket
|
|
30
|
+
│ ConvexHttpClient
|
|
31
|
+
↓
|
|
32
|
+
┌──────────────────────────────────────┐
|
|
33
|
+
│ BACKEND (Convex - Separate Repo) │
|
|
34
|
+
│ ✅ Database (things/connections) │
|
|
35
|
+
│ ✅ Business logic │
|
|
36
|
+
│ ✅ Data validation │
|
|
37
|
+
│ ✅ Event logging │
|
|
38
|
+
│ ✅ Queries & Mutations │
|
|
39
|
+
│ ✅ Real-time subscriptions │
|
|
40
|
+
└──────────────────────────────────────┘
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
**What Frontend Builds:**
|
|
44
|
+
- 66 thing types → 198 UI components (card, list, detail per type)
|
|
45
|
+
- 25 connection types → 75 relationship UIs
|
|
46
|
+
- Organizations → Multi-tenant websites at `{slug}.one.ie`
|
|
47
|
+
|
|
48
|
+
**Tech Stack:**
|
|
49
|
+
- **Astro** - SSR/SSG (pages, layouts)
|
|
50
|
+
- **React 19** - Interactive components
|
|
51
|
+
- **Effect.ts** - Type-safe, composable API calls (2 generic services handle all 66 types)
|
|
52
|
+
- **Tailwind + shadcn/ui** - Styling
|
|
53
|
+
- **TypeScript** - Type safety
|
|
54
|
+
- **Convex Client** - Backend connection (NOT Convex backend itself)
|
|
55
|
+
|
|
56
|
+
**Effect.ts Philosophy:**
|
|
57
|
+
- **2 generic services** (ThingClientService + ConnectionClientService) handle ALL 66 thing types
|
|
58
|
+
- **Specialized services are optional** - add only when you repeat patterns 3+ times
|
|
59
|
+
- Course is just a thing with `type: 'course'` - no special service needed
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## Table of Contents
|
|
64
|
+
|
|
65
|
+
1. [What Frontend IS and IS NOT](#what-frontend-is-and-is-not)
|
|
66
|
+
2. [Frontend File Structure](#frontend-file-structure)
|
|
67
|
+
3. [Ontology Config (Display Only)](#ontology-config-display-only)
|
|
68
|
+
4. [Connecting to Backend](#connecting-to-backend)
|
|
69
|
+
5. [Effect.ts Frontend Architecture](#effectts-frontend-architecture)
|
|
70
|
+
6. [Client-Side Services (Effect.ts)](#client-side-services-effectts)
|
|
71
|
+
7. [React Integration (useEffectRunner)](#react-integration-useeffectrunner)
|
|
72
|
+
8. [Component Patterns](#component-patterns)
|
|
73
|
+
9. [Page Patterns (SSR)](#page-patterns-ssr)
|
|
74
|
+
10. [Real-Time Components](#real-time-components)
|
|
75
|
+
11. [Forms (Calls Backend)](#forms-calls-backend)
|
|
76
|
+
12. [Multi-Tenant Routing](#multi-tenant-routing)
|
|
77
|
+
13. [Deployment](#deployment)
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## What Frontend IS and IS NOT
|
|
82
|
+
|
|
83
|
+
### ✅ Frontend IS Responsible For:
|
|
84
|
+
|
|
85
|
+
**1. Rendering**
|
|
86
|
+
```tsx
|
|
87
|
+
// Display data from backend
|
|
88
|
+
<h1>{course.name}</h1>
|
|
89
|
+
<p>{course.properties.description}</p>
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
**2. Calling Backend APIs**
|
|
93
|
+
```tsx
|
|
94
|
+
// Get data from backend
|
|
95
|
+
const courses = useQuery(api.queries.things.list, { type: 'course' })
|
|
96
|
+
|
|
97
|
+
// Send data to backend
|
|
98
|
+
const create = useMutation(api.mutations.things.create)
|
|
99
|
+
await create({ type: 'course', name: 'Fitness 101', properties: {...} })
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
**3. Managing UI State**
|
|
103
|
+
```tsx
|
|
104
|
+
const [loading, setLoading] = useState(false)
|
|
105
|
+
const [error, setError] = useState(null)
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
**4. User Interactions**
|
|
109
|
+
```tsx
|
|
110
|
+
<button onClick={handleClick}>Create Course</button>
|
|
111
|
+
<input onChange={handleChange} />
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
**5. Client-Side Routing**
|
|
115
|
+
```tsx
|
|
116
|
+
// Navigate between pages
|
|
117
|
+
<Link href="/courses">View Courses</Link>
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### ❌ Frontend IS NOT Responsible For:
|
|
121
|
+
|
|
122
|
+
**1. Database Operations**
|
|
123
|
+
```tsx
|
|
124
|
+
// ❌ NEVER do this in frontend
|
|
125
|
+
const courses = await db.query('things').filter(...).collect()
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
**2. Business Logic**
|
|
129
|
+
```tsx
|
|
130
|
+
// ❌ NEVER do this in frontend
|
|
131
|
+
if (user.tokens < course.price) {
|
|
132
|
+
// Calculate discount, check quotas, etc.
|
|
133
|
+
}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
**3. Data Validation**
|
|
137
|
+
```tsx
|
|
138
|
+
// ❌ NEVER trust frontend validation alone
|
|
139
|
+
if (formData.email.includes('@')) {
|
|
140
|
+
// Backend MUST validate, frontend only for UX
|
|
141
|
+
}
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
**4. Event Logging**
|
|
145
|
+
```tsx
|
|
146
|
+
// ❌ NEVER log events in frontend
|
|
147
|
+
await db.insert('events', { type: 'course_created', ... })
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
**5. Authorization**
|
|
151
|
+
```tsx
|
|
152
|
+
// ❌ NEVER check permissions in frontend alone
|
|
153
|
+
if (user.role === 'admin') {
|
|
154
|
+
// Backend MUST authorize, frontend only for UI hints
|
|
155
|
+
}
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
---
|
|
159
|
+
|
|
160
|
+
## Frontend File Structure
|
|
161
|
+
|
|
162
|
+
```
|
|
163
|
+
frontend/ # Frontend repo (separate from backend)
|
|
164
|
+
├── src/
|
|
165
|
+
│ ├── pages/ # Astro pages (SSR/SSG)
|
|
166
|
+
│ │ ├── index.astro # Homepage
|
|
167
|
+
│ │ ├── courses/
|
|
168
|
+
│ │ │ ├── index.astro # Course list (SSR)
|
|
169
|
+
│ │ │ └── [id].astro # Course detail (SSR)
|
|
170
|
+
│ │ └── [thingType]/ # Dynamic routes
|
|
171
|
+
│ │ ├── index.astro # Generic list page
|
|
172
|
+
│ │ └── [id].astro # Generic detail page
|
|
173
|
+
│ ├── components/ # React components
|
|
174
|
+
│ │ ├── cards/
|
|
175
|
+
│ │ │ └── ThingCard.tsx # Generic card (adapts to any type)
|
|
176
|
+
│ │ ├── lists/
|
|
177
|
+
│ │ │ └── ThingList.tsx # Generic list
|
|
178
|
+
│ │ ├── forms/
|
|
179
|
+
│ │ │ └── ThingForm.tsx # Generic form (calls backend)
|
|
180
|
+
│ │ └── ui/ # shadcn/ui components
|
|
181
|
+
│ ├── services/ # Effect.ts client services
|
|
182
|
+
│ │ ├── ConvexHttpClient.ts # Convex client wrapper (required)
|
|
183
|
+
│ │ ├── ThingClientService.ts # Thing operations (required)
|
|
184
|
+
│ │ ├── ConnectionClientService.ts # Connection operations (required)
|
|
185
|
+
│ │ ├── ClientLayer.ts # Dependency injection layer (required)
|
|
186
|
+
│ │ └── CourseClientService.ts # OPTIONAL: Course-specific convenience
|
|
187
|
+
│ ├── hooks/ # React hooks
|
|
188
|
+
│ │ └── useEffectRunner.ts # Run Effect programs in React
|
|
189
|
+
│ ├── layouts/
|
|
190
|
+
│ │ └── Layout.astro # Main layout
|
|
191
|
+
│ ├── ontology/ # Display config ONLY
|
|
192
|
+
│ │ ├── types.ts # Type definitions (synced from backend)
|
|
193
|
+
│ │ └── config.ts # UI display config (colors, icons, labels)
|
|
194
|
+
│ ├── lib/
|
|
195
|
+
│ │ └── convex.ts # Backend client setup
|
|
196
|
+
│ └── middleware.ts # Multi-tenant routing
|
|
197
|
+
├── .env
|
|
198
|
+
│ PUBLIC_CONVEX_URL=https://backend.convex.cloud # Backend URL
|
|
199
|
+
└── package.json
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
**Key Point:** Frontend has NO `convex/` directory. That's in the backend repo.
|
|
203
|
+
|
|
204
|
+
---
|
|
205
|
+
|
|
206
|
+
## Ontology Config (Display Only)
|
|
207
|
+
|
|
208
|
+
Frontend needs **display configuration** for UI rendering. NOT business logic.
|
|
209
|
+
|
|
210
|
+
```typescript
|
|
211
|
+
// frontend/src/ontology/config.ts
|
|
212
|
+
// THIS IS NOT BUSINESS LOGIC - JUST UI CONFIGURATION
|
|
213
|
+
|
|
214
|
+
export const thingConfigs = {
|
|
215
|
+
course: {
|
|
216
|
+
// Display names
|
|
217
|
+
displayName: 'Course',
|
|
218
|
+
displayNamePlural: 'Courses',
|
|
219
|
+
|
|
220
|
+
// UI presentation
|
|
221
|
+
icon: 'BookOpen', // Lucide icon name
|
|
222
|
+
color: 'green', // Tailwind color
|
|
223
|
+
|
|
224
|
+
// Which fields to show in UI
|
|
225
|
+
primaryField: 'title', // Main display field
|
|
226
|
+
secondaryField: 'description',
|
|
227
|
+
imageField: 'thumbnail',
|
|
228
|
+
|
|
229
|
+
// Form fields (for UI only, backend validates)
|
|
230
|
+
fields: {
|
|
231
|
+
title: {
|
|
232
|
+
label: 'Course Title',
|
|
233
|
+
type: 'text',
|
|
234
|
+
required: true,
|
|
235
|
+
placeholder: 'e.g., Fitness 101'
|
|
236
|
+
},
|
|
237
|
+
description: {
|
|
238
|
+
label: 'Description',
|
|
239
|
+
type: 'textarea',
|
|
240
|
+
required: true
|
|
241
|
+
},
|
|
242
|
+
price: {
|
|
243
|
+
label: 'Price (USD)',
|
|
244
|
+
type: 'number',
|
|
245
|
+
required: true
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
},
|
|
249
|
+
|
|
250
|
+
creator: {
|
|
251
|
+
displayName: 'Creator',
|
|
252
|
+
displayNamePlural: 'Creators',
|
|
253
|
+
icon: 'User',
|
|
254
|
+
color: 'blue',
|
|
255
|
+
primaryField: 'name',
|
|
256
|
+
secondaryField: 'bio',
|
|
257
|
+
imageField: 'avatar',
|
|
258
|
+
fields: {
|
|
259
|
+
name: { label: 'Name', type: 'text', required: true },
|
|
260
|
+
email: { label: 'Email', type: 'text', required: true },
|
|
261
|
+
bio: { label: 'Bio', type: 'textarea', required: false }
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// ... all 66 types (UI config only)
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// Helper function
|
|
269
|
+
export function getThingConfig(type: ThingType) {
|
|
270
|
+
return thingConfigs[type]
|
|
271
|
+
}
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
**What This Is:**
|
|
275
|
+
- ✅ UI labels and placeholders
|
|
276
|
+
- ✅ Icon and color choices
|
|
277
|
+
- ✅ Which fields to display
|
|
278
|
+
- ✅ Form field types
|
|
279
|
+
|
|
280
|
+
**What This Is NOT:**
|
|
281
|
+
- ❌ Business logic
|
|
282
|
+
- ❌ Validation rules (backend validates)
|
|
283
|
+
- ❌ Authorization rules (backend authorizes)
|
|
284
|
+
- ❌ Database schema (that's in backend)
|
|
285
|
+
|
|
286
|
+
---
|
|
287
|
+
|
|
288
|
+
## Connecting to Backend
|
|
289
|
+
|
|
290
|
+
### Setup Convex Client
|
|
291
|
+
|
|
292
|
+
```typescript
|
|
293
|
+
// frontend/src/lib/convex.ts
|
|
294
|
+
import { ConvexHttpClient } from 'convex/browser'
|
|
295
|
+
|
|
296
|
+
// Get backend URL from environment
|
|
297
|
+
const BACKEND_URL = import.meta.env.PUBLIC_CONVEX_URL
|
|
298
|
+
|
|
299
|
+
if (!BACKEND_URL) {
|
|
300
|
+
throw new Error('PUBLIC_CONVEX_URL not set')
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
// Create HTTP client for SSR
|
|
304
|
+
export function getConvexClient() {
|
|
305
|
+
return new ConvexHttpClient(BACKEND_URL)
|
|
306
|
+
}
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
### Setup React Provider
|
|
310
|
+
|
|
311
|
+
```astro
|
|
312
|
+
---
|
|
313
|
+
// frontend/src/layouts/Layout.astro
|
|
314
|
+
import { ConvexProvider, ConvexReactClient } from 'convex/react'
|
|
315
|
+
|
|
316
|
+
const convex = new ConvexReactClient(import.meta.env.PUBLIC_CONVEX_URL)
|
|
317
|
+
---
|
|
318
|
+
|
|
319
|
+
<html>
|
|
320
|
+
<head>
|
|
321
|
+
<title>{title}</title>
|
|
322
|
+
</head>
|
|
323
|
+
<body>
|
|
324
|
+
<ConvexProvider client={convex}>
|
|
325
|
+
<slot />
|
|
326
|
+
</ConvexProvider>
|
|
327
|
+
</body>
|
|
328
|
+
</html>
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
### Environment Variables
|
|
332
|
+
|
|
333
|
+
```bash
|
|
334
|
+
# frontend/.env
|
|
335
|
+
PUBLIC_CONVEX_URL=https://shocking-falcon-870.convex.cloud
|
|
336
|
+
|
|
337
|
+
# This points to BACKEND deployment
|
|
338
|
+
# Frontend has NO access to backend code, only HTTP/WebSocket API
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
---
|
|
342
|
+
|
|
343
|
+
## Effect.ts Frontend Architecture
|
|
344
|
+
|
|
345
|
+
**Effect.ts provides type-safe, composable patterns for frontend API calls.**
|
|
346
|
+
|
|
347
|
+
### Why Effect.ts in Frontend?
|
|
348
|
+
|
|
349
|
+
```typescript
|
|
350
|
+
// ❌ Traditional approach - untyped errors, hard to compose
|
|
351
|
+
async function getCourse(id: string) {
|
|
352
|
+
try {
|
|
353
|
+
const response = await fetch(`/api/courses/${id}`)
|
|
354
|
+
const course = await response.json()
|
|
355
|
+
return course
|
|
356
|
+
} catch (error) {
|
|
357
|
+
// What type of error? Network? 404? 500?
|
|
358
|
+
console.error(error)
|
|
359
|
+
throw error
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
// ✅ Effect.ts approach - typed errors, composable
|
|
364
|
+
import { Effect } from 'effect'
|
|
365
|
+
|
|
366
|
+
class CourseNotFoundError {
|
|
367
|
+
readonly _tag = 'CourseNotFoundError'
|
|
368
|
+
constructor(readonly courseId: string) {}
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
class NetworkError {
|
|
372
|
+
readonly _tag = 'NetworkError'
|
|
373
|
+
constructor(readonly message: string) {}
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
function getCourse(id: string) {
|
|
377
|
+
return Effect.gen(function* () {
|
|
378
|
+
const client = yield* ConvexHttpClient
|
|
379
|
+
|
|
380
|
+
const course = yield* client.query(api.queries.things.get, { id })
|
|
381
|
+
.pipe(
|
|
382
|
+
Effect.catchTag('NetworkError', err =>
|
|
383
|
+
Effect.fail(new NetworkError(err.message))
|
|
384
|
+
)
|
|
385
|
+
)
|
|
386
|
+
|
|
387
|
+
if (!course) {
|
|
388
|
+
return yield* Effect.fail(new CourseNotFoundError(id))
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
return course
|
|
392
|
+
})
|
|
393
|
+
}
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
### Frontend Effect.ts Stack
|
|
397
|
+
|
|
398
|
+
```
|
|
399
|
+
┌────────────────────────────────────────────┐
|
|
400
|
+
│ React Components │
|
|
401
|
+
│ - useEffectRunner hook │
|
|
402
|
+
│ - Render UI from Effect results │
|
|
403
|
+
│ - Handle typed errors │
|
|
404
|
+
└────────────────┬───────────────────────────┘
|
|
405
|
+
│ Effect.runPromise
|
|
406
|
+
↓
|
|
407
|
+
┌────────────────────────────────────────────┐
|
|
408
|
+
│ Client Services (Effect.ts) │
|
|
409
|
+
│ - CourseClientService │
|
|
410
|
+
│ - UserClientService │
|
|
411
|
+
│ - TokenClientService │
|
|
412
|
+
│ - Composable, testable │
|
|
413
|
+
└────────────────┬───────────────────────────┘
|
|
414
|
+
│ ConvexHttpClient
|
|
415
|
+
↓
|
|
416
|
+
┌────────────────────────────────────────────┐
|
|
417
|
+
│ Backend API (Convex) │
|
|
418
|
+
│ - Queries & Mutations │
|
|
419
|
+
│ - Business logic │
|
|
420
|
+
│ - Database operations │
|
|
421
|
+
└────────────────────────────────────────────┘
|
|
422
|
+
```
|
|
423
|
+
|
|
424
|
+
### Key Benefits
|
|
425
|
+
|
|
426
|
+
1. **Type-Safe Errors**
|
|
427
|
+
- Compiler enforces error handling
|
|
428
|
+
- No more `catch(error: any)`
|
|
429
|
+
- Know exactly what can fail
|
|
430
|
+
|
|
431
|
+
2. **Composability**
|
|
432
|
+
- Small functions combine into complex flows
|
|
433
|
+
- Reusable across components
|
|
434
|
+
- Easy to reason about
|
|
435
|
+
|
|
436
|
+
3. **Testability**
|
|
437
|
+
- No mocking required
|
|
438
|
+
- Test layers replace real dependencies
|
|
439
|
+
- Pure functions = deterministic tests
|
|
440
|
+
|
|
441
|
+
4. **Observability**
|
|
442
|
+
- Built-in logging
|
|
443
|
+
- Tracing support
|
|
444
|
+
- Runtime metrics
|
|
445
|
+
|
|
446
|
+
---
|
|
447
|
+
|
|
448
|
+
## Client-Side Services (Effect.ts)
|
|
449
|
+
|
|
450
|
+
**Client services wrap backend API calls in Effect.ts patterns.**
|
|
451
|
+
|
|
452
|
+
### Core Principle: Generic Services Handle Everything
|
|
453
|
+
|
|
454
|
+
The ontology has **66 thing types**, but you only need **2 generic services**:
|
|
455
|
+
|
|
456
|
+
1. **ThingClientService** - All CRUD for all 66 types
|
|
457
|
+
2. **ConnectionClientService** - All relationships
|
|
458
|
+
|
|
459
|
+
```typescript
|
|
460
|
+
// ✅ This handles courses, lessons, products, everything
|
|
461
|
+
const thingService = yield* ThingClientService
|
|
462
|
+
|
|
463
|
+
// Get any thing
|
|
464
|
+
const course = yield* thingService.get(courseId)
|
|
465
|
+
const lesson = yield* thingService.get(lessonId)
|
|
466
|
+
|
|
467
|
+
// List any type
|
|
468
|
+
const courses = yield* thingService.list('course', orgId)
|
|
469
|
+
const products = yield* thingService.list('product', orgId)
|
|
470
|
+
|
|
471
|
+
// Create any type
|
|
472
|
+
const courseId = yield* thingService.create({
|
|
473
|
+
type: 'course',
|
|
474
|
+
name: 'Fitness 101',
|
|
475
|
+
properties: { price: 99, description: '...' }
|
|
476
|
+
})
|
|
477
|
+
```
|
|
478
|
+
|
|
479
|
+
**Specialized services are OPTIONAL** - only add them if you repeat the same multi-step operations frequently.
|
|
480
|
+
|
|
481
|
+
---
|
|
482
|
+
|
|
483
|
+
### Pattern: Generic Thing Service (Required)
|
|
484
|
+
|
|
485
|
+
```typescript
|
|
486
|
+
// frontend/src/services/ThingClientService.ts
|
|
487
|
+
import { Effect, Context, Layer } from 'effect'
|
|
488
|
+
import { ConvexHttpClient } from './ConvexHttpClient'
|
|
489
|
+
import { api } from '@/lib/api'
|
|
490
|
+
|
|
491
|
+
// Define errors
|
|
492
|
+
export class ThingNotFoundError {
|
|
493
|
+
readonly _tag = 'ThingNotFoundError'
|
|
494
|
+
constructor(readonly thingId: string) {}
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
export class ThingCreateError {
|
|
498
|
+
readonly _tag = 'ThingCreateError'
|
|
499
|
+
constructor(readonly reason: string) {}
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
// Define service interface
|
|
503
|
+
export class ThingClientService extends Effect.Service<ThingClientService>()(
|
|
504
|
+
'ThingClientService',
|
|
505
|
+
{
|
|
506
|
+
effect: Effect.gen(function* () {
|
|
507
|
+
// Depend on HTTP client
|
|
508
|
+
const client = yield* ConvexHttpClient
|
|
509
|
+
|
|
510
|
+
return {
|
|
511
|
+
// Get single thing
|
|
512
|
+
get: (id: string) =>
|
|
513
|
+
Effect.gen(function* () {
|
|
514
|
+
const thing = yield* client.query(api.queries.things.get, { id })
|
|
515
|
+
|
|
516
|
+
if (!thing) {
|
|
517
|
+
return yield* Effect.fail(new ThingNotFoundError(id))
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
return thing
|
|
521
|
+
}),
|
|
522
|
+
|
|
523
|
+
// List things
|
|
524
|
+
list: (type: string, orgId?: string) =>
|
|
525
|
+
Effect.gen(function* () {
|
|
526
|
+
return yield* client.query(api.queries.things.list, {
|
|
527
|
+
type,
|
|
528
|
+
organizationId: orgId
|
|
529
|
+
})
|
|
530
|
+
}),
|
|
531
|
+
|
|
532
|
+
// Create thing
|
|
533
|
+
create: (input: { type: string; name: string; properties: any }) =>
|
|
534
|
+
Effect.gen(function* () {
|
|
535
|
+
const id = yield* client.mutation(api.mutations.things.create, input)
|
|
536
|
+
.pipe(
|
|
537
|
+
Effect.catchAll(err =>
|
|
538
|
+
Effect.fail(new ThingCreateError(err.message))
|
|
539
|
+
)
|
|
540
|
+
)
|
|
541
|
+
|
|
542
|
+
return id
|
|
543
|
+
}),
|
|
544
|
+
|
|
545
|
+
// Update thing
|
|
546
|
+
update: (id: string, updates: any) =>
|
|
547
|
+
Effect.gen(function* () {
|
|
548
|
+
return yield* client.mutation(api.mutations.things.update, {
|
|
549
|
+
id,
|
|
550
|
+
updates
|
|
551
|
+
})
|
|
552
|
+
}),
|
|
553
|
+
|
|
554
|
+
// Delete thing
|
|
555
|
+
delete: (id: string) =>
|
|
556
|
+
Effect.gen(function* () {
|
|
557
|
+
return yield* client.mutation(api.mutations.things.delete, { id })
|
|
558
|
+
})
|
|
559
|
+
}
|
|
560
|
+
}),
|
|
561
|
+
dependencies: [ConvexHttpClient.Default]
|
|
562
|
+
}
|
|
563
|
+
) {}
|
|
564
|
+
```
|
|
565
|
+
|
|
566
|
+
### Pattern: Specialized Service (Optional - Course Example)
|
|
567
|
+
|
|
568
|
+
**You don't need this!** A course is just a thing. But if you repeat operations, add convenience methods:
|
|
569
|
+
|
|
570
|
+
```typescript
|
|
571
|
+
// frontend/src/services/CourseClientService.ts (OPTIONAL)
|
|
572
|
+
import { Effect } from 'effect'
|
|
573
|
+
import { ThingClientService } from './ThingClientService'
|
|
574
|
+
import { ConnectionClientService } from './ConnectionClientService'
|
|
575
|
+
|
|
576
|
+
export class CourseClientService extends Effect.Service<CourseClientService>()(
|
|
577
|
+
'CourseClientService',
|
|
578
|
+
{
|
|
579
|
+
effect: Effect.gen(function* () {
|
|
580
|
+
const thingService = yield* ThingClientService
|
|
581
|
+
const connectionService = yield* ConnectionClientService
|
|
582
|
+
|
|
583
|
+
return {
|
|
584
|
+
// Convenience: Get course with lessons
|
|
585
|
+
// Without this, you'd do:
|
|
586
|
+
// const course = yield* thingService.get(courseId)
|
|
587
|
+
// const lessons = yield* connectionService.getRelated(courseId, 'part_of', 'to')
|
|
588
|
+
getCourseWithLessons: (courseId: string) =>
|
|
589
|
+
Effect.gen(function* () {
|
|
590
|
+
const [course, lessons] = yield* Effect.all([
|
|
591
|
+
thingService.get(courseId),
|
|
592
|
+
connectionService.getRelated(courseId, 'part_of', 'to')
|
|
593
|
+
])
|
|
594
|
+
|
|
595
|
+
return { course, lessons }
|
|
596
|
+
}),
|
|
597
|
+
|
|
598
|
+
// Convenience: Clearer domain vocabulary
|
|
599
|
+
// Without this, you'd do:
|
|
600
|
+
// yield* connectionService.create({
|
|
601
|
+
// fromThingId: userId,
|
|
602
|
+
// toThingId: courseId,
|
|
603
|
+
// relationshipType: 'enrolled_in'
|
|
604
|
+
// })
|
|
605
|
+
enrollUser: (userId: string, courseId: string) =>
|
|
606
|
+
Effect.gen(function* () {
|
|
607
|
+
return yield* connectionService.create({
|
|
608
|
+
fromThingId: userId,
|
|
609
|
+
toThingId: courseId,
|
|
610
|
+
relationshipType: 'enrolled_in'
|
|
611
|
+
})
|
|
612
|
+
}),
|
|
613
|
+
|
|
614
|
+
// Convenience: Specific count query
|
|
615
|
+
getEnrollmentCount: (courseId: string) =>
|
|
616
|
+
Effect.gen(function* () {
|
|
617
|
+
return yield* connectionService.getCount(courseId, 'enrolled_in')
|
|
618
|
+
})
|
|
619
|
+
}
|
|
620
|
+
}),
|
|
621
|
+
dependencies: [ThingClientService.Default, ConnectionClientService.Default]
|
|
622
|
+
}
|
|
623
|
+
) {}
|
|
624
|
+
```
|
|
625
|
+
|
|
626
|
+
**When to add specialized services:**
|
|
627
|
+
- ✅ Repeat the same multi-step operation 3+ times
|
|
628
|
+
- ✅ Want domain vocabulary (`enrollUser` vs `create connection`)
|
|
629
|
+
- ✅ Need to encapsulate complex business workflows
|
|
630
|
+
- ❌ Don't add them upfront for all 66 types
|
|
631
|
+
- ❌ Don't add them for simple CRUD (use ThingClientService)
|
|
632
|
+
|
|
633
|
+
### ConvexHttpClient Wrapper
|
|
634
|
+
|
|
635
|
+
```typescript
|
|
636
|
+
// frontend/src/services/ConvexHttpClient.ts
|
|
637
|
+
import { Effect, Context, Layer } from 'effect'
|
|
638
|
+
import { ConvexHttpClient as ConvexClient } from 'convex/browser'
|
|
639
|
+
|
|
640
|
+
// Define client interface
|
|
641
|
+
export class ConvexHttpClient extends Context.Tag('ConvexHttpClient')<
|
|
642
|
+
ConvexHttpClient,
|
|
643
|
+
{
|
|
644
|
+
query: <T>(endpoint: any, args: any) => Effect.Effect<T, Error>
|
|
645
|
+
mutation: <T>(endpoint: any, args: any) => Effect.Effect<T, Error>
|
|
646
|
+
}
|
|
647
|
+
>() {}
|
|
648
|
+
|
|
649
|
+
// Live implementation
|
|
650
|
+
export const ConvexHttpClientLive = Layer.succeed(
|
|
651
|
+
ConvexHttpClient,
|
|
652
|
+
{
|
|
653
|
+
query: (endpoint, args) =>
|
|
654
|
+
Effect.tryPromise({
|
|
655
|
+
try: () => {
|
|
656
|
+
const client = new ConvexClient(import.meta.env.PUBLIC_CONVEX_URL)
|
|
657
|
+
return client.query(endpoint, args)
|
|
658
|
+
},
|
|
659
|
+
catch: (error) => new Error(String(error))
|
|
660
|
+
}),
|
|
661
|
+
|
|
662
|
+
mutation: (endpoint, args) =>
|
|
663
|
+
Effect.tryPromise({
|
|
664
|
+
try: () => {
|
|
665
|
+
const client = new ConvexClient(import.meta.env.PUBLIC_CONVEX_URL)
|
|
666
|
+
return client.mutation(endpoint, args)
|
|
667
|
+
},
|
|
668
|
+
catch: (error) => new Error(String(error))
|
|
669
|
+
})
|
|
670
|
+
}
|
|
671
|
+
)
|
|
672
|
+
```
|
|
673
|
+
|
|
674
|
+
### Client Layer (Dependency Injection)
|
|
675
|
+
|
|
676
|
+
```typescript
|
|
677
|
+
// frontend/src/services/ClientLayer.ts
|
|
678
|
+
import { Layer } from 'effect'
|
|
679
|
+
import { ConvexHttpClientLive } from './ConvexHttpClient'
|
|
680
|
+
import { ThingClientService } from './ThingClientService'
|
|
681
|
+
import { ConnectionClientService } from './ConnectionClientService'
|
|
682
|
+
// import { CourseClientService } from './CourseClientService' // OPTIONAL
|
|
683
|
+
|
|
684
|
+
// ✅ Minimal layer - handles all 66 thing types
|
|
685
|
+
export const ClientLayer = Layer.mergeAll(
|
|
686
|
+
ConvexHttpClientLive,
|
|
687
|
+
ThingClientService.Default,
|
|
688
|
+
ConnectionClientService.Default
|
|
689
|
+
// CourseClientService.Default // Add ONLY if you created it
|
|
690
|
+
)
|
|
691
|
+
```
|
|
692
|
+
|
|
693
|
+
**Most apps only need the 2 generic services.** Add specialized services as you discover repeated patterns.
|
|
694
|
+
|
|
695
|
+
---
|
|
696
|
+
|
|
697
|
+
## React Integration (useEffectRunner)
|
|
698
|
+
|
|
699
|
+
**Custom hook for running Effect programs in React components.**
|
|
700
|
+
|
|
701
|
+
### useEffectRunner Hook
|
|
702
|
+
|
|
703
|
+
```typescript
|
|
704
|
+
// frontend/src/hooks/useEffectRunner.ts
|
|
705
|
+
import { useCallback, useState } from 'react'
|
|
706
|
+
import { Effect } from 'effect'
|
|
707
|
+
import { ClientLayer } from '@/services/ClientLayer'
|
|
708
|
+
|
|
709
|
+
export function useEffectRunner() {
|
|
710
|
+
const [loading, setLoading] = useState(false)
|
|
711
|
+
const [error, setError] = useState<string | null>(null)
|
|
712
|
+
|
|
713
|
+
const run = useCallback(async <A, E>(
|
|
714
|
+
effect: Effect.Effect<A, E>,
|
|
715
|
+
options?: {
|
|
716
|
+
onSuccess?: (result: A) => void
|
|
717
|
+
onError?: (error: E) => void
|
|
718
|
+
}
|
|
719
|
+
) => {
|
|
720
|
+
setLoading(true)
|
|
721
|
+
setError(null)
|
|
722
|
+
|
|
723
|
+
try {
|
|
724
|
+
const result = await Effect.runPromise(
|
|
725
|
+
effect.pipe(Effect.provide(ClientLayer))
|
|
726
|
+
)
|
|
727
|
+
|
|
728
|
+
options?.onSuccess?.(result)
|
|
729
|
+
return result
|
|
730
|
+
} catch (err) {
|
|
731
|
+
const errorMessage = err instanceof Error ? err.message : String(err)
|
|
732
|
+
setError(errorMessage)
|
|
733
|
+
options?.onError?.(err as E)
|
|
734
|
+
throw err
|
|
735
|
+
} finally {
|
|
736
|
+
setLoading(false)
|
|
737
|
+
}
|
|
738
|
+
}, [])
|
|
739
|
+
|
|
740
|
+
return { run, loading, error }
|
|
741
|
+
}
|
|
742
|
+
```
|
|
743
|
+
|
|
744
|
+
### Using in Components
|
|
745
|
+
|
|
746
|
+
```tsx
|
|
747
|
+
// frontend/src/components/CourseEnrollButton.tsx
|
|
748
|
+
import { useEffectRunner } from '@/hooks/useEffectRunner'
|
|
749
|
+
import { ConnectionClientService } from '@/services/ConnectionClientService'
|
|
750
|
+
import { Effect } from 'effect'
|
|
751
|
+
import { Button } from '@/components/ui/button'
|
|
752
|
+
import { Alert } from '@/components/ui/alert'
|
|
753
|
+
|
|
754
|
+
interface Props {
|
|
755
|
+
courseId: string
|
|
756
|
+
userId: string
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
export function CourseEnrollButton({ courseId, userId }: Props) {
|
|
760
|
+
const { run, loading, error } = useEffectRunner()
|
|
761
|
+
|
|
762
|
+
const handleEnroll = () => {
|
|
763
|
+
// Define Effect program using GENERIC service
|
|
764
|
+
const program = Effect.gen(function* () {
|
|
765
|
+
const connectionService = yield* ConnectionClientService
|
|
766
|
+
|
|
767
|
+
// Enroll = create connection (course is just a thing)
|
|
768
|
+
const enrollmentId = yield* connectionService.create({
|
|
769
|
+
fromThingId: userId,
|
|
770
|
+
toThingId: courseId,
|
|
771
|
+
relationshipType: 'enrolled_in'
|
|
772
|
+
})
|
|
773
|
+
|
|
774
|
+
// Log success (client-side only for UX)
|
|
775
|
+
yield* Effect.logInfo(`Enrolled in course ${courseId}`)
|
|
776
|
+
|
|
777
|
+
return enrollmentId
|
|
778
|
+
})
|
|
779
|
+
|
|
780
|
+
// Run Effect program
|
|
781
|
+
run(program, {
|
|
782
|
+
onSuccess: (enrollmentId) => {
|
|
783
|
+
console.log('Enrolled successfully:', enrollmentId)
|
|
784
|
+
window.location.href = `/courses/${courseId}/learn`
|
|
785
|
+
},
|
|
786
|
+
onError: (err) => {
|
|
787
|
+
console.error('Enrollment failed:', err)
|
|
788
|
+
}
|
|
789
|
+
})
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
return (
|
|
793
|
+
<div>
|
|
794
|
+
<Button onClick={handleEnroll} disabled={loading}>
|
|
795
|
+
{loading ? 'Enrolling...' : 'Enroll Now'}
|
|
796
|
+
</Button>
|
|
797
|
+
|
|
798
|
+
{error && (
|
|
799
|
+
<Alert variant="destructive">{error}</Alert>
|
|
800
|
+
)}
|
|
801
|
+
</div>
|
|
802
|
+
)
|
|
803
|
+
}
|
|
804
|
+
```
|
|
805
|
+
|
|
806
|
+
**Alternative with specialized service (if you created CourseClientService):**
|
|
807
|
+
```tsx
|
|
808
|
+
// OPTIONAL: If you have CourseClientService
|
|
809
|
+
const program = Effect.gen(function* () {
|
|
810
|
+
const courseService = yield* CourseClientService
|
|
811
|
+
return yield* courseService.enrollUser(userId, courseId)
|
|
812
|
+
})
|
|
813
|
+
```
|
|
814
|
+
|
|
815
|
+
### Pattern: Composable Operations
|
|
816
|
+
|
|
817
|
+
```tsx
|
|
818
|
+
// frontend/src/components/CourseCreator.tsx
|
|
819
|
+
import { useEffectRunner } from '@/hooks/useEffectRunner'
|
|
820
|
+
import { ThingClientService } from '@/services/ThingClientService'
|
|
821
|
+
import { ConnectionClientService } from '@/services/ConnectionClientService'
|
|
822
|
+
import { Effect } from 'effect'
|
|
823
|
+
import { useState } from 'react'
|
|
824
|
+
|
|
825
|
+
export function CourseCreator() {
|
|
826
|
+
const { run, loading, error } = useEffectRunner()
|
|
827
|
+
const [formData, setFormData] = useState({
|
|
828
|
+
title: '',
|
|
829
|
+
description: '',
|
|
830
|
+
price: 0
|
|
831
|
+
})
|
|
832
|
+
|
|
833
|
+
const handleSubmit = async (e: React.FormEvent) => {
|
|
834
|
+
e.preventDefault()
|
|
835
|
+
|
|
836
|
+
// Define COMPLEX Effect program with ONLY generic services
|
|
837
|
+
const program = Effect.gen(function* () {
|
|
838
|
+
const thingService = yield* ThingClientService
|
|
839
|
+
const connectionService = yield* ConnectionClientService
|
|
840
|
+
|
|
841
|
+
// 1. Create course (just a thing with type='course')
|
|
842
|
+
const courseId = yield* thingService.create({
|
|
843
|
+
type: 'course',
|
|
844
|
+
name: formData.title,
|
|
845
|
+
properties: {
|
|
846
|
+
title: formData.title,
|
|
847
|
+
description: formData.description,
|
|
848
|
+
price: formData.price
|
|
849
|
+
}
|
|
850
|
+
})
|
|
851
|
+
|
|
852
|
+
// 2. Create default lesson (just a thing with type='lesson')
|
|
853
|
+
const lessonId = yield* thingService.create({
|
|
854
|
+
type: 'lesson',
|
|
855
|
+
name: 'Introduction',
|
|
856
|
+
properties: {
|
|
857
|
+
content: 'Welcome to the course!'
|
|
858
|
+
}
|
|
859
|
+
})
|
|
860
|
+
|
|
861
|
+
// 3. Connect lesson to course (generic connection)
|
|
862
|
+
yield* connectionService.create({
|
|
863
|
+
fromThingId: lessonId,
|
|
864
|
+
toThingId: courseId,
|
|
865
|
+
relationshipType: 'part_of'
|
|
866
|
+
})
|
|
867
|
+
|
|
868
|
+
// 4. Return course ID
|
|
869
|
+
return courseId
|
|
870
|
+
}).pipe(
|
|
871
|
+
// Add retry logic
|
|
872
|
+
Effect.retry({ times: 3 }),
|
|
873
|
+
// Add timeout
|
|
874
|
+
Effect.timeout('5 seconds'),
|
|
875
|
+
// Handle specific errors
|
|
876
|
+
Effect.catchTag('ThingCreateError', err =>
|
|
877
|
+
Effect.fail(new Error(`Failed to create course: ${err.reason}`))
|
|
878
|
+
)
|
|
879
|
+
)
|
|
880
|
+
|
|
881
|
+
// Run the program
|
|
882
|
+
const courseId = await run(program, {
|
|
883
|
+
onSuccess: (id) => {
|
|
884
|
+
window.location.href = `/courses/${id}`
|
|
885
|
+
}
|
|
886
|
+
})
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
return (
|
|
890
|
+
<form onSubmit={handleSubmit}>
|
|
891
|
+
<input
|
|
892
|
+
type="text"
|
|
893
|
+
value={formData.title}
|
|
894
|
+
onChange={(e) => setFormData({ ...formData, title: e.target.value })}
|
|
895
|
+
placeholder="Course Title"
|
|
896
|
+
/>
|
|
897
|
+
|
|
898
|
+
<textarea
|
|
899
|
+
value={formData.description}
|
|
900
|
+
onChange={(e) => setFormData({ ...formData, description: e.target.value })}
|
|
901
|
+
placeholder="Description"
|
|
902
|
+
/>
|
|
903
|
+
|
|
904
|
+
<input
|
|
905
|
+
type="number"
|
|
906
|
+
value={formData.price}
|
|
907
|
+
onChange={(e) => setFormData({ ...formData, price: parseFloat(e.target.value) })}
|
|
908
|
+
placeholder="Price"
|
|
909
|
+
/>
|
|
910
|
+
|
|
911
|
+
<button type="submit" disabled={loading}>
|
|
912
|
+
{loading ? 'Creating...' : 'Create Course'}
|
|
913
|
+
</button>
|
|
914
|
+
|
|
915
|
+
{error && <Alert variant="destructive">{error}</Alert>}
|
|
916
|
+
</form>
|
|
917
|
+
)
|
|
918
|
+
}
|
|
919
|
+
```
|
|
920
|
+
|
|
921
|
+
**Key Point:** This handles courses, products, lessons, EVERYTHING with just 2 generic services. No specialized services needed.
|
|
922
|
+
|
|
923
|
+
### Pattern: Parallel Data Fetching
|
|
924
|
+
|
|
925
|
+
```tsx
|
|
926
|
+
// frontend/src/components/CourseDashboard.tsx
|
|
927
|
+
import { useEffect, useState } from 'react'
|
|
928
|
+
import { useEffectRunner } from '@/hooks/useEffectRunner'
|
|
929
|
+
import { ThingClientService } from '@/services/ThingClientService'
|
|
930
|
+
import { ConnectionClientService } from '@/services/ConnectionClientService'
|
|
931
|
+
import { Effect } from 'effect'
|
|
932
|
+
|
|
933
|
+
interface Props {
|
|
934
|
+
courseId: string
|
|
935
|
+
}
|
|
936
|
+
|
|
937
|
+
export function CourseDashboard({ courseId }: Props) {
|
|
938
|
+
const { run, loading } = useEffectRunner()
|
|
939
|
+
const [data, setData] = useState<any>(null)
|
|
940
|
+
|
|
941
|
+
useEffect(() => {
|
|
942
|
+
// Fetch all data in parallel using GENERIC services
|
|
943
|
+
const program = Effect.gen(function* () {
|
|
944
|
+
const thingService = yield* ThingClientService
|
|
945
|
+
const connectionService = yield* ConnectionClientService
|
|
946
|
+
|
|
947
|
+
// Parallel fetch (all run at once)
|
|
948
|
+
// Course is just a thing, lessons are connected things
|
|
949
|
+
const [course, lessons, enrollmentCount] = yield* Effect.all([
|
|
950
|
+
thingService.get(courseId),
|
|
951
|
+
connectionService.getRelated(courseId, 'part_of', 'to'),
|
|
952
|
+
connectionService.getCount(courseId, 'enrolled_in')
|
|
953
|
+
], { concurrency: 'unbounded' })
|
|
954
|
+
|
|
955
|
+
return { course, lessons, enrollmentCount }
|
|
956
|
+
})
|
|
957
|
+
|
|
958
|
+
run(program, {
|
|
959
|
+
onSuccess: setData
|
|
960
|
+
})
|
|
961
|
+
}, [courseId])
|
|
962
|
+
|
|
963
|
+
if (loading) return <div>Loading...</div>
|
|
964
|
+
if (!data) return <div>No data</div>
|
|
965
|
+
|
|
966
|
+
return (
|
|
967
|
+
<div>
|
|
968
|
+
<h1>{data.course.name}</h1>
|
|
969
|
+
<p>{data.enrollmentCount} students enrolled</p>
|
|
970
|
+
|
|
971
|
+
<h2>Lessons</h2>
|
|
972
|
+
{data.lessons.map((lesson: any) => (
|
|
973
|
+
<div key={lesson._id}>{lesson.name}</div>
|
|
974
|
+
))}
|
|
975
|
+
</div>
|
|
976
|
+
)
|
|
977
|
+
}
|
|
978
|
+
```
|
|
979
|
+
|
|
980
|
+
**This is where a specialized service provides value** - compare:
|
|
981
|
+
|
|
982
|
+
```tsx
|
|
983
|
+
// ❌ Without specialized service (3 separate operations)
|
|
984
|
+
const [course, lessons, enrollmentCount] = yield* Effect.all([
|
|
985
|
+
thingService.get(courseId),
|
|
986
|
+
connectionService.getRelated(courseId, 'part_of', 'to'),
|
|
987
|
+
connectionService.getCount(courseId, 'enrolled_in')
|
|
988
|
+
])
|
|
989
|
+
|
|
990
|
+
// ✅ With specialized service (cleaner, if you repeat this pattern)
|
|
991
|
+
const data = yield* courseService.getCourseWithLessons(courseId)
|
|
992
|
+
const count = yield* courseService.getEnrollmentCount(courseId)
|
|
993
|
+
```
|
|
994
|
+
|
|
995
|
+
But you only add `CourseClientService` **after** you repeat this pattern 3+ times.
|
|
996
|
+
|
|
997
|
+
---
|
|
998
|
+
|
|
999
|
+
### Summary: Generic vs Specialized Services
|
|
1000
|
+
|
|
1001
|
+
```
|
|
1002
|
+
┌─────────────────────────────────────────────────────────┐
|
|
1003
|
+
│ 66 Thing Types │
|
|
1004
|
+
│ course, lesson, product, video, post, comment, etc. │
|
|
1005
|
+
└──────────────────────┬──────────────────────────────────┘
|
|
1006
|
+
│
|
|
1007
|
+
↓
|
|
1008
|
+
┌─────────────────────────────────────────────────────────┐
|
|
1009
|
+
│ 2 GENERIC SERVICES (handle everything) │
|
|
1010
|
+
│ │
|
|
1011
|
+
│ ThingClientService: │
|
|
1012
|
+
│ - get(id) │
|
|
1013
|
+
│ - list(type, orgId) │
|
|
1014
|
+
│ - create({ type, name, properties }) │
|
|
1015
|
+
│ - update(id, updates) │
|
|
1016
|
+
│ - delete(id) │
|
|
1017
|
+
│ │
|
|
1018
|
+
│ ConnectionClientService: │
|
|
1019
|
+
│ - create({ fromThingId, toThingId, relationshipType })│
|
|
1020
|
+
│ - getRelated(thingId, relationshipType, direction) │
|
|
1021
|
+
│ - getCount(thingId, relationshipType) │
|
|
1022
|
+
│ - delete(connectionId) │
|
|
1023
|
+
└──────────────────────┬──────────────────────────────────┘
|
|
1024
|
+
│
|
|
1025
|
+
↓
|
|
1026
|
+
┌─────────────────────────────────────────────────────────┐
|
|
1027
|
+
│ SPECIALIZED SERVICES (optional, add as needed) │
|
|
1028
|
+
│ │
|
|
1029
|
+
│ CourseClientService (if you repeat patterns): │
|
|
1030
|
+
│ - getCourseWithLessons() → wraps 2 calls │
|
|
1031
|
+
│ - enrollUser() → clearer vocabulary │
|
|
1032
|
+
│ - getEnrollmentCount() → specific query │
|
|
1033
|
+
│ │
|
|
1034
|
+
│ Add specialized services ONLY when: │
|
|
1035
|
+
│ ✅ You repeat the same 2-3 step operation 3+ times │
|
|
1036
|
+
│ ✅ You want clearer domain vocabulary │
|
|
1037
|
+
│ ❌ Don't add upfront for all 66 types │
|
|
1038
|
+
└─────────────────────────────────────────────────────────┘
|
|
1039
|
+
```
|
|
1040
|
+
|
|
1041
|
+
**Start with generic services. Add specialized services as patterns emerge.**
|
|
1042
|
+
|
|
1043
|
+
---
|
|
1044
|
+
|
|
1045
|
+
## Component Patterns
|
|
1046
|
+
|
|
1047
|
+
### Pattern 1: Generic Card (Pure Presentation)
|
|
1048
|
+
|
|
1049
|
+
```tsx
|
|
1050
|
+
// frontend/src/components/cards/ThingCard.tsx
|
|
1051
|
+
import { Card } from '@/components/ui/card'
|
|
1052
|
+
import { getThingConfig } from '@/ontology/config'
|
|
1053
|
+
import * as Icons from 'lucide-react'
|
|
1054
|
+
|
|
1055
|
+
interface ThingCardProps {
|
|
1056
|
+
thing: {
|
|
1057
|
+
_id: string
|
|
1058
|
+
type: string
|
|
1059
|
+
name: string
|
|
1060
|
+
properties: Record<string, any>
|
|
1061
|
+
}
|
|
1062
|
+
}
|
|
1063
|
+
|
|
1064
|
+
export function ThingCard({ thing }: ThingCardProps) {
|
|
1065
|
+
// Get UI config
|
|
1066
|
+
const config = getThingConfig(thing.type as any)
|
|
1067
|
+
const Icon = Icons[config.icon as keyof typeof Icons]
|
|
1068
|
+
|
|
1069
|
+
// Extract display values
|
|
1070
|
+
const title = thing.properties[config.primaryField] || thing.name
|
|
1071
|
+
const subtitle = config.secondaryField
|
|
1072
|
+
? thing.properties[config.secondaryField]
|
|
1073
|
+
: null
|
|
1074
|
+
const image = config.imageField
|
|
1075
|
+
? thing.properties[config.imageField]
|
|
1076
|
+
: null
|
|
1077
|
+
|
|
1078
|
+
// Pure presentation - NO logic
|
|
1079
|
+
return (
|
|
1080
|
+
<Card>
|
|
1081
|
+
{image && <img src={image} alt={title} />}
|
|
1082
|
+
|
|
1083
|
+
<div className="p-4">
|
|
1084
|
+
<div className="flex items-center gap-2">
|
|
1085
|
+
<Icon className="w-5 h-5" />
|
|
1086
|
+
<span>{config.displayName}</span>
|
|
1087
|
+
</div>
|
|
1088
|
+
|
|
1089
|
+
<h3 className="text-xl font-bold">{title}</h3>
|
|
1090
|
+
{subtitle && <p className="text-gray-600">{subtitle}</p>}
|
|
1091
|
+
|
|
1092
|
+
<a href={`/${thing.type}s/${thing._id}`}>
|
|
1093
|
+
<button>View Details</button>
|
|
1094
|
+
</a>
|
|
1095
|
+
</div>
|
|
1096
|
+
</Card>
|
|
1097
|
+
)
|
|
1098
|
+
}
|
|
1099
|
+
```
|
|
1100
|
+
|
|
1101
|
+
**Key Points:**
|
|
1102
|
+
- ✅ Receives data as props
|
|
1103
|
+
- ✅ Uses UI config for display
|
|
1104
|
+
- ✅ Pure presentation logic
|
|
1105
|
+
- ❌ NO database calls
|
|
1106
|
+
- ❌ NO business logic
|
|
1107
|
+
- ❌ NO validation
|
|
1108
|
+
|
|
1109
|
+
---
|
|
1110
|
+
|
|
1111
|
+
## Page Patterns (SSR)
|
|
1112
|
+
|
|
1113
|
+
### Pattern: Fetch from Backend, Render HTML
|
|
1114
|
+
|
|
1115
|
+
```astro
|
|
1116
|
+
---
|
|
1117
|
+
// frontend/src/pages/courses/[id].astro
|
|
1118
|
+
import { getConvexClient } from '@/lib/convex'
|
|
1119
|
+
import { api } from '@/lib/api'
|
|
1120
|
+
import Layout from '@/layouts/Layout.astro'
|
|
1121
|
+
|
|
1122
|
+
// SSR: Fetch data from backend via HTTP
|
|
1123
|
+
const convex = getConvexClient()
|
|
1124
|
+
|
|
1125
|
+
const course = await convex.query(api.queries.things.get, {
|
|
1126
|
+
id: Astro.params.id
|
|
1127
|
+
})
|
|
1128
|
+
|
|
1129
|
+
if (!course) {
|
|
1130
|
+
return Astro.redirect('/404')
|
|
1131
|
+
}
|
|
1132
|
+
|
|
1133
|
+
// Get related lessons from backend
|
|
1134
|
+
const lessons = await convex.query(api.queries.things.getRelated, {
|
|
1135
|
+
thingId: course._id,
|
|
1136
|
+
relationshipType: 'part_of',
|
|
1137
|
+
direction: 'to'
|
|
1138
|
+
})
|
|
1139
|
+
---
|
|
1140
|
+
|
|
1141
|
+
<Layout title={course.name}>
|
|
1142
|
+
<!-- Static HTML rendered on server -->
|
|
1143
|
+
<header>
|
|
1144
|
+
<h1>{course.name}</h1>
|
|
1145
|
+
<p>{course.properties.description}</p>
|
|
1146
|
+
<span className="text-2xl">${course.properties.price}</span>
|
|
1147
|
+
</header>
|
|
1148
|
+
|
|
1149
|
+
<!-- Lessons list (static) -->
|
|
1150
|
+
<section>
|
|
1151
|
+
<h2>Lessons</h2>
|
|
1152
|
+
{lessons.map(lesson => (
|
|
1153
|
+
<div>
|
|
1154
|
+
<h3>{lesson.name}</h3>
|
|
1155
|
+
<p>{lesson.properties.content}</p>
|
|
1156
|
+
</div>
|
|
1157
|
+
))}
|
|
1158
|
+
</section>
|
|
1159
|
+
|
|
1160
|
+
<!-- Interactive enrollment button (React Island) -->
|
|
1161
|
+
<EnrollButton client:load courseId={course._id} />
|
|
1162
|
+
</Layout>
|
|
1163
|
+
```
|
|
1164
|
+
|
|
1165
|
+
**Key Points:**
|
|
1166
|
+
- ✅ Calls backend API to get data
|
|
1167
|
+
- ✅ Renders static HTML
|
|
1168
|
+
- ✅ Fast initial load (SSR)
|
|
1169
|
+
- ❌ NO database access
|
|
1170
|
+
- ❌ NO business logic in page
|
|
1171
|
+
|
|
1172
|
+
---
|
|
1173
|
+
|
|
1174
|
+
## Real-Time Components
|
|
1175
|
+
|
|
1176
|
+
### Pattern: Subscribe to Backend Changes
|
|
1177
|
+
|
|
1178
|
+
```tsx
|
|
1179
|
+
// frontend/src/components/LiveEnrollmentCount.tsx
|
|
1180
|
+
import { useQuery } from 'convex/react'
|
|
1181
|
+
import { api } from '@/lib/api'
|
|
1182
|
+
|
|
1183
|
+
export function LiveEnrollmentCount({ courseId }: Props) {
|
|
1184
|
+
// Real-time subscription to backend
|
|
1185
|
+
// When ANYONE enrolls, this updates EVERYWHERE instantly
|
|
1186
|
+
const count = useQuery(api.queries.connections.getCount, {
|
|
1187
|
+
toThingId: courseId,
|
|
1188
|
+
relationshipType: 'enrolled_in'
|
|
1189
|
+
})
|
|
1190
|
+
|
|
1191
|
+
if (count === undefined) return <div>Loading...</div>
|
|
1192
|
+
|
|
1193
|
+
return (
|
|
1194
|
+
<div>
|
|
1195
|
+
<span className="text-3xl font-bold">{count}</span>
|
|
1196
|
+
<span className="text-sm text-gray-600"> students enrolled</span>
|
|
1197
|
+
</div>
|
|
1198
|
+
)
|
|
1199
|
+
}
|
|
1200
|
+
```
|
|
1201
|
+
|
|
1202
|
+
**How It Works:**
|
|
1203
|
+
1. Component subscribes to backend query via WebSocket
|
|
1204
|
+
2. Backend watches database for changes
|
|
1205
|
+
3. When connection created → backend pushes update to frontend
|
|
1206
|
+
4. Component auto-re-renders
|
|
1207
|
+
5. **Frontend does NOTHING except display the number**
|
|
1208
|
+
|
|
1209
|
+
---
|
|
1210
|
+
|
|
1211
|
+
## Forms (Calls Backend)
|
|
1212
|
+
|
|
1213
|
+
### Pattern: Collect Input, Send to Backend
|
|
1214
|
+
|
|
1215
|
+
```tsx
|
|
1216
|
+
// frontend/src/components/forms/ThingForm.tsx
|
|
1217
|
+
import { useMutation } from 'convex/react'
|
|
1218
|
+
import { api } from '@/lib/api'
|
|
1219
|
+
import { getThingConfig } from '@/ontology/config'
|
|
1220
|
+
import { useState } from 'react'
|
|
1221
|
+
|
|
1222
|
+
interface ThingFormProps {
|
|
1223
|
+
type: ThingType
|
|
1224
|
+
onSuccess?: (id: string) => void
|
|
1225
|
+
}
|
|
1226
|
+
|
|
1227
|
+
export function ThingForm({ type, onSuccess }: ThingFormProps) {
|
|
1228
|
+
const config = getThingConfig(type)
|
|
1229
|
+
const [formData, setFormData] = useState({})
|
|
1230
|
+
const [error, setError] = useState<string | null>(null)
|
|
1231
|
+
|
|
1232
|
+
// Backend mutation (frontend just calls it)
|
|
1233
|
+
const createThing = useMutation(api.mutations.things.create)
|
|
1234
|
+
|
|
1235
|
+
const handleSubmit = async (e: React.FormEvent) => {
|
|
1236
|
+
e.preventDefault()
|
|
1237
|
+
setError(null)
|
|
1238
|
+
|
|
1239
|
+
try {
|
|
1240
|
+
// Send to backend - backend validates, creates, logs events
|
|
1241
|
+
const id = await createThing({
|
|
1242
|
+
type,
|
|
1243
|
+
name: formData[config.primaryField],
|
|
1244
|
+
properties: formData
|
|
1245
|
+
})
|
|
1246
|
+
|
|
1247
|
+
onSuccess?.(id)
|
|
1248
|
+
} catch (err) {
|
|
1249
|
+
// Display backend error
|
|
1250
|
+
setError(err.message)
|
|
1251
|
+
}
|
|
1252
|
+
}
|
|
1253
|
+
|
|
1254
|
+
return (
|
|
1255
|
+
<form onSubmit={handleSubmit}>
|
|
1256
|
+
{/* Form fields from UI config */}
|
|
1257
|
+
{Object.entries(config.fields).map(([field, fieldConfig]) => (
|
|
1258
|
+
<div key={field}>
|
|
1259
|
+
<label>{fieldConfig.label}</label>
|
|
1260
|
+
<input
|
|
1261
|
+
type={fieldConfig.type}
|
|
1262
|
+
value={formData[field] || ''}
|
|
1263
|
+
onChange={(e) => setFormData({ ...formData, [field]: e.target.value })}
|
|
1264
|
+
placeholder={fieldConfig.placeholder}
|
|
1265
|
+
required={fieldConfig.required}
|
|
1266
|
+
/>
|
|
1267
|
+
</div>
|
|
1268
|
+
))}
|
|
1269
|
+
|
|
1270
|
+
{error && <div className="text-red-600">{error}</div>}
|
|
1271
|
+
|
|
1272
|
+
<button type="submit">Create</button>
|
|
1273
|
+
</form>
|
|
1274
|
+
)
|
|
1275
|
+
}
|
|
1276
|
+
```
|
|
1277
|
+
|
|
1278
|
+
**Key Points:**
|
|
1279
|
+
- ✅ Collects user input
|
|
1280
|
+
- ✅ Sends to backend mutation
|
|
1281
|
+
- ✅ Displays backend errors
|
|
1282
|
+
- ⚠️ Frontend validation is optional (UX only)
|
|
1283
|
+
- ❌ Backend MUST validate (security)
|
|
1284
|
+
- ❌ Frontend does NOT create database records
|
|
1285
|
+
|
|
1286
|
+
---
|
|
1287
|
+
|
|
1288
|
+
## Multi-Tenant Routing
|
|
1289
|
+
|
|
1290
|
+
### Middleware: Extract Org from Subdomain
|
|
1291
|
+
|
|
1292
|
+
```typescript
|
|
1293
|
+
// frontend/src/middleware.ts
|
|
1294
|
+
import { defineMiddleware } from 'astro:middleware'
|
|
1295
|
+
import { getConvexClient } from './lib/convex'
|
|
1296
|
+
import { api } from './lib/api'
|
|
1297
|
+
|
|
1298
|
+
export const onRequest = defineMiddleware(async (context, next) => {
|
|
1299
|
+
const url = new URL(context.request.url)
|
|
1300
|
+
|
|
1301
|
+
// Extract org slug from subdomain
|
|
1302
|
+
// fitnesspro.one.ie → "fitnesspro"
|
|
1303
|
+
const hostname = url.hostname
|
|
1304
|
+
const orgSlug = hostname.split('.')[0]
|
|
1305
|
+
|
|
1306
|
+
// Skip for main domains
|
|
1307
|
+
if (['api', 'www', 'localhost'].includes(orgSlug)) {
|
|
1308
|
+
return next()
|
|
1309
|
+
}
|
|
1310
|
+
|
|
1311
|
+
// Fetch org from backend
|
|
1312
|
+
const convex = getConvexClient()
|
|
1313
|
+
const org = await convex.query(api.queries.orgs.getBySlug, {
|
|
1314
|
+
slug: orgSlug
|
|
1315
|
+
})
|
|
1316
|
+
|
|
1317
|
+
if (org) {
|
|
1318
|
+
// Inject org context for pages to use
|
|
1319
|
+
context.locals.org = org
|
|
1320
|
+
context.locals.orgId = org._id
|
|
1321
|
+
}
|
|
1322
|
+
|
|
1323
|
+
return next()
|
|
1324
|
+
})
|
|
1325
|
+
```
|
|
1326
|
+
|
|
1327
|
+
### Use Org Context in Pages
|
|
1328
|
+
|
|
1329
|
+
```astro
|
|
1330
|
+
---
|
|
1331
|
+
// frontend/src/pages/courses/index.astro
|
|
1332
|
+
import { getConvexClient } from '@/lib/convex'
|
|
1333
|
+
import { api } from '@/lib/api'
|
|
1334
|
+
|
|
1335
|
+
// Get org from middleware
|
|
1336
|
+
const org = Astro.locals.org
|
|
1337
|
+
|
|
1338
|
+
if (!org) {
|
|
1339
|
+
return Astro.redirect('/404')
|
|
1340
|
+
}
|
|
1341
|
+
|
|
1342
|
+
// Fetch org's courses from backend
|
|
1343
|
+
const convex = getConvexClient()
|
|
1344
|
+
const courses = await convex.query(api.queries.things.list, {
|
|
1345
|
+
type: 'course',
|
|
1346
|
+
organizationId: org._id // Backend filters by org
|
|
1347
|
+
})
|
|
1348
|
+
---
|
|
1349
|
+
|
|
1350
|
+
<Layout title={`${org.name} - Courses`}>
|
|
1351
|
+
<h1>{org.name} Courses</h1>
|
|
1352
|
+
|
|
1353
|
+
<!-- Display org's courses -->
|
|
1354
|
+
{courses.map(course => (
|
|
1355
|
+
<CourseCard thing={course} />
|
|
1356
|
+
))}
|
|
1357
|
+
</Layout>
|
|
1358
|
+
```
|
|
1359
|
+
|
|
1360
|
+
**Result:**
|
|
1361
|
+
- `fitnesspro.one.ie/courses` → FitnessPro courses only
|
|
1362
|
+
- `techcorp.one.ie/courses` → TechCorp courses only
|
|
1363
|
+
- **Backend enforces data isolation, frontend just passes orgId**
|
|
1364
|
+
|
|
1365
|
+
---
|
|
1366
|
+
|
|
1367
|
+
## Deployment
|
|
1368
|
+
|
|
1369
|
+
### Frontend Deployment (Separate from Backend)
|
|
1370
|
+
|
|
1371
|
+
```bash
|
|
1372
|
+
# Frontend (Astro)
|
|
1373
|
+
cd frontend
|
|
1374
|
+
npm run build
|
|
1375
|
+
# Deploy to Cloudflare Pages / Vercel / Netlify
|
|
1376
|
+
|
|
1377
|
+
# Backend (Convex - separate deployment)
|
|
1378
|
+
cd backend
|
|
1379
|
+
npx convex deploy
|
|
1380
|
+
# Deployed to shocking-falcon-870.convex.cloud
|
|
1381
|
+
```
|
|
1382
|
+
|
|
1383
|
+
### Environment Setup
|
|
1384
|
+
|
|
1385
|
+
```bash
|
|
1386
|
+
# Frontend .env
|
|
1387
|
+
PUBLIC_CONVEX_URL=https://shocking-falcon-870.convex.cloud
|
|
1388
|
+
|
|
1389
|
+
# Frontend connects to this URL
|
|
1390
|
+
# Frontend NEVER deploys to Convex
|
|
1391
|
+
# Frontend is static site on Cloudflare Pages
|
|
1392
|
+
```
|
|
1393
|
+
|
|
1394
|
+
---
|
|
1395
|
+
|
|
1396
|
+
## Summary
|
|
1397
|
+
|
|
1398
|
+
### Frontend Responsibilities (ONLY These)
|
|
1399
|
+
|
|
1400
|
+
| What | How | Example |
|
|
1401
|
+
|------|-----|---------|
|
|
1402
|
+
| **Render UI** | Astro pages + React components | `<h1>{course.name}</h1>` |
|
|
1403
|
+
| **Call Backend** | Effect.ts services or Convex hooks | `yield* courseService.get(id)` or `useQuery(api.queries.things.list)` |
|
|
1404
|
+
| **Manage UI State** | `useState`, `useReducer`, `useEffectRunner` | `const { run, loading, error } = useEffectRunner()` |
|
|
1405
|
+
| **Route Users** | Astro routing, middleware | `/courses/[id].astro` |
|
|
1406
|
+
| **Display Errors** | Show typed backend errors | `Effect.catchTag('NotFoundError', ...)` |
|
|
1407
|
+
|
|
1408
|
+
### Backend Responsibilities (See ontology-backend.md)
|
|
1409
|
+
|
|
1410
|
+
| What | Where | Example |
|
|
1411
|
+
|------|-------|---------|
|
|
1412
|
+
| **Database Operations** | Backend only | `ctx.db.query('things')...` |
|
|
1413
|
+
| **Business Logic** | Backend only | Calculate prices, check quotas |
|
|
1414
|
+
| **Data Validation** | Backend only | Validate email, check permissions |
|
|
1415
|
+
| **Event Logging** | Backend only | `ctx.db.insert('events', ...)` |
|
|
1416
|
+
| **Authorization** | Backend only | Check if user can access resource |
|
|
1417
|
+
|
|
1418
|
+
### The Contract
|
|
1419
|
+
|
|
1420
|
+
```typescript
|
|
1421
|
+
// Frontend → Backend (only way to interact)
|
|
1422
|
+
|
|
1423
|
+
// ✅ Frontend calls backend query
|
|
1424
|
+
const courses = useQuery(api.queries.things.list, { type: 'course' })
|
|
1425
|
+
|
|
1426
|
+
// ✅ Frontend calls backend mutation
|
|
1427
|
+
const create = useMutation(api.mutations.things.create)
|
|
1428
|
+
await create({ type: 'course', name: 'Fitness 101', properties: {...} })
|
|
1429
|
+
|
|
1430
|
+
// ✅ Backend implements logic
|
|
1431
|
+
export const create = mutation({
|
|
1432
|
+
handler: async (ctx, args) => {
|
|
1433
|
+
// Validate
|
|
1434
|
+
// Create in database
|
|
1435
|
+
// Log event
|
|
1436
|
+
// Return result
|
|
1437
|
+
}
|
|
1438
|
+
})
|
|
1439
|
+
|
|
1440
|
+
// ❌ Frontend NEVER accesses database directly
|
|
1441
|
+
const courses = await ctx.db.query('things') // IMPOSSIBLE in frontend
|
|
1442
|
+
```
|
|
1443
|
+
|
|
1444
|
+
### Key Principles
|
|
1445
|
+
|
|
1446
|
+
1. **Separation:** Frontend renders, backend manages data
|
|
1447
|
+
2. **Type-Safe:** Effect.ts enforces error handling, backend generates types
|
|
1448
|
+
3. **Composability:** Effect.ts services combine into complex flows
|
|
1449
|
+
4. **Real-Time:** WebSocket subscriptions auto-update UI
|
|
1450
|
+
5. **Multi-Tenant:** Middleware extracts org → pages filter by org
|
|
1451
|
+
6. **Testability:** Effect.ts test layers replace mocks
|
|
1452
|
+
7. **Stateless:** Frontend has no state beyond UI, backend is source of truth
|
|
1453
|
+
|
|
1454
|
+
### Next Steps
|
|
1455
|
+
|
|
1456
|
+
1. **Setup Backend First** (see ontology-backend.md)
|
|
1457
|
+
2. **Get Backend URL** from Convex deployment
|
|
1458
|
+
3. **Create Frontend** with `npm create astro@latest`
|
|
1459
|
+
4. **Install Effect.ts** - `npm install effect @effect/schema`
|
|
1460
|
+
5. **Add Convex Client** and set `PUBLIC_CONVEX_URL`
|
|
1461
|
+
6. **Create Client Services** (ThingClientService, CourseClientService, etc.)
|
|
1462
|
+
7. **Build ClientLayer** with all service dependencies
|
|
1463
|
+
8. **Create useEffectRunner Hook** for React integration
|
|
1464
|
+
9. **Sync Types** from backend to frontend
|
|
1465
|
+
10. **Build UI Config** for all 66 thing types
|
|
1466
|
+
11. **Create Generic Components** (ThingCard, ThingList, ThingForm)
|
|
1467
|
+
12. **Add Pages** that call backend via Effect.ts services
|
|
1468
|
+
13. **Deploy Frontend** to Cloudflare Pages
|
|
1469
|
+
|
|
1470
|
+
---
|
|
1471
|
+
|
|
1472
|
+
**Frontend is pure rendering. Backend is everything else.**
|
|
1473
|
+
|
|
1474
|
+
Effect.ts for type-safe composability. Separate deployments. Real-time updates.
|
|
1475
|
+
|
|
1476
|
+
---
|
|
1477
|
+
|
|
1478
|
+
## Additional Resources
|
|
1479
|
+
|
|
1480
|
+
### Effect.ts Documentation
|
|
1481
|
+
- [Frontend Integration](../things/docs/effect/frontend.mdx) - React + Effect.ts patterns
|
|
1482
|
+
- [Testing](../things/docs/effect/testing.mdx) - Test layers and no-mock testing
|
|
1483
|
+
- [Effect.ts Official Docs](https://effect.website) - Complete Effect.ts guide
|
|
1484
|
+
|
|
1485
|
+
### Related Guides
|
|
1486
|
+
- **ontology-backend.md** - Backend implementation (Convex + Effect.ts)
|
|
1487
|
+
- **ontology-documentation.md** - Complete ontology overview
|
|
1488
|
+
- **Ontology.md** - Full technical specification
|
|
1489
|
+
|
|
1490
|
+
---
|
|
1491
|
+
|
|
1492
|
+
**END OF FRONTEND GUIDE**
|