oneie 3.6.12 → 3.6.14

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.
Files changed (775) hide show
  1. package/.claude/agents/AUDIT-agent-ops-alignment.md +379 -0
  2. package/.claude/agents/NEWS-QUICKSTART.md +321 -0
  3. package/.claude/agents/NEWS-README.md +353 -0
  4. package/.claude/agents/agent-backend.md +1 -1
  5. package/.claude/agents/agent-builder.md +220 -151
  6. package/.claude/agents/agent-clean.md +39 -31
  7. package/.claude/agents/agent-clone.md +107 -54
  8. package/.claude/agents/agent-designer.md +76 -71
  9. package/.claude/agents/agent-director.md +164 -1
  10. package/.claude/agents/agent-documenter.md +169 -132
  11. package/.claude/agents/agent-frontend.md +442 -446
  12. package/.claude/agents/agent-integrator.md +30 -23
  13. package/.claude/agents/agent-lawyer.md +145 -98
  14. package/.claude/agents/agent-news.md +363 -0
  15. package/.claude/agents/agent-onboard.md +99 -69
  16. package/.claude/agents/agent-ontology.md +585 -0
  17. package/.claude/agents/agent-ops.md +178 -171
  18. package/.claude/agents/agent-problem-solver.md +132 -115
  19. package/.claude/agents/agent-quality.md +94 -77
  20. package/.claude/agents/agent-sales.md +89 -67
  21. package/.claude/commands/release.md +3 -1
  22. package/.claude/commands/server.md +64 -5
  23. package/.claude/hooks/README-knowledge-hooks.md +266 -80
  24. package/.claude/hooks/README-root-cleanup.md +200 -0
  25. package/.claude/hooks/README.md +284 -0
  26. package/.claude/hooks/__pycache__/done.cpython-313.pyc +0 -0
  27. package/.claude/hooks/__pycache__/todo.cpython-313.pyc +0 -0
  28. package/.claude/hooks/check-filenames.py +169 -32
  29. package/.claude/hooks/clean-post.py +195 -28
  30. package/.claude/hooks/clean-pre.py +96 -11
  31. package/.claude/hooks/done.py +74 -13
  32. package/.claude/hooks/format-hook.sh +105 -17
  33. package/.claude/hooks/hook-logger.sh +121 -7
  34. package/.claude/hooks/knowledge-post.py +136 -32
  35. package/.claude/hooks/knowledge-pre.py +129 -34
  36. package/.claude/hooks/notification-hook.sh +184 -17
  37. package/.claude/hooks/root-cleanup.py +181 -39
  38. package/.claude/hooks/security-hook.sh +248 -8
  39. package/.claude/hooks/tag-all-docs.py +175 -49
  40. package/.claude/hooks/test-validate-ontology.sh +170 -0
  41. package/.claude/hooks/todo.py +92 -22
  42. package/.claude/hooks/validate-ontology-structure-summary.md +243 -0
  43. package/.claude/hooks/validate-ontology-structure.py +83 -20
  44. package/AGENTS.md +60 -245
  45. package/CLAUDE.md +70 -1
  46. package/README.md +25 -0
  47. package/folders.yaml +1 -1
  48. package/one/.claude/settings.local.json +11 -0
  49. package/one/.obsidian/community-plugins.json +3 -1
  50. package/one/.obsidian/plugins/editing-toolbar/data.json +328 -0
  51. package/one/.obsidian/plugins/editing-toolbar/main.js +12 -0
  52. package/one/.obsidian/plugins/editing-toolbar/manifest.json +10 -0
  53. package/one/.obsidian/plugins/editing-toolbar/styles.css +1338 -0
  54. package/one/.obsidian/plugins/terminal/data.json +154 -0
  55. package/one/.obsidian/plugins/terminal/main.js +197 -0
  56. package/one/.obsidian/plugins/terminal/manifest.json +14 -0
  57. package/one/.obsidian/plugins/terminal/styles.css +32 -0
  58. package/one/.obsidian/workspace.json +71 -45
  59. package/one/README.md +18 -0
  60. package/one/connections/a2a.md +49 -0
  61. package/one/connections/acp.md +47 -0
  62. package/one/connections/acps.md +18 -0
  63. package/one/connections/agentkit.md +18 -0
  64. package/one/connections/agui.md +18 -0
  65. package/one/connections/any-backend.md +39 -21
  66. package/one/connections/ap2.md +74 -0
  67. package/one/connections/api/queries-reference.md +18 -0
  68. package/one/connections/api-docs.md +18 -0
  69. package/one/connections/api-reference.md +18 -0
  70. package/one/connections/api.md +18 -0
  71. package/one/connections/architecture-diagram.md +18 -0
  72. package/one/connections/communications.md +18 -0
  73. package/one/connections/connections.md +18 -0
  74. package/one/connections/copilotkit.md +18 -0
  75. package/one/connections/cryptonetworks.md +18 -0
  76. package/one/connections/documentation.md +18 -0
  77. package/one/connections/effect.md +18 -0
  78. package/one/connections/elizaos.md +18 -0
  79. package/one/connections/groups.md +814 -0
  80. package/one/connections/inference.md +18 -0
  81. package/one/connections/integration-examples.md +18 -0
  82. package/one/connections/integration-guide.md +18 -0
  83. package/one/connections/integration-phase2.md +32 -14
  84. package/one/connections/kyc.md +18 -0
  85. package/one/connections/mcp.md +18 -0
  86. package/one/connections/membership.md +18 -0
  87. package/one/connections/middleware.md +18 -0
  88. package/one/connections/multitenant.md +18 -0
  89. package/one/connections/n8n.md +18 -0
  90. package/one/connections/patterns.md +18 -0
  91. package/one/connections/protocols.md +20 -2
  92. package/one/connections/relationships.md +18 -0
  93. package/one/connections/schema.md +18 -0
  94. package/one/connections/service-layer.md +18 -0
  95. package/one/connections/vectors.md +18 -0
  96. package/one/connections/wordpress.md +18 -0
  97. package/one/connections/workflow-copy.md +18 -0
  98. package/one/connections/workflow-examples.md +18 -0
  99. package/one/connections/workflow-onboarding.md +18 -0
  100. package/one/connections/workflow.md +18 -0
  101. package/one/connections/workflows/delegation.md +18 -0
  102. package/one/connections/workflows/frontend.md +18 -0
  103. package/one/connections/workflows/strategy.md +18 -0
  104. package/one/connections/workflows/tasks.md +18 -0
  105. package/one/connections/x402-baazar.md +131 -0
  106. package/one/connections/x402.md +268 -164
  107. package/one/events/2024-10-14-deployment-plan.md +15 -16
  108. package/one/events/2024-10-14-deployment-success.md +15 -16
  109. package/one/events/2024-10-14-final-sync-complete.md +15 -16
  110. package/one/events/2024-10-14-release-v2.0.6.md +15 -16
  111. package/one/events/2024-10-15-agent-clean-v2-summary.md +15 -16
  112. package/one/events/2024-10-15-handoff-to-clean.md +15 -16
  113. package/one/events/2024-10-15-package-manager-tests.md +15 -16
  114. package/one/events/2024-10-15-release-command-complete.md +15 -16
  115. package/one/events/2025-10-15-private-files-secured.md +18 -0
  116. package/one/events/2025-10-15-unignore-public-group-docs.md +18 -0
  117. package/one/events/ALIGNMENT_REPORT_PROBLEM_SOLVER.md +335 -0
  118. package/one/events/ALIGNMENT_SUMMARY.md +280 -0
  119. package/one/events/API_ROUTES_FIXES_SUMMARY.md +18 -0
  120. package/one/events/ASTRO-INTEGRATION-EXAMPLES.md +18 -0
  121. package/one/events/AUDIT-ONTOLOGY-ALIGNMENT.md +598 -0
  122. package/one/events/BEFORE_AFTER_COMPARISON.md +18 -0
  123. package/one/events/CART-DRAWER-INTEGRATION-GUIDE.md +18 -0
  124. package/one/events/CASCADE-2-BACKEND-AGNOSTIC.md +18 -0
  125. package/one/events/CLAUDE copy.md +897 -0
  126. package/one/events/CLEANUP-RELEASE-V2.0.8.md +18 -0
  127. package/one/events/CONNECTIONS_DEMO.md +18 -0
  128. package/one/events/CREATE-WEBSITE.md +18 -0
  129. package/one/events/CRITICAL-FIXES-COMPLETE.md +18 -0
  130. package/one/events/CUSTOM-DOMAIN.md +18 -0
  131. package/one/events/DELIVERABLES.md +18 -0
  132. package/one/events/DEMO-GROUPS-PAGE.md +18 -0
  133. package/one/events/DEMO-TESTING-SUMMARY.md +18 -0
  134. package/one/events/DEMO_COMPONENTS.md +18 -0
  135. package/one/events/DEMO_HOOKS_INDEX.md +18 -0
  136. package/one/events/DEMO_INFRASTRUCTURE.md +18 -0
  137. package/one/events/DEMO_INFRASTRUCTURE_SUMMARY.md +18 -0
  138. package/one/events/DEMO_INTEGRATION_CHECKLIST.md +18 -0
  139. package/one/events/DEMO_QUICK_REFERENCE.md +18 -0
  140. package/one/events/DEMO_SETUP.md +18 -0
  141. package/one/events/DEPLOYMENT copy.md +18 -0
  142. package/one/events/DEPLOYMENT.md +18 -0
  143. package/one/events/ECOMMERCE-BEFORE-AFTER.md +16 -0
  144. package/one/events/ECOMMERCE-DEMO-PLAN.md +18 -0
  145. package/one/events/ECOMMERCE-ENHANCEMENTS.md +18 -0
  146. package/one/events/ECOMMERCE-HIGH-CONVERTING-ELEMENTS.md +18 -0
  147. package/one/events/ECOMMERCE-LIVE-DEMO.md +18 -0
  148. package/one/events/ECOMMERCE-REFACTOR-SUMMARY.md +18 -0
  149. package/one/events/ECOMMERCE-SETUP-SUMMARY.md +18 -0
  150. package/one/events/ECOMMERCE-TEMPLATE-COMPLETE.md +18 -0
  151. package/one/events/ECOMMERCE-TEMPLATES-SUMMARY.md +18 -0
  152. package/one/events/EFFECT_TS_API_PATTERN.md +18 -0
  153. package/one/events/FEATURE-2-4-COMPLETE.md +18 -0
  154. package/one/events/FEATURE_2_3_COMPLETE.md +18 -0
  155. package/one/events/GRADIENT-TEXT-PERMANENT-FIX.md +18 -0
  156. package/one/events/GROUPS-MIGRATION.md +18 -0
  157. package/one/events/GROUPS_DEMO_IMPLEMENTATION.md +18 -0
  158. package/one/events/HANDOFF.md +18 -0
  159. package/one/events/HOOKS-DEMO.md +18 -0
  160. package/one/events/IMPLEMENTATION-SUMMARY-FINAL.md +18 -0
  161. package/one/events/IMPLEMENTATION_SUMMARY.md +18 -0
  162. package/one/events/INSTALL-TESTS.md +18 -0
  163. package/one/events/INSTALLATION_FOLDERS.md +18 -0
  164. package/one/events/INSTALLATION_FOLDERS_FILES.md +18 -0
  165. package/one/events/INSTALLATION_FOLDERS_SUMMARY.md +18 -0
  166. package/one/events/INTEGRATION-ARCHITECTURE.md +18 -0
  167. package/one/events/INTEGRATION-CHECKLIST.md +18 -0
  168. package/one/events/INTEGRATION-ORCHESTRATION.md +18 -0
  169. package/one/events/INTEGRATION-SUMMARY.md +18 -0
  170. package/one/events/LANDING-PAGE-EXAMPLE-OUTPUT.md +18 -0
  171. package/one/events/LANDING-PAGE-IMPLEMENTATION.md +18 -0
  172. package/one/events/LANDING-PAGE-QUICKSTART.md +18 -0
  173. package/one/events/LICENSE.md +18 -0
  174. package/one/events/MCP-CONFIGURATION.md +18 -0
  175. package/one/events/MCP-SETUP-COMPLETE.md +18 -0
  176. package/one/events/MIGRATION-REPORT.md +18 -0
  177. package/one/events/MIGRATION.md +18 -0
  178. package/one/events/MULTI-ONTOLOGY-COMPLETE-GUIDE.md +18 -0
  179. package/one/events/MULTI-ONTOLOGY-IMPLEMENTATION-COMPLETE.md +18 -0
  180. package/one/events/NODE-UPGRADE.md +18 -0
  181. package/one/events/ONBOARDING-IMPLEMENTATION-COMPLETE copy.md +18 -0
  182. package/one/events/ONTOLOGY-HOOKS-README.md +18 -0
  183. package/one/events/ONTOLOGY-INTEGRATION-MANIFEST.md +18 -0
  184. package/one/events/ONTOLOGY-TUTORIALS-SUMMARY.md +18 -0
  185. package/one/events/ONTOLOGY-TYPE-GENERATOR-SUMMARY.md +18 -0
  186. package/one/events/ONTOLOGY_DISCOVERY_IMPLEMENTATION.md +18 -0
  187. package/one/events/ONTOLOGY_DISCOVERY_QUICKSTART.md +18 -0
  188. package/one/events/PACKAGE-STRUCTURE.md +18 -0
  189. package/one/events/PLAYBOOK-SETUP-SUMMARY.md +18 -0
  190. package/one/events/PROMPT_FIX_FRONTEND_ONLY.md +18 -0
  191. package/one/events/QA-CHECKLIST.md +18 -0
  192. package/one/events/QUICK-START-ONTOLOGY.md +18 -0
  193. package/one/events/README-archived.md +18 -0
  194. package/one/events/SEARCH_DEMO_CODE_REFERENCE.md +18 -0
  195. package/one/events/SEARCH_DEMO_DELIVERY.md +18 -0
  196. package/one/events/SEARCH_DEMO_SUMMARY.md +18 -0
  197. package/one/events/SEARCH_DEMO_VISUAL_GUIDE.md +18 -0
  198. package/one/events/SECURITY-AUDIT-FIXES.md +18 -0
  199. package/one/events/SECURITY-SCAN-COMPLETE.md +18 -0
  200. package/one/events/SHOP-BUILD-STATUS.md +18 -0
  201. package/one/events/SHOP-PREMIUM-UPDATE.md +16 -0
  202. package/one/events/SIMPLE_FIX_FRONTEND_ONLY.md +18 -0
  203. package/one/events/SITE-WIDE-GRADIENT-FIX.md +18 -0
  204. package/one/events/STORE-PRODUCTION-READY-STATUS.md +18 -0
  205. package/one/events/STRIPE-INTEGRATION.md +18 -0
  206. package/one/events/STRIPE-PAYMENT-METHODS-GUIDE.md +18 -0
  207. package/one/events/STRIPE-SETUP-GUIDE.md +18 -0
  208. package/one/events/TEST-PLAN-INDEX.md +18 -0
  209. package/one/events/TEST-PLAN.md +18 -0
  210. package/one/events/TEST-SUMMARY.md +18 -0
  211. package/one/events/TESTS-QUICK-REF.md +18 -0
  212. package/one/events/TRANSITIONS-QUICK-START.md +18 -0
  213. package/one/events/TRANSPARENCY-FIXES.md +18 -0
  214. package/one/events/TYPESCRIPT_FIXES.md +18 -0
  215. package/one/events/TYPESCRIPT_FIXES_INDEX.md +18 -0
  216. package/one/events/VIEW-TRANSITIONS.md +18 -0
  217. package/one/events/agent-director-enhancement-summary.md +18 -0
  218. package/one/events/agent-onboard-implementation-summary.md +18 -0
  219. package/one/events/agent-ontology-alignment-completion.md +263 -0
  220. package/one/events/backend-integration-tests.md +18 -0
  221. package/one/events/clean-agent-ontology-cleanup-report.md +18 -0
  222. package/one/events/clean-agent-todo-analysis-summary.md +336 -0
  223. package/one/events/cloudflare-automation-complete.md +18 -0
  224. package/one/events/cloudflare-pages-infrastructure-setup.md +18 -0
  225. package/one/events/contact-page-complete.md +18 -0
  226. package/one/events/convex-analysis-index.md +18 -0
  227. package/one/events/convex-structure-analysis.md +18 -0
  228. package/one/events/deployment-installation-folders.md +18 -0
  229. package/one/events/deployment-ops-summary.md +18 -0
  230. package/one/events/deployment-verification.md +18 -0
  231. package/one/events/design-spec-complete.md +18 -0
  232. package/one/events/documentation-audit-index.md +473 -0
  233. package/one/events/documentation-audit-summary.md +417 -0
  234. package/one/events/documentation-improvement-roadmap.md +906 -0
  235. package/one/events/documentation-standards-compliance-report.md +538 -0
  236. package/one/events/events.md +18 -0
  237. package/one/events/frontend-effects-complete.md +584 -0
  238. package/one/events/frontend-effects-orchestration.md +1356 -0
  239. package/one/events/frontend-effects-risk-register.md +1055 -0
  240. package/one/events/frontend-effects-week1-assignments.md +1594 -0
  241. package/one/events/hook-ontology-alignment-summary.md +528 -0
  242. package/one/events/installation-folders-workflow-integration.md +18 -0
  243. package/one/events/landing-page-generator.md +18 -0
  244. package/one/events/legal-assessment-2025-10-16.md +18 -0
  245. package/one/events/onboarding-implementation-complete.md +18 -0
  246. package/one/events/ontology-test-examples.md +18 -0
  247. package/one/events/phase1-backend-implementation-complete.md +18 -0
  248. package/one/events/release.md +18 -0
  249. package/one/events/root-cleanup-alignment-report.md +265 -0
  250. package/one/events/separate-implementation-status.md +18 -0
  251. package/one/events/session-summary-2025-10-18.md +18 -0
  252. package/one/events/skills-complete.md +18 -0
  253. package/one/events/skills-infer-6-10-summary.md +18 -0
  254. package/one/events/skills-phase1-complete.md +18 -0
  255. package/one/events/structural-analysis-architecture-vs-plans.md +559 -0
  256. package/one/events/test-dashboard.md +18 -0
  257. package/one/events/test-index.md +18 -0
  258. package/one/events/test-report-ontology.md +18 -0
  259. package/one/events/testing-summary.md +18 -0
  260. package/one/events/todo-refactoring-complete.md +408 -0
  261. package/one/events/wave1-backend-implementation-complete.md +698 -0
  262. package/one/groups/features.md +26 -0
  263. package/one/groups/groups.md +83 -39
  264. package/one/groups/one.md +47 -27
  265. package/one/groups/{strategy copy.md → strategy-copy.md} +23 -5
  266. package/one/knowledge/.obsidian/ecommerce-ontology.md +18 -0
  267. package/one/knowledge/100-inference-quick-reference.md +18 -0
  268. package/one/knowledge/agent-onboard-usage.md +18 -0
  269. package/one/knowledge/agentic-commerce.md +146 -0
  270. package/one/knowledge/ai-agents-vs-memecoins-thesis.md +683 -0
  271. package/one/knowledge/ai-platform.md +18 -0
  272. package/one/knowledge/ai-token-crypto-analysis-framework.md +1191 -0
  273. package/one/knowledge/ai-token-paradigm-shift-2025.md +732 -0
  274. package/one/knowledge/altcoin-cycle-prediction-ontology.md +884 -0
  275. package/one/knowledge/altcoin-cycle-trading-strategy.md +642 -0
  276. package/one/knowledge/architecture-any-backend.md +265 -42
  277. package/one/knowledge/architecture-diagram.md +404 -94
  278. package/one/knowledge/architecture-frontend.md +130 -51
  279. package/one/knowledge/architecture.md +1496 -1831
  280. package/one/knowledge/{ontology.md.backup → archived/ontology.old.md} +18 -0
  281. package/one/knowledge/astro-effect-complete-vision.md +2148 -0
  282. package/one/knowledge/astro-effect-simple-architecture.md +717 -0
  283. package/one/knowledge/audit-agent-onboard-alignment.md +481 -0
  284. package/one/knowledge/audit-agent-sales-alignment.md +444 -0
  285. package/one/knowledge/backend-api-reference.md +18 -0
  286. package/one/knowledge/cli-claude-handoff.md +18 -0
  287. package/one/knowledge/context-engineering.md +610 -0
  288. package/one/knowledge/crypto-analysis-strategy.md +1276 -0
  289. package/one/knowledge/crypto-cycle-2024-2025-analysis.md +44 -0
  290. package/one/knowledge/crypto.md +18 -0
  291. package/one/knowledge/docs.md +627 -0
  292. package/one/knowledge/dsl.md +18 -0
  293. package/one/knowledge/files.md +18 -0
  294. package/one/knowledge/frontend.md +18 -0
  295. package/one/knowledge/hono.md +18 -0
  296. package/one/knowledge/implementation-examples.md +18 -0
  297. package/one/knowledge/installation-folders.md +18 -0
  298. package/one/knowledge/institutional-cycle-paradigm-2025.md +555 -0
  299. package/one/knowledge/knowledge.md +18 -0
  300. package/one/knowledge/language.md +18 -0
  301. package/one/knowledge/lessons-learned.md +18 -0
  302. package/one/knowledge/lessons-website-building-focus.md +18 -0
  303. package/one/knowledge/merge-report.md +254 -0
  304. package/one/knowledge/nine-padel-playbook.md +18 -0
  305. package/one/knowledge/ontology-blog.yaml +42 -26
  306. package/one/knowledge/ontology-cheatsheet.md +18 -0
  307. package/one/knowledge/ontology-community.yaml +60 -37
  308. package/one/knowledge/ontology-core-universal.md +19 -1
  309. package/one/knowledge/ontology-core.yaml +58 -45
  310. package/one/knowledge/ontology-courses.yaml +71 -48
  311. package/one/knowledge/ontology-creator.md +30 -4
  312. package/one/knowledge/ontology-crypto.md +1603 -0
  313. package/one/knowledge/ontology-developer-guide.md +18 -0
  314. package/one/knowledge/ontology-documentation.md +46 -25
  315. package/one/knowledge/ontology-ecommerce.md +24 -6
  316. package/one/knowledge/ontology-education.md +18 -0
  317. package/one/knowledge/ontology-engineering-specification.md +22 -4
  318. package/one/knowledge/ontology-engineering.md +67 -43
  319. package/one/knowledge/ontology-files.yaml +525 -0
  320. package/one/knowledge/ontology-frontend-master.md +2898 -0
  321. package/one/knowledge/ontology-frontend-specifications.md +57 -49
  322. package/one/knowledge/ontology-frontend.md +40 -22
  323. package/one/knowledge/ontology-index.md +18 -0
  324. package/one/knowledge/ontology-minimal.yaml +18 -16
  325. package/one/knowledge/ontology-portfolio.yaml +40 -26
  326. package/one/knowledge/ontology-quickstart.md +18 -0
  327. package/one/knowledge/ontology-release.md +317 -0
  328. package/one/knowledge/ontology-shop.yaml +146 -119
  329. package/one/knowledge/ontology-tokens.yaml +46 -27
  330. package/one/knowledge/ontology-tutorial.md +18 -0
  331. package/one/knowledge/ontology-video-script.md +18 -0
  332. package/one/knowledge/ontology-visual-guide.md +20 -2
  333. package/one/knowledge/ontology.md +1329 -304
  334. package/one/knowledge/ontology.yaml +763 -275
  335. package/one/knowledge/patterns/backend/convex-mutation-pattern.md +48 -18
  336. package/one/knowledge/patterns/backend/convex-query-pattern.md +78 -23
  337. package/one/knowledge/patterns/backend/mutation-template.md +28 -10
  338. package/one/knowledge/patterns/backend/query-template.md +44 -25
  339. package/one/knowledge/patterns/backend/service-template.md +35 -14
  340. package/one/knowledge/patterns/design/component-architecture.md +45 -9
  341. package/one/knowledge/patterns/design/test-driven-design-pattern.md +37 -3
  342. package/one/knowledge/patterns/design/wireframe-template.md +36 -2
  343. package/one/knowledge/patterns/frontend/component-template.md +91 -40
  344. package/one/knowledge/patterns/frontend/form-template.md +131 -59
  345. package/one/knowledge/patterns/frontend/page-template.md +59 -28
  346. package/one/knowledge/patterns/frontend/react-component-pattern.md +87 -27
  347. package/one/knowledge/patterns/test/acceptance-criteria-template.md +28 -10
  348. package/one/knowledge/patterns/test/technical-test-template.md +48 -26
  349. package/one/knowledge/patterns/test/test-driven-pattern.md +25 -5
  350. package/one/knowledge/patterns/test/user-flow-template.md +18 -0
  351. package/one/knowledge/provider-agnostic-content.md +995 -0
  352. package/one/knowledge/provider-creation-guide.md +18 -0
  353. package/one/knowledge/quality-loop.md +18 -0
  354. package/one/knowledge/readme-architecture.md +158 -0
  355. package/one/knowledge/readme.md +18 -0
  356. package/one/knowledge/rules.md +18 -0
  357. package/one/knowledge/score.md +18 -0
  358. package/one/knowledge/specifications.md +18 -0
  359. package/one/knowledge/tags.md +18 -0
  360. package/one/knowledge/todo-template.md +18 -0
  361. package/one/knowledge/todo.md +18 -0
  362. package/one/knowledge/typescript-patterns.md +18 -0
  363. package/one/knowledge/universal-generation-language.md +827 -0
  364. package/one/knowledge/x402-research.md +104 -0
  365. package/one/license.md +18 -0
  366. package/one/people/anthony-o-connell.md +48 -19
  367. package/one/people/people.md +54 -31
  368. package/one/things/ALIGNMENT_AUDIT_QUALITY_AGENT.md +401 -0
  369. package/one/things/AUDIT_AGENT_INTEGRATOR_ALIGNMENT.md +588 -0
  370. package/one/things/AUDIT_REPORT_AGENT_CLEAN.md +461 -0
  371. package/one/things/CHECKLIST.md +51 -0
  372. package/one/things/IMPLEMENTATION_STATUS.md +379 -0
  373. package/one/things/ONE.md +19 -1
  374. package/one/things/agents/agent-backend.md +198 -98
  375. package/one/things/agents/agent-builder.md +267 -158
  376. package/one/things/agents/agent-clean.md +40 -15
  377. package/one/things/agents/agent-clone.md +33 -50
  378. package/one/things/agents/agent-deploy.md +59 -11
  379. package/one/things/agents/agent-designer.md +274 -146
  380. package/one/things/agents/agent-director.md +20 -2
  381. package/one/things/agents/agent-documenter.md +126 -46
  382. package/one/things/agents/agent-frontend.md +104 -22
  383. package/one/things/agents/agent-integrator.md +153 -76
  384. package/one/things/agents/agent-lawyer.md +197 -92
  385. package/one/things/agents/agent-problem-solver.md +302 -224
  386. package/one/things/agents/agent-quality.md +149 -19
  387. package/one/things/agents/agent-sales.md +95 -7
  388. package/one/things/cascade/cascade.yaml +20 -3
  389. package/one/things/cascade/docs/examples/1-1-agent-prompts/design.md +53 -0
  390. package/one/things/cascade/docs/examples/1-1-agent-prompts/tests.md +50 -0
  391. package/one/things/cascade/docs/examples/1-1-agent-prompts.md +76 -0
  392. package/one/things/cascade/docs/examples/1-2-yaml-orchestrator/design.md +49 -3
  393. package/one/things/cascade/docs/examples/1-2-yaml-orchestrator/tests.md +45 -0
  394. package/one/things/cascade/docs/examples/1-2-yaml-orchestrator.md +32 -0
  395. package/one/things/cascade/docs/examples/1-3-event-coordination/design.md +45 -3
  396. package/one/things/cascade/docs/examples/1-3-event-coordination/tests.md +44 -0
  397. package/one/things/cascade/docs/examples/1-3-event-coordination.md +40 -1
  398. package/one/things/cascade/docs/examples/1-4-knowledge-management/design.md +81 -25
  399. package/one/things/cascade/docs/examples/1-4-knowledge-management/tests.md +41 -0
  400. package/one/things/cascade/docs/examples/1-4-knowledge-management.md +91 -16
  401. package/one/things/cascade/docs/examples/1-5-quality-loops/design.md +136 -73
  402. package/one/things/cascade/docs/examples/1-5-quality-loops/tests.md +43 -0
  403. package/one/things/cascade/docs/examples/1-5-quality-loops.md +88 -4
  404. package/one/things/cascade/docs/examples/1-6-numbering-structure/design.md +52 -3
  405. package/one/things/cascade/docs/examples/1-6-numbering-structure/tests.md +44 -1
  406. package/one/things/cascade/docs/examples/1-6-numbering-structure.md +78 -14
  407. package/one/things/cascade/docs/examples/readme.md +37 -0
  408. package/one/things/cascade/docs/getting-started.md +18 -0
  409. package/one/things/cascade/docs/workflow.md +18 -12
  410. package/one/things/cascade/readme.md +43 -0
  411. package/one/things/cascade/templates/feature-template.md +28 -6
  412. package/one/things/claude/agents/advocacy-activation-manager.md +64 -39
  413. package/one/things/claude/agents/advocacy-campaign-designer.md +64 -39
  414. package/one/things/claude/agents/analyst.md +64 -39
  415. package/one/things/claude/agents/architect.md +64 -39
  416. package/one/things/claude/agents/brand-identity-specialist.md +64 -39
  417. package/one/things/claude/agents/bstp-token-strategist.md +48 -25
  418. package/one/things/claude/agents/builder-repo.md +69 -26
  419. package/one/things/claude/agents/bullstamp-community-builder.md +48 -25
  420. package/one/things/claude/agents/bullstamp-marketing-orchestrator.md +48 -25
  421. package/one/things/claude/agents/bulltilt-platform-growth.md +48 -25
  422. package/one/things/claude/agents/company-bullstamp-character.md +45 -30
  423. package/one/things/claude/agents/company-bullstamp-community.md +45 -30
  424. package/one/things/claude/agents/company-bullstamp-marketing.md +45 -30
  425. package/one/things/claude/agents/company-bullstamp-token.md +45 -30
  426. package/one/things/claude/agents/company-bulltilt-growth.md +45 -30
  427. package/one/things/claude/agents/content-bibliography-formatter.md +48 -25
  428. package/one/things/claude/agents/content-calendar-planner.md +59 -34
  429. package/one/things/claude/agents/content-chapter-formatter.md +60 -35
  430. package/one/things/claude/agents/content-formatter.md +59 -34
  431. package/one/things/claude/agents/content-hook-specialist.md +54 -31
  432. package/one/things/claude/agents/content-image-formatter.md +59 -34
  433. package/one/things/claude/agents/content-introduction-formatter.md +59 -34
  434. package/one/things/claude/agents/content-multiplication-engine.md +54 -31
  435. package/one/things/claude/agents/content-playbook-writer.md +60 -35
  436. package/one/things/claude/agents/content-team-manager.md +59 -34
  437. package/one/things/claude/agents/content-toc-formatter.md +60 -35
  438. package/one/things/claude/agents/convex-backend-specialist.md +380 -216
  439. package/one/things/claude/agents/core-manager.md +59 -34
  440. package/one/things/claude/agents/core-master.md +55 -32
  441. package/one/things/claude/agents/cross-functional-manager.md +46 -41
  442. package/one/things/claude/agents/crypto-airdrop-strategist.md +74 -54
  443. package/one/things/claude/agents/crypto-analytics-educator.md +73 -30
  444. package/one/things/claude/agents/crypto-architecture-specialist.md +70 -39
  445. package/one/things/claude/agents/crypto-community-analyst.md +47 -31
  446. package/one/things/claude/agents/crypto-community-psychologist.md +68 -31
  447. package/one/things/claude/agents/crypto-dex-optimization-expert.md +72 -31
  448. package/one/things/claude/agents/crypto-dex-optimizer.md +45 -30
  449. package/one/things/claude/agents/crypto-diamond-formation-specialist.md +69 -30
  450. package/one/things/claude/agents/crypto-diamond-hands.md +45 -30
  451. package/one/things/claude/agents/crypto-ecosystem-expansion-manager.md +73 -30
  452. package/one/things/claude/agents/crypto-engagement-specialist.md +71 -30
  453. package/one/things/claude/agents/crypto-market-researcher.md +45 -30
  454. package/one/things/claude/agents/crypto-marketing-orchestrator.md +74 -34
  455. package/one/things/claude/agents/crypto-network-effect-amplifier.md +75 -30
  456. package/one/things/claude/agents/crypto-optimization-analyst.md +73 -30
  457. package/one/things/claude/agents/crypto-strategic-synthesizer.md +69 -30
  458. package/one/things/claude/agents/crypto-team-manager.md +45 -40
  459. package/one/things/claude/agents/crypto-token-analyst.md +66 -25
  460. package/one/things/claude/agents/crypto-viral-content-creator.md +64 -61
  461. package/one/things/claude/agents/crypto-wallet-identification-expert.md +61 -51
  462. package/one/things/claude/agents/crypto-wallet-identifier.md +45 -30
  463. package/one/things/claude/agents/customer-journey-designer.md +51 -58
  464. package/one/things/claude/agents/customer-success-manager.md +51 -58
  465. package/one/things/claude/agents/dev.md +51 -58
  466. package/one/things/claude/agents/documenter.md +71 -69
  467. package/one/things/claude/agents/elevate-marketing-orchestrator.md +45 -52
  468. package/one/things/claude/agents/engagement-specialist.md +45 -52
  469. package/one/things/claude/agents/engineering-architect.md +54 -54
  470. package/one/things/claude/agents/engineering-business-analyst.md +46 -56
  471. package/one/things/claude/agents/engineering-developer.md +51 -52
  472. package/one/things/claude/agents/engineering-director.md +65 -25
  473. package/one/things/claude/agents/engineering-ingestor.md +110 -100
  474. package/one/things/claude/agents/engineering-product-manager.md +43 -55
  475. package/one/things/claude/agents/engineering-product-owner.md +46 -56
  476. package/one/things/claude/agents/engineering-project-coordinator.md +44 -56
  477. package/one/things/claude/agents/engineering-quality-assurance.md +53 -54
  478. package/one/things/claude/agents/engineering-team-manager.md +46 -43
  479. package/one/things/claude/agents/engineering-user-experience.md +51 -52
  480. package/one/things/claude/agents/framework-elevate-manager.md +45 -30
  481. package/one/things/claude/agents/improver.md +120 -78
  482. package/one/things/claude/agents/intelligence-team-manager.md +45 -40
  483. package/one/things/claude/agents/lead-capture-expert.md +45 -52
  484. package/one/things/claude/agents/lead-magnet-creator.md +45 -52
  485. package/one/things/claude/agents/market-research-analyst.md +48 -25
  486. package/one/things/claude/agents/marketing-brand-identity.md +57 -27
  487. package/one/things/claude/agents/marketing-content-hooks.md +45 -40
  488. package/one/things/claude/agents/marketing-content-multiplier.md +45 -40
  489. package/one/things/claude/agents/marketing-content-poster.md +71 -60
  490. package/one/things/claude/agents/marketing-customer-journey.md +45 -40
  491. package/one/things/claude/agents/marketing-director.md +46 -41
  492. package/one/things/claude/agents/marketing-engagement.md +45 -40
  493. package/one/things/claude/agents/marketing-lead-capture.md +45 -40
  494. package/one/things/claude/agents/marketing-lead-magnet.md +45 -40
  495. package/one/things/claude/agents/marketing-network-effects.md +45 -40
  496. package/one/things/claude/agents/marketing-nurture-campaigns.md +45 -40
  497. package/one/things/claude/agents/marketing-share-optimizer.md +45 -40
  498. package/one/things/claude/agents/marketing-team-manager.md +45 -40
  499. package/one/things/claude/agents/marketing-viral-growth.md +49 -18
  500. package/one/things/claude/agents/mission-commander.md +45 -40
  501. package/one/things/claude/agents/network-effect-analyst.md +48 -31
  502. package/one/things/claude/agents/nextjs-15-specialist.md +209 -122
  503. package/one/things/claude/agents/npx.md +126 -70
  504. package/one/things/claude/agents/nurture-campaign-manager.md +48 -25
  505. package/one/things/claude/agents/one-master.md +48 -25
  506. package/one/things/claude/agents/one-orchestrator.md +57 -27
  507. package/one/things/claude/agents/one.md +88 -31
  508. package/one/things/claude/agents/playbook-generator.md +48 -25
  509. package/one/things/claude/agents/pm.md +48 -25
  510. package/one/things/claude/agents/po.md +51 -26
  511. package/one/things/claude/agents/qa.md +50 -25
  512. package/one/things/claude/agents/research-foundation-analyst.md +48 -31
  513. package/one/things/claude/agents/research-intelligence-gatherer.md +59 -32
  514. package/one/things/claude/agents/research-market-analyst.md +47 -30
  515. package/one/things/claude/agents/research-team-manager.md +47 -40
  516. package/one/things/claude/agents/sales-environment-optimizer.md +50 -25
  517. package/one/things/claude/agents/sales-team-manager.md +47 -40
  518. package/one/things/claude/agents/sales-upsell-strategist.md +47 -30
  519. package/one/things/claude/agents/service-advocacy-campaigns.md +47 -30
  520. package/one/things/claude/agents/service-advocacy-manager.md +47 -30
  521. package/one/things/claude/agents/service-success-manager.md +47 -30
  522. package/one/things/claude/agents/service-team-manager.md +45 -40
  523. package/one/things/claude/agents/shadcn-ui-design-system-specialist.md +85 -30
  524. package/one/things/claude/agents/share-optimization-specialist.md +50 -25
  525. package/one/things/claude/agents/sm.md +50 -25
  526. package/one/things/claude/agents/story-teller.md +51 -26
  527. package/one/things/claude/agents/task-master.md +52 -27
  528. package/one/things/claude/agents/tauri-cross-platform-specialist.md +201 -116
  529. package/one/things/claude/agents/tester.md +85 -46
  530. package/one/things/claude/agents/the-bull-character-manager.md +48 -25
  531. package/one/things/claude/agents/tools-playbook-generator.md +43 -40
  532. package/one/things/claude/agents/turbo-repo-builder.md +57 -27
  533. package/one/things/claude/agents/upsell-strategist.md +48 -25
  534. package/one/things/claude/agents/ux-expert.md +50 -25
  535. package/one/things/claude/agents/viral-growth-orchestrator.md +50 -27
  536. package/one/things/claude/commands/agent.md +25 -5
  537. package/one/things/claude/commands/cascade-status.md +33 -8
  538. package/one/things/claude/commands/ingest.md +64 -11
  539. package/one/things/claude/commands/ingestor.md +29 -7
  540. package/one/things/claude/commands/mission.md +24 -4
  541. package/one/things/claude/commands/npx.md +30 -7
  542. package/one/things/claude/commands/one.md +114 -68
  543. package/one/things/claude/commands/quality-check.md +72 -24
  544. package/one/things/claude/commands/smart-route.md +45 -4
  545. package/one/things/claude/commands/start.md +22 -4
  546. package/one/things/claude/commands/story.md +25 -5
  547. package/one/things/claude/commands/task.md +21 -1
  548. package/one/things/cli/cli-code.md +244 -219
  549. package/one/things/cli/cli-compiler-code.md +244 -219
  550. package/one/things/cli/cli.md +30 -6
  551. package/one/things/components/card-shadcn.md +252 -228
  552. package/one/things/components/card.md +315 -324
  553. package/one/things/components.md +667 -593
  554. package/one/things/componets.md +16 -1
  555. package/one/things/creator-diagram.md +23 -5
  556. package/one/things/demo-accessibility-animations.md +73 -47
  557. package/one/things/demo-components.md +225 -219
  558. package/one/things/demo-design-summary.md +89 -26
  559. package/one/things/demo-design-system.md +184 -130
  560. package/one/things/demo-page-layouts.md +52 -25
  561. package/one/things/designs/accessibility-audit.md +153 -66
  562. package/one/things/designs/component-specifications.md +163 -65
  563. package/one/things/designs/design-overview.md +81 -22
  564. package/one/things/designs/design-tokens.md +127 -93
  565. package/one/things/designs/wireframes-dashboard.md +64 -7
  566. package/one/things/docs/api-requests.md +75 -11
  567. package/one/things/docs/ecommerce/ARCHITECTURE-DIAGRAM.md +18 -0
  568. package/one/things/docs/ecommerce/CONVERSION-ELEMENTS-IMPLEMENTATION.md +57 -0
  569. package/one/things/docs/ecommerce/CONVERSION-ELEMENTS-SUMMARY.md +62 -6
  570. package/one/things/docs/ecommerce/CONVERSION-UX-IMPLEMENTATION-SUMMARY.md +60 -5
  571. package/one/things/docs/ecommerce/FEATURE-SUMMARY.md +95 -27
  572. package/one/things/docs/ecommerce/IMPLEMENTATION-NOTES.md +130 -62
  573. package/one/things/docs/ecommerce/INTEGRATION-EXAMPLE.md +43 -19
  574. package/one/things/docs/ecommerce/QUICK-START.md +41 -4
  575. package/one/things/docs/ecommerce/URGENCY-IMPLEMENTATION-SUMMARY.md +75 -6
  576. package/one/things/docs/ecommerce/URGENCY-QUICK-REFERENCE.md +58 -24
  577. package/one/things/examples/children/lemonade-stand.md +52 -14
  578. package/one/things/examples/enterprise/crm-saas.md +43 -28
  579. package/one/things/features/1-1-agent-prompts.md +76 -0
  580. package/one/things/features/1-2-yaml-orchestrator.md +32 -0
  581. package/one/things/features/1-3-event-coordination.md +40 -1
  582. package/one/things/features/1-4-knowledge-management.md +91 -16
  583. package/one/things/features/1-5-quality-loops.md +88 -4
  584. package/one/things/features/1-6-numbering-structure.md +78 -14
  585. package/one/things/features/2-1-dataprovider-interface.md +311 -86
  586. package/one/things/features/2-2-config-system.md +307 -140
  587. package/one/things/features/2-3-effectts-services.md +263 -116
  588. package/one/things/features/2-4-react-hooks.md +217 -201
  589. package/one/things/features/2-5-auth-migration.md +406 -308
  590. package/one/things/features/2-6-dashboard-migration.md +112 -13
  591. package/one/things/features/2-7-alternative-providers.md +138 -65
  592. package/one/things/features/2-7-implementation-report.md +68 -24
  593. package/one/things/features/2-cli.md +88 -76
  594. package/one/things/features/2-design.md +112 -80
  595. package/one/things/features/2-tests.md +56 -0
  596. package/one/things/features/AUTH_HOOKS_IMPLEMENTATION.md +91 -36
  597. package/one/things/features/DECOUPLING.md +36 -18
  598. package/one/things/features/DEPLOYMENT.md +22 -4
  599. package/one/things/features/IMPLEMENTATION_SUMMARY.md +48 -2
  600. package/one/things/features/improve.md +47 -29
  601. package/one/things/features/remove-convex-deps.md +18 -0
  602. package/one/things/features/top-features.md +28 -20
  603. package/one/things/features/use-one-backend.md +210 -173
  604. package/one/things/features-in-english.md +19 -6
  605. package/one/things/files.yaml +721 -0
  606. package/one/things/ideas/1-create-workflow.md +18 -0
  607. package/one/things/ideas/2-backend-agnostic-frontend.md +57 -2
  608. package/one/things/implementation/backend-guide.md +64 -19
  609. package/one/things/interface.md +43 -0
  610. package/one/things/landing-page-implementation.md +455 -0
  611. package/one/things/legal/README.md +44 -0
  612. package/one/things/legal/privacy-policy.md +186 -23
  613. package/one/things/legal/terms-of-service.md +164 -3
  614. package/one/things/master-workflow-plan.md +806 -0
  615. package/one/things/plans/0-timeline.md +36 -0
  616. package/one/things/plans/1-create-workflow.md +19 -0
  617. package/one/things/plans/QUICK-START-SIMPLIFICATION.md +333 -0
  618. package/one/things/plans/README-SIMPLIFICATION.md +349 -0
  619. package/one/things/plans/SIMPLIFICATION-EXAMPLES.md +16 -0
  620. package/one/things/plans/SIMPLIFICATION-SUMMARY.md +455 -0
  621. package/one/things/plans/ai-elements.md +21 -2
  622. package/one/things/plans/ai-integration.md +108 -59
  623. package/one/things/plans/ai-sdk.md +85 -48
  624. package/one/things/plans/ai-tools.md +621 -0
  625. package/one/things/plans/app.md +142 -71
  626. package/one/things/plans/architecture-summary.md +34 -5
  627. package/one/things/plans/async-ai-agents.md +19 -1
  628. package/one/things/plans/backend-agnostic-frontend.md +70 -8
  629. package/one/things/plans/backend-cleanup-quickstart.md +52 -18
  630. package/one/things/plans/backend-ontology-conformance.md +110 -51
  631. package/one/things/plans/backend-status.md +58 -0
  632. package/one/things/plans/backend-structure.md +103 -55
  633. package/one/things/plans/backend-target-structure.md +61 -17
  634. package/one/things/plans/backend.md +60 -18
  635. package/one/things/plans/better-auth-any-backend-revised.md +325 -287
  636. package/one/things/plans/better-auth-any-backend.md +575 -531
  637. package/one/things/plans/better-auth-available-features.md +43 -5
  638. package/one/things/plans/big-plan.md +20 -6
  639. package/one/things/plans/cli-updates-required.md +44 -4
  640. package/one/things/plans/complete-step-by-step.md +223 -116
  641. package/one/things/plans/components.md +709 -0
  642. package/one/things/plans/convex-agents.md +79 -50
  643. package/one/things/plans/convex-better-auth.md +186 -154
  644. package/one/things/plans/convex-on-off.md +47 -29
  645. package/one/things/plans/crypto-token-researcher.md +629 -0
  646. package/one/things/plans/data-quality-metrics.md +745 -0
  647. package/one/things/plans/deep-researcher-agent.md +466 -0
  648. package/one/things/plans/deploy-to-cloudflare.md +55 -13
  649. package/one/things/plans/deployment-architecture.md +54 -11
  650. package/one/things/plans/desktop.md +21 -3
  651. package/one/things/plans/development-plan.md +184 -121
  652. package/one/things/plans/development-workflow-tldr.md +207 -0
  653. package/one/things/plans/development-workflow.md +959 -0
  654. package/one/things/plans/effect-components.md +667 -593
  655. package/one/things/plans/effect-patterns-reference.md +2235 -0
  656. package/one/things/plans/effect.md +204 -131
  657. package/one/things/plans/email.md +21 -8
  658. package/one/things/plans/enhance-auth.md +64 -41
  659. package/one/things/plans/execution-strategy.md +1291 -0
  660. package/one/things/plans/existing-infrastructure.md +712 -0
  661. package/one/things/plans/feature-based-sites.md +124 -51
  662. package/one/things/plans/frontend-effects.md +1276 -0
  663. package/one/things/plans/group-folder-multi-tenancy.md +92 -29
  664. package/one/things/plans/improve-codebase.md +498 -421
  665. package/one/things/plans/install-components.md +18 -1
  666. package/one/things/plans/integrate-frontend-and-backend.md +68 -44
  667. package/one/things/plans/landing.md +92 -0
  668. package/one/things/plans/layout.md +45 -1
  669. package/one/things/plans/mail-backend.md +546 -493
  670. package/one/things/plans/mail.md +379 -326
  671. package/one/things/plans/mcp-clear-context-prompt.md +21 -0
  672. package/one/things/plans/mcp-simple.md +20 -0
  673. package/one/things/plans/multi-ontology-architecture.md +115 -66
  674. package/one/things/plans/next-features.md +31 -0
  675. package/one/things/plans/onboarding.md +20 -1
  676. package/one/things/plans/one.md +18 -0
  677. package/one/things/plans/ontology-6-dimensions.md +24 -45
  678. package/one/things/plans/ontology-compliance-audit.md +315 -0
  679. package/one/things/plans/ontology-driven-strategy.md +19 -3
  680. package/one/things/plans/ontology-refine.md +586 -0
  681. package/one/things/plans/ontology-ui-approach.md +18 -0
  682. package/one/things/plans/open-agent.md +152 -97
  683. package/one/things/plans/performace.md +32 -0
  684. package/one/things/plans/phase-1-foundation.md +620 -0
  685. package/one/things/plans/phase-3-implementation.md +1037 -0
  686. package/one/things/plans/quick-wins.md +342 -187
  687. package/one/things/plans/readme-backend-cleanup.md +54 -13
  688. package/one/things/plans/release.md +55 -2
  689. package/one/things/plans/repos.md +22 -0
  690. package/one/things/plans/separate-copy-2.md +127 -71
  691. package/one/things/plans/separate-copy-3.md +35 -14
  692. package/one/things/plans/separate-copy.md +127 -71
  693. package/one/things/plans/separate-demo.md +37 -3
  694. package/one/things/plans/separate.md +24 -6
  695. package/one/things/plans/sequence.md +155 -12
  696. package/one/things/plans/shadcn-integration-summary.md +104 -44
  697. package/one/things/plans/sidebar.md +44 -10
  698. package/one/things/plans/skills.md +103 -0
  699. package/one/things/plans/small-fixes.md +19 -1
  700. package/one/things/plans/start-new.md +34 -8
  701. package/one/things/plans/switch-off-auth.md +22 -0
  702. package/one/things/plans/sync-checklist.md +30 -0
  703. package/one/things/plans/test-backend-connection.md +38 -0
  704. package/one/things/plans/unified-implementation-plan.md +144 -62
  705. package/one/things/plans/update-demos.md +103 -35
  706. package/one/things/plans/use-our-backend.md +572 -0
  707. package/one/things/plans/wave1-onboarding-100-inferences.md +1686 -0
  708. package/one/things/plans/wave1-onboarding-vision.md +744 -0
  709. package/one/things/plans/wave1-orchestration-summary.md +604 -0
  710. package/one/things/plans/wave1-specialist-assignments.md +1413 -0
  711. package/one/things/plans/workflow-files.md +28 -14
  712. package/one/things/plans/workflow.md +18 -12
  713. package/one/things/products/cascade-landing-page.md +150 -46
  714. package/one/things/products/cascade.md +185 -135
  715. package/one/things/products/context-engineering.md +411 -350
  716. package/one/things/products/onthology.md +15 -0
  717. package/one/things/products/ontology-ui-shadcn.md +375 -353
  718. package/one/things/products/ontology-ui.md +101 -59
  719. package/one/things/products/ontology.md +90 -18
  720. package/one/things/products/sdk.md +181 -165
  721. package/one/things/promptkit.md +70 -43
  722. package/one/things/repos/all-repos.md +0 -0
  723. package/one/things/service-providers-new.md +95 -25
  724. package/one/things/service-providers.md +231 -202
  725. package/one/things/structure.md +532 -0
  726. package/one/things/system.md +18 -0
  727. package/one/things/templates.md +40 -0
  728. package/one/things/tests/2-1-dataprovider-interface.md +103 -31
  729. package/one/things/tests/2-1-test-analysis.md +65 -17
  730. package/one/things/things.md +48 -13
  731. package/one/things/todo-acp-integration.md +744 -0
  732. package/one/things/todo-ai.md +933 -0
  733. package/one/things/todo-api.md +1078 -0
  734. package/one/things/todo-assignment.md +580 -0
  735. package/one/things/todo-buy-chatgpt.md +1450 -0
  736. package/one/things/todo-components.md +1683 -0
  737. package/one/things/todo-connections.md +278 -0
  738. package/one/things/todo-ecommerce-frontend.md +1313 -0
  739. package/one/things/todo-ecommerce.md +569 -0
  740. package/one/things/todo-effects.md +1075 -0
  741. package/one/things/todo-frontend-effects.md +977 -0
  742. package/one/things/todo-landing-page.md +1091 -0
  743. package/one/things/todo-mail.md +1160 -0
  744. package/one/things/todo-master-plan.md +490 -0
  745. package/one/things/todo-onboard.md +666 -0
  746. package/one/things/todo-one-ie.md +538 -0
  747. package/one/things/todo-page.md +606 -0
  748. package/one/things/todo-plans.md +282 -0
  749. package/one/things/todo-projects.md +241 -0
  750. package/one/things/todo-refactoring-plan.md +366 -0
  751. package/one/things/todo-sequence.md +1621 -0
  752. package/one/things/todo-use-our-backend.md +1908 -0
  753. package/one/things/todo-workflow.md +626 -0
  754. package/one/things/todo-x402.md +2047 -0
  755. package/one/things/todo.md +459 -1075
  756. package/one/things/video/scripts-crypto.md +835 -0
  757. package/one/things/video-script-ontology.md +334 -0
  758. package/package.json +1 -1
  759. package/one/knowledge/CLOUDFLARE_ENV_SETUP.md +0 -49
  760. package/one/knowledge/docs/flow.md +0 -0
  761. package/one/knowledge/documentation-summary.md +0 -285
  762. package/one/knowledge/inference-score.md +0 -159
  763. package/one/knowledge/ontology-frontend-copy-2.md +0 -1492
  764. package/one/knowledge/ontology-frontend-copy.md +0 -753
  765. package/one/knowledge/ontology-migration-guide.md +0 -811
  766. package/one/things/features/0 All Features.md +0 -2
  767. package/one/things/plans/1-create-workflow-status.md +0 -555
  768. package/one/things/plans/2-backend-agnostic-frontend.md +0 -546
  769. package/one/things/plans/2-sites.md +0 -895
  770. package/one/things/plans/3-groups.md +0 -735
  771. package/one/things/plans/5-build-frontend.md +0 -0
  772. package/one/things/plans/5-complete.md +0 -17
  773. package/one/things/plans/agent-director-100-inference-plans.md +0 -410
  774. package/one/things/plans/dual-website-strategy.md +0 -612
  775. package/one/things/plans/releases.md +0 -809
@@ -0,0 +1,2898 @@
1
+ ---
2
+ title: Ontology Frontend Master
3
+ dimension: knowledge
4
+ category: ontology-frontend-master.md
5
+ tags: 6-dimensions, architecture, backend, frontend, ontology, ui
6
+ related_dimensions: events, groups, things
7
+ scope: global
8
+ created: 2025-11-03
9
+ updated: 2025-11-03
10
+ version: 1.0.0
11
+ ai_context: |
12
+ This document is part of the knowledge dimension in the ontology-frontend-master.md category.
13
+ Location: one/knowledge/ontology-frontend-master.md
14
+ Purpose: Documents frontend development ontology - master reference
15
+ Related dimensions: events, groups, things
16
+ For AI agents: Read this to understand ontology frontend master.
17
+ ---
18
+
19
+ # Frontend Development Ontology - Master Reference
20
+
21
+ **Version:** 2.1.0
22
+ **Type System:** Formal ontology for backend-agnostic Astro website development
23
+ **Paradigm:** Pure declarative type theory + Provider pattern + Context engineering
24
+
25
+ **Master Document:** Unified reference combining architecture, specifications, and patterns
26
+
27
+ ---
28
+
29
+ ## Table of Contents
30
+
31
+ 1. [Overview](#overview)
32
+ 2. [Core Axioms](#core-axioms)
33
+ 3. [Architecture Overview](#architecture-overview)
34
+ 4. [Provider Pattern & Context Engineering](#provider-pattern--context-engineering)
35
+ 5. [Type Hierarchy](#type-hierarchy)
36
+ 6. [What Frontend IS and IS NOT](#what-frontend-is-and-is-not)
37
+ 7. [Frontend File Structure](#frontend-file-structure)
38
+ 8. [Backend-Agnostic Data Layer](#backend-agnostic-data-layer)
39
+ 9. [DataProvider Interface](#dataprovider-interface)
40
+ 10. [Provider Implementations](#provider-implementations)
41
+ 11. [Configuration](#configuration)
42
+ 12. [State Management Hierarchy](#state-management-hierarchy)
43
+ 13. [Effect.ts Service Layer](#effectts-service-layer)
44
+ 14. [React Hooks & Integration](#react-hooks--integration)
45
+ 15. [Component Patterns](#component-patterns)
46
+ 16. [Page Patterns & SSR](#page-patterns--ssr)
47
+ 17. [Real-Time Components](#real-time-components)
48
+ 18. [Forms & Data Mutations](#forms--data-mutations)
49
+ 19. [Multi-Tenant Routing](#multi-tenant-routing)
50
+ 20. [Caching Ontology](#caching-ontology)
51
+ 21. [Error Propagation & Handling](#error-propagation--handling)
52
+ 22. [Testing Patterns](#testing-patterns)
53
+ 23. [Common Mistakes & Solutions](#common-mistakes--solutions)
54
+ 24. [Summary & Key Patterns](#summary--key-patterns)
55
+
56
+ ---
57
+
58
+ ## Overview
59
+
60
+ The frontend is **purely a rendering and interaction layer**. It has:
61
+
62
+ - ✅ ZERO database access (provider abstracts)
63
+ - ✅ ZERO business logic (backend validates)
64
+ - ✅ ZERO direct backend coupling (interface-based)
65
+ - ✅ 100% backend-agnostic code
66
+
67
+ **What Frontend Does:**
68
+
69
+ 1. **Renders UI** from data via Astro + React
70
+ 2. **Calls backend APIs** via abstract DataProvider interface (works with Convex, WordPress, Notion, Supabase, etc.)
71
+ 3. **Manages local UI state** (loading, errors, forms, modals)
72
+ 4. **Displays real-time updates** via subscriptions (if backend supports)
73
+
74
+ **Backend Abstraction:**
75
+
76
+ ```
77
+ ┌─────────────────────────────────────────┐
78
+ │ FRONTEND (Astro + React + Effect.ts) │
79
+ │ ✅ Renders UI │
80
+ │ ✅ Calls DataProvider interface │
81
+ │ ✅ Manages UI state only │
82
+ │ ❌ NO database, logic, validation │
83
+ └──────────────────┬──────────────────────┘
84
+ │ DataProvider Interface
85
+ │ (6-dimension ontology)
86
+ ↓
87
+ ┌─────────────────────────────────────────┐
88
+ │ BACKEND PROVIDERS (Choose One) │
89
+ │ ├─ ConvexProvider │
90
+ │ ├─ WordPressProvider │
91
+ │ ├─ NotionProvider │
92
+ │ ├─ SupabaseProvider │
93
+ │ └─ CustomProvider │
94
+ └─────────────────────────────────────────┘
95
+ ```
96
+
97
+ **Key Insight:** The 6-dimension ontology becomes a **universal data API**. Frontend doesn't care if data comes from Convex, WordPress, or Notion—it only knows the interface.
98
+
99
+ ---
100
+
101
+ ## Core Axioms
102
+
103
+ ### Axiom 1: Everything is a Thing
104
+
105
+ ```
106
+ ∀x ∈ Frontend → x : Thing
107
+ Thing ::= Page | Component | Content | Service | Provider | Configuration
108
+ ```
109
+
110
+ ### Axiom 2: All Things Have Type
111
+
112
+ ```
113
+ type : Thing → TypeID
114
+ TypeID ::= String ∈ ontology.things.types
115
+ ```
116
+
117
+ ### Axiom 3: Things Connect
118
+
119
+ ```
120
+ connect : Thing × Thing → Connection
121
+ Connection ::= { from: Thing, to: Thing, type: RelationType, metadata: Object }
122
+ ```
123
+
124
+ ### Axiom 4: Actions Emit Events
125
+
126
+ ```
127
+ action : Thing → Event
128
+ Event ::= { type: EventType, actor: Thing, target: Thing, timestamp: Time, metadata: Object }
129
+ ```
130
+
131
+ ### Axiom 5: Patterns Compose
132
+
133
+ ```
134
+ compose : Pattern × Pattern → Pattern
135
+ Pattern ::= { type: PatternType, inputs: [Thing], outputs: [Thing], transform: Function }
136
+ ```
137
+
138
+ ### Axiom 6: Backend Agnosticism
139
+
140
+ ```
141
+ ∀Provider. Provider implements DataProviderInterface → Frontend works with Provider
142
+ DataProviderInterface ::= { organizations, people, things, connections, events, knowledge }
143
+ ```
144
+
145
+ ### Axiom 7: Context Minimalism
146
+
147
+ ```
148
+ ∀Operation. Load only required types, not implementations
149
+ ContextUsed << ContextAvailable
150
+ target_reduction: 98%+
151
+ ```
152
+
153
+ **Key Principle:** Frontend knows 6-dimension ontology, not backend implementation.
154
+
155
+ ---
156
+
157
+ ## Architecture Overview
158
+
159
+ ### Three-Layer Backend-Agnostic Architecture
160
+
161
+ ```
162
+ ┌──────────────────────────────────────┐
163
+ │ RENDERING LAYER (Astro + React) │
164
+ │ - SSR pages (.astro files) │
165
+ │ - Interactive components (.tsx) │
166
+ │ - Astro islands for interactivity │
167
+ └──────────────────┬───────────────────┘
168
+ │ Effect.ts
169
+ ↓
170
+ ┌──────────────────────────────────────┐
171
+ │ SERVICE LAYER (Effect.ts) │
172
+ │ - ThingService │
173
+ │ - ConnectionService │
174
+ │ - Type-safe error handling │
175
+ │ - Composable operations │
176
+ └──────────────────┬───────────────────┘
177
+ │ DataProviderInterface
178
+ ↓
179
+ ┌──────────────────────────────────────┐
180
+ │ DATA LAYER (Providers) │
181
+ │ - ConvexProvider (Convex backend) │
182
+ │ - WordPressProvider (WordPress) │
183
+ │ - NotionProvider (Notion) │
184
+ │ - SupabaseProvider (PostgreSQL) │
185
+ │ - CustomProvider (Any API) │
186
+ └──────────────────────────────────────┘
187
+ ```
188
+
189
+ **Why Three Layers?**
190
+
191
+ - **Rendering Layer:** HTML output (SSR fast, SEO friendly)
192
+ - **Service Layer:** Type-safe business operations (Effect.ts)
193
+ - **Data Layer:** Backend abstraction (swap backends by changing 1 config line)
194
+
195
+ **Tech Stack:**
196
+
197
+ - **Astro 5.14+** - SSR/SSG with file-based routing
198
+ - **React 19** - Interactive components with islands architecture
199
+ - **Effect.ts** - Type-safe, composable operations
200
+ - **DataProvider Pattern** - Backend-agnostic interface
201
+ - **Tailwind + shadcn/ui** - Component styling
202
+ - **TypeScript 5.9+** - Strict type safety
203
+
204
+ ---
205
+
206
+ ## Provider Pattern & Context Engineering
207
+
208
+ ### The Core Insight: Providers ARE Context Loaders
209
+
210
+ **Problem:** Traditional frontend development loads massive context to interact with one backend.
211
+
212
+ **Solution:** Provider pattern = 99.9% context reduction through interface abstraction.
213
+
214
+ ```typescript
215
+ {
216
+ // ❌ Traditional: Load entire backend
217
+ traditionalApproach: {
218
+ load: "Full Convex schema + all implementations + all docs",
219
+ tokens: 280_000,
220
+ problem: "Frontend context explodes with backend knowledge"
221
+ }
222
+
223
+ // ✅ Provider pattern: Load only interface
224
+ providerApproach: {
225
+ load: "DataProviderInterface only (contract)",
226
+ tokens: 300,
227
+ benefit: "Frontend never loads backend implementation"
228
+ }
229
+
230
+ result: {
231
+ context_reduction: "99.9%",
232
+ backend_flexibility: "infinite (swap with config)",
233
+ type_safety: "Effect.ts typed errors",
234
+ testability: "Mock provider for tests"
235
+ }
236
+ }
237
+ ```
238
+
239
+ ### Context Engineering Formula
240
+
241
+ ```typescript
242
+ {
243
+ traditional: {
244
+ formula: "ContextSize = Σ(all_files + all_docs + all_examples)",
245
+ typical: "50k-300k tokens per request",
246
+ problem: "Hits context limits, slow, expensive"
247
+ }
248
+
249
+ provider: {
250
+ formula: "ContextSize = interface_definition + operation_signatures",
251
+ typical: "300-500 tokens per request",
252
+ benefit: "Never hits limits, fast, cheap, infinite backends"
253
+ }
254
+
255
+ improvement: {
256
+ context_reduction: "99%+",
257
+ cost_reduction: "100x cheaper",
258
+ speed_improvement: "10x faster",
259
+ backend_flexibility: "∞ backends supported"
260
+ }
261
+ }
262
+ ```
263
+
264
+ ### Provider as Just-In-Time Loader
265
+
266
+ **Traditional AI code generation:**
267
+ ```typescript
268
+ ❌ function generateCourseComponent_Traditional() {
269
+ context = {
270
+ convexSchema: loadConvexSchema(), // 15,000 tokens
271
+ convexMutations: loadMutations(), // 20,000 tokens
272
+ convexQueries: loadQueries(), // 18,000 tokens
273
+ implementations: loadImplementations() // 50,000 tokens
274
+ } // Total: 103,000 tokens
275
+
276
+ return ai.generate(task, context)
277
+ }
278
+ ```
279
+
280
+ **Provider pattern:**
281
+ ```typescript
282
+ ✅ function generateCourseComponent_Provider() {
283
+ context = {
284
+ interface: "DataProviderInterface", // 300 tokens
285
+ operations: ["things.get", "things.list"] // Which operations needed
286
+ } // Total: 300 tokens (99.7% reduction)
287
+
288
+ // AI generates code using interface
289
+ code = ai.generate(task, context)
290
+ // Result: provider.things.get(id) - works with ANY backend
291
+ return code
292
+ }
293
+ ```
294
+
295
+ ---
296
+
297
+ ## Type Hierarchy
298
+
299
+ ### The Complete Frontend Type System
300
+
301
+ ```
302
+ Thing
303
+ ├── Artifact // Code artifacts (what agents create)
304
+ │ ├── Page
305
+ │ │ ├── LandingPage
306
+ │ │ ├── BlogIndex
307
+ │ │ ├── BlogPost
308
+ │ │ ├── AppPage
309
+ │ │ ├── AccountPage
310
+ │ │ └── APIRoute
311
+ │ ├── Component
312
+ │ │ ├── UIComponent
313
+ │ │ ├── FeatureComponent
314
+ │ │ ├── Layout
315
+ │ │ └── Island
316
+ │ ├── Content
317
+ │ │ ├── Collection
318
+ │ │ ├── Entry
319
+ │ │ └── Schema
320
+ │ ├── Service
321
+ │ │ ├── GenericService // Handles all 66 types
322
+ │ │ └── SpecializedService // Optional convenience
323
+ │ ├── Provider
324
+ │ │ ├── ConvexProvider
325
+ │ │ ├── WordPressProvider
326
+ │ │ ├── NotionProvider
327
+ │ │ ├── SupabaseProvider
328
+ │ │ └── CustomProvider
329
+ │ └── Configuration
330
+ │ ├── DisplayConfig // UI labels, icons, colors
331
+ │ └── ProviderConfig // Backend URL, API keys
332
+ ├── Pattern // Reusable templates
333
+ ├── Interface // Abstract contracts
334
+ └── Capability // Agent capabilities
335
+ ```
336
+
337
+ ---
338
+
339
+ ## What Frontend IS and IS NOT
340
+
341
+ ### ✅ Frontend IS Responsible For
342
+
343
+ **1. Rendering**
344
+ ```tsx
345
+ // Display data from backend
346
+ <h1>{course.name}</h1>
347
+ <p>{course.properties.description}</p>
348
+ ```
349
+
350
+ **2. Calling Backend APIs**
351
+ ```tsx
352
+ // Get data from backend
353
+ const courses = useQuery(api.queries.things.list, { type: 'course' })
354
+
355
+ // Send data to backend
356
+ const create = useMutation(api.mutations.things.create)
357
+ await create({ type: 'course', name: 'Fitness 101', properties: {...} })
358
+ ```
359
+
360
+ **3. Managing UI State**
361
+ ```tsx
362
+ const [loading, setLoading] = useState(false)
363
+ const [error, setError] = useState(null)
364
+ const [formData, setFormData] = useState({})
365
+ ```
366
+
367
+ **4. User Interactions**
368
+ ```tsx
369
+ <button onClick={handleClick}>Create Course</button>
370
+ <input onChange={handleChange} />
371
+ ```
372
+
373
+ **5. Client-Side Routing**
374
+ ```tsx
375
+ <Link href="/courses">View Courses</Link>
376
+ ```
377
+
378
+ **6. Component-Local UI Logic**
379
+ ```typescript
380
+ type FrontendResponsibility =
381
+ | { type: "render"; data: any } // Display UI from data
382
+ | { type: "call_provider"; operation: any } // Call DataProvider (not direct backend)
383
+ | { type: "manage_ui_state"; state: any } // Form inputs, modals, loading
384
+ | { type: "route"; path: string } // Client-side navigation
385
+ | { type: "cache_display"; data: any }; // Cache UI data (not business data)
386
+ ```
387
+
388
+ ### ❌ Frontend IS NOT Responsible For
389
+
390
+ **1. Database Operations**
391
+ ```tsx
392
+ // ❌ NEVER do this in frontend
393
+ const courses = await db.query('things').filter(...).collect()
394
+ ```
395
+
396
+ **2. Business Logic**
397
+ ```tsx
398
+ // ❌ NEVER do this in frontend
399
+ if (user.tokens < course.price) {
400
+ // Calculate discount, check quotas, etc.
401
+ }
402
+ ```
403
+
404
+ **3. Data Validation**
405
+ ```tsx
406
+ // ❌ NEVER trust frontend validation alone (UX hint only, backend MUST validate)
407
+ if (formData.email.includes('@')) {
408
+ // Backend MUST validate, not frontend
409
+ }
410
+ ```
411
+
412
+ **4. Event Logging**
413
+ ```tsx
414
+ // ❌ NEVER log events in frontend
415
+ await db.insert('events', { type: 'course_created', ... })
416
+ ```
417
+
418
+ **5. Authorization**
419
+ ```tsx
420
+ // ❌ NEVER check permissions in frontend alone (UI hint only, backend MUST authorize)
421
+ if (user.role === 'admin') {
422
+ // Backend MUST authorize, frontend only for UI hints
423
+ }
424
+ ```
425
+
426
+ **6. Backend-Specific Code**
427
+ ```typescript
428
+ type FrontendProhibition =
429
+ | { type: "database_access" }
430
+ | { type: "business_logic" }
431
+ | { type: "event_logging" }
432
+ | { type: "authorization_enforcement" }
433
+ | { type: "data_validation_enforcement" }
434
+ | { type: "org_filtering" }
435
+ | { type: "backend_specific_code" };
436
+ ```
437
+
438
+ ---
439
+
440
+ ## Frontend File Structure
441
+
442
+ ```
443
+ frontend/ # Frontend repo (separate from backend)
444
+ ├── src/
445
+ │ ├── pages/ # Astro pages (SSR/SSG)
446
+ │ │ ├── index.astro # Homepage
447
+ │ │ ├── courses/
448
+ │ │ │ ├── index.astro # Course list (SSR)
449
+ │ │ │ └── [id].astro # Course detail (SSR)
450
+ │ │ └── [thingType]/ # Dynamic routes
451
+ │ │ ├── index.astro # Generic list page
452
+ │ │ └── [id].astro # Generic detail page
453
+ │ ├── components/ # React components
454
+ │ │ ├── cards/
455
+ │ │ │ └── ThingCard.tsx # Generic card (adapts to any type)
456
+ │ │ ├── lists/
457
+ │ │ │ └── ThingList.tsx # Generic list
458
+ │ │ ├── forms/
459
+ │ │ │ └── ThingForm.tsx # Generic form (calls backend)
460
+ │ │ └── ui/ # shadcn/ui components
461
+ │ ├── services/ # Effect.ts client services
462
+ │ │ ├── ConvexHttpClient.ts # Convex client wrapper (required)
463
+ │ │ ├── ThingClientService.ts # Thing operations (required)
464
+ │ │ ├── ConnectionClientService.ts # Connection operations (required)
465
+ │ │ ├── ClientLayer.ts # Dependency injection layer (required)
466
+ │ │ └── CourseClientService.ts # OPTIONAL: Convenience
467
+ │ ├── hooks/ # React hooks
468
+ │ │ └── useEffectRunner.ts # Run Effect programs in React
469
+ │ ├── layouts/
470
+ │ │ └── Layout.astro # Main layout
471
+ │ ├── ontology/ # Display config ONLY
472
+ │ │ ├── types.ts # Type definitions (synced from backend)
473
+ │ │ └── config.ts # UI display config (colors, icons, labels)
474
+ │ ├── providers/ # Backend provider implementations
475
+ │ │ ├── DataProvider.ts # Interface definition
476
+ │ │ ├── convex/
477
+ │ │ │ └── ConvexProvider.ts
478
+ │ │ ├── wordpress/
479
+ │ │ │ └── WordPressProvider.ts
480
+ │ │ ├── notion/
481
+ │ │ │ └── NotionProvider.ts
482
+ │ │ └── supabase/
483
+ │ │ └── SupabaseProvider.ts
484
+ │ ├── lib/
485
+ │ │ └── convex.ts # Backend client setup
486
+ │ ├── middleware.ts # Multi-tenant routing
487
+ │ └── styles/ # Tailwind + CSS
488
+ ├── .env.local
489
+ │ PUBLIC_CONVEX_URL=https://backend.convex.cloud
490
+ └── package.json
491
+ ```
492
+
493
+ **Key Point:** Frontend has NO `convex/` directory. Backend-specific code lives in provider implementations only.
494
+
495
+ ---
496
+
497
+ ## Backend-Agnostic Data Layer
498
+
499
+ **Inspired by Astro's Content Layer Pattern**
500
+
501
+ Astro elegantly abstracts content sources via a universal interface. ONE applies this pattern to **data operations**:
502
+
503
+ ```typescript
504
+ // frontend/astro.config.ts
505
+ import { defineConfig } from 'astro/config'
506
+ import { convexProvider } from './src/providers/convex'
507
+ // import { wordpressProvider } from './src/providers/wordpress'
508
+ // import { notionProvider } from './src/providers/notion'
509
+
510
+ export default defineConfig({
511
+ integrations: [
512
+ one({
513
+ // ✅ Change this ONE line to swap backends
514
+ provider: convexProvider({
515
+ url: import.meta.env.PUBLIC_BACKEND_URL
516
+ })
517
+
518
+ // Or use WordPress:
519
+ // provider: wordpressProvider({
520
+ // url: 'https://yoursite.com',
521
+ // apiKey: import.meta.env.WORDPRESS_API_KEY
522
+ // })
523
+
524
+ // Or use Notion:
525
+ // provider: notionProvider({
526
+ // apiKey: import.meta.env.NOTION_API_KEY,
527
+ // databaseId: import.meta.env.NOTION_DB_ID
528
+ // })
529
+ })
530
+ ]
531
+ })
532
+ ```
533
+
534
+ **Key Principle:** Frontend components never know which backend they're talking to. The provider interface is the universal contract.
535
+
536
+ ---
537
+
538
+ ## DataProvider Interface
539
+
540
+ **The universal ontology API that all backends must implement.**
541
+
542
+ ```typescript
543
+ // Error types (universal across all providers)
544
+ export class ThingNotFoundError {
545
+ readonly _tag = 'ThingNotFoundError'
546
+ constructor(readonly thingId: string) {}
547
+ }
548
+
549
+ export class ConnectionCreateError {
550
+ readonly _tag = 'ConnectionCreateError'
551
+ constructor(readonly reason: string) {}
552
+ }
553
+
554
+ export class UnauthorizedError {
555
+ readonly _tag = 'UnauthorizedError'
556
+ }
557
+
558
+ export class GroupNotFoundError {
559
+ readonly _tag = 'GroupNotFoundError'
560
+ constructor(readonly groupId: string) {}
561
+ }
562
+
563
+ export class PersonNotFoundError {
564
+ readonly _tag = 'PersonNotFoundError'
565
+ constructor(readonly personId: string) {}
566
+ }
567
+
568
+ export class PersonCreateError {
569
+ readonly _tag = 'PersonCreateError'
570
+ constructor(readonly reason: string) {}
571
+ }
572
+
573
+ // Type definitions for 6 dimensions
574
+ export interface Group {
575
+ _id: string
576
+ slug: string
577
+ name: string
578
+ type: 'friend_circle' | 'business' | 'community' | 'dao' | 'government' | 'organization'
579
+ parentGroupId?: string
580
+ description?: string
581
+ status: 'active' | 'archived'
582
+ settings: {
583
+ visibility: 'public' | 'private'
584
+ joinPolicy: 'open' | 'invite_only' | 'approval_required'
585
+ plan?: 'starter' | 'pro' | 'enterprise'
586
+ }
587
+ createdAt: number
588
+ updatedAt: number
589
+ }
590
+
591
+ export interface Person {
592
+ _id: string
593
+ email: string
594
+ username: string
595
+ displayName: string
596
+ emailVerified: boolean
597
+ role: 'platform_owner' | 'group_owner' | 'group_user' | 'customer'
598
+ groupId?: string
599
+ groups: string[]
600
+ permissions?: string[]
601
+ image?: string
602
+ bio?: string
603
+ createdAt: number
604
+ updatedAt: number
605
+ }
606
+
607
+ export interface Thing {
608
+ _id: string
609
+ type: ThingType
610
+ name: string
611
+ groupId?: string
612
+ properties: Record<string, any>
613
+ status: 'draft' | 'active' | 'archived'
614
+ createdAt: number
615
+ updatedAt: number
616
+ }
617
+
618
+ // DataProvider interface (every backend must implement this)
619
+ export interface DataProvider {
620
+ // Dimension 1: Groups operations
621
+ groups: {
622
+ get: (id: string) => Effect.Effect<Group, GroupNotFoundError>
623
+ list: (params: {
624
+ status?: 'active' | 'archived'
625
+ limit?: number
626
+ }) => Effect.Effect<Group[], Error>
627
+ update: (id: string, updates: Partial<Group>) => Effect.Effect<void, Error>
628
+ }
629
+
630
+ // Dimension 2: People operations
631
+ people: {
632
+ get: (id: string) => Effect.Effect<Person, PersonNotFoundError | UnauthorizedError>
633
+ list: (params: {
634
+ groupId?: string
635
+ role?: 'platform_owner' | 'group_owner' | 'group_user' | 'customer'
636
+ filters?: Record<string, any>
637
+ limit?: number
638
+ }) => Effect.Effect<Person[], Error>
639
+ create: (input: {
640
+ email: string
641
+ displayName: string
642
+ role: 'platform_owner' | 'group_owner' | 'group_user' | 'customer'
643
+ groupId: string
644
+ password?: string
645
+ }) => Effect.Effect<string, PersonCreateError>
646
+ update: (id: string, updates: Partial<Person>) => Effect.Effect<void, Error>
647
+ delete: (id: string) => Effect.Effect<void, Error>
648
+ }
649
+
650
+ // Dimension 3: Things operations
651
+ things: {
652
+ get: (id: string) => Effect.Effect<Thing, ThingNotFoundError | UnauthorizedError>
653
+ list: (params: {
654
+ type: ThingType
655
+ groupId?: string
656
+ filters?: Record<string, any>
657
+ limit?: number
658
+ }) => Effect.Effect<Thing[], Error>
659
+ create: (input: {
660
+ type: ThingType
661
+ name: string
662
+ groupId: string
663
+ properties: Record<string, any>
664
+ }) => Effect.Effect<string, ThingCreateError>
665
+ update: (id: string, updates: Partial<Thing>) => Effect.Effect<void, Error>
666
+ delete: (id: string) => Effect.Effect<void, Error>
667
+ }
668
+
669
+ // Dimension 4: Connections operations
670
+ connections: {
671
+ create: (input: {
672
+ fromThingId: string
673
+ toThingId: string
674
+ relationshipType: ConnectionType
675
+ metadata?: Record<string, any>
676
+ }) => Effect.Effect<string, ConnectionCreateError>
677
+ getRelated: (params: {
678
+ thingId: string
679
+ relationshipType: ConnectionType
680
+ direction: 'from' | 'to' | 'both'
681
+ }) => Effect.Effect<Thing[], Error>
682
+ getCount: (thingId: string, relationshipType: ConnectionType) => Effect.Effect<number, Error>
683
+ delete: (id: string) => Effect.Effect<void, Error>
684
+ }
685
+
686
+ // Dimension 5: Events operations
687
+ events: {
688
+ log: (event: {
689
+ type: EventType
690
+ actorId: string
691
+ targetId?: string
692
+ groupId: string
693
+ metadata?: Record<string, any>
694
+ }) => Effect.Effect<void, Error>
695
+ query: (params: {
696
+ type?: EventType
697
+ actorId?: string
698
+ targetId?: string
699
+ groupId?: string
700
+ from?: Date
701
+ to?: Date
702
+ }) => Effect.Effect<Event[], Error>
703
+ }
704
+
705
+ // Dimension 6: Knowledge operations
706
+ knowledge: {
707
+ embed: (params: {
708
+ text: string
709
+ sourceThingId?: string
710
+ sourcePersonId?: string
711
+ groupId: string
712
+ labels?: string[]
713
+ }) => Effect.Effect<string, Error>
714
+ search: (params: {
715
+ query: string
716
+ groupId?: string
717
+ limit?: number
718
+ }) => Effect.Effect<KnowledgeMatch[], Error>
719
+ }
720
+
721
+ // Optional: Real-time subscriptions
722
+ subscriptions?: {
723
+ watchThing: (id: string) => Effect.Effect<Observable<Thing>, Error>
724
+ watchList: (type: ThingType, groupId?: string) => Effect.Effect<Observable<Thing[]>, Error>
725
+ }
726
+ }
727
+ ```
728
+
729
+ **Provider Algebra:**
730
+
731
+ ```typescript
732
+ // Provider composition
733
+ implement : Backend × DataProviderInterface → Provider
734
+
735
+ // Examples:
736
+ ConvexProvider = implement(ConvexBackend, DataProviderInterface)
737
+ WordPressProvider = implement(WordPressBackend, DataProviderInterface)
738
+ NotionProvider = implement(NotionBackend, DataProviderInterface)
739
+
740
+ // Swapping backends (change ONE line in config)
741
+ config.provider = ConvexProvider({ url: "..." })
742
+ // OR
743
+ config.provider = WordPressProvider({ url: "...", apiKey: "..." })
744
+ // OR
745
+ config.provider = NotionProvider({ apiKey: "...", databaseId: "..." })
746
+
747
+ // Result: Frontend components don't change
748
+ ```
749
+
750
+ ---
751
+
752
+ ## Provider Implementations
753
+
754
+ ### Convex Provider
755
+
756
+ ```typescript
757
+ // frontend/src/providers/convex/ConvexProvider.ts
758
+ import { Effect, Layer } from 'effect'
759
+ import { ConvexHttpClient } from 'convex/browser'
760
+ import { DataProvider } from '../DataProvider'
761
+ import { api } from './api'
762
+
763
+ export class ConvexProvider implements DataProvider {
764
+ constructor(private client: ConvexHttpClient) {}
765
+
766
+ things = {
767
+ get: (id: string) =>
768
+ Effect.gen(function* () {
769
+ const thing = yield* Effect.tryPromise({
770
+ try: () => this.client.query(api.queries.things.get, { id }),
771
+ catch: (error) => new Error(String(error))
772
+ })
773
+
774
+ if (!thing) {
775
+ return yield* Effect.fail(new ThingNotFoundError(id))
776
+ }
777
+
778
+ return thing
779
+ }),
780
+
781
+ list: (params) =>
782
+ Effect.tryPromise({
783
+ try: () => this.client.query(api.queries.things.list, params),
784
+ catch: (error) => new Error(String(error))
785
+ }),
786
+
787
+ create: (input) =>
788
+ Effect.tryPromise({
789
+ try: () => this.client.mutation(api.mutations.things.create, input),
790
+ catch: (error) => new Error(String(error))
791
+ }),
792
+
793
+ update: (id, updates) =>
794
+ Effect.tryPromise({
795
+ try: () => this.client.mutation(api.mutations.things.update, { id, updates }),
796
+ catch: (error) => new Error(String(error))
797
+ }),
798
+
799
+ delete: (id) =>
800
+ Effect.tryPromise({
801
+ try: () => this.client.mutation(api.mutations.things.delete, { id }),
802
+ catch: (error) => new Error(String(error))
803
+ })
804
+ }
805
+
806
+ connections = { /* Similar implementation for connections... */ }
807
+ events = { /* Similar implementation for events... */ }
808
+ knowledge = { /* Similar implementation for knowledge... */ }
809
+ }
810
+
811
+ // Factory function
812
+ export function convexProvider(config: { url: string }) {
813
+ return Layer.succeed(
814
+ DataProvider,
815
+ new ConvexProvider(new ConvexHttpClient(config.url))
816
+ )
817
+ }
818
+ ```
819
+
820
+ ### WordPress Provider
821
+
822
+ ```typescript
823
+ // frontend/src/providers/wordpress/WordPressProvider.ts
824
+ import { Effect, Layer } from 'effect'
825
+ import { DataProvider } from '../DataProvider'
826
+
827
+ export class WordPressProvider implements DataProvider {
828
+ constructor(
829
+ private baseUrl: string,
830
+ private apiKey: string
831
+ ) {}
832
+
833
+ things = {
834
+ get: (id: string) =>
835
+ Effect.gen(function* () {
836
+ // Map ONE ontology → WordPress REST API
837
+ const response = yield* Effect.tryPromise({
838
+ try: () =>
839
+ fetch(`${this.baseUrl}/wp-json/wp/v2/posts/${id}`, {
840
+ headers: { Authorization: `Bearer ${this.apiKey}` }
841
+ }),
842
+ catch: (error) => new Error(String(error))
843
+ })
844
+
845
+ if (!response.ok) {
846
+ return yield* Effect.fail(new ThingNotFoundError(id))
847
+ }
848
+
849
+ const post = yield* Effect.tryPromise({
850
+ try: () => response.json(),
851
+ catch: (error) => new Error(String(error))
852
+ })
853
+
854
+ // Transform WordPress post → ONE thing
855
+ return {
856
+ _id: post.id.toString(),
857
+ type: 'post' as ThingType,
858
+ name: post.title.rendered,
859
+ properties: {
860
+ content: post.content.rendered,
861
+ excerpt: post.excerpt.rendered,
862
+ author: post.author,
863
+ publishedAt: post.date
864
+ },
865
+ status: post.status,
866
+ createdAt: new Date(post.date).getTime(),
867
+ updatedAt: new Date(post.modified).getTime()
868
+ }
869
+ }),
870
+
871
+ list: (params) =>
872
+ Effect.gen(function* () {
873
+ const query = new URLSearchParams({
874
+ per_page: String(params.limit || 10)
875
+ })
876
+
877
+ const response = yield* Effect.tryPromise({
878
+ try: () =>
879
+ fetch(`${this.baseUrl}/wp-json/wp/v2/posts?${query}`, {
880
+ headers: { Authorization: `Bearer ${this.apiKey}` }
881
+ }),
882
+ catch: (error) => new Error(String(error))
883
+ })
884
+
885
+ const posts = yield* Effect.tryPromise({
886
+ try: () => response.json(),
887
+ catch: (error) => new Error(String(error))
888
+ })
889
+
890
+ return posts.map((post: any) => ({
891
+ _id: post.id.toString(),
892
+ type: 'post' as ThingType,
893
+ name: post.title.rendered,
894
+ properties: {
895
+ content: post.content.rendered,
896
+ excerpt: post.excerpt.rendered
897
+ },
898
+ status: post.status,
899
+ createdAt: new Date(post.date).getTime(),
900
+ updatedAt: new Date(post.modified).getTime()
901
+ }))
902
+ }),
903
+
904
+ create: (input) =>
905
+ Effect.gen(function* () {
906
+ const response = yield* Effect.tryPromise({
907
+ try: () =>
908
+ fetch(`${this.baseUrl}/wp-json/wp/v2/posts`, {
909
+ method: 'POST',
910
+ headers: {
911
+ 'Content-Type': 'application/json',
912
+ Authorization: `Bearer ${this.apiKey}`
913
+ },
914
+ body: JSON.stringify({
915
+ title: input.name,
916
+ content: input.properties.content || '',
917
+ status: 'draft'
918
+ })
919
+ }),
920
+ catch: (error) => new Error(String(error))
921
+ })
922
+
923
+ const post = yield* Effect.tryPromise({
924
+ try: () => response.json(),
925
+ catch: (error) => new Error(String(error))
926
+ })
927
+
928
+ return post.id.toString()
929
+ }),
930
+
931
+ update: (id, updates) => { /* Similar WordPress update */ },
932
+ delete: (id) => { /* Similar WordPress delete */ }
933
+ }
934
+
935
+ connections = { /* WordPress relationships via post meta or custom tables */ }
936
+ events = { /* Log to WordPress activity log */ }
937
+ knowledge = { /* Elasticsearch, Algolia, or vector search */ }
938
+ }
939
+
940
+ // Factory function
941
+ export function wordpressProvider(config: { url: string; apiKey: string }) {
942
+ return Layer.succeed(
943
+ DataProvider,
944
+ new WordPressProvider(config.url, config.apiKey)
945
+ )
946
+ }
947
+ ```
948
+
949
+ ### Notion Provider
950
+
951
+ ```typescript
952
+ // frontend/src/providers/notion/NotionProvider.ts
953
+ import { Effect, Layer } from 'effect'
954
+ import { Client } from '@notionhq/client'
955
+ import { DataProvider } from '../DataProvider'
956
+
957
+ export class NotionProvider implements DataProvider {
958
+ private notion: Client
959
+
960
+ constructor(apiKey: string, private databaseId: string) {
961
+ this.notion = new Client({ auth: apiKey })
962
+ }
963
+
964
+ things = {
965
+ get: (id: string) =>
966
+ Effect.gen(function* () {
967
+ const page = yield* Effect.tryPromise({
968
+ try: () => this.notion.pages.retrieve({ page_id: id }),
969
+ catch: (error) => new Error(String(error))
970
+ })
971
+
972
+ return {
973
+ _id: page.id,
974
+ type: 'document' as ThingType,
975
+ name: (page.properties.Name as any).title[0]?.plain_text || '',
976
+ properties: {},
977
+ status: 'active',
978
+ createdAt: new Date(page.created_time).getTime(),
979
+ updatedAt: new Date(page.last_edited_time).getTime()
980
+ }
981
+ }),
982
+
983
+ list: (params) =>
984
+ Effect.gen(function* () {
985
+ const response = yield* Effect.tryPromise({
986
+ try: () =>
987
+ this.notion.databases.query({
988
+ database_id: this.databaseId,
989
+ page_size: params.limit || 10
990
+ }),
991
+ catch: (error) => new Error(String(error))
992
+ })
993
+
994
+ return response.results.map((page: any) => ({
995
+ _id: page.id,
996
+ type: params.type,
997
+ name: page.properties.Name?.title[0]?.plain_text || '',
998
+ properties: {},
999
+ status: 'active',
1000
+ createdAt: new Date(page.created_time).getTime(),
1001
+ updatedAt: new Date(page.last_edited_time).getTime()
1002
+ }))
1003
+ }),
1004
+
1005
+ create: (input) =>
1006
+ Effect.gen(function* () {
1007
+ const page = yield* Effect.tryPromise({
1008
+ try: () =>
1009
+ this.notion.pages.create({
1010
+ parent: { database_id: this.databaseId },
1011
+ properties: {
1012
+ Name: { title: [{ text: { content: input.name } }] }
1013
+ }
1014
+ }),
1015
+ catch: (error) => new Error(String(error))
1016
+ })
1017
+
1018
+ return page.id
1019
+ }),
1020
+
1021
+ update: (id, updates) => { /* Similar Notion update */ },
1022
+ delete: (id) => { /* Notion archive page */ }
1023
+ }
1024
+
1025
+ connections = { /* Notion relations map to connections */ }
1026
+ events = { /* Log to separate Notion database */ }
1027
+ knowledge = { /* Notion's built-in search or external vector DB */ }
1028
+ }
1029
+
1030
+ // Factory function
1031
+ export function notionProvider(config: { apiKey: string; databaseId: string }) {
1032
+ return Layer.succeed(
1033
+ DataProvider,
1034
+ new NotionProvider(config.apiKey, config.databaseId)
1035
+ )
1036
+ }
1037
+ ```
1038
+
1039
+ ### Supabase Provider
1040
+
1041
+ ```typescript
1042
+ // frontend/src/providers/supabase/SupabaseProvider.ts
1043
+ import { Effect, Layer } from 'effect'
1044
+ import { createClient, SupabaseClient } from '@supabase/supabase-js'
1045
+ import { DataProvider } from '../DataProvider'
1046
+
1047
+ export class SupabaseProvider implements DataProvider {
1048
+ private supabase: SupabaseClient
1049
+
1050
+ constructor(url: string, apiKey: string) {
1051
+ this.supabase = createClient(url, apiKey)
1052
+ }
1053
+
1054
+ things = {
1055
+ get: (id: string) =>
1056
+ Effect.gen(function* () {
1057
+ const { data, error } = yield* Effect.tryPromise({
1058
+ try: () => this.supabase.from('things').select('*').eq('id', id).single(),
1059
+ catch: (err) => new Error(String(err))
1060
+ })
1061
+
1062
+ if (error) {
1063
+ return yield* Effect.fail(new ThingNotFoundError(id))
1064
+ }
1065
+
1066
+ return data
1067
+ }),
1068
+
1069
+ list: (params) =>
1070
+ Effect.gen(function* () {
1071
+ let query = this.supabase
1072
+ .from('things')
1073
+ .select('*')
1074
+ .eq('type', params.type)
1075
+ .limit(params.limit || 10)
1076
+
1077
+ if (params.groupId) {
1078
+ query = query.eq('groupId', params.groupId)
1079
+ }
1080
+
1081
+ const { data, error } = yield* Effect.tryPromise({
1082
+ try: () => query,
1083
+ catch: (err) => new Error(String(err))
1084
+ })
1085
+
1086
+ if (error) {
1087
+ return yield* Effect.fail(new Error(error.message))
1088
+ }
1089
+
1090
+ return data
1091
+ }),
1092
+
1093
+ create: (input) =>
1094
+ Effect.gen(function* () {
1095
+ const { data, error } = yield* Effect.tryPromise({
1096
+ try: () =>
1097
+ this.supabase.from('things').insert([input]).select().single(),
1098
+ catch: (err) => new Error(String(err))
1099
+ })
1100
+
1101
+ if (error) {
1102
+ return yield* Effect.fail(new Error(error.message))
1103
+ }
1104
+
1105
+ return data.id
1106
+ }),
1107
+
1108
+ update: (id, updates) => { /* Similar Supabase update */ },
1109
+ delete: (id) => { /* Similar Supabase delete */ }
1110
+ }
1111
+
1112
+ connections = { /* Use Supabase 'connections' table */ }
1113
+ events = { /* Use Supabase 'events' table */ }
1114
+ knowledge = { /* Use pgvector extension for embeddings */ }
1115
+
1116
+ // ✅ Supabase supports real-time!
1117
+ subscriptions = {
1118
+ watchThing: (id: string) =>
1119
+ Effect.gen(function* () {
1120
+ const channel = this.supabase
1121
+ .channel(`thing:${id}`)
1122
+ .on('postgres_changes', {
1123
+ event: '*',
1124
+ schema: 'public',
1125
+ table: 'things',
1126
+ filter: `id=eq.${id}`
1127
+ }, (payload) => {
1128
+ // Emit updates
1129
+ })
1130
+
1131
+ yield* Effect.tryPromise({
1132
+ try: () => channel.subscribe(),
1133
+ catch: (err) => new Error(String(err))
1134
+ })
1135
+
1136
+ // Return observable
1137
+ })
1138
+ }
1139
+ }
1140
+
1141
+ // Factory function
1142
+ export function supabaseProvider(config: { url: string; apiKey: string }) {
1143
+ return Layer.succeed(
1144
+ DataProvider,
1145
+ new SupabaseProvider(config.url, config.apiKey)
1146
+ )
1147
+ }
1148
+ ```
1149
+
1150
+ **Key Insight:** Each provider translates between ONE ontology ↔ backend-specific API. Frontend stays the same.
1151
+
1152
+ ---
1153
+
1154
+ ## Configuration
1155
+
1156
+ ### Astro-Style Backend Swapping
1157
+
1158
+ **Swap backends by changing ONE line:**
1159
+
1160
+ ```typescript
1161
+ // frontend/astro.config.ts
1162
+ import { defineConfig } from 'astro/config'
1163
+ import react from '@astrojs/react'
1164
+ import { one } from '@one/astro-integration'
1165
+
1166
+ // Import providers
1167
+ import { convexProvider } from './src/providers/convex'
1168
+ import { wordpressProvider } from './src/providers/wordpress'
1169
+ import { notionProvider } from './src/providers/notion'
1170
+ import { supabaseProvider } from './src/providers/supabase'
1171
+
1172
+ export default defineConfig({
1173
+ integrations: [
1174
+ react(),
1175
+ one({
1176
+ // ✅ Choose your backend (change this ONE line)
1177
+
1178
+ // Option 1: Convex (real-time, serverless)
1179
+ provider: convexProvider({
1180
+ url: import.meta.env.PUBLIC_CONVEX_URL
1181
+ })
1182
+
1183
+ // Option 2: WordPress (existing CMS)
1184
+ // provider: wordpressProvider({
1185
+ // url: 'https://yoursite.com',
1186
+ // apiKey: import.meta.env.WORDPRESS_API_KEY
1187
+ // })
1188
+
1189
+ // Option 3: Notion (databases as backend)
1190
+ // provider: notionProvider({
1191
+ // apiKey: import.meta.env.NOTION_API_KEY,
1192
+ // databaseId: import.meta.env.NOTION_DB_ID
1193
+ // })
1194
+
1195
+ // Option 4: Supabase (PostgreSQL + real-time)
1196
+ // provider: supabaseProvider({
1197
+ // url: import.meta.env.PUBLIC_SUPABASE_URL,
1198
+ // apiKey: import.meta.env.PUBLIC_SUPABASE_ANON_KEY
1199
+ // })
1200
+
1201
+ // Option 5: Custom backend
1202
+ // provider: customProvider({ ... })
1203
+ })
1204
+ ]
1205
+ })
1206
+ ```
1207
+
1208
+ **Result:**
1209
+ - Frontend components don't change
1210
+ - UI stays the same
1211
+ - Only data source changes
1212
+ - Organizations can use their existing infrastructure
1213
+
1214
+ ### Display Configuration (UI Only)
1215
+
1216
+ Frontend needs **display configuration** for UI rendering. NOT business logic.
1217
+
1218
+ ```typescript
1219
+ // frontend/src/ontology/config.ts
1220
+ // THIS IS NOT BUSINESS LOGIC - JUST UI CONFIGURATION
1221
+
1222
+ export const thingConfigs = {
1223
+ course: {
1224
+ // Display names
1225
+ displayName: 'Course',
1226
+ displayNamePlural: 'Courses',
1227
+
1228
+ // UI presentation
1229
+ icon: 'BookOpen',
1230
+ color: 'green',
1231
+
1232
+ // Which fields to show in UI
1233
+ primaryField: 'title',
1234
+ secondaryField: 'description',
1235
+ imageField: 'thumbnail',
1236
+
1237
+ // Form fields (frontend only, backend validates)
1238
+ fields: {
1239
+ title: {
1240
+ label: 'Course Title',
1241
+ type: 'text',
1242
+ required: true,
1243
+ placeholder: 'e.g., Fitness 101'
1244
+ },
1245
+ description: {
1246
+ label: 'Description',
1247
+ type: 'textarea',
1248
+ required: true
1249
+ },
1250
+ price: {
1251
+ label: 'Price (USD)',
1252
+ type: 'number',
1253
+ required: true
1254
+ }
1255
+ }
1256
+ },
1257
+
1258
+ creator: {
1259
+ displayName: 'Creator',
1260
+ displayNamePlural: 'Creators',
1261
+ icon: 'User',
1262
+ color: 'blue',
1263
+ primaryField: 'name',
1264
+ secondaryField: 'bio',
1265
+ imageField: 'avatar',
1266
+ fields: {
1267
+ name: { label: 'Name', type: 'text', required: true },
1268
+ email: { label: 'Email', type: 'text', required: true },
1269
+ bio: { label: 'Bio', type: 'textarea', required: false }
1270
+ }
1271
+ }
1272
+ // ... all 66 types (UI config only)
1273
+ }
1274
+
1275
+ // Helper function
1276
+ export function getThingConfig(type: ThingType) {
1277
+ return thingConfigs[type]
1278
+ }
1279
+ ```
1280
+
1281
+ **What This Is:**
1282
+ - ✅ UI labels and placeholders
1283
+ - ✅ Icon and color choices
1284
+ - ✅ Which fields to display
1285
+ - ✅ Form field types
1286
+
1287
+ **What This Is NOT:**
1288
+ - ❌ Business logic
1289
+ - ❌ Validation rules (backend validates)
1290
+ - ❌ Authorization rules (backend authorizes)
1291
+ - ❌ Database schema (that's in backend)
1292
+
1293
+ ---
1294
+
1295
+ ## State Management Hierarchy
1296
+
1297
+ ### Four-Layer State Architecture
1298
+
1299
+ ```typescript
1300
+ {
1301
+ // Level 1: Server State (Provider owns - SOURCE OF TRUTH)
1302
+ ServerState: {
1303
+ owner: "Provider (backed by database)",
1304
+ source: "Backend database",
1305
+ access: "Query/Mutation via provider.interface only",
1306
+ examples: [
1307
+ "course list",
1308
+ "user profile",
1309
+ "enrollment count",
1310
+ "lesson progress"
1311
+ ],
1312
+ caching: "Provider-level (Cloudflare KV, Edge cache)",
1313
+ lifetime: "Persistent (until backend changes)",
1314
+ rule: "NEVER duplicate in frontend state. Query when needed."
1315
+ },
1316
+
1317
+ // Level 2: SSR State (Astro owns - REQUEST SCOPED)
1318
+ SSRState: {
1319
+ owner: "Astro page (.astro files)",
1320
+ source: "Server-side provider fetch",
1321
+ access: "Props passed to components",
1322
+ examples: [
1323
+ "Initial page data (course details)",
1324
+ "SEO metadata (title, description)",
1325
+ "Organization context (from subdomain)"
1326
+ ],
1327
+ lifetime: "One HTTP request (not persisted)",
1328
+ pattern: `
1329
+ ---
1330
+ const course = await provider.things.get(id)
1331
+ ---
1332
+ <Layout title={course.name}>
1333
+ <CourseDetail course={course} />
1334
+ </Layout>
1335
+ `,
1336
+ rule: "Use for SEO, initial render, server-only data"
1337
+ },
1338
+
1339
+ // Level 3: Island State (React owns - COMPONENT SCOPED)
1340
+ IslandState: {
1341
+ owner: "React component (useState/useReducer)",
1342
+ source: "Component-local logic",
1343
+ access: "Component-private (not shared)",
1344
+ examples: [
1345
+ "Form input values",
1346
+ "Modal open/closed",
1347
+ "Dropdown expanded",
1348
+ "Loading spinner visible"
1349
+ ],
1350
+ lifetime: "Component mounted (unmount = state destroyed)",
1351
+ pattern: `
1352
+ export function CourseForm() {
1353
+ const [title, setTitle] = useState('')
1354
+ const [loading, setLoading] = useState(false)
1355
+ // State dies when component unmounts
1356
+ }
1357
+ `,
1358
+ rule: "UI-only state. Never duplicate server state."
1359
+ },
1360
+
1361
+ // Level 4: Shared Client State (Nanostores owns - SESSION SCOPED)
1362
+ SharedState: {
1363
+ owner: "Nanostores (global atoms)",
1364
+ source: "Cross-component coordination",
1365
+ access: "Multiple components subscribe",
1366
+ examples: [
1367
+ "Sidebar expanded/collapsed",
1368
+ "Dark/light theme preference",
1369
+ "User locale (en/es/fr)",
1370
+ "Toast notifications"
1371
+ ],
1372
+ lifetime: "Browser session + localStorage",
1373
+ pattern: `
1374
+ // stores/layout.ts
1375
+ export const sidebarExpanded = atom(true)
1376
+
1377
+ // Component A
1378
+ const expanded = useStore(sidebarExpanded)
1379
+
1380
+ // Component B (synced with A)
1381
+ const expanded = useStore(sidebarExpanded)
1382
+ `,
1383
+ rule: "UI preferences only. NOT server data."
1384
+ },
1385
+
1386
+ // Anti-Pattern: Duplicating Server State
1387
+ antiPattern: {
1388
+ problem: "Storing server data in frontend state",
1389
+ bad: `
1390
+ ❌ const [courses, setCourses] = useState([])
1391
+ ❌ useEffect(() => {
1392
+ provider.things.list('course').then(setCourses)
1393
+ }, [])
1394
+ // Problem: Server state duplicated in frontend
1395
+ // Problem: Stale data, manual sync, cache invalidation
1396
+ `,
1397
+ solution: `
1398
+ ✅ const courses = useQuery(api.courses.list)
1399
+ // Provider handles caching, revalidation, subscriptions
1400
+ // Frontend just renders. No state duplication.
1401
+ `
1402
+ },
1403
+
1404
+ // Decision Tree
1405
+ decisionTree: {
1406
+ question: "Does this state persist after page reload?",
1407
+ yes: {
1408
+ question: "Is this data from backend?",
1409
+ yes: "ServerState (provider query)",
1410
+ no: "SharedState (nanostores + localStorage)"
1411
+ },
1412
+ no: {
1413
+ question: "Do multiple components need this state?",
1414
+ yes: "SharedState (nanostores, session-only)",
1415
+ no: {
1416
+ question: "Is this SSR data?",
1417
+ yes: "SSRState (Astro props)",
1418
+ no: "IslandState (useState)"
1419
+ }
1420
+ }
1421
+ }
1422
+ }
1423
+ ```
1424
+
1425
+ ---
1426
+
1427
+ ## Effect.ts Service Layer
1428
+
1429
+ **Effect.ts services consume the DataProvider interface.**
1430
+
1431
+ ### Why Effect.ts?
1432
+
1433
+ ```typescript
1434
+ // ❌ Traditional approach - untyped errors, hard to compose
1435
+ async function getCourse(id: string) {
1436
+ try {
1437
+ const response = await fetch(`/api/courses/${id}`)
1438
+ const course = await response.json()
1439
+ return course
1440
+ } catch (error) {
1441
+ // What type of error? Network? 404? 500?
1442
+ console.error(error)
1443
+ throw error
1444
+ }
1445
+ }
1446
+
1447
+ // ✅ Effect.ts approach - typed errors, backend-agnostic
1448
+ import { Effect } from 'effect'
1449
+
1450
+ function getCourse(id: string) {
1451
+ return Effect.gen(function* () {
1452
+ const provider = yield* DataProvider
1453
+
1454
+ // Works with ANY backend (Convex, WordPress, Notion, etc.)
1455
+ const course = yield* provider.things.get(id)
1456
+
1457
+ return course
1458
+ }).pipe(
1459
+ // Handle specific errors
1460
+ Effect.catchTag('ThingNotFoundError', err =>
1461
+ Effect.fail(new Error(`Course ${err.thingId} not found`))
1462
+ )
1463
+ )
1464
+ }
1465
+ ```
1466
+
1467
+ **Key Benefits:**
1468
+ 1. **Backend-Agnostic** - Works with any DataProvider implementation
1469
+ 2. **Type-Safe Errors** - Compiler enforces error handling
1470
+ 3. **Composability** - Small functions combine into complex flows
1471
+ 4. **Testability** - Test layers replace real providers
1472
+
1473
+ ### Core Principle: Generic Services Handle Everything
1474
+
1475
+ The ontology has **66 thing types**, but you only need **2 generic services**:
1476
+
1477
+ 1. **ThingClientService** - All CRUD for all 66 types
1478
+ 2. **ConnectionClientService** - All relationships
1479
+
1480
+ ```typescript
1481
+ // ✅ This handles courses, lessons, products, everything
1482
+ const provider = yield* DataProvider
1483
+
1484
+ // Get any thing
1485
+ const course = yield* provider.things.get(courseId)
1486
+ const lesson = yield* provider.things.get(lessonId)
1487
+
1488
+ // List any type
1489
+ const courses = yield* provider.things.list({ type: 'course', groupId: orgId })
1490
+ const products = yield* provider.things.list({ type: 'product', groupId: orgId })
1491
+
1492
+ // Create any type
1493
+ const courseId = yield* provider.things.create({
1494
+ type: 'course',
1495
+ name: 'Fitness 101',
1496
+ properties: { price: 99, description: '...' }
1497
+ })
1498
+ ```
1499
+
1500
+ **Specialized services are OPTIONAL** - only add them if you repeat the same multi-step operations 3+ times.
1501
+
1502
+ ### Generic Service Pattern
1503
+
1504
+ ```typescript
1505
+ // frontend/src/services/ThingService.ts
1506
+ import { Effect } from 'effect'
1507
+ import { DataProvider } from '@/providers/DataProvider'
1508
+
1509
+ export class ThingService extends Effect.Service<ThingService>()(
1510
+ 'ThingService',
1511
+ {
1512
+ effect: Effect.gen(function* () {
1513
+ const provider = yield* DataProvider
1514
+
1515
+ return {
1516
+ get: (id: string) => provider.things.get(id),
1517
+
1518
+ list: (type: ThingType, orgId?: string) =>
1519
+ provider.things.list({ type, groupId: orgId }),
1520
+
1521
+ create: (input: { type: ThingType; name: string; properties: any }) =>
1522
+ provider.things.create(input),
1523
+
1524
+ update: (id: string, updates: any) =>
1525
+ provider.things.update(id, updates),
1526
+
1527
+ delete: (id: string) =>
1528
+ provider.things.delete(id)
1529
+ }
1530
+ }),
1531
+ dependencies: [DataProvider]
1532
+ }
1533
+ ) {}
1534
+ ```
1535
+
1536
+ **Key Point:** `ThingService` doesn't care if provider is Convex, WordPress, or Notion. It just calls `provider.things.get()`. The provider handles backend-specific logic.
1537
+
1538
+ ### Specialized Service Pattern (Optional)
1539
+
1540
+ **Only add if you repeat the same multi-step operation 3+ times:**
1541
+
1542
+ ```typescript
1543
+ // frontend/src/services/CourseClientService.ts (OPTIONAL)
1544
+ import { Effect } from 'effect'
1545
+ import { ThingClientService } from './ThingClientService'
1546
+ import { ConnectionClientService } from './ConnectionClientService'
1547
+
1548
+ export class CourseClientService extends Effect.Service<CourseClientService>()(
1549
+ 'CourseClientService',
1550
+ {
1551
+ effect: Effect.gen(function* () {
1552
+ const thingService = yield* ThingClientService
1553
+ const connectionService = yield* ConnectionClientService
1554
+
1555
+ return {
1556
+ // Convenience: Get course with lessons
1557
+ getCourseWithLessons: (courseId: string) =>
1558
+ Effect.gen(function* () {
1559
+ const [course, lessons] = yield* Effect.all([
1560
+ thingService.get(courseId),
1561
+ connectionService.getRelated(courseId, 'part_of', 'to')
1562
+ ])
1563
+
1564
+ return { course, lessons }
1565
+ }),
1566
+
1567
+ // Convenience: Clearer domain vocabulary
1568
+ enrollUser: (userId: string, courseId: string) =>
1569
+ Effect.gen(function* () {
1570
+ return yield* connectionService.create({
1571
+ fromThingId: userId,
1572
+ toThingId: courseId,
1573
+ relationshipType: 'enrolled_in'
1574
+ })
1575
+ }),
1576
+
1577
+ // Convenience: Specific count query
1578
+ getEnrollmentCount: (courseId: string) =>
1579
+ Effect.gen(function* () {
1580
+ return yield* connectionService.getCount(courseId, 'enrolled_in')
1581
+ })
1582
+ }
1583
+ }),
1584
+ dependencies: [ThingClientService.Default, ConnectionClientService.Default]
1585
+ }
1586
+ ) {}
1587
+ ```
1588
+
1589
+ **When to add specialized services:**
1590
+ - ✅ Repeat the same multi-step operation 3+ times
1591
+ - ✅ Want domain vocabulary (`enrollUser` vs `create connection`)
1592
+ - ✅ Need to encapsulate complex business workflows
1593
+ - ❌ Don't add them upfront for all 66 types
1594
+ - ❌ Don't add them for simple CRUD (use ThingClientService)
1595
+
1596
+ ### Dependency Injection Layer
1597
+
1598
+ ```typescript
1599
+ // frontend/src/services/ClientLayer.ts
1600
+ import { Layer } from 'effect'
1601
+ import { ConvexHttpClientLive } from './ConvexHttpClient'
1602
+ import { ThingClientService } from './ThingClientService'
1603
+ import { ConnectionClientService } from './ConnectionClientService'
1604
+ // import { CourseClientService } from './CourseClientService' // OPTIONAL
1605
+
1606
+ // ✅ Minimal layer - handles all 66 thing types
1607
+ export const ClientLayer = Layer.mergeAll(
1608
+ ConvexHttpClientLive,
1609
+ ThingClientService.Default,
1610
+ ConnectionClientService.Default
1611
+ // CourseClientService.Default // Add ONLY if you created it
1612
+ )
1613
+ ```
1614
+
1615
+ **Most apps only need the 2 generic services.** Add specialized services as you discover repeated patterns.
1616
+
1617
+ ---
1618
+
1619
+ ## React Hooks & Integration
1620
+
1621
+ ### useEffectRunner Hook
1622
+
1623
+ Custom hook for running Effect programs in React components.
1624
+
1625
+ ```typescript
1626
+ // frontend/src/hooks/useEffectRunner.ts
1627
+ import { useCallback, useState } from 'react'
1628
+ import { Effect } from 'effect'
1629
+ import { ClientLayer } from '@/services/ClientLayer'
1630
+
1631
+ export function useEffectRunner() {
1632
+ const [loading, setLoading] = useState(false)
1633
+ const [error, setError] = useState<string | null>(null)
1634
+
1635
+ const run = useCallback(async <A, E>(
1636
+ effect: Effect.Effect<A, E>,
1637
+ options?: {
1638
+ onSuccess?: (result: A) => void
1639
+ onError?: (error: E) => void
1640
+ }
1641
+ ) => {
1642
+ setLoading(true)
1643
+ setError(null)
1644
+
1645
+ try {
1646
+ const result = await Effect.runPromise(
1647
+ effect.pipe(Effect.provide(ClientLayer))
1648
+ )
1649
+
1650
+ options?.onSuccess?.(result)
1651
+ return result
1652
+ } catch (err) {
1653
+ const errorMessage = err instanceof Error ? err.message : String(err)
1654
+ setError(errorMessage)
1655
+ options?.onError?.(err as E)
1656
+ throw err
1657
+ } finally {
1658
+ setLoading(false)
1659
+ }
1660
+ }, [])
1661
+
1662
+ return { run, loading, error }
1663
+ }
1664
+ ```
1665
+
1666
+ ### Using in Components
1667
+
1668
+ ```tsx
1669
+ // frontend/src/components/CourseEnrollButton.tsx
1670
+ import { useEffectRunner } from '@/hooks/useEffectRunner'
1671
+ import { ConnectionClientService } from '@/services/ConnectionClientService'
1672
+ import { Effect } from 'effect'
1673
+ import { Button } from '@/components/ui/button'
1674
+ import { Alert } from '@/components/ui/alert'
1675
+
1676
+ interface Props {
1677
+ courseId: string
1678
+ userId: string
1679
+ }
1680
+
1681
+ export function CourseEnrollButton({ courseId, userId }: Props) {
1682
+ const { run, loading, error } = useEffectRunner()
1683
+
1684
+ const handleEnroll = () => {
1685
+ // Define Effect program using GENERIC service
1686
+ const program = Effect.gen(function* () {
1687
+ const connectionService = yield* ConnectionClientService
1688
+
1689
+ // Enroll = create connection (course is just a thing)
1690
+ const enrollmentId = yield* connectionService.create({
1691
+ fromThingId: userId,
1692
+ toThingId: courseId,
1693
+ relationshipType: 'enrolled_in'
1694
+ })
1695
+
1696
+ return enrollmentId
1697
+ })
1698
+
1699
+ // Run Effect program
1700
+ run(program, {
1701
+ onSuccess: (enrollmentId) => {
1702
+ console.log('Enrolled successfully:', enrollmentId)
1703
+ window.location.href = `/courses/${courseId}/learn`
1704
+ },
1705
+ onError: (err) => {
1706
+ console.error('Enrollment failed:', err)
1707
+ }
1708
+ })
1709
+ }
1710
+
1711
+ return (
1712
+ <div>
1713
+ <Button onClick={handleEnroll} disabled={loading}>
1714
+ {loading ? 'Enrolling...' : 'Enroll Now'}
1715
+ </Button>
1716
+
1717
+ {error && (
1718
+ <Alert variant="destructive">{error}</Alert>
1719
+ )}
1720
+ </div>
1721
+ )
1722
+ }
1723
+ ```
1724
+
1725
+ ### Composable Operations
1726
+
1727
+ ```tsx
1728
+ // frontend/src/components/CourseCreator.tsx
1729
+ import { useEffectRunner } from '@/hooks/useEffectRunner'
1730
+ import { ThingClientService } from '@/services/ThingClientService'
1731
+ import { ConnectionClientService } from '@/services/ConnectionClientService'
1732
+ import { Effect } from 'effect'
1733
+ import { useState } from 'react'
1734
+
1735
+ export function CourseCreator() {
1736
+ const { run, loading, error } = useEffectRunner()
1737
+ const [formData, setFormData] = useState({
1738
+ title: '',
1739
+ description: '',
1740
+ price: 0
1741
+ })
1742
+
1743
+ const handleSubmit = async (e: React.FormEvent) => {
1744
+ e.preventDefault()
1745
+
1746
+ // Define COMPLEX Effect program with ONLY generic services
1747
+ const program = Effect.gen(function* () {
1748
+ const thingService = yield* ThingClientService
1749
+ const connectionService = yield* ConnectionClientService
1750
+
1751
+ // 1. Create course (just a thing with type='course')
1752
+ const courseId = yield* thingService.create({
1753
+ type: 'course',
1754
+ name: formData.title,
1755
+ properties: {
1756
+ title: formData.title,
1757
+ description: formData.description,
1758
+ price: formData.price
1759
+ }
1760
+ })
1761
+
1762
+ // 2. Create default lesson (just a thing with type='lesson')
1763
+ const lessonId = yield* thingService.create({
1764
+ type: 'lesson',
1765
+ name: 'Introduction',
1766
+ properties: {
1767
+ content: 'Welcome to the course!'
1768
+ }
1769
+ })
1770
+
1771
+ // 3. Connect lesson to course (generic connection)
1772
+ yield* connectionService.create({
1773
+ fromThingId: lessonId,
1774
+ toThingId: courseId,
1775
+ relationshipType: 'part_of'
1776
+ })
1777
+
1778
+ // 4. Return course ID
1779
+ return courseId
1780
+ }).pipe(
1781
+ Effect.retry({ times: 3 }),
1782
+ Effect.timeout('5 seconds'),
1783
+ Effect.catchTag('ThingCreateError', err =>
1784
+ Effect.fail(new Error(`Failed to create course: ${err.reason}`))
1785
+ )
1786
+ )
1787
+
1788
+ // Run the program
1789
+ const courseId = await run(program, {
1790
+ onSuccess: (id) => {
1791
+ window.location.href = `/courses/${id}`
1792
+ }
1793
+ })
1794
+ }
1795
+
1796
+ return (
1797
+ <form onSubmit={handleSubmit}>
1798
+ <input
1799
+ type="text"
1800
+ value={formData.title}
1801
+ onChange={(e) => setFormData({ ...formData, title: e.target.value })}
1802
+ placeholder="Course Title"
1803
+ />
1804
+
1805
+ <textarea
1806
+ value={formData.description}
1807
+ onChange={(e) => setFormData({ ...formData, description: e.target.value })}
1808
+ placeholder="Description"
1809
+ />
1810
+
1811
+ <input
1812
+ type="number"
1813
+ value={formData.price}
1814
+ onChange={(e) => setFormData({ ...formData, price: parseFloat(e.target.value) })}
1815
+ placeholder="Price"
1816
+ />
1817
+
1818
+ <button type="submit" disabled={loading}>
1819
+ {loading ? 'Creating...' : 'Create Course'}
1820
+ </button>
1821
+
1822
+ {error && <Alert variant="destructive">{error}</Alert>}
1823
+ </form>
1824
+ )
1825
+ }
1826
+ ```
1827
+
1828
+ ### Parallel Data Fetching
1829
+
1830
+ ```tsx
1831
+ // frontend/src/components/CourseDashboard.tsx
1832
+ import { useEffect, useState } from 'react'
1833
+ import { useEffectRunner } from '@/hooks/useEffectRunner'
1834
+ import { ThingClientService } from '@/services/ThingClientService'
1835
+ import { ConnectionClientService } from '@/services/ConnectionClientService'
1836
+ import { Effect } from 'effect'
1837
+
1838
+ interface Props {
1839
+ courseId: string
1840
+ }
1841
+
1842
+ export function CourseDashboard({ courseId }: Props) {
1843
+ const { run, loading } = useEffectRunner()
1844
+ const [data, setData] = useState<any>(null)
1845
+
1846
+ useEffect(() => {
1847
+ // Fetch all data in parallel using GENERIC services
1848
+ const program = Effect.gen(function* () {
1849
+ const thingService = yield* ThingClientService
1850
+ const connectionService = yield* ConnectionClientService
1851
+
1852
+ // Parallel fetch (all run at once)
1853
+ const [course, lessons, enrollmentCount] = yield* Effect.all([
1854
+ thingService.get(courseId),
1855
+ connectionService.getRelated(courseId, 'part_of', 'to'),
1856
+ connectionService.getCount(courseId, 'enrolled_in')
1857
+ ], { concurrency: 'unbounded' })
1858
+
1859
+ return { course, lessons, enrollmentCount }
1860
+ })
1861
+
1862
+ run(program, {
1863
+ onSuccess: setData
1864
+ })
1865
+ }, [courseId])
1866
+
1867
+ if (loading) return <div>Loading...</div>
1868
+ if (!data) return <div>No data</div>
1869
+
1870
+ return (
1871
+ <div>
1872
+ <h1>{data.course.name}</h1>
1873
+ <p>{data.enrollmentCount} students enrolled</p>
1874
+
1875
+ <h2>Lessons</h2>
1876
+ {data.lessons.map((lesson: any) => (
1877
+ <div key={lesson._id}>{lesson.name}</div>
1878
+ ))}
1879
+ </div>
1880
+ )
1881
+ }
1882
+ ```
1883
+
1884
+ ---
1885
+
1886
+ ## Component Patterns
1887
+
1888
+ ### Generic Card (Pure Presentation)
1889
+
1890
+ ```tsx
1891
+ // frontend/src/components/cards/ThingCard.tsx
1892
+ import { Card } from '@/components/ui/card'
1893
+ import { getThingConfig } from '@/ontology/config'
1894
+ import * as Icons from 'lucide-react'
1895
+
1896
+ interface ThingCardProps {
1897
+ thing: {
1898
+ _id: string
1899
+ type: string
1900
+ name: string
1901
+ properties: Record<string, any>
1902
+ }
1903
+ }
1904
+
1905
+ export function ThingCard({ thing }: ThingCardProps) {
1906
+ // Get UI config
1907
+ const config = getThingConfig(thing.type as any)
1908
+ const Icon = Icons[config.icon as keyof typeof Icons]
1909
+
1910
+ // Extract display values
1911
+ const title = thing.properties[config.primaryField] || thing.name
1912
+ const subtitle = config.secondaryField
1913
+ ? thing.properties[config.secondaryField]
1914
+ : null
1915
+ const image = config.imageField
1916
+ ? thing.properties[config.imageField]
1917
+ : null
1918
+
1919
+ // Pure presentation - NO logic
1920
+ return (
1921
+ <Card>
1922
+ {image && <img src={image} alt={title} />}
1923
+
1924
+ <div className="p-4">
1925
+ <div className="flex items-center gap-2">
1926
+ <Icon className="w-5 h-5" />
1927
+ <span>{config.displayName}</span>
1928
+ </div>
1929
+
1930
+ <h3 className="text-xl font-bold">{title}</h3>
1931
+ {subtitle && <p className="text-gray-600">{subtitle}</p>}
1932
+
1933
+ <a href={`/${thing.type}s/${thing._id}`}>
1934
+ <button>View Details</button>
1935
+ </a>
1936
+ </div>
1937
+ </Card>
1938
+ )
1939
+ }
1940
+ ```
1941
+
1942
+ **Key Points:**
1943
+ - ✅ Receives data as props
1944
+ - ✅ Uses UI config for display
1945
+ - ✅ Pure presentation logic
1946
+ - ❌ NO database calls
1947
+ - ❌ NO business logic
1948
+ - ❌ NO validation
1949
+
1950
+ ---
1951
+
1952
+ ## Page Patterns & SSR
1953
+
1954
+ ### Fetch from Backend, Render HTML
1955
+
1956
+ ```astro
1957
+ ---
1958
+ // frontend/src/pages/courses/[id].astro
1959
+ import { getConvexClient } from '@/lib/convex'
1960
+ import { api } from '@/lib/api'
1961
+ import Layout from '@/layouts/Layout.astro'
1962
+ import EnrollButton from '@/components/EnrollButton.tsx'
1963
+
1964
+ // SSR: Fetch data from backend via HTTP
1965
+ const convex = getConvexClient()
1966
+
1967
+ const course = await convex.query(api.queries.things.get, {
1968
+ id: Astro.params.id
1969
+ })
1970
+
1971
+ if (!course) {
1972
+ return Astro.redirect('/404')
1973
+ }
1974
+
1975
+ // Get related lessons from backend
1976
+ const lessons = await convex.query(api.queries.things.getRelated, {
1977
+ thingId: course._id,
1978
+ relationshipType: 'part_of',
1979
+ direction: 'to'
1980
+ })
1981
+ ---
1982
+
1983
+ <Layout title={course.name}>
1984
+ <!-- Static HTML rendered on server -->
1985
+ <header>
1986
+ <h1>{course.name}</h1>
1987
+ <p>{course.properties.description}</p>
1988
+ <span className="text-2xl">${course.properties.price}</span>
1989
+ </header>
1990
+
1991
+ <!-- Lessons list (static) -->
1992
+ <section>
1993
+ <h2>Lessons</h2>
1994
+ {lessons.map(lesson => (
1995
+ <div>
1996
+ <h3>{lesson.name}</h3>
1997
+ <p>{lesson.properties.content}</p>
1998
+ </div>
1999
+ ))}
2000
+ </section>
2001
+
2002
+ <!-- Interactive enrollment button (React Island) -->
2003
+ <EnrollButton client:load courseId={course._id} />
2004
+ </Layout>
2005
+ ```
2006
+
2007
+ **Key Points:**
2008
+ - ✅ Calls backend API to get data
2009
+ - ✅ Renders static HTML
2010
+ - ✅ Fast initial load (SSR)
2011
+ - ❌ NO database access
2012
+ - ❌ NO business logic in page
2013
+
2014
+ ---
2015
+
2016
+ ## Real-Time Components
2017
+
2018
+ ### Subscribe to Backend Changes
2019
+
2020
+ ```tsx
2021
+ // frontend/src/components/LiveEnrollmentCount.tsx
2022
+ import { useQuery } from 'convex/react'
2023
+ import { api } from '@/lib/api'
2024
+
2025
+ export function LiveEnrollmentCount({ courseId }: Props) {
2026
+ // Real-time subscription to backend
2027
+ // When ANYONE enrolls, this updates EVERYWHERE instantly
2028
+ const count = useQuery(api.queries.connections.getCount, {
2029
+ toThingId: courseId,
2030
+ relationshipType: 'enrolled_in'
2031
+ })
2032
+
2033
+ if (count === undefined) return <div>Loading...</div>
2034
+
2035
+ return (
2036
+ <div>
2037
+ <span className="text-3xl font-bold">{count}</span>
2038
+ <span className="text-sm text-gray-600"> students enrolled</span>
2039
+ </div>
2040
+ )
2041
+ }
2042
+ ```
2043
+
2044
+ **How It Works:**
2045
+ 1. Component subscribes to backend query via WebSocket
2046
+ 2. Backend watches database for changes
2047
+ 3. When connection created → backend pushes update to frontend
2048
+ 4. Component auto-re-renders
2049
+ 5. **Frontend does NOTHING except display the number**
2050
+
2051
+ ---
2052
+
2053
+ ## Forms & Data Mutations
2054
+
2055
+ ### Collect Input, Send to Backend
2056
+
2057
+ ```tsx
2058
+ // frontend/src/components/forms/ThingForm.tsx
2059
+ import { useMutation } from 'convex/react'
2060
+ import { api } from '@/lib/api'
2061
+ import { getThingConfig } from '@/ontology/config'
2062
+ import { useState } from 'react'
2063
+
2064
+ interface ThingFormProps {
2065
+ type: ThingType
2066
+ onSuccess?: (id: string) => void
2067
+ }
2068
+
2069
+ export function ThingForm({ type, onSuccess }: ThingFormProps) {
2070
+ const config = getThingConfig(type)
2071
+ const [formData, setFormData] = useState({})
2072
+ const [error, setError] = useState<string | null>(null)
2073
+
2074
+ // Backend mutation (frontend just calls it)
2075
+ const createThing = useMutation(api.mutations.things.create)
2076
+
2077
+ const handleSubmit = async (e: React.FormEvent) => {
2078
+ e.preventDefault()
2079
+ setError(null)
2080
+
2081
+ try {
2082
+ // Send to backend - backend validates, creates, logs events
2083
+ const id = await createThing({
2084
+ type,
2085
+ name: formData[config.primaryField],
2086
+ properties: formData
2087
+ })
2088
+
2089
+ onSuccess?.(id)
2090
+ } catch (err) {
2091
+ // Display backend error
2092
+ setError(err.message)
2093
+ }
2094
+ }
2095
+
2096
+ return (
2097
+ <form onSubmit={handleSubmit}>
2098
+ {/* Form fields from UI config */}
2099
+ {Object.entries(config.fields).map(([field, fieldConfig]) => (
2100
+ <div key={field}>
2101
+ <label>{fieldConfig.label}</label>
2102
+ <input
2103
+ type={fieldConfig.type}
2104
+ value={formData[field] || ''}
2105
+ onChange={(e) => setFormData({ ...formData, [field]: e.target.value })}
2106
+ placeholder={fieldConfig.placeholder}
2107
+ required={fieldConfig.required}
2108
+ />
2109
+ </div>
2110
+ ))}
2111
+
2112
+ {error && <div className="text-red-600">{error}</div>}
2113
+
2114
+ <button type="submit">Create</button>
2115
+ </form>
2116
+ )
2117
+ }
2118
+ ```
2119
+
2120
+ **Key Points:**
2121
+ - ✅ Collects user input
2122
+ - ✅ Sends to backend mutation
2123
+ - ✅ Displays backend errors
2124
+ - ⚠️ Frontend validation is optional (UX only)
2125
+ - ❌ Backend MUST validate (security)
2126
+ - ❌ Frontend does NOT create database records
2127
+
2128
+ ---
2129
+
2130
+ ## Multi-Tenant Routing
2131
+
2132
+ ### Middleware: Extract Org from Subdomain
2133
+
2134
+ ```typescript
2135
+ // frontend/src/middleware.ts
2136
+ import { defineMiddleware } from 'astro:middleware'
2137
+ import { getConvexClient } from './lib/convex'
2138
+ import { api } from './lib/api'
2139
+
2140
+ export const onRequest = defineMiddleware(async (context, next) => {
2141
+ const url = new URL(context.request.url)
2142
+
2143
+ // Extract org slug from subdomain
2144
+ // fitnesspro.one.ie → "fitnesspro"
2145
+ const hostname = url.hostname
2146
+ const orgSlug = hostname.split('.')[0]
2147
+
2148
+ // Skip for main domains
2149
+ if (['api', 'www', 'localhost'].includes(orgSlug)) {
2150
+ return next()
2151
+ }
2152
+
2153
+ // Fetch org from backend
2154
+ const convex = getConvexClient()
2155
+ const org = await convex.query(api.queries.orgs.getBySlug, {
2156
+ slug: orgSlug
2157
+ })
2158
+
2159
+ if (org) {
2160
+ // Inject org context for pages to use
2161
+ context.locals.org = org
2162
+ context.locals.orgId = org._id
2163
+ }
2164
+
2165
+ return next()
2166
+ })
2167
+ ```
2168
+
2169
+ ### Use Org Context in Pages
2170
+
2171
+ ```astro
2172
+ ---
2173
+ // frontend/src/pages/courses/index.astro
2174
+ import { getConvexClient } from '@/lib/convex'
2175
+ import { api } from '@/lib/api'
2176
+
2177
+ // Get org from middleware
2178
+ const org = Astro.locals.org
2179
+
2180
+ if (!org) {
2181
+ return Astro.redirect('/404')
2182
+ }
2183
+
2184
+ // Fetch org's courses from backend
2185
+ const convex = getConvexClient()
2186
+ const courses = await convex.query(api.queries.things.list, {
2187
+ type: 'course',
2188
+ groupId: org._id // Backend filters by group
2189
+ })
2190
+ ---
2191
+
2192
+ <Layout title={`${org.name} - Courses`}>
2193
+ <h1>{org.name} Courses</h1>
2194
+
2195
+ <!-- Display org's courses -->
2196
+ {courses.map(course => (
2197
+ <CourseCard thing={course} />
2198
+ ))}
2199
+ </Layout>
2200
+ ```
2201
+
2202
+ **Result:**
2203
+ - `fitnesspro.one.ie/courses` → FitnessPro courses only
2204
+ - `techcorp.one.ie/courses` → TechCorp courses only
2205
+ - **Backend enforces data isolation, frontend just passes orgId**
2206
+
2207
+ ---
2208
+
2209
+ ## Caching Ontology
2210
+
2211
+ ### Four-Tier Caching Architecture
2212
+
2213
+ ```typescript
2214
+ {
2215
+ // Tier 1: Type Definition Cache (STATIC - INFINITE TTL)
2216
+ L1_TypeDefinitions: {
2217
+ what: "Ontology type structures",
2218
+ ttl: "∞ (types never change at runtime)",
2219
+ storage: "Memory (startup load)",
2220
+ size: "200 tokens × 66 types = 13,200 tokens",
2221
+ hitRate: "99.9%+ (loaded once)",
2222
+ benefit: "AI loads 200 tokens (not 15k implementation tokens)"
2223
+ },
2224
+
2225
+ // Tier 2: Provider Interface Cache (STATIC - INFINITE TTL)
2226
+ L2_ProviderInterface: {
2227
+ what: "DataProvider method signatures",
2228
+ ttl: "∞ (interface never changes)",
2229
+ storage: "Memory (startup load)",
2230
+ size: "300 tokens (entire interface)",
2231
+ hitRate: "100% (never changes)",
2232
+ benefit: "AI never loads backend implementation (0 tokens)"
2233
+ },
2234
+
2235
+ // Tier 3: SSR Data Cache (DYNAMIC - TTL: 1-60s)
2236
+ L3_SSRData: {
2237
+ what: "Server-rendered page data",
2238
+ ttl: "1-60s (configurable per route)",
2239
+ storage: "Cloudflare KV / Edge cache",
2240
+ size: "Variable (full pages or data)",
2241
+ strategy: "Stale-while-revalidate",
2242
+ benefit: "Reduces provider calls by 80-95%"
2243
+ },
2244
+
2245
+ // Tier 4: Client Subscriptions (REALTIME - TTL: 0)
2246
+ L4_RealtimeSubscriptions: {
2247
+ what: "WebSocket live updates",
2248
+ ttl: "0 (always fresh)",
2249
+ storage: "Client memory (ephemeral)",
2250
+ strategy: "Provider pushes updates",
2251
+ when_to_use: [
2252
+ "Real-time dashboards",
2253
+ "Live enrollment counts",
2254
+ "Collaborative editing",
2255
+ "Chat/notifications"
2256
+ ]
2257
+ },
2258
+
2259
+ // Cache Hierarchy Decision Tree
2260
+ decisionTree: {
2261
+ question: "Is this ontology type data?",
2262
+ yes: "L1 (Type Definition Cache) - infinite TTL",
2263
+ no: {
2264
+ question: "Is this provider interface?",
2265
+ yes: "L2 (Provider Interface Cache) - infinite TTL",
2266
+ no: {
2267
+ question: "Does data change in real-time?",
2268
+ yes: "L4 (Real-time Subscriptions) - 0 TTL",
2269
+ no: {
2270
+ question: "Is data page-level?",
2271
+ yes: "L3 (SSR Data Cache) - 1-60s TTL",
2272
+ no: "No cache (fetch on demand)"
2273
+ }
2274
+ }
2275
+ }
2276
+ },
2277
+
2278
+ // Golden Rule
2279
+ rule: "Cache closer to definition = less context loaded. Types/interface = cached forever."
2280
+ }
2281
+ ```
2282
+
2283
+ ### Cache Invalidation Strategies
2284
+
2285
+ ```typescript
2286
+ {
2287
+ strategies: {
2288
+ // L1 & L2: Never invalidate (static types/interface)
2289
+ static: {
2290
+ invalidation: "None (only invalidate on deployment)",
2291
+ reason: "Types and interface don't change at runtime"
2292
+ },
2293
+
2294
+ // L3: Time-based + event-based
2295
+ ssr: {
2296
+ time_based: "TTL expires → fetch fresh",
2297
+ event_based: "Backend mutation → invalidate affected pages",
2298
+ example: `
2299
+ // When course updated, invalidate course page cache
2300
+ await provider.things.update(courseId, updates)
2301
+ await cache.delete(\`course:\${courseId}\`)
2302
+ `
2303
+ },
2304
+
2305
+ // L4: Automatic (subscription handles)
2306
+ realtime: {
2307
+ invalidation: "Provider pushes updates automatically",
2308
+ reason: "WebSocket connection = always fresh"
2309
+ }
2310
+ }
2311
+ }
2312
+ ```
2313
+
2314
+ ---
2315
+
2316
+ ## Error Propagation & Handling
2317
+
2318
+ ### Full Error Flow: Provider → Service → Component → UI
2319
+
2320
+ ```typescript
2321
+ {
2322
+ errorFlow: "Provider → Service → Component → UI",
2323
+
2324
+ // Level 1: Provider Errors (Effect.ts tagged errors)
2325
+ providerErrors: {
2326
+ ThingNotFoundError: {
2327
+ _tag: "ThingNotFoundError",
2328
+ fields: { thingId: string; type: ThingType },
2329
+ recovery: "Show 404 page or 'Not Found' component",
2330
+ httpStatus: 404
2331
+ },
2332
+
2333
+ UnauthorizedError: {
2334
+ _tag: "UnauthorizedError",
2335
+ fields: { userId?: string; requiredPermission: string },
2336
+ recovery: "Redirect to /login with returnUrl",
2337
+ httpStatus: 401
2338
+ },
2339
+
2340
+ NetworkError: {
2341
+ _tag: "NetworkError",
2342
+ fields: { message: string; retryable: boolean },
2343
+ recovery: "Retry with exponential backoff (if retryable)",
2344
+ httpStatus: 503
2345
+ },
2346
+
2347
+ RateLimitError: {
2348
+ _tag: "RateLimitError",
2349
+ fields: { retryAfter: number },
2350
+ recovery: "Show 'Try again in X seconds' message",
2351
+ httpStatus: 429
2352
+ }
2353
+ },
2354
+
2355
+ // Level 2: Service Errors (Domain-specific)
2356
+ serviceErrors: {
2357
+ pattern: "Transform provider error → domain error",
2358
+ example: `
2359
+ getCourseWithLessons(id: string) {
2360
+ return Effect.gen(function* () {
2361
+ const course = yield* thingService.get(id)
2362
+ const lessons = yield* connectionService.getRelated(id, 'part_of', 'to')
2363
+ return { course, lessons }
2364
+ }).pipe(
2365
+ Effect.catchTag('ThingNotFoundError', (e) =>
2366
+ Effect.fail(new CourseNotFoundError({
2367
+ courseId: e.thingId,
2368
+ message: \`Course \${e.thingId} not found\`
2369
+ }))
2370
+ )
2371
+ )
2372
+ }
2373
+ `
2374
+ },
2375
+
2376
+ // Level 3: Component Errors (Catch and render)
2377
+ componentErrors: {
2378
+ pattern: "Match error._tag → Render UI component",
2379
+ example: `
2380
+ if (error) {
2381
+ switch (error._tag) {
2382
+ case 'CourseNotFoundError':
2383
+ return <Alert variant="warning">Course not found</Alert>
2384
+ case 'UnauthorizedError':
2385
+ return <Alert variant="error">Please log in to view</Alert>
2386
+ case 'NetworkError':
2387
+ return <Alert variant="error">Network error. Retrying...</Alert>
2388
+ default:
2389
+ return <Alert variant="error">Something went wrong</Alert>
2390
+ }
2391
+ }
2392
+ `
2393
+ },
2394
+
2395
+ // Level 4: UI Errors (User-facing messages)
2396
+ uiErrors: {
2397
+ pattern: "Error → User-friendly message + Action",
2398
+ mapping: {
2399
+ ThingNotFoundError: {
2400
+ message: "This {type} doesn't exist",
2401
+ action: "Go back or search for another",
2402
+ component: "<Alert404 />"
2403
+ },
2404
+
2405
+ UnauthorizedError: {
2406
+ message: "You need to log in to see this",
2407
+ action: "Log in or Sign up",
2408
+ component: "<LoginPrompt returnUrl={currentPath} />"
2409
+ },
2410
+
2411
+ NetworkError: {
2412
+ message: "Connection issue",
2413
+ action: "Retrying automatically...",
2414
+ component: "<RetryAlert retrying={true} />"
2415
+ }
2416
+ }
2417
+ },
2418
+
2419
+ // Error Boundary Pattern
2420
+ errorBoundary: `
2421
+ export class ErrorBoundary extends React.Component {
2422
+ state = { error: null }
2423
+
2424
+ static getDerivedStateFromError(error) {
2425
+ return { error }
2426
+ }
2427
+
2428
+ render() {
2429
+ if (this.state.error) {
2430
+ return <ErrorFallback error={this.state.error} />
2431
+ }
2432
+
2433
+ return this.props.children
2434
+ }
2435
+ }
2436
+
2437
+ // Usage: Wrap islands in error boundaries
2438
+ <ErrorBoundary>
2439
+ <CourseDetail client:load courseId={id} />
2440
+ </ErrorBoundary>
2441
+ `,
2442
+
2443
+ // Golden Rule
2444
+ invariant: "Every error path has explicit UI recovery. No silent failures."
2445
+ }
2446
+ ```
2447
+
2448
+ ---
2449
+
2450
+ ## Testing Patterns
2451
+
2452
+ ### Three-Layer Testing Strategy
2453
+
2454
+ ```typescript
2455
+ {
2456
+ // Layer 1: Unit Tests (Service logic with mock provider)
2457
+ unitTests: {
2458
+ what: "Test service logic in isolation",
2459
+ mock: "MockProvider (no real backend)",
2460
+ fast: "Milliseconds per test",
2461
+
2462
+ example: `
2463
+ describe('CourseService.getCourseWithLessons', () => {
2464
+ it('should return course with lessons', async () => {
2465
+ // Mock provider
2466
+ const MockProvider = Layer.succeed(DataProvider, {
2467
+ things: {
2468
+ get: (id) => Effect.succeed({
2469
+ _id: id,
2470
+ type: 'course',
2471
+ name: 'Test Course'
2472
+ })
2473
+ },
2474
+ connections: {
2475
+ getRelated: (thingId, type, direction) => Effect.succeed([
2476
+ { _id: 'lesson1', type: 'lesson', name: 'Lesson 1' },
2477
+ { _id: 'lesson2', type: 'lesson', name: 'Lesson 2' }
2478
+ ])
2479
+ }
2480
+ })
2481
+
2482
+ // Test service
2483
+ const result = await Effect.runPromise(
2484
+ Effect.gen(function* () {
2485
+ const service = yield* CourseService
2486
+ return yield* service.getCourseWithLessons('course123')
2487
+ }).pipe(Effect.provide(MockProvider))
2488
+ )
2489
+
2490
+ expect(result.course.name).toBe('Test Course')
2491
+ expect(result.lessons).toHaveLength(2)
2492
+ })
2493
+ })
2494
+ `,
2495
+
2496
+ coverage: [
2497
+ "Service logic (business rules)",
2498
+ "Error transformations",
2499
+ "Effect composition",
2500
+ "Edge cases"
2501
+ ]
2502
+ },
2503
+
2504
+ // Layer 2: Integration Tests (Service + Real Provider + Test Backend)
2505
+ integrationTests: {
2506
+ what: "Test service + provider + real backend",
2507
+ backend: "Test Convex deployment (isolated database)",
2508
+ slow: "Seconds per test (real network calls)",
2509
+
2510
+ coverage: [
2511
+ "Full data flow (service → provider → backend → database)",
2512
+ "Real mutations and queries",
2513
+ "Data consistency",
2514
+ "Backend constraints"
2515
+ ]
2516
+ },
2517
+
2518
+ // Layer 3: E2E Tests (Full UI flow in browser)
2519
+ e2eTests: {
2520
+ what: "Test complete user flows in browser",
2521
+ tool: "Playwright (headless Chrome)",
2522
+ slow: "10-30s per test (full page loads)",
2523
+
2524
+ coverage: [
2525
+ "User flows (click, type, navigate)",
2526
+ "Visual rendering",
2527
+ "Loading states",
2528
+ "Error states",
2529
+ "Authentication flows"
2530
+ ]
2531
+ },
2532
+
2533
+ // Test Pyramid
2534
+ pyramid: {
2535
+ unit: "70% (fast, many tests, mock provider)",
2536
+ integration: "20% (medium, key flows, test backend)",
2537
+ e2e: "10% (slow, critical paths, real UI)"
2538
+ },
2539
+
2540
+ // Golden Rule
2541
+ invariant: "Mock providers for unit tests. Real providers for integration. Real UI for E2E."
2542
+ }
2543
+ ```
2544
+
2545
+ ---
2546
+
2547
+ ## Common Mistakes & Solutions
2548
+
2549
+ ### Top 10 Anti-Patterns to Avoid
2550
+
2551
+ ```typescript
2552
+ {
2553
+ // Mistake 1: Coupling to specific provider
2554
+ mistake1: {
2555
+ problem: "Importing Convex directly in frontend code",
2556
+ bad: `
2557
+ // ❌ BAD
2558
+ import { ConvexClient } from 'convex/browser'
2559
+ const client = new ConvexClient(url)
2560
+ const course = await client.query(api.courses.get, { id })
2561
+ `,
2562
+ good: `
2563
+ // ✅ GOOD
2564
+ const provider = yield* DataProvider
2565
+ const course = yield* provider.things.get(id)
2566
+ `,
2567
+ why: "Bad code breaks when you swap backends. Good code works with ANY backend."
2568
+ },
2569
+
2570
+ // Mistake 2: Creating specialized services prematurely
2571
+ mistake2: {
2572
+ problem: "Creating CourseService before patterns emerge",
2573
+ bad: `
2574
+ // ❌ BAD (created after 1 use)
2575
+ class CourseService {
2576
+ getCourseWithLessons(id) {
2577
+ // Used once, doesn't justify specialized service
2578
+ }
2579
+ }
2580
+ `,
2581
+ good: `
2582
+ // ✅ GOOD (use generic services until pattern repeats 3+ times)
2583
+ const course = yield* thingService.get(id)
2584
+ const lessons = yield* connectionService.getRelated(id, 'part_of', 'to')
2585
+
2586
+ // Only create CourseService after repeating this 3+ times
2587
+ `,
2588
+ why: "Premature abstraction creates unnecessary complexity. Wait for patterns."
2589
+ },
2590
+
2591
+ // Mistake 3: Duplicating server state in frontend
2592
+ mistake3: {
2593
+ problem: "Storing backend data in useState",
2594
+ bad: `
2595
+ // ❌ BAD
2596
+ const [courses, setCourses] = useState([])
2597
+ useEffect(() => {
2598
+ provider.things.list({ type: 'course' })
2599
+ .then(setCourses)
2600
+ }, [])
2601
+ `,
2602
+ good: `
2603
+ // ✅ GOOD
2604
+ const courses = useQuery(api.courses.list)
2605
+ // Provider handles caching, no state duplication
2606
+ `,
2607
+ why: "Duplicating state creates sync issues. Let provider handle caching."
2608
+ },
2609
+
2610
+ // Mistake 4: Not handling error states
2611
+ mistake4: {
2612
+ problem: "No UI for errors",
2613
+ bad: `
2614
+ // ❌ BAD
2615
+ const course = await provider.things.get(id)
2616
+ return <div>{course.name}</div>
2617
+ // What if course is undefined? No error handling!
2618
+ `,
2619
+ good: `
2620
+ // ✅ GOOD
2621
+ try {
2622
+ const course = await provider.things.get(id)
2623
+ return <div>{course.name}</div>
2624
+ } catch (error) {
2625
+ if (error._tag === 'ThingNotFoundError') {
2626
+ return <Alert>Course not found</Alert>
2627
+ }
2628
+ return <Alert>Error loading course</Alert>
2629
+ }
2630
+ `,
2631
+ why: "Errors WILL happen. Always have UI for error states."
2632
+ },
2633
+
2634
+ // Mistake 5: Manual group filtering
2635
+ mistake5: {
2636
+ problem: "Manually filtering by groupId",
2637
+ bad: `
2638
+ // ❌ BAD
2639
+ const courses = await provider.things.list({
2640
+ type: 'course',
2641
+ groupId: ctx.locals.groupId // Manual filtering
2642
+ })
2643
+ `,
2644
+ good: `
2645
+ // ✅ GOOD
2646
+ const courses = await provider.things.list({ type: 'course' })
2647
+ // Provider auto-injects groupId
2648
+ `,
2649
+ why: "Provider enforces multi-tenancy. Frontend shouldn't know about groups."
2650
+ },
2651
+
2652
+ // Mistake 6: Not testing with mock providers
2653
+ mistake6: {
2654
+ problem: "Testing with real backend (slow, flaky)",
2655
+ bad: `
2656
+ // ❌ BAD
2657
+ test('gets course', async () => {
2658
+ const course = await service.get('real_id_from_db')
2659
+ // Depends on real database state
2660
+ })
2661
+ `,
2662
+ good: `
2663
+ // ✅ GOOD
2664
+ test('gets course', async () => {
2665
+ const MockProvider = Layer.succeed(DataProvider, {
2666
+ things: { get: (id) => Effect.succeed(mockCourse) }
2667
+ })
2668
+
2669
+ const course = await service.get('any_id')
2670
+ .pipe(Effect.provide(MockProvider))
2671
+ // Fast, deterministic, no database
2672
+ })
2673
+ `,
2674
+ why: "Unit tests should be fast and deterministic. Use mocks."
2675
+ },
2676
+
2677
+ // Mistake 7: Skipping progressive enhancement
2678
+ mistake7: {
2679
+ problem: "JavaScript-only forms (don't work without JS)",
2680
+ bad: `
2681
+ // ❌ BAD
2682
+ <button onClick={() => enroll()}>Enroll</button>
2683
+ // Doesn't work if JS fails to load
2684
+ `,
2685
+ good: `
2686
+ // ✅ GOOD
2687
+ <form action="/api/enroll" method="post">
2688
+ <button type="submit">Enroll</button>
2689
+ </form>
2690
+ // Works with or without JS
2691
+
2692
+ // Then enhance with JS:
2693
+ <EnrollButton client:load /> // Adds optimistic UI
2694
+ `,
2695
+ why: "Always start with working HTML. JavaScript should enhance, not enable."
2696
+ },
2697
+
2698
+ // Mistake 8: Ignoring type sync
2699
+ mistake8: {
2700
+ problem: "Manually duplicating backend types in frontend",
2701
+ bad: `
2702
+ // ❌ BAD
2703
+ // frontend/types.ts
2704
+ type Course = {
2705
+ id: string
2706
+ title: string
2707
+ // Manually copied from backend
2708
+ }
2709
+ `,
2710
+ good: `
2711
+ // ✅ GOOD
2712
+ import type { Thing } from '@/convex/_generated/dataModel'
2713
+ // Auto-synced from backend schema
2714
+ `,
2715
+ why: "Manual type sync breaks. Use generated types from backend."
2716
+ },
2717
+
2718
+ // Mistake 9: Loading too much context
2719
+ mistake9: {
2720
+ problem: "Loading entire codebase for AI generation",
2721
+ bad: `
2722
+ // ❌ BAD
2723
+ const context = {
2724
+ allFiles: loadFiles('**/*.ts'), // 200k tokens
2725
+ allDocs: loadDocs(), // 50k tokens
2726
+ allExamples: loadExamples() // 30k tokens
2727
+ } // 280k tokens
2728
+ `,
2729
+ good: `
2730
+ // ✅ GOOD
2731
+ const context = {
2732
+ interface: DataProviderInterface, // 300 tokens
2733
+ pattern: servicePattern // 400 tokens
2734
+ } // 700 tokens (99.7% reduction)
2735
+ `,
2736
+ why: "Context explosion wastes time and money. Load only what's needed."
2737
+ },
2738
+
2739
+ // Mistake 10: Business logic in frontend
2740
+ mistake10: {
2741
+ problem: "Validating business rules in frontend only",
2742
+ bad: `
2743
+ // ❌ BAD
2744
+ if (user.tokens >= course.price) {
2745
+ // Frontend calculates eligibility
2746
+ }
2747
+ `,
2748
+ good: `
2749
+ // ✅ GOOD
2750
+ // Backend validates (frontend just shows loading)
2751
+ const result = await provider.things.create(courseData)
2752
+ // Backend enforces: tokens >= price
2753
+ `,
2754
+ why: "Frontend can be bypassed. Backend MUST enforce all rules."
2755
+ }
2756
+ }
2757
+ ```
2758
+
2759
+ ---
2760
+
2761
+ ## Summary & Key Patterns
2762
+
2763
+ ### Frontend Responsibilities (ONLY These)
2764
+
2765
+ | What | How | Example |
2766
+ |------|-----|---------|
2767
+ | **Render UI** | Astro pages + React components | `<h1>{course.name}</h1>` |
2768
+ | **Call Backend** | Effect.ts services or Convex hooks | `yield* courseService.get(id)` |
2769
+ | **Manage UI State** | `useState`, `useReducer`, `useEffectRunner` | `const { run, loading, error } = useEffectRunner()` |
2770
+ | **Route Users** | Astro routing, middleware | `/courses/[id].astro` |
2771
+ | **Display Errors** | Show typed backend errors | `Effect.catchTag('NotFoundError', ...)` |
2772
+
2773
+ ### The Architecture Contract
2774
+
2775
+ ```typescript
2776
+ // Frontend → Backend (only way to interact)
2777
+
2778
+ // ✅ Frontend calls backend query
2779
+ const courses = useQuery(api.queries.things.list, { type: 'course' })
2780
+
2781
+ // ✅ Frontend calls backend mutation
2782
+ const create = useMutation(api.mutations.things.create)
2783
+ await create({ type: 'course', name: 'Fitness 101', properties: {...} })
2784
+
2785
+ // ✅ Backend implements logic
2786
+ export const create = mutation({
2787
+ handler: async (ctx, args) => {
2788
+ // Validate
2789
+ // Create in database
2790
+ // Log event
2791
+ // Return result
2792
+ }
2793
+ })
2794
+
2795
+ // ❌ Frontend NEVER accesses database directly
2796
+ const courses = await ctx.db.query('things') // IMPOSSIBLE in frontend
2797
+ ```
2798
+
2799
+ ### Key Principles
2800
+
2801
+ 1. **Separation:** Frontend renders, backend manages data
2802
+ 2. **Type-Safe:** Effect.ts enforces error handling, backend generates types
2803
+ 3. **Composability:** Effect.ts services combine into complex flows
2804
+ 4. **Real-Time:** WebSocket subscriptions auto-update UI
2805
+ 5. **Multi-Tenant:** Middleware extracts org → pages filter by org
2806
+ 6. **Testability:** Effect.ts test layers replace mocks
2807
+ 7. **Stateless:** Frontend has no state beyond UI, backend is source of truth
2808
+ 8. **Backend-Agnostic:** Provider pattern works with ANY backend (Convex, WordPress, Notion, Supabase, etc.)
2809
+
2810
+ ### Generic vs Specialized Services Decision Tree
2811
+
2812
+ ```
2813
+ ┌──────────────────────────────────────────────────┐
2814
+ │ 66 Thing Types │
2815
+ │ course, lesson, product, video, post, etc. │
2816
+ └────────────────┬─────────────────────────────────┘
2817
+ │
2818
+ ↓
2819
+ ┌──────────────────────────────────────────────────┐
2820
+ │ 2 GENERIC SERVICES (handle everything) │
2821
+ │ │
2822
+ │ ThingClientService: │
2823
+ │ - get(id) │
2824
+ │ - list(type, orgId) │
2825
+ │ - create({ type, name, properties }) │
2826
+ │ - update(id, updates) │
2827
+ │ - delete(id) │
2828
+ │ │
2829
+ │ ConnectionClientService: │
2830
+ │ - create({ fromThingId, toThingId, type }) │
2831
+ │ - getRelated(thingId, type, direction) │
2832
+ │ - getCount(thingId, type) │
2833
+ │ - delete(connectionId) │
2834
+ └────────────────┬─────────────────────────────────┘
2835
+ │
2836
+ ↓
2837
+ ┌──────────────────────────────────────────────────┐
2838
+ │ SPECIALIZED SERVICES (optional, add as needed) │
2839
+ │ │
2840
+ │ CourseClientService (if you repeat patterns): │
2841
+ │ - getCourseWithLessons() │
2842
+ │ - enrollUser() │
2843
+ │ - getEnrollmentCount() │
2844
+ │ │
2845
+ │ Add ONLY when patterns repeat 3+ times │
2846
+ └──────────────────────────────────────────────────┘
2847
+ ```
2848
+
2849
+ **Start with generic services. Add specialized services as patterns emerge.**
2850
+
2851
+ ### Context Engineering Results
2852
+
2853
+ **Traditional approach:**
2854
+ - Load: 50k-300k tokens per request
2855
+ - Cost: $0.50-$3.00 per request
2856
+ - Speed: 30-60 seconds
2857
+ - Backends: 1 (tightly coupled)
2858
+
2859
+ **Ontology-driven approach:**
2860
+ - Load: 300-5k tokens per request (98-99% reduction)
2861
+ - Cost: $0.003-$0.05 per request (100x cheaper)
2862
+ - Speed: 2-5 seconds (10x faster)
2863
+ - Backends: ∞ (swap with 1 line)
2864
+
2865
+ ### Success Criteria
2866
+
2867
+ | Level | Requirement |
2868
+ |-------|-------------|
2869
+ | **Layer 1: Rendering** | ✅ Pages render from backend data via SSR ✅ React islands for interactivity ✅ No database access |
2870
+ | **Layer 2: Services** | ✅ Effect.ts services with typed errors ✅ Generic services handle all 66 types ✅ No backend-specific code |
2871
+ | **Layer 3: Data** | ✅ DataProvider interface implemented ✅ Multiple backends work (Convex, WordPress, Notion, etc.) ✅ Swap backends with 1 config line |
2872
+ | **Quality** | ✅ Unit tests with mock provider ✅ Integration tests with real backend ✅ E2E tests verify user flows ✅ TypeScript strict mode ✅ No manual type duplication |
2873
+
2874
+ ### Final Checklist
2875
+
2876
+ - [ ] DataProvider interface defined
2877
+ - [ ] At least one provider implemented (ConvexProvider minimum)
2878
+ - [ ] ThingClientService and ConnectionClientService created
2879
+ - [ ] ClientLayer dependency injection set up
2880
+ - [ ] useEffectRunner hook implemented
2881
+ - [ ] Astro pages call backend via provider
2882
+ - [ ] React components use useEffectRunner for mutations
2883
+ - [ ] Error boundaries wrap interactive islands
2884
+ - [ ] Real-time components use subscriptions (optional)
2885
+ - [ ] Forms submit to backend (don't validate locally)
2886
+ - [ ] Multi-tenant middleware extracts org from subdomain
2887
+ - [ ] Unit tests use mock provider
2888
+ - [ ] Integration tests use test backend
2889
+ - [ ] Types synced from backend schema
2890
+ - [ ] UI config for all 66 thing types
2891
+ - [ ] Display components adapt to config
2892
+
2893
+ ---
2894
+
2895
+ **Frontend is pure rendering. Backend is everything else.**
2896
+
2897
+ **Effect.ts for type-safe composability. Separate deployments. Real-time updates. Backend-agnostic forever.**
2898
+