oneie 2.0.2 → 2.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (405) hide show
  1. package/AGENTS.md +245 -0
  2. package/CLAUDE.md +534 -0
  3. package/one/.obsidian/app.json +1 -0
  4. package/one/.obsidian/appearance.json +1 -0
  5. package/one/.obsidian/core-plugins.json +33 -0
  6. package/one/.obsidian/workspace.json +211 -0
  7. package/one/connections/a2a.md +551 -0
  8. package/one/connections/acp.md +761 -0
  9. package/one/connections/acps.md +731 -0
  10. package/one/connections/agui.md +767 -0
  11. package/one/connections/any-backend.md +1702 -0
  12. package/one/connections/ap2.md +998 -0
  13. package/one/connections/api-docs.md +1891 -0
  14. package/one/connections/api.md +2190 -0
  15. package/one/connections/architecture-diagram.md +94 -0
  16. package/one/connections/communications.md +449 -0
  17. package/one/connections/connections.md +339 -0
  18. package/one/connections/cryptonetworks.md +781 -0
  19. package/one/connections/documentation.md +1120 -0
  20. package/one/connections/effect.md +279 -0
  21. package/one/connections/elizaos.md +1290 -0
  22. package/one/connections/inference.md +58 -0
  23. package/one/connections/kyc.md +632 -0
  24. package/one/connections/mcp.md +842 -0
  25. package/one/connections/membership.md +1152 -0
  26. package/one/connections/middleware.md +1067 -0
  27. package/one/connections/multitenant.md +1341 -0
  28. package/one/connections/n8n.md +1015 -0
  29. package/one/connections/patterns.md +89 -0
  30. package/one/connections/protocols.md +279 -0
  31. package/one/connections/relationships.md +107 -0
  32. package/one/connections/schema.md +587 -0
  33. package/one/connections/service-layer.md +550 -0
  34. package/one/connections/structure.md +0 -0
  35. package/one/connections/vectors.md +207 -0
  36. package/one/connections/wordpress.md +1302 -0
  37. package/one/connections/workflow-copy.md +905 -0
  38. package/one/connections/workflow-examples.md +741 -0
  39. package/one/connections/workflow.md +905 -0
  40. package/one/connections/workflows/delegation.md +885 -0
  41. package/one/connections/workflows/frontend.md +1037 -0
  42. package/one/connections/workflows/strategy.md +903 -0
  43. package/one/connections/workflows/tasks.md +698 -0
  44. package/one/connections/x402.md +1249 -0
  45. package/one/events/events.md +545 -0
  46. package/one/knowledge/ai-platform.md +305 -0
  47. package/one/knowledge/architecture-diagram.md +94 -0
  48. package/one/knowledge/architecture-frontend.md +930 -0
  49. package/one/knowledge/architecture.md +2077 -0
  50. package/one/knowledge/crypto.md +960 -0
  51. package/one/knowledge/dsl.md +1660 -0
  52. package/one/knowledge/files.md +2471 -0
  53. package/one/knowledge/frontend.md +1038 -0
  54. package/one/knowledge/hono.md +2109 -0
  55. package/one/knowledge/implementation-examples.md +2536 -0
  56. package/one/knowledge/inference-score.md +159 -0
  57. package/one/knowledge/knowledge.md +642 -0
  58. package/one/knowledge/language.md +980 -0
  59. package/one/knowledge/lessons-learned.md +70 -0
  60. package/one/knowledge/ontology-6-dimensions.md +0 -0
  61. package/one/knowledge/ontology-documentation.md +356 -0
  62. package/one/knowledge/ontology-engineering-specification.md +1292 -0
  63. package/one/knowledge/ontology-engineering.md +1652 -0
  64. package/one/knowledge/ontology-frontend-copy-2.md +1492 -0
  65. package/one/knowledge/ontology-frontend-copy.md +753 -0
  66. package/one/knowledge/ontology-frontend-specifications.md +2188 -0
  67. package/one/knowledge/ontology-frontend.md +2427 -0
  68. package/one/knowledge/ontology-minimal.yaml +299 -0
  69. package/one/knowledge/ontology.md +2819 -0
  70. package/one/knowledge/ontology.yaml +1165 -0
  71. package/one/knowledge/patterns/backend/convex-mutation-pattern.md +100 -0
  72. package/one/knowledge/patterns/backend/convex-query-pattern.md +88 -0
  73. package/one/knowledge/patterns/backend/mutation-template.md +231 -0
  74. package/one/knowledge/patterns/backend/query-template.md +267 -0
  75. package/one/knowledge/patterns/backend/service-template.md +237 -0
  76. package/one/knowledge/patterns/design/component-architecture.md +399 -0
  77. package/one/knowledge/patterns/design/test-driven-design-pattern.md +162 -0
  78. package/one/knowledge/patterns/design/wireframe-template.md +216 -0
  79. package/one/knowledge/patterns/frontend/component-template.md +195 -0
  80. package/one/knowledge/patterns/frontend/form-template.md +276 -0
  81. package/one/knowledge/patterns/frontend/page-template.md +178 -0
  82. package/one/knowledge/patterns/frontend/react-component-pattern.md +128 -0
  83. package/one/knowledge/patterns/test/acceptance-criteria-template.md +378 -0
  84. package/one/knowledge/patterns/test/technical-test-template.md +544 -0
  85. package/one/knowledge/patterns/test/test-driven-pattern.md +140 -0
  86. package/one/knowledge/patterns/test/user-flow-template.md +254 -0
  87. package/one/knowledge/quality-loop.md +401 -0
  88. package/one/knowledge/readme.md +131 -0
  89. package/one/knowledge/rules.md +626 -0
  90. package/one/knowledge/score.md +67 -0
  91. package/one/knowledge/specifications.md +855 -0
  92. package/one/knowledge/tags.md +130 -0
  93. package/one/organisation/one.md +599 -0
  94. package/one/organisation/organisation.md +438 -0
  95. package/one/organisation/revenue.md +673 -0
  96. package/one/organisation/strategy.md +869 -0
  97. package/one/organisation/vision.md +98 -0
  98. package/one/people/anthony-o-connell.md +440 -0
  99. package/one/people/people.md +567 -0
  100. package/one/repomix-output.md +92634 -0
  101. package/one/things/agentkit.md +349 -0
  102. package/one/things/agents/agent-backend.md +1401 -0
  103. package/one/things/agents/agent-builder.md +955 -0
  104. package/one/things/agents/agent-clean.md +709 -0
  105. package/one/things/agents/agent-clone.md +1341 -0
  106. package/one/things/agents/agent-designer.md +2177 -0
  107. package/one/things/agents/agent-director.md +1508 -0
  108. package/one/things/agents/agent-documenter.md +1049 -0
  109. package/one/things/agents/agent-frontend.md +1119 -0
  110. package/one/things/agents/agent-integrator.md +1192 -0
  111. package/one/things/agents/agent-problem-solver.md +1379 -0
  112. package/one/things/agents/agent-quality.md +1353 -0
  113. package/one/things/agents/agent-sales.md +986 -0
  114. package/one/things/cascade/cascade.yaml +464 -0
  115. package/one/things/cascade/docs/examples/1-1-agent-prompts/design.md +470 -0
  116. package/one/things/cascade/docs/examples/1-1-agent-prompts/tests.md +264 -0
  117. package/one/things/cascade/docs/examples/1-1-agent-prompts.md +486 -0
  118. package/one/things/cascade/docs/examples/1-2-yaml-orchestrator/design.md +497 -0
  119. package/one/things/cascade/docs/examples/1-2-yaml-orchestrator/tests.md +227 -0
  120. package/one/things/cascade/docs/examples/1-2-yaml-orchestrator.md +516 -0
  121. package/one/things/cascade/docs/examples/1-3-event-coordination/design.md +544 -0
  122. package/one/things/cascade/docs/examples/1-3-event-coordination/tests.md +223 -0
  123. package/one/things/cascade/docs/examples/1-3-event-coordination.md +508 -0
  124. package/one/things/cascade/docs/examples/1-4-knowledge-management/design.md +609 -0
  125. package/one/things/cascade/docs/examples/1-4-knowledge-management/tests.md +195 -0
  126. package/one/things/cascade/docs/examples/1-4-knowledge-management.md +577 -0
  127. package/one/things/cascade/docs/examples/1-5-quality-loops/design.md +797 -0
  128. package/one/things/cascade/docs/examples/1-5-quality-loops/tests.md +212 -0
  129. package/one/things/cascade/docs/examples/1-5-quality-loops.md +641 -0
  130. package/one/things/cascade/docs/examples/1-6-numbering-structure/design.md +610 -0
  131. package/one/things/cascade/docs/examples/1-6-numbering-structure/tests.md +213 -0
  132. package/one/things/cascade/docs/examples/1-6-numbering-structure.md +575 -0
  133. package/one/things/cascade/docs/examples/readme.md +222 -0
  134. package/one/things/cascade/docs/getting-started.md +515 -0
  135. package/one/things/cascade/docs/workflow.md +1372 -0
  136. package/one/things/cascade/readme.md +336 -0
  137. package/one/things/cascade/templates/feature-template.md +267 -0
  138. package/one/things/claude/agents/advocacy-activation-manager.md +685 -0
  139. package/one/things/claude/agents/advocacy-campaign-designer.md +663 -0
  140. package/one/things/claude/agents/analyst.md +483 -0
  141. package/one/things/claude/agents/architect.md +480 -0
  142. package/one/things/claude/agents/brand-identity-specialist.md +513 -0
  143. package/one/things/claude/agents/bstp-token-strategist.md +667 -0
  144. package/one/things/claude/agents/builder-repo.md +489 -0
  145. package/one/things/claude/agents/bullstamp-community-builder.md +574 -0
  146. package/one/things/claude/agents/bullstamp-marketing-orchestrator.md +506 -0
  147. package/one/things/claude/agents/bulltilt-platform-growth.md +567 -0
  148. package/one/things/claude/agents/company-bullstamp-character.md +587 -0
  149. package/one/things/claude/agents/company-bullstamp-community.md +292 -0
  150. package/one/things/claude/agents/company-bullstamp-marketing.md +292 -0
  151. package/one/things/claude/agents/company-bullstamp-token.md +292 -0
  152. package/one/things/claude/agents/company-bulltilt-growth.md +292 -0
  153. package/one/things/claude/agents/content-bibliography-formatter.md +381 -0
  154. package/one/things/claude/agents/content-calendar-planner.md +448 -0
  155. package/one/things/claude/agents/content-chapter-formatter.md +488 -0
  156. package/one/things/claude/agents/content-formatter.md +546 -0
  157. package/one/things/claude/agents/content-hook-specialist.md +462 -0
  158. package/one/things/claude/agents/content-image-formatter.md +535 -0
  159. package/one/things/claude/agents/content-introduction-formatter.md +485 -0
  160. package/one/things/claude/agents/content-multiplication-engine.md +556 -0
  161. package/one/things/claude/agents/content-playbook-writer.md +448 -0
  162. package/one/things/claude/agents/content-team-manager.md +622 -0
  163. package/one/things/claude/agents/content-toc-formatter.md +522 -0
  164. package/one/things/claude/agents/convex-backend-specialist.md +2561 -0
  165. package/one/things/claude/agents/core-manager.md +582 -0
  166. package/one/things/claude/agents/core-master.md +403 -0
  167. package/one/things/claude/agents/cross-functional-manager.md +471 -0
  168. package/one/things/claude/agents/crypto-airdrop-strategist.md +602 -0
  169. package/one/things/claude/agents/crypto-analytics-educator.md +553 -0
  170. package/one/things/claude/agents/crypto-architecture-specialist.md +466 -0
  171. package/one/things/claude/agents/crypto-community-analyst.md +298 -0
  172. package/one/things/claude/agents/crypto-community-psychologist.md +509 -0
  173. package/one/things/claude/agents/crypto-dex-optimization-expert.md +538 -0
  174. package/one/things/claude/agents/crypto-dex-optimizer.md +292 -0
  175. package/one/things/claude/agents/crypto-diamond-formation-specialist.md +513 -0
  176. package/one/things/claude/agents/crypto-diamond-hands.md +292 -0
  177. package/one/things/claude/agents/crypto-ecosystem-expansion-manager.md +554 -0
  178. package/one/things/claude/agents/crypto-engagement-specialist.md +540 -0
  179. package/one/things/claude/agents/crypto-market-researcher.md +292 -0
  180. package/one/things/claude/agents/crypto-marketing-orchestrator.md +523 -0
  181. package/one/things/claude/agents/crypto-network-effect-amplifier.md +569 -0
  182. package/one/things/claude/agents/crypto-optimization-analyst.md +554 -0
  183. package/one/things/claude/agents/crypto-strategic-synthesizer.md +517 -0
  184. package/one/things/claude/agents/crypto-team-manager.md +387 -0
  185. package/one/things/claude/agents/crypto-token-analyst.md +278 -0
  186. package/one/things/claude/agents/crypto-viral-content-creator.md +546 -0
  187. package/one/things/claude/agents/crypto-wallet-identification-expert.md +517 -0
  188. package/one/things/claude/agents/crypto-wallet-identifier.md +292 -0
  189. package/one/things/claude/agents/customer-journey-designer.md +481 -0
  190. package/one/things/claude/agents/customer-success-manager.md +581 -0
  191. package/one/things/claude/agents/dev.md +413 -0
  192. package/one/things/claude/agents/documenter.md +546 -0
  193. package/one/things/claude/agents/elevate-marketing-orchestrator.md +410 -0
  194. package/one/things/claude/agents/engagement-specialist.md +509 -0
  195. package/one/things/claude/agents/engineering-architect.md +387 -0
  196. package/one/things/claude/agents/engineering-business-analyst.md +537 -0
  197. package/one/things/claude/agents/engineering-developer.md +387 -0
  198. package/one/things/claude/agents/engineering-director.md +282 -0
  199. package/one/things/claude/agents/engineering-ingestor.md +649 -0
  200. package/one/things/claude/agents/engineering-product-manager.md +537 -0
  201. package/one/things/claude/agents/engineering-product-owner.md +537 -0
  202. package/one/things/claude/agents/engineering-project-coordinator.md +537 -0
  203. package/one/things/claude/agents/engineering-quality-assurance.md +393 -0
  204. package/one/things/claude/agents/engineering-team-manager.md +512 -0
  205. package/one/things/claude/agents/engineering-user-experience.md +387 -0
  206. package/one/things/claude/agents/framework-elevate-manager.md +294 -0
  207. package/one/things/claude/agents/improver.md +763 -0
  208. package/one/things/claude/agents/intelligence-team-manager.md +385 -0
  209. package/one/things/claude/agents/lead-capture-expert.md +466 -0
  210. package/one/things/claude/agents/lead-magnet-creator.md +453 -0
  211. package/one/things/claude/agents/market-research-analyst.md +412 -0
  212. package/one/things/claude/agents/marketing-brand-identity.md +314 -0
  213. package/one/things/claude/agents/marketing-content-hooks.md +450 -0
  214. package/one/things/claude/agents/marketing-content-multiplier.md +326 -0
  215. package/one/things/claude/agents/marketing-content-poster.md +361 -0
  216. package/one/things/claude/agents/marketing-customer-journey.md +326 -0
  217. package/one/things/claude/agents/marketing-director.md +397 -0
  218. package/one/things/claude/agents/marketing-engagement.md +326 -0
  219. package/one/things/claude/agents/marketing-lead-capture.md +326 -0
  220. package/one/things/claude/agents/marketing-lead-magnet.md +326 -0
  221. package/one/things/claude/agents/marketing-network-effects.md +326 -0
  222. package/one/things/claude/agents/marketing-nurture-campaigns.md +326 -0
  223. package/one/things/claude/agents/marketing-share-optimizer.md +326 -0
  224. package/one/things/claude/agents/marketing-team-manager.md +446 -0
  225. package/one/things/claude/agents/marketing-viral-growth.md +201 -0
  226. package/one/things/claude/agents/mission-commander.md +373 -0
  227. package/one/things/claude/agents/network-effect-analyst.md +587 -0
  228. package/one/things/claude/agents/nextjs-15-specialist.md +1547 -0
  229. package/one/things/claude/agents/npx.md +890 -0
  230. package/one/things/claude/agents/nurture-campaign-manager.md +531 -0
  231. package/one/things/claude/agents/one-master.md +355 -0
  232. package/one/things/claude/agents/one-orchestrator.md +315 -0
  233. package/one/things/claude/agents/one.md +601 -0
  234. package/one/things/claude/agents/playbook-generator.md +503 -0
  235. package/one/things/claude/agents/pm.md +326 -0
  236. package/one/things/claude/agents/po.md +345 -0
  237. package/one/things/claude/agents/qa.md +336 -0
  238. package/one/things/claude/agents/research-foundation-analyst.md +307 -0
  239. package/one/things/claude/agents/research-intelligence-gatherer.md +408 -0
  240. package/one/things/claude/agents/research-market-analyst.md +307 -0
  241. package/one/things/claude/agents/research-team-manager.md +482 -0
  242. package/one/things/claude/agents/sales-environment-optimizer.md +494 -0
  243. package/one/things/claude/agents/sales-team-manager.md +400 -0
  244. package/one/things/claude/agents/sales-upsell-strategist.md +307 -0
  245. package/one/things/claude/agents/service-advocacy-campaigns.md +307 -0
  246. package/one/things/claude/agents/service-advocacy-manager.md +307 -0
  247. package/one/things/claude/agents/service-success-manager.md +307 -0
  248. package/one/things/claude/agents/service-team-manager.md +400 -0
  249. package/one/things/claude/agents/shadcn-ui-design-system-specialist.md +2302 -0
  250. package/one/things/claude/agents/share-optimization-specialist.md +551 -0
  251. package/one/things/claude/agents/sm.md +327 -0
  252. package/one/things/claude/agents/story-teller.md +473 -0
  253. package/one/things/claude/agents/task-master.md +596 -0
  254. package/one/things/claude/agents/tauri-cross-platform-specialist.md +1827 -0
  255. package/one/things/claude/agents/tester.md +556 -0
  256. package/one/things/claude/agents/the-bull-character-manager.md +580 -0
  257. package/one/things/claude/agents/tools-playbook-generator.md +489 -0
  258. package/one/things/claude/agents/turbo-repo-builder.md +316 -0
  259. package/one/things/claude/agents/upsell-strategist.md +480 -0
  260. package/one/things/claude/agents/ux-expert.md +335 -0
  261. package/one/things/claude/agents/viral-growth-orchestrator.md +497 -0
  262. package/one/things/claude/claude-code-hooks-development.json +21 -0
  263. package/one/things/claude/claude-code-hooks-production.json +21 -0
  264. package/one/things/claude/claude-code-hooks.json +25 -0
  265. package/one/things/claude/commands/agent.md +104 -0
  266. package/one/things/claude/commands/cascade-status.md +128 -0
  267. package/one/things/claude/commands/ingest.md +290 -0
  268. package/one/things/claude/commands/ingestor.md +136 -0
  269. package/one/things/claude/commands/mission.md +83 -0
  270. package/one/things/claude/commands/npx.md +133 -0
  271. package/one/things/claude/commands/one.md +440 -0
  272. package/one/things/claude/commands/quality-check.md +204 -0
  273. package/one/things/claude/commands/smart-route.md +220 -0
  274. package/one/things/claude/commands/start.md +121 -0
  275. package/one/things/claude/commands/story.md +83 -0
  276. package/one/things/claude/commands/task.md +173 -0
  277. package/one/things/claude/hook-bypass.json +32 -0
  278. package/one/things/claude/hooks/agent-hook-config.json +427 -0
  279. package/one/things/claude/hooks/agent-hook-manager.js +525 -0
  280. package/one/things/claude/hooks/agent-load-balancer.js +271 -0
  281. package/one/things/claude/hooks/agent-request-interceptor.js +70 -0
  282. package/one/things/claude/hooks/build-hook.sh +156 -0
  283. package/one/things/claude/hooks/cascade-feedback.js +297 -0
  284. package/one/things/claude/hooks/cascade-integration-hooks.js +648 -0
  285. package/one/things/claude/hooks/cleanup-hook.sh +201 -0
  286. package/one/things/claude/hooks/continuous-improvement-monitor.js +510 -0
  287. package/one/things/claude/hooks/file-organization-engine.js +427 -0
  288. package/one/things/claude/hooks/file-organization-hook.sh +80 -0
  289. package/one/things/claude/hooks/file-organization-monitor.js +269 -0
  290. package/one/things/claude/hooks/format-hook.sh +43 -0
  291. package/one/things/claude/hooks/hook-bypass.sh +293 -0
  292. package/one/things/claude/hooks/hook-config-manager.js +202 -0
  293. package/one/things/claude/hooks/hook-debouncer.sh +62 -0
  294. package/one/things/claude/hooks/hook-logger.sh +89 -0
  295. package/one/things/claude/hooks/hook-orchestrator.js +662 -0
  296. package/one/things/claude/hooks/hook-performance-report.js +120 -0
  297. package/one/things/claude/hooks/lint-hook.sh +140 -0
  298. package/one/things/claude/hooks/mcp-cascade-integration.js +816 -0
  299. package/one/things/claude/hooks/memory-optimizer.js +510 -0
  300. package/one/things/claude/hooks/notification-hook.sh +204 -0
  301. package/one/things/claude/hooks/ontology-compliance.js +394 -0
  302. package/one/things/claude/hooks/ontology-hook-manager.js +316 -0
  303. package/one/things/claude/hooks/ontology-validation-engine.js +317 -0
  304. package/one/things/claude/hooks/ontology-validation-hook.sh +86 -0
  305. package/one/things/claude/hooks/performance-metrics.json +25 -0
  306. package/one/things/claude/hooks/performance-monitoring-hook.js +422 -0
  307. package/one/things/claude/hooks/quality-scoring-engine.js +834 -0
  308. package/one/things/claude/hooks/security-hook.sh +256 -0
  309. package/one/things/claude/hooks/simple-load-balancer.js +238 -0
  310. package/one/things/claude/hooks/startup-optimizer.js +625 -0
  311. package/one/things/claude/hooks/story-scoring-system.js +445 -0
  312. package/one/things/claude/hooks/story-validation-engine.js +473 -0
  313. package/one/things/claude/hooks/story-validation-hook-enhanced.sh +210 -0
  314. package/one/things/claude/hooks/story-validation-hook.sh +145 -0
  315. package/one/things/claude/hooks/structure-synchronizer.js +194 -0
  316. package/one/things/claude/hooks/sub-agent-output-validator.js +647 -0
  317. package/one/things/claude/hooks/sub-agent-validation-hook.js +343 -0
  318. package/one/things/claude/hooks/test-hook.sh +145 -0
  319. package/one/things/claude/hooks/test-story-validation.sh +170 -0
  320. package/one/things/claude/hooks/trinity-validation-system.js +392 -0
  321. package/one/things/claude/settings-local.json +86 -0
  322. package/one/things/cli-code.md +652 -0
  323. package/one/things/cli-compiler-code.md +652 -0
  324. package/one/things/cli.md +1045 -0
  325. package/one/things/components/card-shadcn.md +929 -0
  326. package/one/things/components/card.md +1050 -0
  327. package/one/things/components.md +1669 -0
  328. package/one/things/componets.md +4 -0
  329. package/one/things/copilotkit.md +1559 -0
  330. package/one/things/creator-diagram.md +166 -0
  331. package/one/things/examples/children/lemonade-stand.md +366 -0
  332. package/one/things/examples/enterprise/crm-saas.md +1429 -0
  333. package/one/things/features/1-1-agent-prompts/design.md +470 -0
  334. package/one/things/features/1-1-agent-prompts/tests.md +264 -0
  335. package/one/things/features/1-1-agent-prompts.md +486 -0
  336. package/one/things/features/1-2-yaml-orchestrator/design.md +497 -0
  337. package/one/things/features/1-2-yaml-orchestrator/tests.md +227 -0
  338. package/one/things/features/1-2-yaml-orchestrator.md +516 -0
  339. package/one/things/features/1-3-event-coordination/design.md +544 -0
  340. package/one/things/features/1-3-event-coordination/tests.md +223 -0
  341. package/one/things/features/1-3-event-coordination.md +508 -0
  342. package/one/things/features/1-4-knowledge-management/design.md +609 -0
  343. package/one/things/features/1-4-knowledge-management/tests.md +195 -0
  344. package/one/things/features/1-4-knowledge-management.md +577 -0
  345. package/one/things/features/1-5-quality-loops/design.md +797 -0
  346. package/one/things/features/1-5-quality-loops/tests.md +212 -0
  347. package/one/things/features/1-5-quality-loops.md +641 -0
  348. package/one/things/features/1-6-numbering-structure/design.md +610 -0
  349. package/one/things/features/1-6-numbering-structure/tests.md +213 -0
  350. package/one/things/features/1-6-numbering-structure.md +575 -0
  351. package/one/things/features/2-cli.md +1235 -0
  352. package/one/things/features/use-one-backend.md +1180 -0
  353. package/one/things/ideas/1-create-workflow.md +189 -0
  354. package/one/things/plans/1-create-workflow-status.md +555 -0
  355. package/one/things/plans/1-create-workflow.md +713 -0
  356. package/one/things/plans/app.md +761 -0
  357. package/one/things/plans/better-auth-any-backend-revised.md +1065 -0
  358. package/one/things/plans/better-auth-any-backend.md +1852 -0
  359. package/one/things/plans/better-auth-available-features.md +235 -0
  360. package/one/things/plans/big-plan.md +38 -0
  361. package/one/things/plans/convex-better-auth.md +1109 -0
  362. package/one/things/plans/convex-on-off.md +389 -0
  363. package/one/things/plans/desktop.md +1121 -0
  364. package/one/things/plans/effect-components.md +1669 -0
  365. package/one/things/plans/effect.md +973 -0
  366. package/one/things/plans/email.md +953 -0
  367. package/one/things/plans/enhance-auth.md +1669 -0
  368. package/one/things/plans/install-components.md +198 -0
  369. package/one/things/plans/landing.md +728 -0
  370. package/one/things/plans/layout.md +205 -0
  371. package/one/things/plans/mail-backend.md +1308 -0
  372. package/one/things/plans/mail.md +2624 -0
  373. package/one/things/plans/next-features.md +83 -0
  374. package/one/things/plans/one.md +658 -0
  375. package/one/things/plans/ontology-6-dimensions.md +2216 -0
  376. package/one/things/plans/ontology-driven-strategy.md +866 -0
  377. package/one/things/plans/ontology-ui-approach.md +357 -0
  378. package/one/things/plans/open-agent.md +785 -0
  379. package/one/things/plans/performace.md +90 -0
  380. package/one/things/plans/releases.md +809 -0
  381. package/one/things/plans/repos.md +76 -0
  382. package/one/things/plans/separate-copy-2.md +1293 -0
  383. package/one/things/plans/separate-copy-3.md +2458 -0
  384. package/one/things/plans/separate-copy.md +1293 -0
  385. package/one/things/plans/separate.md +1983 -0
  386. package/one/things/plans/shadcn-integration-summary.md +450 -0
  387. package/one/things/plans/sidebar.md +172 -0
  388. package/one/things/plans/small-fixes.md +5 -0
  389. package/one/things/plans/test-backend-connection.md +476 -0
  390. package/one/things/plans/workflow-files.md +1196 -0
  391. package/one/things/plans/workflow.md +1372 -0
  392. package/one/things/products/cascade-landing-page.md +737 -0
  393. package/one/things/products/cascade.md +1518 -0
  394. package/one/things/products/context-engineering.md +1427 -0
  395. package/one/things/products/onthology.md +0 -0
  396. package/one/things/products/ontology-ui-shadcn.md +1280 -0
  397. package/one/things/products/ontology-ui.md +1387 -0
  398. package/one/things/products/ontology.md +717 -0
  399. package/one/things/products/sdk.md +557 -0
  400. package/one/things/promptkit.md +903 -0
  401. package/one/things/service-providers-new.md +982 -0
  402. package/one/things/service-providers.md +1092 -0
  403. package/one/things/things.md +349 -0
  404. package/one/things/todo.md +1248 -0
  405. package/package.json +5 -2
@@ -0,0 +1,1669 @@
1
+ # Comprehensive Phased Implementation Plan: Better Auth with Convex & Shadcn UI
2
+
3
+ ## Implementation Status
4
+
5
+ ### ✅ Better Auth IS Active (Hybrid Architecture)
6
+
7
+ **Current Setup:**
8
+ - ✅ Better Auth React Client (frontend)
9
+ - ✅ Better Auth Convex Component (NOW configured in `convex/convex.config.ts`)
10
+ - ✅ API bridge connecting Better Auth UI to custom backend
11
+ - ⚠️ Backend still using custom Convex mutations (not Better Auth built-in functions)
12
+
13
+ **Architecture:** Hybrid approach using Better Auth UI/client but custom backend logic
14
+
15
+ ### ✅ Completed Features
16
+ - [x] Better Auth React client integration
17
+ - [x] Better Auth Convex component configured
18
+ - [x] Email/password authentication with custom Convex backend
19
+ - [x] Password reset flow with Resend email component
20
+ - [x] UI components (AuthCard, SocialLoginButtons, PasswordStrengthIndicator)
21
+ - [x] Session management with httpOnly cookies
22
+ - [x] API bridge at `/api/auth/[...all]`
23
+
24
+ ### 🚨 Current Limitations
25
+ - [ ] Not using Better Auth's built-in auth functions (using custom mutations instead)
26
+ - [ ] Using SHA-256 for passwords (should migrate to Better Auth's Argon2)
27
+ - [ ] No rate limiting on auth endpoints
28
+ - [ ] No email verification
29
+ - [ ] Social OAuth UI exists but not functional
30
+
31
+ ### 🚧 Next Steps (Migrate from Custom to Full Better Auth)
32
+ 1. [ ] **Replace custom mutations with Better Auth functions** (1-2 days)
33
+ 2. [ ] **Set up Better Auth HTTP routes** in `convex/http.ts`
34
+ 3. [ ] **Enable Better Auth plugins** (OAuth, magic links, 2FA)
35
+ 4. [ ] **Migrate user data** to Better Auth schema
36
+
37
+ ### 📋 Planned Features (Requires Better Auth)
38
+ - [ ] Anonymous login
39
+ - [ ] Account linking architecture
40
+ - [ ] Magic links
41
+ - [ ] Two-factor authentication (TOTP)
42
+ - [ ] Passkeys (WebAuthn)
43
+ - [ ] Stripe integration
44
+ - [ ] Social OAuth (GitHub, Google)
45
+
46
+ ## Executive Summary
47
+
48
+ This plan delivers a streamlined, high-converting auth system for your Astro + Convex + Shadcn UI application. Based on extensive research, the implementation prioritizes **friction reduction, clean architecture, and progressive security enhancement**. The phased approach enables rapid deployment while building toward industry-leading passkey-based authentication.
49
+
50
+ **Current Status**: Basic custom auth implemented. Recommendation: Migrate to Better Auth for automatic account linking, session management, and advanced features—eliminating 100+ hours of manual development.
51
+
52
+ **Key Insight**: Better Auth with Convex provides automatic account linking, session management, and database integration—eliminating most complexity. The plan leverages this to deliver production-ready auth in 6-8 weeks.
53
+
54
+ ---
55
+
56
+ ## Phase Ordering Recommendation
57
+
58
+ ### **Phase 1: Foundation** (Week 1-2)
59
+
60
+ - [ ] Anonymous login *Deferred - requires Better Auth*
61
+ - [ ] Enhanced account linking architecture
62
+ - [x] Base component structure with Shadcn UI ✅
63
+ - [x] Forgot password flow improvements ✅
64
+
65
+ **Status**: Base components and password reset completed with Resend email component.
66
+
67
+ **Rationale**: Anonymous login delivers immediate conversion lift (86% of users prefer exploring before signup) while establishing the component foundation. Account linking configured now prevents friction later.
68
+
69
+ ### **Phase 2: Passwordless Options** (Week 3-4)
70
+
71
+ - [ ] Magic links (email-based)
72
+ - [x] Enhanced email templates with React Email + Resend ✅ *Basic implementation*
73
+
74
+ **Status**: Resend component integrated for password reset. Magic links require Better Auth plugin.
75
+
76
+ **Rationale**: Passwordless is the industry trend. Magic links provide 20-40% conversion boost with low implementation complexity.
77
+
78
+ ### **Phase 3: Enhanced Security** (Week 4-6)
79
+
80
+ - [ ] Phone/SMS authentication (via Twilio)
81
+ - [ ] TOTP two-factor authentication
82
+ - [ ] SMS-based 2FA (backup only)
83
+
84
+ **Status**: Not started. Requires Better Auth 2FA plugin.
85
+
86
+ **Rationale**: Security features before handling sensitive data. TOTP prioritized over SMS due to superior security (95% of account takeovers use SMS vs 4.13% with TOTP).
87
+
88
+ ### **Phase 4: Future-Proof Authentication** (Week 6-8)
89
+
90
+ - [ ] Passkeys (WebAuthn)
91
+ - [ ] Progressive enhancement UX
92
+ - [ ] Cross-device authentication
93
+
94
+ **Status**: Not started. Requires Better Auth passkey plugin.
95
+
96
+ **Rationale**: Industry consensus points toward passkeys. Google reports 6x faster login, phishing-resistant by design. Early adoption positions you as forward-thinking.
97
+
98
+ ### **Phase 5: Monetization** (Week 8-10)
99
+
100
+ - [ ] Stripe Better Auth plugin
101
+ - [ ] Subscription management
102
+ - [ ] Trial abuse prevention
103
+
104
+ **Status**: Not started. Requires Better Auth Stripe plugin.
105
+
106
+ **Rationale**: Implement after auth is production-tested. Stripe integration is business-critical and requires stable user management.
107
+
108
+ ---
109
+
110
+ ## Phase 1: Foundation Implementation
111
+
112
+ ### 1.1 Anonymous Login Setup
113
+
114
+ **Goal**: Let users explore without signup friction, then seamlessly upgrade to permanent accounts.
115
+
116
+ **Better Auth Configuration**:
117
+
118
+ ```typescript
119
+ // convex/auth.ts
120
+ import { betterAuth } from 'better-auth';
121
+ import { anonymous } from 'better-auth/plugins';
122
+ import { convex } from '@convex-dev/better-auth/plugins';
123
+ import { authComponent } from './auth-component';
124
+
125
+ export const createAuth = (ctx) => {
126
+ return betterAuth({
127
+ database: authComponent.adapter(ctx),
128
+ baseURL: process.env.SITE_URL!,
129
+
130
+ // Account linking - CRITICAL for smooth UX
131
+ account: {
132
+ accountLinking: {
133
+ enabled: true,
134
+ trustedProviders: ['google', 'github'],
135
+ updateUserInfoOnLink: true,
136
+ },
137
+ },
138
+
139
+ // Anonymous authentication
140
+ plugins: [
141
+ anonymous({
142
+ emailDomainName: 'temp.yourapp.com',
143
+ onLinkAccount: async ({ anonymousUser, newUser }) => {
144
+ // Migrate user data (cart, preferences, etc.)
145
+ await migrateUserData(anonymousUser.id, newUser.id);
146
+ },
147
+ disableDeleteAnonymousUser: false, // Clean up after linking
148
+ }),
149
+ convex(),
150
+ ],
151
+ });
152
+ };
153
+ ```
154
+
155
+ **Client Implementation**:
156
+
157
+ ```typescript
158
+ // lib/auth-client.ts
159
+ import { createAuthClient } from 'better-auth/react';
160
+ import { anonymousClient } from 'better-auth/plugins/anonymous/client';
161
+ import { convexClient } from '@convex-dev/better-auth/client/plugins';
162
+
163
+ export const authClient = createAuthClient({
164
+ plugins: [anonymousClient(), convexClient()],
165
+ });
166
+
167
+ // Usage in components
168
+ async function handleAnonymousSignIn() {
169
+ await authClient.signIn.anonymous();
170
+ // User can now explore app
171
+ }
172
+ ```
173
+
174
+ **Database Schema**:
175
+
176
+ - Adds `isAnonymous` boolean field to user table
177
+ - Automatic cleanup after 30 days (configurable)
178
+
179
+ **Critical Considerations**:
180
+
181
+ - **Data migration strategy**: Define what data (cart, preferences, drafts) follows users during upgrade
182
+ - **Feature gating**: Restrict sharing, payments, exports to verified users only
183
+ - **Analytics tracking**: Separate anonymous vs authenticated user metrics
184
+
185
+ ### 1.2 Account Linking Architecture
186
+
187
+ **The Problem**: User signs up with email/password, later tries "Continue with Google" with same email. What happens?
188
+
189
+ **Better Auth Solution** (Automatic):
190
+
191
+ ```typescript
192
+ // When accountLinking.enabled = true and Google in trustedProviders:
193
+ // 1. User clicks "Continue with Google"
194
+ // 2. Google returns verified email: user@example.com
195
+ // 3. Better Auth checks if user@example.com exists
196
+ // 4. Finds existing account → Automatically links Google provider
197
+ // 5. User signs in to EXISTING account with new Google method added
198
+ // 6. Both methods now work for this user
199
+ ```
200
+
201
+ **Manual Linking** (User-initiated from settings):
202
+
203
+ ```typescript
204
+ // components/auth/LinkAccountButton.tsx
205
+ export function LinkGoogleButton() {
206
+ const handleLink = async () => {
207
+ await authClient.linkSocial({
208
+ provider: "google",
209
+ callbackURL: "/settings/accounts",
210
+ })
211
+ toast.success("Google account linked successfully")
212
+ }
213
+
214
+ return (
215
+ <Button onClick={handleLink} variant="outline">
216
+ <Icons.google className="mr-2 h-4 w-4" />
217
+ Link Google Account
218
+ </Button>
219
+ )
220
+ }
221
+ ```
222
+
223
+ **Account Linking UI Flow**:
224
+
225
+ ```typescript
226
+ // When duplicate email detected during social signup
227
+ export function AccountLinkingPrompt({ email, provider }: Props) {
228
+ return (
229
+ <Alert>
230
+ <AlertTitle>Account Found</AlertTitle>
231
+ <AlertDescription>
232
+ An account with {email} already exists.
233
+ Sign in with your password to link your {provider} account.
234
+ </AlertDescription>
235
+ <div className="mt-4 flex gap-2">
236
+ <Button onClick={() => router.push('/login')}>
237
+ Sign in to link accounts
238
+ </Button>
239
+ <Button variant="outline" onClick={() => router.push('/signup')}>
240
+ Use different email
241
+ </Button>
242
+ </div>
243
+ </Alert>
244
+ )
245
+ }
246
+ ```
247
+
248
+ **Security Best Practices**:
249
+
250
+ - Only link accounts with **verified emails** (Better Auth enforces this)
251
+ - Notify users via email when accounts are linked
252
+ - Allow unlinking from settings page
253
+ - Show all connected providers in account settings
254
+
255
+ ### 1.3 Component Architecture
256
+
257
+ **File Structure**:
258
+
259
+ ```
260
+ src/
261
+ ├── components/
262
+ │ ├── auth/
263
+ │ │ ├── forms/
264
+ │ │ │ ├── LoginForm.tsx
265
+ │ │ │ ├── RegisterForm.tsx
266
+ │ │ │ ├── ForgotPasswordForm.tsx
267
+ │ │ │ ├── ResetPasswordForm.tsx
268
+ │ │ │ ├── OTPVerifyForm.tsx
269
+ │ │ │ └── PasskeySetupForm.tsx
270
+ │ │ ├── buttons/
271
+ │ │ │ ├── SocialLoginButtons.tsx
272
+ │ │ │ ├── LoadingButton.tsx
273
+ │ │ │ └── AnonymousLoginButton.tsx
274
+ │ │ ├── shared/
275
+ │ │ │ ├── AuthCard.tsx
276
+ │ │ │ ├── AuthHeader.tsx
277
+ │ │ │ ├── PasswordStrengthIndicator.tsx
278
+ │ │ │ └── AccountLinkingPrompt.tsx
279
+ │ │ └── providers/
280
+ │ │ └── AuthProvider.tsx
281
+ │ └── ui/
282
+ │ └── [shadcn components]
283
+ ├── lib/
284
+ │ ├── auth-client.ts # Better Auth client config
285
+ │ ├── auth-server.ts # Server-side auth helpers
286
+ │ └── validations/
287
+ │ └── auth.ts # Zod schemas
288
+ └── pages/
289
+ └── (auth)/
290
+ ├── login/
291
+ ├── signup/
292
+ ├── forgot-password/
293
+ ├── reset-password/
294
+ └── verify-2fa/
295
+ ```
296
+
297
+ **Base Component Architecture**:
298
+
299
+ ```typescript
300
+ // components/auth/shared/AuthCard.tsx
301
+ import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"
302
+
303
+ interface AuthCardProps {
304
+ title: string
305
+ description?: string
306
+ children: React.ReactNode
307
+ footer?: React.ReactNode
308
+ }
309
+
310
+ export function AuthCard({ title, description, children, footer }: AuthCardProps) {
311
+ return (
312
+ <Card className="w-full max-w-md">
313
+ <CardHeader className="space-y-1">
314
+ <CardTitle className="text-2xl font-bold">{title}</CardTitle>
315
+ {description && (
316
+ <CardDescription>{description}</CardDescription>
317
+ )}
318
+ </CardHeader>
319
+ <CardContent className="space-y-4">
320
+ {children}
321
+ </CardContent>
322
+ {footer && (
323
+ <CardFooter>
324
+ {footer}
325
+ </CardFooter>
326
+ )}
327
+ </Card>
328
+ )
329
+ }
330
+ ```
331
+
332
+ **Reusable Social Login Component**:
333
+
334
+ ```typescript
335
+ // components/auth/buttons/SocialLoginButtons.tsx
336
+ import { Button } from "@/components/ui/button"
337
+ import { Separator } from "@/components/ui/separator"
338
+ import { authClient } from "@/lib/auth-client"
339
+ import { toast } from "sonner"
340
+
341
+ interface SocialLoginButtonsProps {
342
+ callbackURL?: string
343
+ newUserCallbackURL?: string
344
+ }
345
+
346
+ export function SocialLoginButtons({
347
+ callbackURL = "/dashboard",
348
+ newUserCallbackURL = "/welcome"
349
+ }: SocialLoginButtonsProps) {
350
+
351
+ const handleSocialLogin = async (provider: "google" | "github") => {
352
+ try {
353
+ await authClient.signIn.social({
354
+ provider,
355
+ callbackURL,
356
+ newUserCallbackURL,
357
+ errorCallbackURL: "/auth-error",
358
+ })
359
+ } catch (error) {
360
+ toast.error(`Failed to sign in with ${provider}`)
361
+ }
362
+ }
363
+
364
+ return (
365
+ <div className="space-y-4">
366
+ <div className="relative">
367
+ <div className="absolute inset-0 flex items-center">
368
+ <Separator />
369
+ </div>
370
+ <div className="relative flex justify-center text-xs uppercase">
371
+ <span className="bg-background px-2 text-muted-foreground">
372
+ Or continue with
373
+ </span>
374
+ </div>
375
+ </div>
376
+
377
+ <div className="grid grid-cols-2 gap-4">
378
+ <Button
379
+ variant="outline"
380
+ onClick={() => handleSocialLogin("google")}
381
+ >
382
+ <Icons.google className="mr-2 h-4 w-4" />
383
+ Google
384
+ </Button>
385
+ <Button
386
+ variant="outline"
387
+ onClick={() => handleSocialLogin("github")}
388
+ >
389
+ <Icons.github className="mr-2 h-4 w-4" />
390
+ GitHub
391
+ </Button>
392
+ </div>
393
+ </div>
394
+ )
395
+ }
396
+ ```
397
+
398
+ ### 1.4 Enhanced Password Reset Flow
399
+
400
+ **Modern Approach**: Magic link-based reset (simpler than traditional password reset).
401
+
402
+ ```typescript
403
+ // components/auth/forms/ForgotPasswordForm.tsx
404
+ import { zodResolver } from "@hookform/resolvers/zod"
405
+ import { useForm } from "react-hook-form"
406
+ import { z } from "zod"
407
+ import { Form, FormField, FormItem, FormLabel, FormControl, FormMessage } from "@/components/ui/form"
408
+ import { Input } from "@/components/ui/input"
409
+ import { LoadingButton } from "@/components/auth/buttons/LoadingButton"
410
+ import { authClient } from "@/lib/auth-client"
411
+
412
+ const forgotPasswordSchema = z.object({
413
+ email: z.string().email({ message: "Invalid email address" }),
414
+ })
415
+
416
+ export function ForgotPasswordForm() {
417
+ const [isSubmitted, setIsSubmitted] = useState(false)
418
+
419
+ const form = useForm({
420
+ resolver: zodResolver(forgotPasswordSchema),
421
+ defaultValues: { email: "" },
422
+ })
423
+
424
+ async function onSubmit(values: z.infer<typeof forgotPasswordSchema>) {
425
+ await authClient.forgetPassword({
426
+ email: values.email,
427
+ redirectTo: "/reset-password",
428
+ })
429
+ setIsSubmitted(true)
430
+ }
431
+
432
+ if (isSubmitted) {
433
+ return (
434
+ <Alert>
435
+ <AlertTitle>Check your email</AlertTitle>
436
+ <AlertDescription>
437
+ If an account exists with that email, you'll receive a password reset link.
438
+ </AlertDescription>
439
+ </Alert>
440
+ )
441
+ }
442
+
443
+ return (
444
+ <AuthCard
445
+ title="Reset password"
446
+ description="Enter your email to receive a reset link"
447
+ >
448
+ <Form {...form}>
449
+ <form onSubmit={form.handleSubmit(onSubmit)} className="space-y-4">
450
+ <FormField
451
+ control={form.control}
452
+ name="email"
453
+ render={({ field }) => (
454
+ <FormItem>
455
+ <FormLabel>Email</FormLabel>
456
+ <FormControl>
457
+ <Input
458
+ type="email"
459
+ placeholder="name@example.com"
460
+ autoFocus
461
+ {...field}
462
+ />
463
+ </FormControl>
464
+ <FormMessage />
465
+ </FormItem>
466
+ )}
467
+ />
468
+
469
+ <LoadingButton
470
+ type="submit"
471
+ className="w-full"
472
+ loading={form.formState.isSubmitting}
473
+ >
474
+ Send reset link
475
+ </LoadingButton>
476
+ </form>
477
+ </Form>
478
+
479
+ <div className="text-center text-sm">
480
+ <Link href="/login" className="text-muted-foreground hover:text-primary">
481
+ Back to login
482
+ </Link>
483
+ </div>
484
+ </AuthCard>
485
+ )
486
+ }
487
+ ```
488
+
489
+ **Password Requirements Component**:
490
+
491
+ ```typescript
492
+ // components/auth/shared/PasswordStrengthIndicator.tsx
493
+ import { CheckCircle2, Circle } from "lucide-react"
494
+
495
+ interface PasswordStrengthIndicatorProps {
496
+ password: string
497
+ }
498
+
499
+ export function PasswordStrengthIndicator({ password }: PasswordStrengthIndicatorProps) {
500
+ const requirements = [
501
+ { label: "At least 12 characters", met: password.length >= 12 },
502
+ { label: "One uppercase letter", met: /[A-Z]/.test(password) },
503
+ { label: "One number", met: /[0-9]/.test(password) },
504
+ ]
505
+
506
+ return (
507
+ <div className="space-y-2 rounded-lg border p-3">
508
+ <p className="text-sm font-medium">Password must contain:</p>
509
+ {requirements.map((req, index) => (
510
+ <div key={index} className="flex items-center gap-2 text-sm">
511
+ {req.met ? (
512
+ <CheckCircle2 className="h-4 w-4 text-green-500" />
513
+ ) : (
514
+ <Circle className="h-4 w-4 text-muted-foreground" />
515
+ )}
516
+ <span className={req.met ? "text-green-700" : "text-muted-foreground"}>
517
+ {req.label}
518
+ </span>
519
+ </div>
520
+ ))}
521
+ </div>
522
+ )
523
+ }
524
+ ```
525
+
526
+ ---
527
+
528
+ ## Phase 2: Magic Links Implementation
529
+
530
+ ### 2.1 Convex Resend Integration
531
+
532
+ **Setup**:
533
+
534
+ ```bash
535
+ npm install @convex-dev/resend
536
+ npx convex env set RESEND_API_KEY "re_your_api_key"
537
+ ```
538
+
539
+ **Configuration**:
540
+
541
+ ```typescript
542
+ // convex/convex.config.ts
543
+ import { defineApp } from 'convex/server';
544
+ import resend from '@convex-dev/resend/convex.config';
545
+ import betterAuth from '@convex-dev/better-auth/convex.config';
546
+
547
+ const app = defineApp();
548
+ app.use(resend);
549
+ app.use(betterAuth);
550
+ export default app;
551
+ ```
552
+
553
+ **Email Service Setup**:
554
+
555
+ ```typescript
556
+ // convex/email.ts
557
+ import { Resend } from "@convex-dev/resend"
558
+ import { components } from "./_generated/api"
559
+ import { internalMutation } from "./_generated/server"
560
+
561
+ export const resend = new Resend(components.resend, {
562
+ testMode: false,
563
+ })
564
+
565
+ export const sendMagicLink = internalMutation({
566
+ args: {
567
+ email: v.string(),
568
+ url: v.string(),
569
+ token: v.string(),
570
+ },
571
+ handler: async (ctx, { email, url }) => {
572
+ await resend.sendEmail(ctx, {
573
+ from: "Your App <auth@yourapp.com>",
574
+ to: email,
575
+ subject: "Sign in to Your App",
576
+ html: await render(
577
+ <MagicLinkEmail url={url} />
578
+ ),
579
+ })
580
+ },
581
+ })
582
+ ```
583
+
584
+ ### 2.2 Magic Link Configuration
585
+
586
+ ```typescript
587
+ // convex/auth.ts - add magic link plugin
588
+ import { magicLink } from 'better-auth/plugins';
589
+
590
+ export const createAuth = (ctx) => {
591
+ return betterAuth({
592
+ // ... existing config
593
+ plugins: [
594
+ magicLink({
595
+ sendMagicLink: async ({ email, token, url }, request) => {
596
+ await ctx.scheduler.runAfter(0, internal.email.sendMagicLink, {
597
+ email,
598
+ url,
599
+ token,
600
+ });
601
+ },
602
+ expiresIn: 300, // 5 minutes
603
+ disableSignUp: false, // Allow new user signups
604
+ }),
605
+ anonymous(),
606
+ convex(),
607
+ ],
608
+ });
609
+ };
610
+ ```
611
+
612
+ ### 2.3 React Email Templates
613
+
614
+ ```typescript
615
+ // convex/emails/MagicLinkEmail.tsx
616
+ "use node" // Required for React Email
617
+
618
+ import { Button, Html, Text, Section, Container } from "@react-email/components"
619
+
620
+ interface MagicLinkEmailProps {
621
+ url: string
622
+ }
623
+
624
+ export function MagicLinkEmail({ url }: MagicLinkEmailProps) {
625
+ return (
626
+ <Html>
627
+ <Container style={{ padding: "20px" }}>
628
+ <Section style={{ textAlign: "center" }}>
629
+ <Text style={{ fontSize: "24px", fontWeight: "bold" }}>
630
+ Sign in to Your App
631
+ </Text>
632
+ <Text style={{ fontSize: "16px", color: "#666" }}>
633
+ Click the button below to sign in. This link expires in 5 minutes.
634
+ </Text>
635
+ <Button
636
+ href={url}
637
+ style={{
638
+ backgroundColor: "#000",
639
+ color: "#fff",
640
+ padding: "12px 24px",
641
+ borderRadius: "6px",
642
+ textDecoration: "none",
643
+ display: "inline-block",
644
+ marginTop: "16px",
645
+ }}
646
+ >
647
+ Sign in to Your App
648
+ </Button>
649
+ <Text style={{ fontSize: "14px", color: "#999", marginTop: "24px" }}>
650
+ If you didn't request this email, you can safely ignore it.
651
+ </Text>
652
+ </Section>
653
+ </Container>
654
+ </Html>
655
+ )
656
+ }
657
+ ```
658
+
659
+ ### 2.4 Magic Link Client Implementation
660
+
661
+ ```typescript
662
+ // components/auth/forms/MagicLinkForm.tsx
663
+ import { magicLinkClient } from "better-auth/plugins/magic-link/client"
664
+
665
+ // Add to auth client
666
+ export const authClient = createAuthClient({
667
+ plugins: [
668
+ magicLinkClient(),
669
+ anonymousClient(),
670
+ convexClient(),
671
+ ],
672
+ })
673
+
674
+ // Usage in component
675
+ export function MagicLinkForm() {
676
+ const [emailSent, setEmailSent] = useState(false)
677
+
678
+ async function handleSubmit(values: { email: string }) {
679
+ await authClient.signIn.magicLink({
680
+ email: values.email,
681
+ callbackURL: "/dashboard",
682
+ })
683
+ setEmailSent(true)
684
+ }
685
+
686
+ if (emailSent) {
687
+ return (
688
+ <Alert>
689
+ <AlertTitle>Check your email</AlertTitle>
690
+ <AlertDescription>
691
+ We've sent a magic link to your email. Click it to sign in.
692
+ </AlertDescription>
693
+ </Alert>
694
+ )
695
+ }
696
+
697
+ return (
698
+ <Form onSubmit={handleSubmit}>
699
+ {/* Form fields */}
700
+ </Form>
701
+ )
702
+ }
703
+ ```
704
+
705
+ ---
706
+
707
+ ## Phase 3: Phone Auth & Two-Factor Authentication
708
+
709
+ ### 3.1 Phone/SMS Authentication with Twilio
710
+
711
+ **Setup**:
712
+
713
+ ```bash
714
+ npx convex env set TWILIO_ACCOUNT_SID "ACxxxxx"
715
+ npx convex env set TWILIO_AUTH_TOKEN "your_token"
716
+ npx convex env set TWILIO_PHONE_NUMBER "+1234567890"
717
+ ```
718
+
719
+ **Better Auth Configuration**:
720
+
721
+ ```typescript
722
+ import { phoneNumber } from 'better-auth/plugins';
723
+ import twilio from 'twilio';
724
+
725
+ const twilioClient = twilio(
726
+ process.env.TWILIO_ACCOUNT_SID,
727
+ process.env.TWILIO_AUTH_TOKEN
728
+ );
729
+
730
+ export const createAuth = (ctx) => {
731
+ return betterAuth({
732
+ // ... existing config
733
+ plugins: [
734
+ phoneNumber({
735
+ sendOTP: async ({ phoneNumber, code }) => {
736
+ await twilioClient.messages.create({
737
+ body: `Your verification code is: ${code}`,
738
+ from: process.env.TWILIO_PHONE_NUMBER,
739
+ to: phoneNumber,
740
+ });
741
+ },
742
+ otpLength: 6,
743
+ expiresIn: 300, // 5 minutes
744
+ allowedAttempts: 3,
745
+ }),
746
+ // ... other plugins
747
+ ],
748
+ });
749
+ };
750
+ ```
751
+
752
+ **Client Implementation**:
753
+
754
+ ```typescript
755
+ // components/auth/forms/PhoneVerifyForm.tsx
756
+ import { phoneNumberClient } from "better-auth/plugins/phone-number/client"
757
+
758
+ export const authClient = createAuthClient({
759
+ plugins: [
760
+ phoneNumberClient(),
761
+ // ... other plugins
762
+ ],
763
+ })
764
+
765
+ export function PhoneVerifyForm() {
766
+ const [step, setStep] = useState<"phone" | "code">("phone")
767
+
768
+ async function sendCode(phoneNumber: string) {
769
+ await authClient.phoneNumber.sendOtp({ phoneNumber })
770
+ setStep("code")
771
+ }
772
+
773
+ async function verifyCode(code: string) {
774
+ await authClient.phoneNumber.verifyOtp({ code })
775
+ router.push("/dashboard")
776
+ }
777
+
778
+ return step === "phone" ? (
779
+ <PhoneNumberInput onSubmit={sendCode} />
780
+ ) : (
781
+ <OTPInput onSubmit={verifyCode} />
782
+ )
783
+ }
784
+ ```
785
+
786
+ ### 3.2 TOTP Two-Factor Authentication
787
+
788
+ **Server Configuration**:
789
+
790
+ ```typescript
791
+ import { twoFactor } from 'better-auth/plugins';
792
+
793
+ export const createAuth = (ctx) => {
794
+ return betterAuth({
795
+ appName: 'Your App', // Used as TOTP issuer
796
+ plugins: [
797
+ twoFactor({
798
+ issuer: 'Your App',
799
+ totpOptions: {
800
+ period: 30,
801
+ digits: 6,
802
+ },
803
+ // Optional: Email-based OTP as backup
804
+ otpOptions: {
805
+ sendOTP: async ({ user, otp }) => {
806
+ await ctx.scheduler.runAfter(0, internal.email.send2FACode, {
807
+ email: user.email,
808
+ code: otp,
809
+ });
810
+ },
811
+ },
812
+ backupCodesOptions: {
813
+ amount: 10,
814
+ length: 10,
815
+ },
816
+ }),
817
+ // ... other plugins
818
+ ],
819
+ });
820
+ };
821
+ ```
822
+
823
+ **Client Implementation**:
824
+
825
+ ```typescript
826
+ // components/auth/TwoFactorSetup.tsx
827
+ import { twoFactorClient } from "better-auth/plugins/two-factor/client"
828
+ import QRCode from "qrcode"
829
+
830
+ export const authClient = createAuthClient({
831
+ plugins: [
832
+ twoFactorClient({
833
+ twoFactorPage: "/verify-2fa", // Redirect here when 2FA required
834
+ }),
835
+ // ... other plugins
836
+ ],
837
+ })
838
+
839
+ export function TwoFactorSetup() {
840
+ const [qrCodeUrl, setQrCodeUrl] = useState("")
841
+ const [backupCodes, setBackupCodes] = useState<string[]>([])
842
+
843
+ async function enable2FA(password: string) {
844
+ const { data } = await authClient.twoFactor.enable({ password })
845
+
846
+ // Generate QR code for user to scan
847
+ const qrUrl = await QRCode.toDataURL(data.totpURI)
848
+ setQrCodeUrl(qrUrl)
849
+ setBackupCodes(data.backupCodes)
850
+ }
851
+
852
+ async function verifySetup(code: string) {
853
+ await authClient.twoFactor.verifyTotp({
854
+ code,
855
+ trustDevice: false,
856
+ })
857
+ toast.success("Two-factor authentication enabled!")
858
+ }
859
+
860
+ return (
861
+ <div>
862
+ <img src={qrCodeUrl} alt="QR Code" />
863
+ <p>Scan with Google Authenticator, Authy, or 1Password</p>
864
+
865
+ {/* Backup codes display - SHOW ONLY ONCE */}
866
+ <Alert>
867
+ <AlertTitle>Save these backup codes</AlertTitle>
868
+ <AlertDescription>
869
+ {backupCodes.map(code => (
870
+ <code key={code}>{code}</code>
871
+ ))}
872
+ </AlertDescription>
873
+ </Alert>
874
+
875
+ {/* Verification step */}
876
+ <OTPInput onSubmit={verifySetup} />
877
+ </div>
878
+ )
879
+ }
880
+ ```
881
+
882
+ **2FA Verification During Login**:
883
+
884
+ ```typescript
885
+ // pages/verify-2fa/page.tsx
886
+ export default function Verify2FAPage() {
887
+ async function handleVerify(code: string) {
888
+ try {
889
+ await authClient.twoFactor.verifyTotp({
890
+ code,
891
+ trustDevice: true, // Remember for 60 days
892
+ })
893
+ router.push("/dashboard")
894
+ } catch (error) {
895
+ toast.error("Invalid code. Please try again.")
896
+ }
897
+ }
898
+
899
+ return (
900
+ <AuthCard
901
+ title="Two-factor authentication"
902
+ description="Enter the 6-digit code from your authenticator app"
903
+ >
904
+ <OTPInput onSubmit={handleVerify} />
905
+
906
+ <div className="text-center">
907
+ <Button variant="link" onClick={showBackupCodeForm}>
908
+ Use backup code instead
909
+ </Button>
910
+ </div>
911
+ </AuthCard>
912
+ )
913
+ }
914
+ ```
915
+
916
+ ---
917
+
918
+ ## Phase 4: Passkeys (WebAuthn)
919
+
920
+ ### 4.1 Server Configuration
921
+
922
+ ```typescript
923
+ import { passkey } from 'better-auth/plugins';
924
+
925
+ export const createAuth = (ctx) => {
926
+ return betterAuth({
927
+ plugins: [
928
+ passkey({
929
+ rpID:
930
+ process.env.NODE_ENV === 'production' ? 'yourapp.com' : 'localhost',
931
+ rpName: 'Your App',
932
+ origin: process.env.SITE_URL,
933
+ authenticatorSelection: {
934
+ authenticatorAttachment: 'platform', // Touch ID, Face ID, Windows Hello
935
+ residentKey: 'preferred',
936
+ userVerification: 'preferred',
937
+ },
938
+ }),
939
+ // ... other plugins
940
+ ],
941
+ });
942
+ };
943
+ ```
944
+
945
+ ### 4.2 Client Implementation
946
+
947
+ ```typescript
948
+ // components/auth/PasskeySetup.tsx
949
+ import { passkeyClient } from "better-auth/plugins/passkey/client"
950
+
951
+ export const authClient = createAuthClient({
952
+ plugins: [
953
+ passkeyClient(),
954
+ // ... other plugins
955
+ ],
956
+ })
957
+
958
+ export function PasskeySetup() {
959
+ async function addPasskey() {
960
+ try {
961
+ await authClient.passkey.addPasskey({
962
+ name: "My MacBook Pro", // User-friendly name
963
+ })
964
+ toast.success("Passkey added successfully!")
965
+ } catch (error) {
966
+ if (error.name === "NotSupportedError") {
967
+ toast.error("Passkeys not supported on this device")
968
+ } else {
969
+ toast.error("Failed to add passkey")
970
+ }
971
+ }
972
+ }
973
+
974
+ return (
975
+ <Card>
976
+ <CardHeader>
977
+ <CardTitle>Passkeys</CardTitle>
978
+ <CardDescription>
979
+ Sign in with your fingerprint, face, or screen lock
980
+ </CardDescription>
981
+ </CardHeader>
982
+ <CardContent>
983
+ <Button onClick={addPasskey}>
984
+ <Fingerprint className="mr-2 h-4 w-4" />
985
+ Add passkey
986
+ </Button>
987
+ </CardContent>
988
+ </Card>
989
+ )
990
+ }
991
+ ```
992
+
993
+ **Passkey Sign-In**:
994
+
995
+ ```typescript
996
+ // components/auth/forms/PasskeySignInForm.tsx
997
+ export function PasskeySignInForm() {
998
+ async function handlePasskeySignIn() {
999
+ try {
1000
+ // Conditional UI - works with browser autofill
1001
+ if (await PublicKeyCredential.isConditionalMediationAvailable()) {
1002
+ await authClient.signIn.passkey({
1003
+ autoFill: true, // Enable browser autofill
1004
+ callbackURL: "/dashboard",
1005
+ })
1006
+ } else {
1007
+ // Manual passkey selection
1008
+ await authClient.signIn.passkey({
1009
+ callbackURL: "/dashboard",
1010
+ })
1011
+ }
1012
+ } catch (error) {
1013
+ toast.error("Passkey authentication failed")
1014
+ }
1015
+ }
1016
+
1017
+ return (
1018
+ <Button onClick={handlePasskeySignIn} variant="outline" className="w-full">
1019
+ <Fingerprint className="mr-2 h-4 w-4" />
1020
+ Sign in with passkey
1021
+ </Button>
1022
+ )
1023
+ }
1024
+ ```
1025
+
1026
+ ---
1027
+
1028
+ ## Phase 5: Stripe Integration
1029
+
1030
+ ### 5.1 Setup
1031
+
1032
+ ```bash
1033
+ npm install @better-auth/stripe stripe
1034
+ npx convex env set STRIPE_SECRET_KEY "sk_test_..."
1035
+ npx convex env set STRIPE_WEBHOOK_SECRET "whsec_..."
1036
+ ```
1037
+
1038
+ ### 5.2 Better Auth Configuration
1039
+
1040
+ ```typescript
1041
+ import { stripe } from '@better-auth/stripe';
1042
+ import Stripe from 'stripe';
1043
+
1044
+ const stripeClient = new Stripe(process.env.STRIPE_SECRET_KEY!, {
1045
+ apiVersion: '2024-06-20',
1046
+ });
1047
+
1048
+ export const createAuth = (ctx) => {
1049
+ return betterAuth({
1050
+ plugins: [
1051
+ stripe({
1052
+ stripeClient,
1053
+ stripeWebhookSecret: process.env.STRIPE_WEBHOOK_SECRET!,
1054
+ createCustomerOnSignUp: true,
1055
+
1056
+ subscription: {
1057
+ enabled: true,
1058
+ plans: [
1059
+ {
1060
+ name: 'free',
1061
+ priceId: 'price_free',
1062
+ limits: { projects: 3, storage: 1 },
1063
+ },
1064
+ {
1065
+ name: 'pro',
1066
+ priceId: 'price_pro_monthly',
1067
+ annualDiscountPriceId: 'price_pro_annual',
1068
+ limits: { projects: 100, storage: 100 },
1069
+ freeTrial: {
1070
+ days: 14,
1071
+ onTrialStart: async (subscription) => {
1072
+ await sendWelcomeEmail(subscription);
1073
+ },
1074
+ },
1075
+ },
1076
+ ],
1077
+
1078
+ onSubscriptionComplete: async ({ subscription, user }) => {
1079
+ await sendSubscriptionConfirmation(user.email);
1080
+ },
1081
+ },
1082
+ }),
1083
+ // ... other plugins
1084
+ ],
1085
+ });
1086
+ };
1087
+ ```
1088
+
1089
+ ### 5.3 Webhook Handler
1090
+
1091
+ ```typescript
1092
+ // convex/http.ts
1093
+ import { httpRouter } from 'convex/server';
1094
+ import { authComponent, createAuth } from './auth';
1095
+
1096
+ const http = httpRouter();
1097
+
1098
+ // Better Auth routes (includes Stripe webhook)
1099
+ authComponent.registerRoutes(http, createAuth);
1100
+
1101
+ export default http;
1102
+ ```
1103
+
1104
+ **Stripe webhook URL**: `https://your-deployment.convex.site/api/auth/webhook/stripe`
1105
+
1106
+ ### 5.4 Client Implementation
1107
+
1108
+ ```typescript
1109
+ // components/stripe/SubscriptionUpgrade.tsx
1110
+ import { stripeClient } from "@better-auth/stripe/client"
1111
+
1112
+ export const authClient = createAuthClient({
1113
+ plugins: [
1114
+ stripeClient(),
1115
+ // ... other plugins
1116
+ ],
1117
+ })
1118
+
1119
+ export function SubscriptionUpgrade() {
1120
+ async function upgradeToPro() {
1121
+ await authClient.subscription.upgrade({
1122
+ plan: "pro",
1123
+ annual: false,
1124
+ successUrl: "/dashboard?upgraded=true",
1125
+ cancelUrl: "/pricing",
1126
+ })
1127
+ // User redirected to Stripe Checkout
1128
+ }
1129
+
1130
+ return (
1131
+ <Button onClick={upgradeToPro}>
1132
+ Upgrade to Pro
1133
+ </Button>
1134
+ )
1135
+ }
1136
+
1137
+ // Check subscription status
1138
+ export function useSubscription() {
1139
+ const { data } = useQuery(api.subscriptions.getCurrent)
1140
+
1141
+ return {
1142
+ isPro: data?.plan === "pro" && data?.status === "active",
1143
+ isTrialing: data?.status === "trialing",
1144
+ subscription: data,
1145
+ }
1146
+ }
1147
+ ```
1148
+
1149
+ ---
1150
+
1151
+ ## Page Specifications with UX Best Practices
1152
+
1153
+ ### Login Page
1154
+
1155
+ **URL**: `/login`
1156
+
1157
+ **Layout**:
1158
+
1159
+ ```
1160
+ ┌─────────────────────────────────────────┐
1161
+ │ [Logo] │
1162
+ │ │
1163
+ │ Welcome back │
1164
+ │ Sign in to Your App │
1165
+ │ │
1166
+ │ ┌────────────────────────────────────┐│
1167
+ │ │ [Google] Continue with Google ││
1168
+ │ └────────────────────────────────────┘│
1169
+ │ ┌────────────────────────────────────┐│
1170
+ │ │ [GitHub] Continue with GitHub ││
1171
+ │ └────────────────────────────────────┘│
1172
+ │ │
1173
+ │ ────────── or ────────── │
1174
+ │ │
1175
+ │ Email │
1176
+ │ [________________________] │
1177
+ │ │
1178
+ │ Password │
1179
+ │ [________________________] [👁] │
1180
+ │ [Forgot password?] │
1181
+ │ │
1182
+ │ [ Sign in ] ← Primary Button │
1183
+ │ │
1184
+ │ Don't have an account? [Sign up] │
1185
+ │ │
1186
+ │ [🔐 Sign in with passkey] ← Optional │
1187
+ └─────────────────────────────────────────┘
1188
+ ```
1189
+
1190
+ **Key Features**:
1191
+
1192
+ - Social login ABOVE email/password (primary method)
1193
+ - Auto-focus on email field
1194
+ - Show password toggle (eye icon)
1195
+ - "Remember me" optional (implement trusted devices with 2FA instead)
1196
+ - Clear link to signup
1197
+ - Passkey option at bottom (progressive enhancement)
1198
+
1199
+ **Error Handling**:
1200
+
1201
+ - Generic error for invalid credentials: "Email or password is incorrect"
1202
+ - Account linking prompt if social email exists
1203
+ - 2FA redirect if enabled
1204
+
1205
+ ### Signup Page
1206
+
1207
+ **URL**: `/signup`
1208
+
1209
+ **Layout**:
1210
+
1211
+ ```
1212
+ ┌─────────────────────────────────────────┐
1213
+ │ [Logo] │
1214
+ │ │
1215
+ │ Create your account │
1216
+ │ Join 10,000+ teams using Your App │
1217
+ │ │
1218
+ │ ┌────────────────────────────────────┐│
1219
+ │ │ [Google] Continue with Google ││
1220
+ │ └────────────────────────────────────┘│
1221
+ │ ┌────────────────────────────────────┐│
1222
+ │ │ [GitHub] Continue with GitHub ││
1223
+ │ └────────────────────────────────────┘│
1224
+ │ │
1225
+ │ ────────── or ────────── │
1226
+ │ │
1227
+ │ Email │
1228
+ │ [________________________] │
1229
+ │ │
1230
+ │ Password │
1231
+ │ [________________________] [👁] │
1232
+ │ │
1233
+ │ ☐ At least 12 characters │
1234
+ │ ☐ One uppercase letter │
1235
+ │ ☐ One number │
1236
+ │ │
1237
+ │ [ Sign up ] ← Primary Button │
1238
+ │ │
1239
+ │ By signing up, you agree to our │
1240
+ │ [Terms of Service] and [Privacy Policy]│
1241
+ │ │
1242
+ │ Already have an account? [Sign in] │
1243
+ └─────────────────────────────────────────┘
1244
+ ```
1245
+
1246
+ **Key Features**:
1247
+
1248
+ - Social login prioritized
1249
+ - Password requirements visible upfront
1250
+ - Real-time validation with checkmarks
1251
+ - Terms acceptance (not checkbox - just text)
1252
+ - Social proof in description
1253
+
1254
+ **Account Linking Flow**:
1255
+
1256
+ ```typescript
1257
+ // If email already exists during social signup
1258
+ if (emailExists && !accountLinked) {
1259
+ showPrompt({
1260
+ title: 'Account Found',
1261
+ message: 'An account with this email already exists.',
1262
+ actions: [
1263
+ { label: 'Sign in to link accounts', href: '/login' },
1264
+ { label: 'Use different email', action: 'retry' },
1265
+ ],
1266
+ });
1267
+ }
1268
+ ```
1269
+
1270
+ ### Forgot Password Page
1271
+
1272
+ **URL**: `/forgot-password`
1273
+
1274
+ **Minimal Design**:
1275
+
1276
+ ```
1277
+ ┌─────────────────────────────────────────┐
1278
+ │ Reset your password │
1279
+ │ Enter your email and we'll send a link │
1280
+ │ │
1281
+ │ Email │
1282
+ │ [________________________] │
1283
+ │ │
1284
+ │ [ Send reset link ] │
1285
+ │ │
1286
+ │ [← Back to login] │
1287
+ └─────────────────────────────────────────┘
1288
+ ```
1289
+
1290
+ **After Submission**:
1291
+
1292
+ ```
1293
+ ┌─────────────────────────────────────────┐
1294
+ │ ✅ Check your email │
1295
+ │ │
1296
+ │ If an account exists with that email, │
1297
+ │ you'll receive a password reset link. │
1298
+ │ │
1299
+ │ Didn't receive it? [Resend] │
1300
+ │ (Available after 60 seconds) │
1301
+ └─────────────────────────────────────────┘
1302
+ ```
1303
+
1304
+ **Security**: Generic success message prevents email enumeration
1305
+
1306
+ ### Two-Factor Verification Page
1307
+
1308
+ **URL**: `/verify-2fa`
1309
+
1310
+ **Layout**:
1311
+
1312
+ ```
1313
+ ┌─────────────────────────────────────────┐
1314
+ │ Two-factor authentication │
1315
+ │ Enter the 6-digit code from your │
1316
+ │ authenticator app │
1317
+ │ │
1318
+ │ [_] [_] [_] [_] [_] [_] ← OTP Input │
1319
+ │ │
1320
+ │ Auto-submits when complete │
1321
+ │ │
1322
+ │ Can't access your code? │
1323
+ │ [Use backup code instead] │
1324
+ └─────────────────────────────────────────┘
1325
+ ```
1326
+
1327
+ **Features**:
1328
+
1329
+ - Auto-focus and auto-advance between boxes
1330
+ - Auto-submit when 6 digits entered
1331
+ - Paste support (splits code automatically)
1332
+ - Clear backup code option
1333
+
1334
+ ### Account Settings Page
1335
+
1336
+ **URL**: `/settings/account`
1337
+
1338
+ **Layout**:
1339
+
1340
+ ```
1341
+ ┌─────────────────────────────────────────┐
1342
+ │ Connected Accounts │
1343
+ │ ┌────────────────────────────────────┐│
1344
+ │ │ [✓] Email/Password ││
1345
+ │ │ user@example.com ││
1346
+ │ │ [Change password] ││
1347
+ │ └────────────────────────────────────┘│
1348
+ │ ┌────────────────────────────────────┐│
1349
+ │ │ [✓] Google ││
1350
+ │ │ Connected ││
1351
+ │ │ [Unlink] ││
1352
+ │ └────────────────────────────────────┘│
1353
+ │ ┌────────────────────────────────────┐│
1354
+ │ │ [ ] GitHub ││
1355
+ │ │ Not connected ││
1356
+ │ │ [Link GitHub account] ││
1357
+ │ └────────────────────────────────────┘│
1358
+ │ │
1359
+ │ Security │
1360
+ │ ┌────────────────────────────────────┐│
1361
+ │ │ Two-Factor Authentication ││
1362
+ │ │ [✓] Enabled ││
1363
+ │ │ [Manage 2FA] [View backup codes] ││
1364
+ │ └────────────────────────────────────┘│
1365
+ │ ┌────────────────────────────────────┐│
1366
+ │ │ Passkeys ││
1367
+ │ │ • MacBook Pro (Added 2 days ago) ││
1368
+ │ │ • iPhone 15 (Added 1 week ago) ││
1369
+ │ │ [Add passkey] ││
1370
+ │ └────────────────────────────────────┘│
1371
+ └─────────────────────────────────────────┘
1372
+ ```
1373
+
1374
+ ---
1375
+
1376
+ ## Complete Code Organization
1377
+
1378
+ ```
1379
+ project-root/
1380
+ ├── src/
1381
+ │ ├── components/
1382
+ │ │ ├── auth/
1383
+ │ │ │ ├── forms/
1384
+ │ │ │ │ ├── LoginForm.tsx
1385
+ │ │ │ │ ├── RegisterForm.tsx
1386
+ │ │ │ │ ├── ForgotPasswordForm.tsx
1387
+ │ │ │ │ ├── ResetPasswordForm.tsx
1388
+ │ │ │ │ ├── MagicLinkForm.tsx
1389
+ │ │ │ │ ├── PhoneVerifyForm.tsx
1390
+ │ │ │ │ ├── OTPVerifyForm.tsx
1391
+ │ │ │ │ └── PasskeySetupForm.tsx
1392
+ │ │ │ ├── buttons/
1393
+ │ │ │ │ ├── SocialLoginButtons.tsx
1394
+ │ │ │ │ ├── LoadingButton.tsx
1395
+ │ │ │ │ ├── AnonymousLoginButton.tsx
1396
+ │ │ │ │ └── PasskeySignInButton.tsx
1397
+ │ │ │ ├── shared/
1398
+ │ │ │ │ ├── AuthCard.tsx
1399
+ │ │ │ │ ├── AuthHeader.tsx
1400
+ │ │ │ │ ├── PasswordStrengthIndicator.tsx
1401
+ │ │ │ │ ├── AccountLinkingPrompt.tsx
1402
+ │ │ │ │ └── OTPInput.tsx
1403
+ │ │ │ └── providers/
1404
+ │ │ │ └── AuthProvider.tsx
1405
+ │ │ └── ui/
1406
+ │ │ └── [shadcn components]
1407
+ │ ├── lib/
1408
+ │ │ ├── auth-client.ts
1409
+ │ │ ├── auth-server.ts
1410
+ │ │ └── validations/
1411
+ │ │ └── auth.ts
1412
+ │ └── pages/
1413
+ │ └── (auth)/
1414
+ │ ├── login/
1415
+ │ ├── signup/
1416
+ │ ├── forgot-password/
1417
+ │ ├── reset-password/
1418
+ │ ├── verify-2fa/
1419
+ │ ├── link-account/
1420
+ │ └── settings/
1421
+ │ └── account/
1422
+ ├── convex/
1423
+ │ ├── _generated/
1424
+ │ ├── auth.ts
1425
+ │ ├── auth.config.ts
1426
+ │ ├── convex.config.ts
1427
+ │ ├── email.ts
1428
+ │ ├── http.ts
1429
+ │ ├── subscriptions.ts
1430
+ │ └── emails/
1431
+ │ ├── MagicLinkEmail.tsx
1432
+ │ ├── WelcomeEmail.tsx
1433
+ │ └── PasswordResetEmail.tsx
1434
+ └── .env.local
1435
+ ```
1436
+
1437
+ ---
1438
+
1439
+ ## Implementation Steps Summary
1440
+
1441
+ ### Phase 1: Foundation (Week 1-2)
1442
+
1443
+ **Day 1-2: Environment Setup**
1444
+
1445
+ 1. Install Better Auth Convex component: `npm install @convex-dev/better-auth`
1446
+ 2. Configure environment variables
1447
+ 3. Set up Better Auth with anonymous plugin
1448
+ 4. Enable account linking in config
1449
+ 5. Run database migration
1450
+
1451
+ **Day 3-5: Component Architecture**
1452
+
1453
+ 1. Install Shadcn UI components: `npx shadcn@latest add form input button card`
1454
+ 2. Create base AuthCard component
1455
+ 3. Build SocialLoginButtons component
1456
+ 4. Implement LoadingButton
1457
+ 5. Set up auth validation schemas with Zod
1458
+
1459
+ **Day 6-10: Core Auth Pages**
1460
+
1461
+ 1. Build LoginForm with email/password
1462
+ 2. Build RegisterForm with password strength indicator
1463
+ 3. Implement ForgotPasswordForm
1464
+ 4. Add anonymous login button
1465
+ 5. Test account linking flows
1466
+
1467
+ ### Phase 2: Magic Links (Week 3-4)
1468
+
1469
+ **Day 1-3: Resend Integration**
1470
+
1471
+ 1. Install Resend component: `npm install @convex-dev/resend`
1472
+ 2. Configure Resend in Convex
1473
+ 3. Set up webhook endpoint
1474
+ 4. Create email templates with React Email
1475
+
1476
+ **Day 4-7: Magic Link Implementation**
1477
+
1478
+ 1. Add magic link plugin to Better Auth
1479
+ 2. Build MagicLinkForm component
1480
+ 3. Test email delivery
1481
+ 4. Implement magic link verification page
1482
+ 5. Test with real email providers
1483
+
1484
+ ### Phase 3: Enhanced Security (Week 4-6)
1485
+
1486
+ **Day 1-4: Phone Authentication**
1487
+
1488
+ 1. Set up Twilio account
1489
+ 2. Configure phone number plugin
1490
+ 3. Build PhoneVerifyForm
1491
+ 4. Implement OTP input component
1492
+ 5. Test SMS delivery
1493
+
1494
+ **Day 5-10: Two-Factor Authentication**
1495
+
1496
+ 1. Add twoFactor plugin to Better Auth
1497
+ 2. Build TwoFactorSetup component
1498
+ 3. Implement QR code generation
1499
+ 4. Create backup codes display
1500
+ 5. Build 2FA verification page
1501
+ 6. Test with authenticator apps
1502
+
1503
+ ### Phase 4: Passkeys (Week 6-8)
1504
+
1505
+ **Day 1-3: WebAuthn Setup**
1506
+
1507
+ 1. Configure passkey plugin
1508
+ 2. Ensure HTTPS in production
1509
+ 3. Test browser compatibility
1510
+
1511
+ 4. Build PasskeySetup component
1512
+ 5. Implement passkey sign-in button
1513
+ 6. Add conditional UI support
1514
+ 7. Create passkey management page
1515
+ 8. Test on multiple devices
1516
+
1517
+ ### Phase 5: Stripe (Week 8-10)
1518
+
1519
+ **Day 1-3: Stripe Configuration**
1520
+
1521
+ 1. Install Stripe plugin: `npm install @better-auth/stripe stripe`
1522
+ 2. Configure Stripe in Better Auth
1523
+ 3. Set up webhook endpoint
1524
+ 4. Test with Stripe CLI locally
1525
+
1526
+ **Day 4-10: Subscription Features**
1527
+
1528
+ 1. Define subscription plans
1529
+ 2. Build SubscriptionUpgrade component
1530
+ 3. Create billing portal link
1531
+ 4. Implement feature gating
1532
+ 5. Test complete subscription flow
1533
+ 6. Test webhook event handling
1534
+
1535
+ ---
1536
+
1537
+ ## Critical Implementation Guidelines
1538
+
1539
+ ### Security Checklist
1540
+
1541
+ ✅ **Always use HTTPS** in production
1542
+ ✅ **Implement rate limiting** on all auth endpoints
1543
+ ✅ **Use CSPRNG** for token generation
1544
+ ✅ **Verify webhook signatures** (Stripe, Resend)
1545
+ ✅ **Store passwords hashed** (Better Auth handles this)
1546
+ ✅ **Implement CSRF protection** (Better Auth handles this)
1547
+ ✅ **Use httpOnly, secure, SameSite cookies** (Better Auth default)
1548
+ ✅ **Generic error messages** to prevent user enumeration
1549
+ ✅ **Log authentication attempts** for monitoring
1550
+ ✅ **Regular security audits** of auth flows
1551
+
1552
+ ### Performance Optimization
1553
+
1554
+ - Enable cookie caching in Better Auth for reduced database calls
1555
+ - Use Convex's reactive queries for real-time auth state
1556
+ - Implement proper loading states everywhere
1557
+ - Lazy load auth components
1558
+ - Optimize email templates for fast rendering
1559
+ - Use Resend batching for bulk emails
1560
+
1561
+ ### Testing Strategy
1562
+
1563
+ **Unit Tests**:
1564
+
1565
+ - Validation schemas
1566
+ - Helper functions
1567
+ - Component logic
1568
+
1569
+ **Integration Tests**:
1570
+
1571
+ - Complete auth flows
1572
+ - Account linking scenarios
1573
+ - Password reset flows
1574
+ - 2FA setup and verification
1575
+ - Passkey registration
1576
+
1577
+ **E2E Tests**:
1578
+
1579
+ - User signup → onboarding
1580
+ - Login → dashboard
1581
+ - Password reset flow
1582
+ - Subscription upgrade flow
1583
+
1584
+ **Security Tests**:
1585
+
1586
+ - CSRF attacks
1587
+ - SQL injection (N/A with Convex)
1588
+ - Rate limit bypass attempts
1589
+ - Session fixation
1590
+
1591
+ ---
1592
+
1593
+ ## Monitoring and Analytics
1594
+
1595
+ ### Key Metrics to Track
1596
+
1597
+ **Conversion Metrics**:
1598
+
1599
+ - Signup completion rate
1600
+ - Anonymous → registered conversion
1601
+ - Social login adoption rate
1602
+ - Magic link click-through rate
1603
+ - 2FA setup completion rate
1604
+ - Passkey adoption rate
1605
+
1606
+ **Security Metrics**:
1607
+
1608
+ - Failed login attempts
1609
+ - Password reset requests
1610
+ - 2FA verification failures
1611
+ - Account linking events
1612
+ - Session hijacking attempts
1613
+
1614
+ **Performance Metrics**:
1615
+
1616
+ - Auth page load time
1617
+ - Email delivery time
1618
+ - SMS delivery time
1619
+ - Database query performance
1620
+ - Webhook processing time
1621
+
1622
+ ### Recommended Tools
1623
+
1624
+ - **Analytics**: PostHog, Mixpanel, or Amplitude
1625
+ - **Error Tracking**: Sentry
1626
+ - **Logging**: Convex built-in logging + external service
1627
+ - **Email Monitoring**: Resend dashboard
1628
+ - **Uptime**: Better Uptime or Pingdom
1629
+
1630
+ ---
1631
+
1632
+ ## Future Enhancements
1633
+
1634
+ **Post-Launch Improvements**:
1635
+
1636
+ 1. **Biometric authentication** on mobile apps
1637
+ 2. **Social login providers**: LinkedIn, Microsoft, Apple
1638
+ 3. **SAML/SSO** for enterprise customers
1639
+ 4. **Advanced fraud detection** with device fingerprinting
1640
+ 5. **Session recording** for security audits
1641
+ 6. **Passwordless-only mode** (remove passwords entirely)
1642
+ 7. **Adaptive authentication** (risk-based 2FA)
1643
+ 8. **Account activity logs** visible to users
1644
+
1645
+ ---
1646
+
1647
+ ## Conclusion
1648
+
1649
+ This phased implementation plan delivers a modern, secure, high-converting authentication system that:
1650
+
1651
+ ✨ **Reduces friction** with anonymous login and magic links
1652
+ ✨ **Maximizes conversions** with beautiful UX and social login
1653
+ ✨ **Ensures security** with 2FA and passkeys
1654
+ ✨ **Enables monetization** with Stripe integration
1655
+ ✨ **Maintains clean code** with reusable Shadcn UI components
1656
+ ✨ **Future-proofs** with WebAuthn/passkey adoption
1657
+
1658
+ **Timeline**: 8-10 weeks for complete implementation
1659
+ **Team Size**: 1-2 developers
1660
+ **Expected Results**:
1661
+
1662
+ - 40%+ increase in signup conversion (anonymous + social)
1663
+ - 90%+ reduction in password reset tickets (magic links)
1664
+ - Production-ready security (2FA + passkeys)
1665
+ - Monetization-ready (Stripe integration)
1666
+
1667
+ The Better Auth + Convex + Shadcn UI stack provides the perfect foundation for this implementation, with automatic account linking, session management, and database integration handling the complexity while you focus on beautiful UX.
1668
+
1669
+ Start with Phase 1 and iterate based on user feedback. Each phase delivers immediate value while building toward the complete vision.