oneie 3.6.40 → 3.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (984) hide show
  1. package/README.md +28 -9
  2. package/dist/admin/build.d.ts +15 -0
  3. package/dist/admin/build.d.ts.map +1 -0
  4. package/dist/admin/build.js +295 -0
  5. package/dist/admin/build.js.map +1 -0
  6. package/dist/admin/index.d.ts +24 -0
  7. package/dist/admin/index.d.ts.map +1 -0
  8. package/dist/admin/index.js +98 -0
  9. package/dist/admin/index.js.map +1 -0
  10. package/dist/admin/list.d.ts +14 -0
  11. package/dist/admin/list.d.ts.map +1 -0
  12. package/dist/admin/list.js +90 -0
  13. package/dist/admin/list.js.map +1 -0
  14. package/dist/admin/manifest.d.ts +86 -0
  15. package/dist/admin/manifest.d.ts.map +1 -0
  16. package/dist/admin/manifest.js +183 -0
  17. package/dist/admin/manifest.js.map +1 -0
  18. package/dist/admin/monorepo.d.ts +25 -0
  19. package/dist/admin/monorepo.d.ts.map +1 -0
  20. package/dist/admin/monorepo.js +59 -0
  21. package/dist/admin/monorepo.js.map +1 -0
  22. package/dist/admin/release.d.ts +17 -0
  23. package/dist/admin/release.d.ts.map +1 -0
  24. package/dist/admin/release.js +144 -0
  25. package/dist/admin/release.js.map +1 -0
  26. package/dist/admin/sync.d.ts +14 -0
  27. package/dist/admin/sync.d.ts.map +1 -0
  28. package/dist/admin/sync.js +104 -0
  29. package/dist/admin/sync.js.map +1 -0
  30. package/dist/admin/validate.d.ts +15 -0
  31. package/dist/admin/validate.d.ts.map +1 -0
  32. package/dist/admin/validate.js +169 -0
  33. package/dist/admin/validate.js.map +1 -0
  34. package/dist/commands/agent.d.ts +2 -0
  35. package/dist/commands/agent.d.ts.map +1 -1
  36. package/dist/commands/agent.js +44 -0
  37. package/dist/commands/agent.js.map +1 -1
  38. package/dist/commands/ask.d.ts +4 -0
  39. package/dist/commands/ask.d.ts.map +1 -0
  40. package/dist/commands/ask.js +8 -0
  41. package/dist/commands/ask.js.map +1 -0
  42. package/dist/commands/bounty.d.ts +4 -0
  43. package/dist/commands/bounty.d.ts.map +1 -0
  44. package/dist/commands/bounty.js +24 -0
  45. package/dist/commands/bounty.js.map +1 -0
  46. package/dist/commands/capabilities.d.ts +4 -0
  47. package/dist/commands/capabilities.d.ts.map +1 -0
  48. package/dist/commands/capabilities.js +18 -0
  49. package/dist/commands/capabilities.js.map +1 -0
  50. package/dist/commands/claw.d.ts +4 -0
  51. package/dist/commands/claw.d.ts.map +1 -0
  52. package/dist/commands/claw.js +14 -0
  53. package/dist/commands/claw.js.map +1 -0
  54. package/dist/commands/commend.d.ts +4 -0
  55. package/dist/commands/commend.d.ts.map +1 -0
  56. package/dist/commands/commend.js +13 -0
  57. package/dist/commands/commend.js.map +1 -0
  58. package/dist/commands/completion.d.ts +4 -0
  59. package/dist/commands/completion.d.ts.map +1 -0
  60. package/dist/commands/completion.js +49 -0
  61. package/dist/commands/completion.js.map +1 -0
  62. package/dist/commands/config.d.ts +4 -0
  63. package/dist/commands/config.d.ts.map +1 -0
  64. package/dist/commands/config.js +78 -0
  65. package/dist/commands/config.js.map +1 -0
  66. package/dist/commands/deploy.d.ts +4 -0
  67. package/dist/commands/deploy.d.ts.map +1 -0
  68. package/dist/commands/deploy.js +10 -0
  69. package/dist/commands/deploy.js.map +1 -0
  70. package/dist/commands/doctor.d.ts +4 -0
  71. package/dist/commands/doctor.d.ts.map +1 -0
  72. package/dist/commands/doctor.js +72 -0
  73. package/dist/commands/doctor.js.map +1 -0
  74. package/dist/commands/export.d.ts +4 -0
  75. package/dist/commands/export.d.ts.map +1 -0
  76. package/dist/commands/export.js +15 -0
  77. package/dist/commands/export.js.map +1 -0
  78. package/dist/commands/fade.d.ts +4 -0
  79. package/dist/commands/fade.d.ts.map +1 -0
  80. package/dist/commands/fade.js +15 -0
  81. package/dist/commands/fade.js.map +1 -0
  82. package/dist/commands/flag.d.ts +4 -0
  83. package/dist/commands/flag.d.ts.map +1 -0
  84. package/dist/commands/flag.js +13 -0
  85. package/dist/commands/flag.js.map +1 -0
  86. package/dist/commands/forget.d.ts +4 -0
  87. package/dist/commands/forget.d.ts.map +1 -0
  88. package/dist/commands/forget.js +16 -0
  89. package/dist/commands/forget.js.map +1 -0
  90. package/dist/commands/frontier.d.ts +4 -0
  91. package/dist/commands/frontier.d.ts.map +1 -0
  92. package/dist/commands/frontier.js +11 -0
  93. package/dist/commands/frontier.js.map +1 -0
  94. package/dist/commands/health.d.ts +4 -0
  95. package/dist/commands/health.d.ts.map +1 -0
  96. package/dist/commands/health.js +11 -0
  97. package/dist/commands/health.js.map +1 -0
  98. package/dist/commands/highways.d.ts +4 -0
  99. package/dist/commands/highways.d.ts.map +1 -0
  100. package/dist/commands/highways.js +14 -0
  101. package/dist/commands/highways.js.map +1 -0
  102. package/dist/commands/hire.d.ts +4 -0
  103. package/dist/commands/hire.d.ts.map +1 -0
  104. package/dist/commands/hire.js +16 -0
  105. package/dist/commands/hire.js.map +1 -0
  106. package/dist/commands/init.d.ts.map +1 -1
  107. package/dist/commands/init.js +69 -42
  108. package/dist/commands/init.js.map +1 -1
  109. package/dist/commands/know.d.ts +4 -0
  110. package/dist/commands/know.d.ts.map +1 -0
  111. package/dist/commands/know.js +8 -0
  112. package/dist/commands/know.js.map +1 -0
  113. package/dist/commands/launch.d.ts +4 -0
  114. package/dist/commands/launch.d.ts.map +1 -0
  115. package/dist/commands/launch.js +16 -0
  116. package/dist/commands/launch.js.map +1 -0
  117. package/dist/commands/mark.d.ts +4 -0
  118. package/dist/commands/mark.d.ts.map +1 -0
  119. package/dist/commands/mark.js +15 -0
  120. package/dist/commands/mark.js.map +1 -0
  121. package/dist/commands/pay.d.ts +4 -0
  122. package/dist/commands/pay.d.ts.map +1 -0
  123. package/dist/commands/pay.js +21 -0
  124. package/dist/commands/pay.js.map +1 -0
  125. package/dist/commands/pipe.d.ts +4 -0
  126. package/dist/commands/pipe.d.ts.map +1 -0
  127. package/dist/commands/pipe.js +35 -0
  128. package/dist/commands/pipe.js.map +1 -0
  129. package/dist/commands/publish.d.ts +4 -0
  130. package/dist/commands/publish.d.ts.map +1 -0
  131. package/dist/commands/publish.js +23 -0
  132. package/dist/commands/publish.js.map +1 -0
  133. package/dist/commands/recall.d.ts +4 -0
  134. package/dist/commands/recall.d.ts.map +1 -0
  135. package/dist/commands/recall.js +12 -0
  136. package/dist/commands/recall.js.map +1 -0
  137. package/dist/commands/repl.d.ts +4 -0
  138. package/dist/commands/repl.d.ts.map +1 -0
  139. package/dist/commands/repl.js +56 -0
  140. package/dist/commands/repl.js.map +1 -0
  141. package/dist/commands/reveal.d.ts +4 -0
  142. package/dist/commands/reveal.d.ts.map +1 -0
  143. package/dist/commands/reveal.js +11 -0
  144. package/dist/commands/reveal.js.map +1 -0
  145. package/dist/commands/revenue.d.ts +4 -0
  146. package/dist/commands/revenue.d.ts.map +1 -0
  147. package/dist/commands/revenue.js +11 -0
  148. package/dist/commands/revenue.js.map +1 -0
  149. package/dist/commands/select.d.ts +4 -0
  150. package/dist/commands/select.d.ts.map +1 -0
  151. package/dist/commands/select.js +19 -0
  152. package/dist/commands/select.js.map +1 -0
  153. package/dist/commands/signal.d.ts +4 -0
  154. package/dist/commands/signal.d.ts.map +1 -0
  155. package/dist/commands/signal.js +8 -0
  156. package/dist/commands/signal.js.map +1 -0
  157. package/dist/commands/stats.d.ts +4 -0
  158. package/dist/commands/stats.d.ts.map +1 -0
  159. package/dist/commands/stats.js +11 -0
  160. package/dist/commands/stats.js.map +1 -0
  161. package/dist/commands/status.d.ts +4 -0
  162. package/dist/commands/status.d.ts.map +1 -0
  163. package/dist/commands/status.js +18 -0
  164. package/dist/commands/status.js.map +1 -0
  165. package/dist/commands/sync.d.ts +4 -0
  166. package/dist/commands/sync.d.ts.map +1 -0
  167. package/dist/commands/sync.js +20 -0
  168. package/dist/commands/sync.js.map +1 -0
  169. package/dist/commands/tail.d.ts +4 -0
  170. package/dist/commands/tail.d.ts.map +1 -0
  171. package/dist/commands/tail.js +51 -0
  172. package/dist/commands/tail.js.map +1 -0
  173. package/dist/commands/warn.d.ts +4 -0
  174. package/dist/commands/warn.d.ts.map +1 -0
  175. package/dist/commands/warn.js +15 -0
  176. package/dist/commands/warn.js.map +1 -0
  177. package/dist/create-org-profile.js +2 -2
  178. package/dist/create-user-profile.js +2 -2
  179. package/dist/index.js +135 -7
  180. package/dist/index.js.map +1 -1
  181. package/dist/lib/args.d.ts +11 -0
  182. package/dist/lib/args.d.ts.map +1 -0
  183. package/dist/lib/args.js +57 -0
  184. package/dist/lib/args.js.map +1 -0
  185. package/dist/lib/config.d.ts +12 -0
  186. package/dist/lib/config.d.ts.map +1 -0
  187. package/dist/lib/config.js +38 -0
  188. package/dist/lib/config.js.map +1 -0
  189. package/dist/lib/http.d.ts +9 -0
  190. package/dist/lib/http.d.ts.map +1 -0
  191. package/dist/lib/http.js +25 -0
  192. package/dist/lib/http.js.map +1 -0
  193. package/dist/lib/output.d.ts +5 -0
  194. package/dist/lib/output.d.ts.map +1 -0
  195. package/dist/lib/output.js +32 -0
  196. package/dist/lib/output.js.map +1 -0
  197. package/dist/lib/sdk.d.ts +10 -0
  198. package/dist/lib/sdk.d.ts.map +1 -0
  199. package/dist/lib/sdk.js +22 -0
  200. package/dist/lib/sdk.js.map +1 -0
  201. package/dist/lib/telemetry.d.ts +4 -0
  202. package/dist/lib/telemetry.d.ts.map +1 -0
  203. package/dist/lib/telemetry.js +61 -0
  204. package/dist/lib/telemetry.js.map +1 -0
  205. package/dist/utils/file-resolver.js +1 -3
  206. package/dist/utils/file-resolver.js.map +1 -1
  207. package/dist/utils/installation-setup.d.ts +15 -0
  208. package/dist/utils/installation-setup.d.ts.map +1 -1
  209. package/dist/utils/installation-setup.js +71 -8
  210. package/dist/utils/installation-setup.js.map +1 -1
  211. package/package.json +5 -21
  212. package/.claude/agents/TROUBLESHOOTING.md +0 -530
  213. package/.claude/agents/agent-backend.md +0 -574
  214. package/.claude/agents/agent-builder.md +0 -911
  215. package/.claude/agents/agent-claude.md +0 -645
  216. package/.claude/agents/agent-clean.md +0 -477
  217. package/.claude/agents/agent-clone.md +0 -554
  218. package/.claude/agents/agent-designer.md +0 -1080
  219. package/.claude/agents/agent-director.md +0 -2254
  220. package/.claude/agents/agent-documenter.md +0 -688
  221. package/.claude/agents/agent-frontend.md +0 -1199
  222. package/.claude/agents/agent-integrator.md +0 -670
  223. package/.claude/agents/agent-lawyer.md +0 -1320
  224. package/.claude/agents/agent-news.md +0 -363
  225. package/.claude/agents/agent-onboard.md +0 -613
  226. package/.claude/agents/agent-ontology.md +0 -585
  227. package/.claude/agents/agent-ops.md +0 -1275
  228. package/.claude/agents/agent-problem-solver.md +0 -669
  229. package/.claude/agents/agent-quality.md +0 -1042
  230. package/.claude/agents/agent-sales.md +0 -507
  231. package/.claude/agents/agent-writer.md +0 -1068
  232. package/.claude/commands/cascade.md +0 -742
  233. package/.claude/commands/chat.md +0 -728
  234. package/.claude/commands/commit.md +0 -95
  235. package/.claude/commands/create.md +0 -544
  236. package/.claude/commands/deploy.md +0 -309
  237. package/.claude/commands/fast.md +0 -636
  238. package/.claude/commands/mcp-on.md +0 -191
  239. package/.claude/commands/media-upload.md +0 -186
  240. package/.claude/commands/news.md +0 -274
  241. package/.claude/commands/onboard.md +0 -440
  242. package/.claude/commands/one.md +0 -398
  243. package/.claude/commands/optimize.md +0 -74
  244. package/.claude/commands/plan.md +0 -719
  245. package/.claude/commands/push.md +0 -214
  246. package/.claude/commands/release.md +0 -105
  247. package/.claude/commands/review.md +0 -99
  248. package/.claude/commands/server.md +0 -487
  249. package/.claude/commands/start.md +0 -227
  250. package/.claude/commands/test.md +0 -197
  251. package/.claude/commands/validate.md +0 -140
  252. package/.claude/hooks/.last-news-context +0 -1
  253. package/.claude/hooks/PULL-BEFORE-PUSH-GUIDE.md +0 -473
  254. package/.claude/hooks/README-knowledge-hooks.md +0 -451
  255. package/.claude/hooks/README-news-generation.md +0 -364
  256. package/.claude/hooks/README-root-cleanup.md +0 -200
  257. package/.claude/hooks/README.md +0 -284
  258. package/.claude/hooks/__pycache__/todo.cpython-312.pyc +0 -0
  259. package/.claude/hooks/__pycache__/todo.cpython-313.pyc +0 -0
  260. package/.claude/hooks/auto-format.sh +0 -106
  261. package/.claude/hooks/check-filenames.py +0 -177
  262. package/.claude/hooks/clean-post.py +0 -468
  263. package/.claude/hooks/clean-pre.py +0 -393
  264. package/.claude/hooks/clean-root-markdown.sh +0 -73
  265. package/.claude/hooks/commit-push.sh +0 -95
  266. package/.claude/hooks/done.py +0 -236
  267. package/.claude/hooks/format-hook.sh +0 -163
  268. package/.claude/hooks/formatting.py +0 -187
  269. package/.claude/hooks/hook-logger.sh +0 -173
  270. package/.claude/hooks/knowledge-post.py +0 -355
  271. package/.claude/hooks/knowledge-pre.py +0 -245
  272. package/.claude/hooks/mcp-on.sh +0 -134
  273. package/.claude/hooks/notification-hook.sh +0 -279
  274. package/.claude/hooks/ontology-validation.py +0 -255
  275. package/.claude/hooks/push.sh +0 -153
  276. package/.claude/hooks/release-cli.sh +0 -205
  277. package/.claude/hooks/root-cleanup.py +0 -217
  278. package/.claude/hooks/security-hook.sh +0 -397
  279. package/.claude/hooks/tag-all-docs.py +0 -464
  280. package/.claude/hooks/test-validate-ontology.sh +0 -170
  281. package/.claude/hooks/todo.py +0 -368
  282. package/.claude/hooks/track-changes.sh +0 -101
  283. package/.claude/hooks/validate-imports.py +0 -182
  284. package/.claude/hooks/validate-ontology-structure-summary.md +0 -243
  285. package/.claude/hooks/validate-ontology-structure.py +0 -558
  286. package/.claude/hooks/validate-ontology-structure.py.backup +0 -518
  287. package/.claude/hooks/validate-ontology.py +0 -140
  288. package/.claude/hooks/write-news.sh +0 -194
  289. package/.claude/skills/INDEX.md +0 -523
  290. package/.claude/skills/REGISTRY.md +0 -529
  291. package/.claude/skills/agent-backend-create-mutation.md +0 -319
  292. package/.claude/skills/agent-designer-create-wireframe.md +0 -341
  293. package/.claude/skills/agent-frontend-create-page.md +0 -413
  294. package/.claude/skills/agents/README.md +0 -238
  295. package/.claude/skills/astro/add-content-collection.md +0 -30
  296. package/.claude/skills/astro/check-build.md +0 -29
  297. package/.claude/skills/astro/create-component.md +0 -29
  298. package/.claude/skills/astro/create-page.md +0 -30
  299. package/.claude/skills/astro/optimize-performance.md +0 -21
  300. package/.claude/skills/convex/check-deployment.md +0 -46
  301. package/.claude/skills/convex/create-mutation.md +0 -405
  302. package/.claude/skills/convex/create-query.md +0 -52
  303. package/.claude/skills/convex/read-schema.md +0 -373
  304. package/.claude/skills/convex/test-function.md +0 -50
  305. package/.claude/skills/deployment/check-deployment-health.md +0 -20
  306. package/.claude/skills/deployment/create-release.md +0 -21
  307. package/.claude/skills/deployment/deploy-cloudflare.md +0 -31
  308. package/.claude/skills/deployment/deploy-convex.md +0 -30
  309. package/.claude/skills/deployment/sync-repositories.md +0 -19
  310. package/.claude/skills/design/check-accessibility.md +0 -21
  311. package/.claude/skills/design/create-component-spec.md +0 -27
  312. package/.claude/skills/design/generate-design-tokens.md +0 -24
  313. package/.claude/skills/design/generate-wireframe.md +0 -30
  314. package/.claude/skills/documentation/create-migration-guide.md +0 -20
  315. package/.claude/skills/documentation/generate-api-docs.md +0 -27
  316. package/.claude/skills/documentation/generate-readme.md +0 -22
  317. package/.claude/skills/documentation/update-knowledge.md +0 -20
  318. package/.claude/skills/integration/connect-external-system.md +0 -21
  319. package/.claude/skills/integration/implement-a2a.md +0 -20
  320. package/.claude/skills/integration/implement-acp.md +0 -20
  321. package/.claude/skills/integration/verify-integration.md +0 -20
  322. package/.claude/skills/ontology/README.md +0 -255
  323. package/.claude/skills/ontology/check-dimension.md +0 -307
  324. package/.claude/skills/ontology/generate-entity-type.md +0 -339
  325. package/.claude/skills/ontology/validate-schema.md +0 -229
  326. package/.claude/skills/ontology/verify-relationships.md +0 -310
  327. package/.claude/skills/problem-solving/analyze-test-failure.md +0 -21
  328. package/.claude/skills/problem-solving/identify-root-cause.md +0 -20
  329. package/.claude/skills/problem-solving/propose-solution.md +0 -29
  330. package/.claude/skills/problem-solving/verify-fix.md +0 -21
  331. package/.claude/skills/sales/generate-demo-script.md +0 -21
  332. package/.claude/skills/sales/qualify-lead.md +0 -30
  333. package/.claude/skills/sales/track-trial.md +0 -20
  334. package/.claude/skills/sales/verify-kyc.md +0 -20
  335. package/.claude/skills/testing/analyze-coverage.md +0 -24
  336. package/.claude/skills/testing/generate-tests.md +0 -24
  337. package/.claude/skills/testing/run-tests.md +0 -27
  338. package/.claude/skills/testing/validate-e2e.md +0 -25
  339. package/AGENTS.md +0 -60
  340. package/CLAUDE.md +0 -321
  341. package/CREATE-WEBSITE.md +0 -458
  342. package/SECURITY.md +0 -31
  343. package/dist/commands/create-website.d.ts +0 -19
  344. package/dist/commands/create-website.d.ts.map +0 -1
  345. package/dist/commands/create-website.js +0 -231
  346. package/dist/commands/create-website.js.map +0 -1
  347. package/folders.yaml +0 -92
  348. package/one/README.md +0 -760
  349. package/one/connections/a2a.md +0 -600
  350. package/one/connections/acp.md +0 -808
  351. package/one/connections/acps.md +0 -749
  352. package/one/connections/agentkit.md +0 -367
  353. package/one/connections/agui.md +0 -785
  354. package/one/connections/any-backend.md +0 -1720
  355. package/one/connections/ap2.md +0 -1072
  356. package/one/connections/api/queries-reference.md +0 -860
  357. package/one/connections/api-docs.md +0 -1909
  358. package/one/connections/api-reference.md +0 -1029
  359. package/one/connections/api.md +0 -2208
  360. package/one/connections/architecture-diagram.md +0 -112
  361. package/one/connections/communications.md +0 -467
  362. package/one/connections/connections.md +0 -357
  363. package/one/connections/copilotkit.md +0 -1577
  364. package/one/connections/cryptonetworks.md +0 -799
  365. package/one/connections/documentation.md +0 -1138
  366. package/one/connections/effect.md +0 -297
  367. package/one/connections/elizaos.md +0 -1308
  368. package/one/connections/groups.md +0 -814
  369. package/one/connections/inference.md +0 -76
  370. package/one/connections/integration-examples.md +0 -893
  371. package/one/connections/integration-guide.md +0 -887
  372. package/one/connections/integration-phase2.md +0 -754
  373. package/one/connections/kyc.md +0 -650
  374. package/one/connections/mcp.md +0 -860
  375. package/one/connections/membership.md +0 -1170
  376. package/one/connections/middleware.md +0 -1085
  377. package/one/connections/multitenant.md +0 -1359
  378. package/one/connections/n8n.md +0 -1033
  379. package/one/connections/patterns.md +0 -107
  380. package/one/connections/protocols.md +0 -297
  381. package/one/connections/relationships.md +0 -125
  382. package/one/connections/schema.md +0 -605
  383. package/one/connections/service-layer.md +0 -568
  384. package/one/connections/vectors.md +0 -225
  385. package/one/connections/wordpress.md +0 -1320
  386. package/one/connections/workflow-copy.md +0 -923
  387. package/one/connections/workflow-examples.md +0 -759
  388. package/one/connections/workflow-onboarding.md +0 -701
  389. package/one/connections/workflow.md +0 -923
  390. package/one/connections/workflows/delegation.md +0 -903
  391. package/one/connections/workflows/frontend.md +0 -1055
  392. package/one/connections/workflows/strategy.md +0 -921
  393. package/one/connections/workflows/tasks.md +0 -716
  394. package/one/connections/x402-baazar.md +0 -131
  395. package/one/connections/x402.md +0 -1353
  396. package/one/groups/features.md +0 -2904
  397. package/one/groups/groups.md +0 -587
  398. package/one/groups/one.md +0 -619
  399. package/one/groups/strategy-copy.md +0 -887
  400. package/one/knowledge/.obsidian/app.json +0 -1
  401. package/one/knowledge/.obsidian/appearance.json +0 -1
  402. package/one/knowledge/.obsidian/core-plugins.json +0 -33
  403. package/one/knowledge/.obsidian/ecommerce-ontology.md +0 -210
  404. package/one/knowledge/.obsidian/workspace.json +0 -211
  405. package/one/knowledge/100-inference-quick-reference.md +0 -449
  406. package/one/knowledge/ag-ui-protocol.md +0 -613
  407. package/one/knowledge/agent-onboard-usage.md +0 -630
  408. package/one/knowledge/agentic-commerce.md +0 -146
  409. package/one/knowledge/ai-agents-vs-memecoins-thesis.md +0 -683
  410. package/one/knowledge/ai-api-reference.md +0 -715
  411. package/one/knowledge/ai-platform.md +0 -323
  412. package/one/knowledge/ai-quickstart.md +0 -355
  413. package/one/knowledge/ai-sdk-implementation.md +0 -436
  414. package/one/knowledge/ai-token-crypto-analysis-framework.md +0 -1191
  415. package/one/knowledge/ai-token-paradigm-shift-2025.md +0 -732
  416. package/one/knowledge/altcoin-cycle-prediction-ontology.md +0 -884
  417. package/one/knowledge/altcoin-cycle-trading-strategy.md +0 -642
  418. package/one/knowledge/architecture-any-backend.md +0 -1589
  419. package/one/knowledge/architecture-diagram.md +0 -404
  420. package/one/knowledge/architecture-frontend.md +0 -1014
  421. package/one/knowledge/architecture.md +0 -1742
  422. package/one/knowledge/archived/ontology.old.md +0 -2840
  423. package/one/knowledge/astro-effect-complete-vision.md +0 -2148
  424. package/one/knowledge/astro-effect-simple-architecture.md +0 -750
  425. package/one/knowledge/audit-agent-onboard-alignment.md +0 -481
  426. package/one/knowledge/audit-agent-sales-alignment.md +0 -444
  427. package/one/knowledge/backend-api-reference.md +0 -728
  428. package/one/knowledge/cascading-context-specification.md +0 -1617
  429. package/one/knowledge/claude-code-integration.md +0 -1293
  430. package/one/knowledge/cli-claude-handoff.md +0 -736
  431. package/one/knowledge/context-engineering.md +0 -610
  432. package/one/knowledge/crypto-analysis-strategy.md +0 -1276
  433. package/one/knowledge/crypto-cycle-2024-2025-analysis.md +0 -44
  434. package/one/knowledge/crypto.md +0 -978
  435. package/one/knowledge/develop/design.md +0 -364
  436. package/one/knowledge/develop/index.md +0 -145
  437. package/one/knowledge/development-commands.md +0 -251
  438. package/one/knowledge/docs.md +0 -627
  439. package/one/knowledge/dsl.md +0 -1678
  440. package/one/knowledge/event-driven-documentation.md +0 -270
  441. package/one/knowledge/files.md +0 -2489
  442. package/one/knowledge/frontend.md +0 -1056
  443. package/one/knowledge/games-english.md +0 -691
  444. package/one/knowledge/games.md +0 -1082
  445. package/one/knowledge/generative-ui-patterns.md +0 -559
  446. package/one/knowledge/guidelines.md +0 -314
  447. package/one/knowledge/hono.md +0 -2127
  448. package/one/knowledge/implementation-examples.md +0 -2554
  449. package/one/knowledge/installation-folders.md +0 -366
  450. package/one/knowledge/institutional-cycle-paradigm-2025.md +0 -555
  451. package/one/knowledge/knowledge.md +0 -660
  452. package/one/knowledge/language.md +0 -998
  453. package/one/knowledge/lessons-learned.md +0 -378
  454. package/one/knowledge/lessons-website-building-focus.md +0 -382
  455. package/one/knowledge/merge-report.md +0 -254
  456. package/one/knowledge/metadata-system.md +0 -504
  457. package/one/knowledge/nine-padel-playbook.md +0 -229
  458. package/one/knowledge/one-protocol-ai-agents.md +0 -892
  459. package/one/knowledge/one-protocol-executive-report.md +0 -617
  460. package/one/knowledge/one-protocol-standard.md +0 -869
  461. package/one/knowledge/one-protocol-whitepaper.md +0 -756
  462. package/one/knowledge/ontology-blog.yaml +0 -47
  463. package/one/knowledge/ontology-cheatsheet.md +0 -617
  464. package/one/knowledge/ontology-community.yaml +0 -65
  465. package/one/knowledge/ontology-core-universal.md +0 -740
  466. package/one/knowledge/ontology-core.yaml +0 -63
  467. package/one/knowledge/ontology-courses.yaml +0 -76
  468. package/one/knowledge/ontology-creator.md +0 -402
  469. package/one/knowledge/ontology-crypto.md +0 -1603
  470. package/one/knowledge/ontology-developer-guide.md +0 -814
  471. package/one/knowledge/ontology-documentation.md +0 -377
  472. package/one/knowledge/ontology-ecommerce.md +0 -269
  473. package/one/knowledge/ontology-education-game.md +0 -1654
  474. package/one/knowledge/ontology-education.md +0 -938
  475. package/one/knowledge/ontology-engineering-specification.md +0 -1310
  476. package/one/knowledge/ontology-engineering.md +0 -1676
  477. package/one/knowledge/ontology-files.yaml +0 -525
  478. package/one/knowledge/ontology-frontend-master.md +0 -2898
  479. package/one/knowledge/ontology-frontend-specifications.md +0 -2196
  480. package/one/knowledge/ontology-frontend.md +0 -2475
  481. package/one/knowledge/ontology-index.md +0 -397
  482. package/one/knowledge/ontology-minimal.yaml +0 -301
  483. package/one/knowledge/ontology-portfolio.yaml +0 -45
  484. package/one/knowledge/ontology-quickstart.md +0 -602
  485. package/one/knowledge/ontology-release.md +0 -317
  486. package/one/knowledge/ontology-shop.yaml +0 -148
  487. package/one/knowledge/ontology-tokens.yaml +0 -51
  488. package/one/knowledge/ontology-tutorial.md +0 -455
  489. package/one/knowledge/ontology-v2.md +0 -4449
  490. package/one/knowledge/ontology-video-script.md +0 -939
  491. package/one/knowledge/ontology-visual-guide.md +0 -378
  492. package/one/knowledge/ontology.md +0 -3847
  493. package/one/knowledge/ontology.yaml +0 -1653
  494. package/one/knowledge/parallel-agents.md +0 -932
  495. package/one/knowledge/patterns/backend/convex-mutation-pattern.md +0 -130
  496. package/one/knowledge/patterns/backend/convex-query-pattern.md +0 -143
  497. package/one/knowledge/patterns/backend/mutation-template.md +0 -249
  498. package/one/knowledge/patterns/backend/query-template.md +0 -286
  499. package/one/knowledge/patterns/backend/service-template.md +0 -258
  500. package/one/knowledge/patterns/design/component-architecture.md +0 -435
  501. package/one/knowledge/patterns/design/index.md +0 -160
  502. package/one/knowledge/patterns/design/test-driven-design-pattern.md +0 -196
  503. package/one/knowledge/patterns/design/wireframe-template.md +0 -250
  504. package/one/knowledge/patterns/frontend/component-template.md +0 -246
  505. package/one/knowledge/patterns/frontend/form-template.md +0 -348
  506. package/one/knowledge/patterns/frontend/page-template.md +0 -209
  507. package/one/knowledge/patterns/frontend/react-component-pattern.md +0 -188
  508. package/one/knowledge/patterns/test/acceptance-criteria-template.md +0 -396
  509. package/one/knowledge/patterns/test/technical-test-template.md +0 -566
  510. package/one/knowledge/patterns/test/test-driven-pattern.md +0 -160
  511. package/one/knowledge/patterns/test/user-flow-template.md +0 -272
  512. package/one/knowledge/performance.md +0 -459
  513. package/one/knowledge/provider-agnostic-content.md +0 -995
  514. package/one/knowledge/provider-creation-guide.md +0 -1082
  515. package/one/knowledge/quality-loop.md +0 -419
  516. package/one/knowledge/quick-start-ontology-mapping.md +0 -773
  517. package/one/knowledge/readme-architecture.md +0 -158
  518. package/one/knowledge/readme.md +0 -149
  519. package/one/knowledge/rules.md +0 -644
  520. package/one/knowledge/score.md +0 -85
  521. package/one/knowledge/specifications.md +0 -873
  522. package/one/knowledge/tags.md +0 -148
  523. package/one/knowledge/todo-template.md +0 -269
  524. package/one/knowledge/todo.md +0 -269
  525. package/one/knowledge/troubleshooting.md +0 -434
  526. package/one/knowledge/typescript-patterns.md +0 -321
  527. package/one/knowledge/universal-generation-language.md +0 -827
  528. package/one/knowledge/x402-research.md +0 -104
  529. package/one/license.md +0 -107
  530. package/one/people/anthony-o-connell.md +0 -469
  531. package/one/people/people.md +0 -590
  532. package/one/things/ALIGNMENT_AUDIT_QUALITY_AGENT.md +0 -401
  533. package/one/things/AUDIT_AGENT_INTEGRATOR_ALIGNMENT.md +0 -588
  534. package/one/things/AUDIT_REPORT_AGENT_CLEAN.md +0 -461
  535. package/one/things/CHECKLIST.md +0 -407
  536. package/one/things/IMPLEMENTATION_STATUS.md +0 -379
  537. package/one/things/ONE.md +0 -529
  538. package/one/things/agents/agent-backend.md +0 -1501
  539. package/one/things/agents/agent-builder.md +0 -1064
  540. package/one/things/agents/agent-clean.md +0 -1112
  541. package/one/things/agents/agent-clone.md +0 -1324
  542. package/one/things/agents/agent-deploy.md +0 -986
  543. package/one/things/agents/agent-designer.md +0 -2305
  544. package/one/things/agents/agent-director.md +0 -1526
  545. package/one/things/agents/agent-documenter.md +0 -1129
  546. package/one/things/agents/agent-frontend.md +0 -1201
  547. package/one/things/agents/agent-integrator.md +0 -1269
  548. package/one/things/agents/agent-lawyer.md +0 -1371
  549. package/one/things/agents/agent-problem-solver.md +0 -1457
  550. package/one/things/agents/agent-quality.md +0 -1483
  551. package/one/things/agents/agent-sales.md +0 -1074
  552. package/one/things/cascade/cascade.yaml +0 -481
  553. package/one/things/cascade/docs/examples/1-1-agent-prompts/design.md +0 -523
  554. package/one/things/cascade/docs/examples/1-1-agent-prompts/tests.md +0 -314
  555. package/one/things/cascade/docs/examples/1-1-agent-prompts.md +0 -562
  556. package/one/things/cascade/docs/examples/1-2-yaml-orchestrator/design.md +0 -543
  557. package/one/things/cascade/docs/examples/1-2-yaml-orchestrator/tests.md +0 -272
  558. package/one/things/cascade/docs/examples/1-2-yaml-orchestrator.md +0 -548
  559. package/one/things/cascade/docs/examples/1-3-event-coordination/design.md +0 -586
  560. package/one/things/cascade/docs/examples/1-3-event-coordination/tests.md +0 -267
  561. package/one/things/cascade/docs/examples/1-3-event-coordination.md +0 -547
  562. package/one/things/cascade/docs/examples/1-4-knowledge-management/design.md +0 -665
  563. package/one/things/cascade/docs/examples/1-4-knowledge-management/tests.md +0 -236
  564. package/one/things/cascade/docs/examples/1-4-knowledge-management.md +0 -652
  565. package/one/things/cascade/docs/examples/1-5-quality-loops/design.md +0 -860
  566. package/one/things/cascade/docs/examples/1-5-quality-loops/tests.md +0 -255
  567. package/one/things/cascade/docs/examples/1-5-quality-loops.md +0 -725
  568. package/one/things/cascade/docs/examples/1-6-numbering-structure/design.md +0 -659
  569. package/one/things/cascade/docs/examples/1-6-numbering-structure/tests.md +0 -256
  570. package/one/things/cascade/docs/examples/1-6-numbering-structure.md +0 -639
  571. package/one/things/cascade/docs/examples/readme.md +0 -259
  572. package/one/things/cascade/docs/getting-started.md +0 -533
  573. package/one/things/cascade/docs/workflow.md +0 -1378
  574. package/one/things/cascade/readme.md +0 -379
  575. package/one/things/cascade/templates/feature-template.md +0 -289
  576. package/one/things/claude/agents/advocacy-activation-manager.md +0 -710
  577. package/one/things/claude/agents/advocacy-campaign-designer.md +0 -688
  578. package/one/things/claude/agents/analyst.md +0 -508
  579. package/one/things/claude/agents/architect.md +0 -505
  580. package/one/things/claude/agents/brand-identity-specialist.md +0 -538
  581. package/one/things/claude/agents/bstp-token-strategist.md +0 -690
  582. package/one/things/claude/agents/builder-repo.md +0 -532
  583. package/one/things/claude/agents/bullstamp-community-builder.md +0 -597
  584. package/one/things/claude/agents/bullstamp-marketing-orchestrator.md +0 -529
  585. package/one/things/claude/agents/bulltilt-platform-growth.md +0 -590
  586. package/one/things/claude/agents/company-bullstamp-character.md +0 -602
  587. package/one/things/claude/agents/company-bullstamp-community.md +0 -307
  588. package/one/things/claude/agents/company-bullstamp-marketing.md +0 -307
  589. package/one/things/claude/agents/company-bullstamp-token.md +0 -307
  590. package/one/things/claude/agents/company-bulltilt-growth.md +0 -307
  591. package/one/things/claude/agents/content-bibliography-formatter.md +0 -404
  592. package/one/things/claude/agents/content-calendar-planner.md +0 -473
  593. package/one/things/claude/agents/content-chapter-formatter.md +0 -513
  594. package/one/things/claude/agents/content-formatter.md +0 -571
  595. package/one/things/claude/agents/content-hook-specialist.md +0 -485
  596. package/one/things/claude/agents/content-image-formatter.md +0 -560
  597. package/one/things/claude/agents/content-introduction-formatter.md +0 -510
  598. package/one/things/claude/agents/content-multiplication-engine.md +0 -579
  599. package/one/things/claude/agents/content-playbook-writer.md +0 -473
  600. package/one/things/claude/agents/content-team-manager.md +0 -647
  601. package/one/things/claude/agents/content-toc-formatter.md +0 -547
  602. package/one/things/claude/agents/convex-backend-specialist.md +0 -2725
  603. package/one/things/claude/agents/core-manager.md +0 -607
  604. package/one/things/claude/agents/core-master.md +0 -426
  605. package/one/things/claude/agents/cross-functional-manager.md +0 -476
  606. package/one/things/claude/agents/crypto-airdrop-strategist.md +0 -622
  607. package/one/things/claude/agents/crypto-analytics-educator.md +0 -596
  608. package/one/things/claude/agents/crypto-architecture-specialist.md +0 -497
  609. package/one/things/claude/agents/crypto-community-analyst.md +0 -314
  610. package/one/things/claude/agents/crypto-community-psychologist.md +0 -546
  611. package/one/things/claude/agents/crypto-dex-optimization-expert.md +0 -579
  612. package/one/things/claude/agents/crypto-dex-optimizer.md +0 -307
  613. package/one/things/claude/agents/crypto-diamond-formation-specialist.md +0 -552
  614. package/one/things/claude/agents/crypto-diamond-hands.md +0 -307
  615. package/one/things/claude/agents/crypto-ecosystem-expansion-manager.md +0 -597
  616. package/one/things/claude/agents/crypto-engagement-specialist.md +0 -581
  617. package/one/things/claude/agents/crypto-market-researcher.md +0 -307
  618. package/one/things/claude/agents/crypto-marketing-orchestrator.md +0 -563
  619. package/one/things/claude/agents/crypto-network-effect-amplifier.md +0 -614
  620. package/one/things/claude/agents/crypto-optimization-analyst.md +0 -597
  621. package/one/things/claude/agents/crypto-strategic-synthesizer.md +0 -556
  622. package/one/things/claude/agents/crypto-team-manager.md +0 -392
  623. package/one/things/claude/agents/crypto-token-analyst.md +0 -319
  624. package/one/things/claude/agents/crypto-viral-content-creator.md +0 -549
  625. package/one/things/claude/agents/crypto-wallet-identification-expert.md +0 -527
  626. package/one/things/claude/agents/crypto-wallet-identifier.md +0 -307
  627. package/one/things/claude/agents/customer-journey-designer.md +0 -474
  628. package/one/things/claude/agents/customer-success-manager.md +0 -574
  629. package/one/things/claude/agents/dev.md +0 -406
  630. package/one/things/claude/agents/documenter.md +0 -548
  631. package/one/things/claude/agents/elevate-marketing-orchestrator.md +0 -403
  632. package/one/things/claude/agents/engagement-specialist.md +0 -502
  633. package/one/things/claude/agents/engineering-architect.md +0 -387
  634. package/one/things/claude/agents/engineering-business-analyst.md +0 -527
  635. package/one/things/claude/agents/engineering-developer.md +0 -386
  636. package/one/things/claude/agents/engineering-director.md +0 -322
  637. package/one/things/claude/agents/engineering-ingestor.md +0 -659
  638. package/one/things/claude/agents/engineering-product-manager.md +0 -525
  639. package/one/things/claude/agents/engineering-product-owner.md +0 -527
  640. package/one/things/claude/agents/engineering-project-coordinator.md +0 -525
  641. package/one/things/claude/agents/engineering-quality-assurance.md +0 -392
  642. package/one/things/claude/agents/engineering-team-manager.md +0 -515
  643. package/one/things/claude/agents/engineering-user-experience.md +0 -386
  644. package/one/things/claude/agents/framework-elevate-manager.md +0 -309
  645. package/one/things/claude/agents/improver.md +0 -805
  646. package/one/things/claude/agents/intelligence-team-manager.md +0 -390
  647. package/one/things/claude/agents/lead-capture-expert.md +0 -459
  648. package/one/things/claude/agents/lead-magnet-creator.md +0 -446
  649. package/one/things/claude/agents/market-research-analyst.md +0 -435
  650. package/one/things/claude/agents/marketing-brand-identity.md +0 -344
  651. package/one/things/claude/agents/marketing-content-hooks.md +0 -455
  652. package/one/things/claude/agents/marketing-content-multiplier.md +0 -331
  653. package/one/things/claude/agents/marketing-content-poster.md +0 -372
  654. package/one/things/claude/agents/marketing-customer-journey.md +0 -331
  655. package/one/things/claude/agents/marketing-director.md +0 -402
  656. package/one/things/claude/agents/marketing-engagement.md +0 -331
  657. package/one/things/claude/agents/marketing-lead-capture.md +0 -331
  658. package/one/things/claude/agents/marketing-lead-magnet.md +0 -331
  659. package/one/things/claude/agents/marketing-network-effects.md +0 -331
  660. package/one/things/claude/agents/marketing-nurture-campaigns.md +0 -331
  661. package/one/things/claude/agents/marketing-share-optimizer.md +0 -331
  662. package/one/things/claude/agents/marketing-team-manager.md +0 -451
  663. package/one/things/claude/agents/marketing-viral-growth.md +0 -232
  664. package/one/things/claude/agents/mission-commander.md +0 -378
  665. package/one/things/claude/agents/network-effect-analyst.md +0 -604
  666. package/one/things/claude/agents/nextjs-15-specialist.md +0 -1634
  667. package/one/things/claude/agents/npx.md +0 -946
  668. package/one/things/claude/agents/nurture-campaign-manager.md +0 -554
  669. package/one/things/claude/agents/one-master.md +0 -378
  670. package/one/things/claude/agents/one-orchestrator.md +0 -345
  671. package/one/things/claude/agents/one.md +0 -658
  672. package/one/things/claude/agents/playbook-generator.md +0 -526
  673. package/one/things/claude/agents/pm.md +0 -349
  674. package/one/things/claude/agents/po.md +0 -370
  675. package/one/things/claude/agents/qa.md +0 -361
  676. package/one/things/claude/agents/research-foundation-analyst.md +0 -324
  677. package/one/things/claude/agents/research-intelligence-gatherer.md +0 -435
  678. package/one/things/claude/agents/research-market-analyst.md +0 -324
  679. package/one/things/claude/agents/research-team-manager.md +0 -489
  680. package/one/things/claude/agents/sales-environment-optimizer.md +0 -519
  681. package/one/things/claude/agents/sales-team-manager.md +0 -407
  682. package/one/things/claude/agents/sales-upsell-strategist.md +0 -324
  683. package/one/things/claude/agents/service-advocacy-campaigns.md +0 -324
  684. package/one/things/claude/agents/service-advocacy-manager.md +0 -324
  685. package/one/things/claude/agents/service-success-manager.md +0 -324
  686. package/one/things/claude/agents/service-team-manager.md +0 -405
  687. package/one/things/claude/agents/shadcn-ui-design-system-specialist.md +0 -2357
  688. package/one/things/claude/agents/share-optimization-specialist.md +0 -576
  689. package/one/things/claude/agents/sm.md +0 -352
  690. package/one/things/claude/agents/story-teller.md +0 -498
  691. package/one/things/claude/agents/task-master.md +0 -621
  692. package/one/things/claude/agents/tauri-cross-platform-specialist.md +0 -1912
  693. package/one/things/claude/agents/tester.md +0 -595
  694. package/one/things/claude/agents/the-bull-character-manager.md +0 -603
  695. package/one/things/claude/agents/tools-playbook-generator.md +0 -492
  696. package/one/things/claude/agents/turbo-repo-builder.md +0 -346
  697. package/one/things/claude/agents/upsell-strategist.md +0 -503
  698. package/one/things/claude/agents/ux-expert.md +0 -360
  699. package/one/things/claude/agents/viral-growth-orchestrator.md +0 -520
  700. package/one/things/claude/claude-code-hooks-development.json +0 -21
  701. package/one/things/claude/claude-code-hooks-production.json +0 -21
  702. package/one/things/claude/claude-code-hooks.json +0 -25
  703. package/one/things/claude/commands/agent.md +0 -124
  704. package/one/things/claude/commands/cascade-status.md +0 -153
  705. package/one/things/claude/commands/ingest.md +0 -343
  706. package/one/things/claude/commands/ingestor.md +0 -158
  707. package/one/things/claude/commands/mission.md +0 -103
  708. package/one/things/claude/commands/npx.md +0 -156
  709. package/one/things/claude/commands/one.md +0 -486
  710. package/one/things/claude/commands/quality-check.md +0 -252
  711. package/one/things/claude/commands/smart-route.md +0 -261
  712. package/one/things/claude/commands/start.md +0 -139
  713. package/one/things/claude/commands/story.md +0 -103
  714. package/one/things/claude/commands/task.md +0 -193
  715. package/one/things/claude/hook-bypass.json +0 -32
  716. package/one/things/claude/hooks/agent-hook-config.json +0 -427
  717. package/one/things/claude/hooks/build-hook.sh +0 -156
  718. package/one/things/claude/hooks/cleanup-hook.sh +0 -201
  719. package/one/things/claude/hooks/file-organization-hook.sh +0 -80
  720. package/one/things/claude/hooks/format-hook.sh +0 -43
  721. package/one/things/claude/hooks/hook-bypass.sh +0 -293
  722. package/one/things/claude/hooks/hook-debouncer.sh +0 -62
  723. package/one/things/claude/hooks/hook-logger.sh +0 -89
  724. package/one/things/claude/hooks/lint-hook.sh +0 -140
  725. package/one/things/claude/hooks/notification-hook.sh +0 -204
  726. package/one/things/claude/hooks/ontology-validation-hook.sh +0 -86
  727. package/one/things/claude/hooks/performance-metrics.json +0 -25
  728. package/one/things/claude/hooks/security-hook.sh +0 -256
  729. package/one/things/claude/hooks/story-validation-hook-enhanced.sh +0 -210
  730. package/one/things/claude/hooks/story-validation-hook.sh +0 -145
  731. package/one/things/claude/hooks/test-hook.sh +0 -145
  732. package/one/things/claude/hooks/test-story-validation.sh +0 -170
  733. package/one/things/claude/settings-local.json +0 -86
  734. package/one/things/cli/cli-code.md +0 -677
  735. package/one/things/cli/cli-compiler-code.md +0 -677
  736. package/one/things/cli/cli.md +0 -871
  737. package/one/things/components/card-shadcn.md +0 -953
  738. package/one/things/components/card.md +0 -1041
  739. package/one/things/components.md +0 -1743
  740. package/one/things/componets.md +0 -19
  741. package/one/things/contracts/Move.toml +0 -12
  742. package/one/things/contracts/README.md +0 -288
  743. package/one/things/contracts/one.move +0 -762
  744. package/one/things/contracts/sdk.ts +0 -578
  745. package/one/things/creator-diagram.md +0 -184
  746. package/one/things/crypto/FEATURES.md +0 -78
  747. package/one/things/crypto/ONECORE.md +0 -62
  748. package/one/things/crypto/ONECOREFAQ.md +0 -22
  749. package/one/things/crypto/ONECOREHOW.md +0 -46
  750. package/one/things/crypto/ONEENTERPRISE.md +0 -64
  751. package/one/things/crypto/ONEENTERPRISEFAQ.md +0 -64
  752. package/one/things/crypto/ONEENTERPRISEHOW.md +0 -53
  753. package/one/things/crypto/ONEPRO.md +0 -60
  754. package/one/things/crypto/ONEPROFAQ.md +0 -22
  755. package/one/things/crypto/ONEPROHOW.md +0 -53
  756. package/one/things/crypto/READMEAGENCY.md +0 -64
  757. package/one/things/crypto/VSL.md +0 -45
  758. package/one/things/crypto/WebsiteCopy.md +0 -176
  759. package/one/things/demo-accessibility-animations.md +0 -1025
  760. package/one/things/demo-components.md +0 -1310
  761. package/one/things/demo-design-summary.md +0 -692
  762. package/one/things/demo-design-system.md +0 -973
  763. package/one/things/demo-page-layouts.md +0 -1016
  764. package/one/things/design-system.md +0 -832
  765. package/one/things/designs/accessibility-audit.md +0 -877
  766. package/one/things/designs/component-specifications.md +0 -855
  767. package/one/things/designs/design-overview.md +0 -377
  768. package/one/things/designs/design-tokens.md +0 -448
  769. package/one/things/designs/wireframes-dashboard.md +0 -710
  770. package/one/things/docs/api-requests.md +0 -987
  771. package/one/things/docs/ecommerce/ARCHITECTURE-DIAGRAM.md +0 -485
  772. package/one/things/docs/ecommerce/CONVERSION-ELEMENTS-IMPLEMENTATION.md +0 -465
  773. package/one/things/docs/ecommerce/CONVERSION-ELEMENTS-SUMMARY.md +0 -425
  774. package/one/things/docs/ecommerce/CONVERSION-UX-IMPLEMENTATION-SUMMARY.md +0 -451
  775. package/one/things/docs/ecommerce/FEATURE-SUMMARY.md +0 -536
  776. package/one/things/docs/ecommerce/IMPLEMENTATION-NOTES.md +0 -650
  777. package/one/things/docs/ecommerce/INTEGRATION-EXAMPLE.md +0 -473
  778. package/one/things/docs/ecommerce/QUICK-START.md +0 -405
  779. package/one/things/docs/ecommerce/URGENCY-IMPLEMENTATION-SUMMARY.md +0 -567
  780. package/one/things/docs/ecommerce/URGENCY-QUICK-REFERENCE.md +0 -271
  781. package/one/things/docs/ecommerce/USAGE-EXAMPLE.astro +0 -171
  782. package/one/things/docs/ecommerce/demo.astro +0 -309
  783. package/one/things/examples/children/lemonade-stand.md +0 -404
  784. package/one/things/examples/enterprise/crm-saas.md +0 -1444
  785. package/one/things/features/1-1-agent-prompts.md +0 -562
  786. package/one/things/features/1-2-yaml-orchestrator.md +0 -548
  787. package/one/things/features/1-3-event-coordination.md +0 -547
  788. package/one/things/features/1-4-knowledge-management.md +0 -652
  789. package/one/things/features/1-5-quality-loops.md +0 -725
  790. package/one/things/features/1-6-numbering-structure.md +0 -639
  791. package/one/things/features/2-1-dataprovider-interface.md +0 -2583
  792. package/one/things/features/2-2-config-system.md +0 -3242
  793. package/one/things/features/2-3-effectts-services.md +0 -1645
  794. package/one/things/features/2-4-react-hooks.md +0 -2136
  795. package/one/things/features/2-5-auth-migration.md +0 -2144
  796. package/one/things/features/2-6-dashboard-migration.md +0 -2084
  797. package/one/things/features/2-7-alternative-providers.md +0 -2578
  798. package/one/things/features/2-7-implementation-report.md +0 -724
  799. package/one/things/features/2-cli.md +0 -1720
  800. package/one/things/features/2-design.md +0 -1770
  801. package/one/things/features/2-tests.md +0 -576
  802. package/one/things/features/AUTH_HOOKS_IMPLEMENTATION.md +0 -576
  803. package/one/things/features/DECOUPLING.md +0 -290
  804. package/one/things/features/DEPLOYMENT.md +0 -470
  805. package/one/things/features/IMPLEMENTATION_SUMMARY.md +0 -362
  806. package/one/things/features/improve.md +0 -861
  807. package/one/things/features/remove-convex-deps.md +0 -63
  808. package/one/things/features/top-features.md +0 -87
  809. package/one/things/features/use-one-backend.md +0 -1217
  810. package/one/things/features-in-english.md +0 -200
  811. package/one/things/files.yaml +0 -721
  812. package/one/things/ideas/1-create-workflow.md +0 -207
  813. package/one/things/ideas/2-backend-agnostic-frontend.md +0 -439
  814. package/one/things/implementation/backend-guide.md +0 -457
  815. package/one/things/interface.md +0 -257
  816. package/one/things/landing-page-implementation.md +0 -455
  817. package/one/things/legal/README.md +0 -234
  818. package/one/things/legal/privacy-policy.md +0 -1227
  819. package/one/things/legal/terms-of-service.md +0 -1432
  820. package/one/things/master-workflow-plan.md +0 -806
  821. package/one/things/pay.one.ie.md +0 -53
  822. package/one/things/plans/0-in-sync.md +0 -136
  823. package/one/things/plans/0-timeline.md +0 -36
  824. package/one/things/plans/1-create-workflow.md +0 -732
  825. package/one/things/plans/QUICK-START-SIMPLIFICATION.md +0 -333
  826. package/one/things/plans/README-SIMPLIFICATION.md +0 -349
  827. package/one/things/plans/SIMPLIFICATION-EXAMPLES.md +0 -16
  828. package/one/things/plans/SIMPLIFICATION-SUMMARY.md +0 -455
  829. package/one/things/plans/ai-elements-integration.md +0 -483
  830. package/one/things/plans/ai-elements.md +0 -1278
  831. package/one/things/plans/ai-integration-plan.md +0 -263
  832. package/one/things/plans/ai-integration.md +0 -996
  833. package/one/things/plans/ai-sdk.md +0 -798
  834. package/one/things/plans/ai-tools.md +0 -621
  835. package/one/things/plans/app.md +0 -832
  836. package/one/things/plans/architecture-summary.md +0 -312
  837. package/one/things/plans/async-ai-agents.md +0 -233
  838. package/one/things/plans/backend-agnostic-frontend.md +0 -390
  839. package/one/things/plans/backend-cleanup-quickstart.md +0 -380
  840. package/one/things/plans/backend-ontology-conformance.md +0 -475
  841. package/one/things/plans/backend-status.md +0 -599
  842. package/one/things/plans/backend-structure.md +0 -847
  843. package/one/things/plans/backend-target-structure.md +0 -482
  844. package/one/things/plans/backend.md +0 -1175
  845. package/one/things/plans/better-auth-any-backend-revised.md +0 -1103
  846. package/one/things/plans/better-auth-any-backend.md +0 -1896
  847. package/one/things/plans/better-auth-available-features.md +0 -273
  848. package/one/things/plans/big-plan.md +0 -52
  849. package/one/things/plans/cli-updates-required.md +0 -320
  850. package/one/things/plans/complete-step-by-step.md +0 -1409
  851. package/one/things/plans/components.md +0 -709
  852. package/one/things/plans/convex-agents.md +0 -1034
  853. package/one/things/plans/convex-better-auth.md +0 -1141
  854. package/one/things/plans/convex-on-off.md +0 -407
  855. package/one/things/plans/crypto-token-researcher.md +0 -629
  856. package/one/things/plans/data-quality-metrics.md +0 -745
  857. package/one/things/plans/deep-researcher-agent.md +0 -466
  858. package/one/things/plans/deploy-to-cloudflare.md +0 -623
  859. package/one/things/plans/deployment-architecture.md +0 -469
  860. package/one/things/plans/desktop.md +0 -1139
  861. package/one/things/plans/development-plan.md +0 -1283
  862. package/one/things/plans/development-workflow-tldr.md +0 -207
  863. package/one/things/plans/development-workflow.md +0 -959
  864. package/one/things/plans/dsl-claude-code.md +0 -1011
  865. package/one/things/plans/effect-components.md +0 -1743
  866. package/one/things/plans/effect-patterns-reference.md +0 -2235
  867. package/one/things/plans/effect.md +0 -1806
  868. package/one/things/plans/email.md +0 -966
  869. package/one/things/plans/enhance-auth.md +0 -1692
  870. package/one/things/plans/execution-strategy.md +0 -1291
  871. package/one/things/plans/existing-infrastructure.md +0 -712
  872. package/one/things/plans/feature-based-sites.md +0 -894
  873. package/one/things/plans/frontend-effects.md +0 -1276
  874. package/one/things/plans/group-folder-multi-tenancy.md +0 -893
  875. package/one/things/plans/improve-codebase.md +0 -1811
  876. package/one/things/plans/install-components.md +0 -215
  877. package/one/things/plans/integrate-frontend-and-backend.md +0 -603
  878. package/one/things/plans/landing.md +0 -820
  879. package/one/things/plans/layout.md +0 -249
  880. package/one/things/plans/mail-backend.md +0 -1361
  881. package/one/things/plans/mail.md +0 -2677
  882. package/one/things/plans/mcp-clear-context-prompt.md +0 -81
  883. package/one/things/plans/mcp-simple.md +0 -248
  884. package/one/things/plans/multi-ontology-architecture.md +0 -885
  885. package/one/things/plans/next-features.md +0 -114
  886. package/one/things/plans/npx-agent-safety.md +0 -785
  887. package/one/things/plans/npx-agent.md +0 -1089
  888. package/one/things/plans/onboarding.md +0 -51
  889. package/one/things/plans/one-protocol-and-payone-usage.md +0 -82
  890. package/one/things/plans/one.md +0 -677
  891. package/one/things/plans/ontology-6-dimensions.md +0 -2201
  892. package/one/things/plans/ontology-compliance-audit.md +0 -342
  893. package/one/things/plans/ontology-driven-strategy.md +0 -882
  894. package/one/things/plans/ontology-refine.md +0 -586
  895. package/one/things/plans/ontology-ui-approach.md +0 -375
  896. package/one/things/plans/open-agent.md +0 -840
  897. package/one/things/plans/performace.md +0 -122
  898. package/one/things/plans/phase-1-foundation.md +0 -620
  899. package/one/things/plans/phase-3-implementation.md +0 -1037
  900. package/one/things/plans/plan-connect-to-api.md +0 -146
  901. package/one/things/plans/quick-wins.md +0 -1428
  902. package/one/things/plans/r2.md +0 -777
  903. package/one/things/plans/readme-backend-cleanup.md +0 -402
  904. package/one/things/plans/release.md +0 -507
  905. package/one/things/plans/remove-backend-development-from-agents.md +0 -1331
  906. package/one/things/plans/repos.md +0 -98
  907. package/one/things/plans/separate-copy-2.md +0 -1349
  908. package/one/things/plans/separate-copy-3.md +0 -2479
  909. package/one/things/plans/separate-copy.md +0 -1349
  910. package/one/things/plans/separate-demo.md +0 -864
  911. package/one/things/plans/separate.md +0 -1999
  912. package/one/things/plans/sequence.md +0 -2040
  913. package/one/things/plans/shadcn-integration-summary.md +0 -510
  914. package/one/things/plans/sidebar.md +0 -206
  915. package/one/things/plans/skills.md +0 -709
  916. package/one/things/plans/small-fixes.md +0 -23
  917. package/one/things/plans/start-new.md +0 -764
  918. package/one/things/plans/switch-off-auth.md +0 -42
  919. package/one/things/plans/sync-checklist.md +0 -351
  920. package/one/things/plans/test-backend-connection.md +0 -514
  921. package/one/things/plans/unified-implementation-plan.md +0 -934
  922. package/one/things/plans/update-demos.md +0 -581
  923. package/one/things/plans/use-our-backend.md +0 -572
  924. package/one/things/plans/video-backend.md +0 -638
  925. package/one/things/plans/video-frontend.md +0 -490
  926. package/one/things/plans/video-old-archived.md +0 -656
  927. package/one/things/plans/wave1-onboarding-100-inferences.md +0 -1686
  928. package/one/things/plans/wave1-onboarding-vision.md +0 -744
  929. package/one/things/plans/wave1-orchestration-summary.md +0 -604
  930. package/one/things/plans/wave1-specialist-assignments.md +0 -1413
  931. package/one/things/plans/workflow-files.md +0 -1210
  932. package/one/things/plans/workflow.md +0 -1378
  933. package/one/things/plans-u.md +0 -905
  934. package/one/things/products/Blockchain Products.md +0 -6278
  935. package/one/things/products/cascade-landing-page.md +0 -841
  936. package/one/things/products/cascade.md +0 -1568
  937. package/one/things/products/context-engineering.md +0 -1488
  938. package/one/things/products/onthology.md +0 -15
  939. package/one/things/products/ontology-ui-shadcn.md +0 -1302
  940. package/one/things/products/ontology-ui.md +0 -1429
  941. package/one/things/products/ontology.md +0 -789
  942. package/one/things/products/sdk.md +0 -573
  943. package/one/things/promptkit.md +0 -930
  944. package/one/things/repos/all-repos.md +0 -0
  945. package/one/things/scripts-clean-mac.sh +0 -409
  946. package/one/things/service-providers-new.md +0 -1052
  947. package/one/things/service-providers.md +0 -1121
  948. package/one/things/structure.md +0 -532
  949. package/one/things/system.md +0 -618
  950. package/one/things/templates.md +0 -294
  951. package/one/things/tests/2-1-dataprovider-interface.md +0 -1216
  952. package/one/things/tests/2-1-test-analysis.md +0 -544
  953. package/one/things/things.md +0 -384
  954. package/one/things/todo-acp-integration.md +0 -744
  955. package/one/things/todo-ai.md +0 -933
  956. package/one/things/todo-api.md +0 -1078
  957. package/one/things/todo-assignment.md +0 -580
  958. package/one/things/todo-buy-chatgpt.md +0 -1450
  959. package/one/things/todo-components.md +0 -1683
  960. package/one/things/todo-connections.md +0 -278
  961. package/one/things/todo-ecommerce-frontend.md +0 -1313
  962. package/one/things/todo-ecommerce.md +0 -569
  963. package/one/things/todo-effects.md +0 -1075
  964. package/one/things/todo-frontend-effects.md +0 -977
  965. package/one/things/todo-landing-page.md +0 -1091
  966. package/one/things/todo-mail.md +0 -1160
  967. package/one/things/todo-master-plan.md +0 -490
  968. package/one/things/todo-onboard.md +0 -666
  969. package/one/things/todo-one-ie.md +0 -538
  970. package/one/things/todo-page.md +0 -606
  971. package/one/things/todo-plans.md +0 -282
  972. package/one/things/todo-projects.md +0 -241
  973. package/one/things/todo-refactoring-plan.md +0 -366
  974. package/one/things/todo-release.md +0 -654
  975. package/one/things/todo-sequence.md +0 -1621
  976. package/one/things/todo-use-our-backend.md +0 -1908
  977. package/one/things/todo-workflow.md +0 -626
  978. package/one/things/todo-x402.md +0 -2047
  979. package/one/things/todo.md +0 -21
  980. package/one/things/video/scripts-crypto.md +0 -835
  981. package/one/things/video-script-backup.md +0 -318
  982. package/one/things/video-script-demo.md +0 -382
  983. package/one/things/video-script-ontology.md +0 -333
  984. package/one/things/video-script.md +0 -361
@@ -1,2898 +0,0 @@
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
-