create-lego-one 2.0.10 → 2.0.13

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 (242) hide show
  1. package/dist/index.cjs +179 -0
  2. package/dist/index.cjs.map +1 -1
  3. package/package.json +5 -3
  4. package/template/.cursor/rules/rules.mdc +639 -0
  5. package/template/.dockerignore +58 -0
  6. package/template/.env.example +18 -0
  7. package/template/.eslintignore +5 -0
  8. package/template/.eslintrc.js +28 -0
  9. package/template/.prettierignore +6 -0
  10. package/template/.prettierrc +11 -0
  11. package/template/CLAUDE.md +634 -0
  12. package/template/Dockerfile +67 -0
  13. package/template/PROMPT.md +457 -0
  14. package/template/README.md +325 -0
  15. package/template/docker-compose.yml +48 -0
  16. package/template/docker-entrypoint.sh +23 -0
  17. package/template/docs/checkpoints/.template.md +64 -0
  18. package/template/docs/checkpoints/framework/01-infrastructure-setup.md +132 -0
  19. package/template/docs/checkpoints/framework/02-pocketbase-setup.md +155 -0
  20. package/template/docs/checkpoints/framework/03-host-kernel.md +170 -0
  21. package/template/docs/checkpoints/framework/04-auth-system.md +163 -0
  22. package/template/docs/checkpoints/framework/phase-05-multitenancy-rbac.md +223 -0
  23. package/template/docs/checkpoints/framework/phase-06-ui-components.md +260 -0
  24. package/template/docs/checkpoints/framework/phase-07-communication-system.md +276 -0
  25. package/template/docs/checkpoints/framework/phase-08-plugin-system.md +91 -0
  26. package/template/docs/checkpoints/framework/phase-09-dashboard-plugin.md +111 -0
  27. package/template/docs/checkpoints/framework/phase-10-todo-plugin.md +169 -0
  28. package/template/docs/checkpoints/framework/phase-11-testing.md +264 -0
  29. package/template/docs/checkpoints/framework/phase-12-deployment.md +294 -0
  30. package/template/docs/checkpoints/framework/phase-13-documentation.md +312 -0
  31. package/template/docs/framework/plans/00-index.md +164 -0
  32. package/template/docs/framework/plans/01-infrastructure-setup.md +855 -0
  33. package/template/docs/framework/plans/02-pocketbase-setup.md +1374 -0
  34. package/template/docs/framework/plans/03-host-kernel.md +1518 -0
  35. package/template/docs/framework/plans/04-auth-system.md +1466 -0
  36. package/template/docs/framework/plans/05-multitenancy-rbac.md +1527 -0
  37. package/template/docs/framework/plans/06-ui-components.md +1478 -0
  38. package/template/docs/framework/plans/07-communication-system.md +1106 -0
  39. package/template/docs/framework/plans/08-plugin-system.md +1179 -0
  40. package/template/docs/framework/plans/09-dashboard-plugin.md +1137 -0
  41. package/template/docs/framework/plans/10-todo-plugin.md +1343 -0
  42. package/template/docs/framework/plans/11-testing.md +935 -0
  43. package/template/docs/framework/plans/12-deployment.md +896 -0
  44. package/template/docs/framework/prompts/0-boilerplate-modernjs.md +151 -0
  45. package/template/docs/framework/research/00-modernjs-audit.md +488 -0
  46. package/template/docs/framework/research/01-system-blueprint.md +721 -0
  47. package/template/docs/framework/research/02-data-migration-protocol.md +699 -0
  48. package/template/docs/framework/research/03-host-setup.md +714 -0
  49. package/template/docs/framework/research/04-plugin-architecture.md +645 -0
  50. package/template/docs/framework/research/05-slot-injection-pattern.md +671 -0
  51. package/template/docs/framework/research/06-cli-strategy.md +615 -0
  52. package/template/docs/framework/research/07-deployment.md +629 -0
  53. package/template/docs/framework/research/README.md +282 -0
  54. package/template/docs/framework/setup/00-index.md +210 -0
  55. package/template/docs/framework/setup/01-framework-structure.md +308 -0
  56. package/template/docs/framework/setup/02-development-workflow.md +405 -0
  57. package/template/docs/framework/setup/03-environment-setup.md +215 -0
  58. package/template/docs/framework/setup/04-kernel-architecture.md +499 -0
  59. package/template/docs/framework/setup/05-plugin-system.md +620 -0
  60. package/template/docs/framework/setup/06-communication-patterns.md +451 -0
  61. package/template/docs/framework/setup/07-plugin-development.md +582 -0
  62. package/template/docs/framework/setup/08-component-library.md +658 -0
  63. package/template/docs/framework/setup/09-data-integration.md +609 -0
  64. package/template/docs/framework/setup/10-auth-rbac.md +497 -0
  65. package/template/docs/framework/setup/11-hooks-api.md +393 -0
  66. package/template/docs/framework/setup/12-components-api.md +665 -0
  67. package/template/docs/framework/setup/13-deployment-guide.md +566 -0
  68. package/template/docs/framework/setup/README.md +548 -0
  69. package/template/host/e2e/auth.spec.ts +38 -0
  70. package/template/host/e2e/layout.spec.ts +38 -0
  71. package/template/host/modern.config.ts +19 -0
  72. package/template/host/package.json +71 -0
  73. package/template/host/playwright.config.ts +34 -0
  74. package/template/host/postcss.config.mjs +6 -0
  75. package/template/host/src/App.tsx +6 -0
  76. package/template/host/src/bootstrap.tsx +74 -0
  77. package/template/host/src/global.css +59 -0
  78. package/template/host/src/index.ts +2 -0
  79. package/template/host/src/kernel/__tests__/lib-utils.test.ts +32 -0
  80. package/template/host/src/kernel/__tests__/rbac-hooks.test.tsx +114 -0
  81. package/template/host/src/kernel/__tests__/rbac-utils.test.ts +108 -0
  82. package/template/host/src/kernel/auth/ProtectedRoute.tsx +41 -0
  83. package/template/host/src/kernel/auth/components/LoginForm.tsx +97 -0
  84. package/template/host/src/kernel/auth/components/LogoutButton.tsx +79 -0
  85. package/template/host/src/kernel/auth/hooks.ts +174 -0
  86. package/template/host/src/kernel/auth/index.ts +5 -0
  87. package/template/host/src/kernel/auth/schemas.ts +27 -0
  88. package/template/host/src/kernel/auth/service.ts +197 -0
  89. package/template/host/src/kernel/auth/types.ts +36 -0
  90. package/template/host/src/kernel/channels/ChannelBus.ts +181 -0
  91. package/template/host/src/kernel/channels/ChannelProvider.tsx +57 -0
  92. package/template/host/src/kernel/channels/events.ts +27 -0
  93. package/template/host/src/kernel/channels/hooks.ts +168 -0
  94. package/template/host/src/kernel/channels/index.ts +6 -0
  95. package/template/host/src/kernel/channels/integrations/ToastIntegration.tsx +60 -0
  96. package/template/host/src/kernel/channels/plugin-hooks.ts +72 -0
  97. package/template/host/src/kernel/channels/types.ts +112 -0
  98. package/template/host/src/kernel/components/__tests__/Badge.test.tsx +35 -0
  99. package/template/host/src/kernel/components/__tests__/Button.test.tsx +63 -0
  100. package/template/host/src/kernel/components/__tests__/Input.test.tsx +64 -0
  101. package/template/host/src/kernel/components/index.ts +32 -0
  102. package/template/host/src/kernel/components/ui/alert.tsx +58 -0
  103. package/template/host/src/kernel/components/ui/avatar.tsx +47 -0
  104. package/template/host/src/kernel/components/ui/badge.tsx +35 -0
  105. package/template/host/src/kernel/components/ui/button.tsx +50 -0
  106. package/template/host/src/kernel/components/ui/card.tsx +78 -0
  107. package/template/host/src/kernel/components/ui/dialog.tsx +116 -0
  108. package/template/host/src/kernel/components/ui/dropdown-menu.tsx +192 -0
  109. package/template/host/src/kernel/components/ui/index.ts +7 -0
  110. package/template/host/src/kernel/components/ui/input.tsx +24 -0
  111. package/template/host/src/kernel/components/ui/label.tsx +21 -0
  112. package/template/host/src/kernel/components/ui/popover.tsx +28 -0
  113. package/template/host/src/kernel/components/ui/progress.tsx +25 -0
  114. package/template/host/src/kernel/components/ui/scroll-area.tsx +45 -0
  115. package/template/host/src/kernel/components/ui/select.tsx +155 -0
  116. package/template/host/src/kernel/components/ui/separator.tsx +28 -0
  117. package/template/host/src/kernel/components/ui/skeleton.tsx +15 -0
  118. package/template/host/src/kernel/components/ui/switch.tsx +26 -0
  119. package/template/host/src/kernel/components/ui/table.tsx +116 -0
  120. package/template/host/src/kernel/components/ui/tabs.tsx +52 -0
  121. package/template/host/src/kernel/components/ui/toast.tsx +126 -0
  122. package/template/host/src/kernel/components/ui/toaster.tsx +34 -0
  123. package/template/host/src/kernel/components/ui/tooltip.tsx +27 -0
  124. package/template/host/src/kernel/components/ui/use-toast.ts +183 -0
  125. package/template/host/src/kernel/index.ts +48 -0
  126. package/template/host/src/kernel/lib/cn.ts +1 -0
  127. package/template/host/src/kernel/lib/utils.ts +36 -0
  128. package/template/host/src/kernel/plugins/Slot.tsx +41 -0
  129. package/template/host/src/kernel/plugins/SlotProvider.tsx +88 -0
  130. package/template/host/src/kernel/plugins/index.ts +23 -0
  131. package/template/host/src/kernel/plugins/loader.ts +122 -0
  132. package/template/host/src/kernel/plugins/schemas.ts +54 -0
  133. package/template/host/src/kernel/plugins/store.ts +185 -0
  134. package/template/host/src/kernel/plugins/types.ts +103 -0
  135. package/template/host/src/kernel/providers/PocketBaseProvider.tsx +70 -0
  136. package/template/host/src/kernel/providers/QueryProvider.tsx +28 -0
  137. package/template/host/src/kernel/providers/ThemeProvider.tsx +25 -0
  138. package/template/host/src/kernel/providers/index.ts +3 -0
  139. package/template/host/src/kernel/rbac/components/OrganizationSelector.tsx +69 -0
  140. package/template/host/src/kernel/rbac/components/PermissionGate.tsx +43 -0
  141. package/template/host/src/kernel/rbac/hooks.ts +379 -0
  142. package/template/host/src/kernel/rbac/index.ts +6 -0
  143. package/template/host/src/kernel/rbac/service.ts +504 -0
  144. package/template/host/src/kernel/rbac/types.ts +164 -0
  145. package/template/host/src/kernel/rbac/utils.ts +34 -0
  146. package/template/host/src/kernel/shared-state/bridge.ts +31 -0
  147. package/template/host/src/kernel/shared-state/index.ts +3 -0
  148. package/template/host/src/kernel/shared-state/store.ts +62 -0
  149. package/template/host/src/kernel/shared-state/types.ts +60 -0
  150. package/template/host/src/kernel/use-migrations.ts +72 -0
  151. package/template/host/src/layout/MobileMenu.tsx +61 -0
  152. package/template/host/src/layout/Shell.tsx +42 -0
  153. package/template/host/src/layout/Sidebar.tsx +178 -0
  154. package/template/host/src/layout/Topbar.tsx +50 -0
  155. package/template/host/src/layout/index.ts +4 -0
  156. package/template/host/src/lib/pocketbase/client.ts +38 -0
  157. package/template/host/src/lib/pocketbase/collections/audit_logs.ts +87 -0
  158. package/template/host/src/lib/pocketbase/collections/index.ts +19 -0
  159. package/template/host/src/lib/pocketbase/collections/organizations.ts +63 -0
  160. package/template/host/src/lib/pocketbase/collections/permissions.ts +57 -0
  161. package/template/host/src/lib/pocketbase/collections/roles.ts +55 -0
  162. package/template/host/src/lib/pocketbase/collections/todos.ts +74 -0
  163. package/template/host/src/lib/pocketbase/collections/user_roles.ts +57 -0
  164. package/template/host/src/lib/pocketbase/collections/users.ts +43 -0
  165. package/template/host/src/lib/pocketbase/index.ts +5 -0
  166. package/template/host/src/lib/pocketbase/migrations.ts +44 -0
  167. package/template/host/src/lib/pocketbase/seed/permissions.ts +8 -0
  168. package/template/host/src/lib/pocketbase/seed/roles.ts +22 -0
  169. package/template/host/src/lib/pocketbase/seed.ts +113 -0
  170. package/template/host/src/lib/pocketbase/types.ts +102 -0
  171. package/template/host/src/modern.runtime.ts +26 -0
  172. package/template/host/src/plugins.d.ts +9 -0
  173. package/template/host/src/providers/PocketBaseProvider.tsx +30 -0
  174. package/template/host/src/routes/_.tsx +6 -0
  175. package/template/host/src/routes/dashboard._.tsx +41 -0
  176. package/template/host/src/routes/index.tsx +93 -0
  177. package/template/host/src/routes/login.tsx +36 -0
  178. package/template/host/src/saas.config.ts +52 -0
  179. package/template/host/src/test/setup.ts +65 -0
  180. package/template/host/src/test/utils.tsx +69 -0
  181. package/template/host/src/test/vitest-globals.d.ts +19 -0
  182. package/template/host/src/vite-env.d.ts +16 -0
  183. package/template/host/tailwind.config.ts +77 -0
  184. package/template/host/tsconfig.json +19 -0
  185. package/template/host/vitest.config.ts +30 -0
  186. package/template/nginx.conf +72 -0
  187. package/template/package.json +44 -0
  188. package/template/packages/plugins/@lego/plugin-dashboard/modern.config.ts +19 -0
  189. package/template/packages/plugins/@lego/plugin-dashboard/package.json +35 -0
  190. package/template/packages/plugins/@lego/plugin-dashboard/postcss.config.mjs +6 -0
  191. package/template/packages/plugins/@lego/plugin-dashboard/src/App.tsx +27 -0
  192. package/template/packages/plugins/@lego/plugin-dashboard/src/components/ActivityFeed.tsx +63 -0
  193. package/template/packages/plugins/@lego/plugin-dashboard/src/components/QuickActionSlot.tsx +11 -0
  194. package/template/packages/plugins/@lego/plugin-dashboard/src/components/QuickActions.tsx +68 -0
  195. package/template/packages/plugins/@lego/plugin-dashboard/src/components/SidebarWidget.tsx +35 -0
  196. package/template/packages/plugins/@lego/plugin-dashboard/src/components/StatCard.tsx +47 -0
  197. package/template/packages/plugins/@lego/plugin-dashboard/src/global.css +24 -0
  198. package/template/packages/plugins/@lego/plugin-dashboard/src/hooks/useChannelIntegration.ts +43 -0
  199. package/template/packages/plugins/@lego/plugin-dashboard/src/hooks/useDashboardStats.ts +65 -0
  200. package/template/packages/plugins/@lego/plugin-dashboard/src/hooks/usePocketBase.ts +47 -0
  201. package/template/packages/plugins/@lego/plugin-dashboard/src/hooks/useRecentActivity.ts +55 -0
  202. package/template/packages/plugins/@lego/plugin-dashboard/src/lib/utils.ts +6 -0
  203. package/template/packages/plugins/@lego/plugin-dashboard/src/pages/DashboardPage.tsx +105 -0
  204. package/template/packages/plugins/@lego/plugin-dashboard/src/plugin.config.ts +121 -0
  205. package/template/packages/plugins/@lego/plugin-dashboard/src/plugin.ts +18 -0
  206. package/template/packages/plugins/@lego/plugin-dashboard/src/vite-env.d.ts +32 -0
  207. package/template/packages/plugins/@lego/plugin-dashboard/tailwind.config.ts +35 -0
  208. package/template/packages/plugins/@lego/plugin-dashboard/tsconfig.json +18 -0
  209. package/template/packages/plugins/@lego/plugin-todo/modern.config.ts +18 -0
  210. package/template/packages/plugins/@lego/plugin-todo/package.json +41 -0
  211. package/template/packages/plugins/@lego/plugin-todo/postcss.config.mjs +6 -0
  212. package/template/packages/plugins/@lego/plugin-todo/src/App.tsx +12 -0
  213. package/template/packages/plugins/@lego/plugin-todo/src/components/SidebarWidget.tsx +16 -0
  214. package/template/packages/plugins/@lego/plugin-todo/src/components/TodoDialog.tsx +55 -0
  215. package/template/packages/plugins/@lego/plugin-todo/src/components/TodoFilters.tsx +79 -0
  216. package/template/packages/plugins/@lego/plugin-todo/src/components/TodoForm.tsx +94 -0
  217. package/template/packages/plugins/@lego/plugin-todo/src/components/TodoItem.tsx +121 -0
  218. package/template/packages/plugins/@lego/plugin-todo/src/components/TodoList.tsx +41 -0
  219. package/template/packages/plugins/@lego/plugin-todo/src/components/index.ts +6 -0
  220. package/template/packages/plugins/@lego/plugin-todo/src/global.css +59 -0
  221. package/template/packages/plugins/@lego/plugin-todo/src/hooks/useCreateTodo.ts +62 -0
  222. package/template/packages/plugins/@lego/plugin-todo/src/hooks/useDeleteTodo.ts +46 -0
  223. package/template/packages/plugins/@lego/plugin-todo/src/hooks/usePocketBase.ts +38 -0
  224. package/template/packages/plugins/@lego/plugin-todo/src/hooks/useTodos.ts +64 -0
  225. package/template/packages/plugins/@lego/plugin-todo/src/hooks/useUpdateTodo.ts +35 -0
  226. package/template/packages/plugins/@lego/plugin-todo/src/index.tsx +5 -0
  227. package/template/packages/plugins/@lego/plugin-todo/src/lib/utils.ts +20 -0
  228. package/template/packages/plugins/@lego/plugin-todo/src/pages/TodoPage.tsx +89 -0
  229. package/template/packages/plugins/@lego/plugin-todo/src/plugin.config.ts +104 -0
  230. package/template/packages/plugins/@lego/plugin-todo/src/plugin.ts +13 -0
  231. package/template/packages/plugins/@lego/plugin-todo/src/schemas.ts +37 -0
  232. package/template/packages/plugins/@lego/plugin-todo/src/types.ts +42 -0
  233. package/template/packages/plugins/@lego/plugin-todo/src/vite-env.d.ts +31 -0
  234. package/template/packages/plugins/@lego/plugin-todo/tailwind.config.ts +51 -0
  235. package/template/packages/plugins/@lego/plugin-todo/tsconfig.json +18 -0
  236. package/template/pnpm-workspace.yaml +4 -0
  237. package/template/pocketbase/CHANGELOG.md +911 -0
  238. package/template/pocketbase/LICENSE.md +17 -0
  239. package/template/scripts/create-plugin.js +221 -0
  240. package/template/scripts/deploy.sh +56 -0
  241. package/template/tsconfig.base.json +26 -0
  242. package/template/tsconfig.json +8 -0
@@ -0,0 +1,548 @@
1
+ # Lego-One Setup Guide
2
+
3
+ **AI-Friendly Documentation for Vibe Coding**
4
+
5
+ Complete guide for installing, configuring, and extending Lego-One. This documentation is optimized for AI agents to understand and execute tasks efficiently.
6
+
7
+ ---
8
+
9
+ ## Quick Reference for AI Agents
10
+
11
+ When an AI agent is asked to work with Lego-One, follow this priority:
12
+
13
+ 1. **Read `00-index.md` first** - This is the main entry point with complete documentation index
14
+ 2. **Read relevant numbered files** based on your task (see table below)
15
+ 3. **Review existing plugins** in `packages/plugins/@lego/` for code patterns
16
+ 4. **Follow the established conventions** - consistency is critical
17
+ 5. **Write checkpoints** for all work in `/docs/checkpoints/`
18
+
19
+ ---
20
+
21
+ ## Documentation Structure
22
+
23
+ Read these files **sequentially** for complete framework understanding:
24
+
25
+ ### Getting Started (Read First)
26
+
27
+ | # | File | Description |
28
+ |---|------|-------------|
29
+ | 00 | [`00-index.md`](./00-index.md) | **MAIN ENTRY POINT** - Complete AI documentation index |
30
+ | 01 | [`01-framework-structure.md`](./01-framework-structure.md) | Project structure, architecture, file locations |
31
+ | 02 | [`02-development-workflow.md`](./02-development-workflow.md) | How to work on this framework (dev, build, test) |
32
+ | 03 | [`03-environment-setup.md`](./03-environment-setup.md) | Environment variables, dependencies, prerequisites |
33
+
34
+ ### Core Concepts
35
+
36
+ | # | File | Description |
37
+ |---|------|-------------|
38
+ | 04 | [`04-kernel-architecture.md`](./04-kernel-architecture.md) | Host/Kernel system, core infrastructure |
39
+ | 05 | [`05-plugin-system.md`](./05-plugin-system.md) | Plugin architecture, Garfish, micro-frontends |
40
+ | 06 | [`06-communication-patterns.md`](./06-communication-patterns.md) | Window bridge, channel bus, plugin-host communication |
41
+
42
+ ### Development Patterns
43
+
44
+ | # | File | Description |
45
+ |---|------|-------------|
46
+ | 07 | [`07-plugin-development.md`](./07-plugin-development.md) | Complete guide to creating plugins |
47
+ | 08 | [`08-component-library.md`](./08-component-library.md) | UI components, styling, design system |
48
+ | 09 | [`09-data-integration.md`](./09-data-integration.md) | PocketBase, multi-tenancy, data fetching |
49
+ | 10 | [`10-auth-rbac.md`](./10-auth-rbac.md) | Authentication, authorization, permissions |
50
+
51
+ ### API Reference
52
+
53
+ | # | File | Description |
54
+ |---|------|-------------|
55
+ | 11 | [`11-hooks-api.md`](./11-hooks-api.md) | All kernel hooks (auth, RBAC, state, channels) |
56
+ | 12 | [`12-components-api.md`](./12-components-api.md) | UI component library reference |
57
+ | 13 | [`13-deployment-guide.md`](./13-deployment-guide.md) | Production deployment instructions |
58
+
59
+ ---
60
+
61
+ ## Quick Start
62
+
63
+ ### For End Users (Creating a New Project)
64
+
65
+ ```bash
66
+ # Create a new Lego-One application
67
+ pnpm create lego-one my-saas-app
68
+
69
+ cd my-saas-app
70
+
71
+ # Install dependencies
72
+ pnpm install
73
+
74
+ # Start development server
75
+ pnpm run dev
76
+ ```
77
+
78
+ The application will be available at http://localhost:8080
79
+
80
+ **Default credentials:**
81
+ - Email: `admin@example.com`
82
+ - Password: `admin123`
83
+
84
+ ### For Developers (Working on Framework)
85
+
86
+ #### Prerequisites
87
+
88
+ Before you begin, ensure you have the following installed:
89
+
90
+ - **Node.js** 20 or higher ([Download](https://nodejs.org/))
91
+ - **pnpm** 9 or higher ([Install](https://pnpm.io/installation))
92
+ - **Git** ([Download](https://git-scm.com/))
93
+ - (Optional) **Docker** and **Docker Compose** for containerized deployment
94
+
95
+ #### Step 1: Clone the Repository
96
+
97
+ ```bash
98
+ git clone https://github.com/your-org/lego-one.git
99
+ cd lego-one
100
+ ```
101
+
102
+ #### Step 2: Install Dependencies
103
+
104
+ ```bash
105
+ pnpm install
106
+ ```
107
+
108
+ This installs all dependencies for the host and included plugins.
109
+
110
+ #### Step 3: Configure Environment
111
+
112
+ Create your environment file:
113
+
114
+ ```bash
115
+ cp .env.development.example .env.development
116
+ ```
117
+
118
+ Edit `.env.development` with your settings. Default configuration works for local development:
119
+
120
+ ```bash
121
+ # PocketBase (local)
122
+ VITE_POCKETBASE_URL=http://127.0.0.1:8090
123
+
124
+ # Application
125
+ VITE_APP_URL=http://localhost:8080
126
+ ```
127
+
128
+ #### Step 4: Start PocketBase
129
+
130
+ PocketBase is the backend database. Start it in a separate terminal:
131
+
132
+ ```bash
133
+ cd pocketbase
134
+
135
+ # Download PocketBase if not present
136
+ # Visit https://pocketbase.io/docs/
137
+ # Download the binary for your OS and extract it
138
+
139
+ ./pocketbase serve
140
+ ```
141
+
142
+ Or use Docker:
143
+
144
+ ```bash
145
+ docker-compose up pocketbase
146
+ ```
147
+
148
+ PocketBase will:
149
+ - Start on http://127.0.0.1:8090
150
+ - Run migrations automatically
151
+ - Create seed data (admin user, demo org)
152
+
153
+ #### Step 5: Start Development
154
+
155
+ ```bash
156
+ pnpm run dev
157
+ ```
158
+
159
+ This starts the host application on http://localhost:8080.
160
+
161
+ Open your browser and navigate to http://localhost:8080
162
+
163
+ **Default credentials:**
164
+ - Email: `admin@example.com`
165
+ - Password: `admin123`
166
+
167
+ ---
168
+
169
+ ## Configuration
170
+
171
+ ### Environment Variables
172
+
173
+ | Variable | Description | Default |
174
+ |----------|-------------|---------|
175
+ | `VITE_POCKETBASE_URL` | PocketBase API URL | `http://127.0.0.1:8090` |
176
+ | `VITE_APP_URL` | Application base URL | `http://localhost:8080` |
177
+ | `VITE_ENABLE_DEV_TOOLS` | Enable React DevTools | `true` (dev only) |
178
+
179
+ ### Plugin Configuration
180
+
181
+ Plugins are enabled/disabled in `host/src/saas.config.ts`:
182
+
183
+ ```typescript
184
+ export const saasConfig = {
185
+ plugins: [
186
+ { name: '@lego/plugin-dashboard', enabled: true },
187
+ { name: '@lego/plugin-todo', enabled: true },
188
+ ],
189
+ };
190
+ ```
191
+
192
+ Change `enabled: false` to disable a plugin.
193
+
194
+ ### Organization Setup
195
+
196
+ After first login:
197
+ 1. An organization is auto-created for you
198
+ 2. You are assigned the "Owner" role
199
+ 3. Use the organization selector in the topbar to switch organizations
200
+
201
+ ---
202
+
203
+ ## Development
204
+
205
+ ### Running All Services
206
+
207
+ To run the host and all plugins on separate ports:
208
+
209
+ ```bash
210
+ pnpm run dev:all
211
+ ```
212
+
213
+ This starts:
214
+ - **Host:** http://localhost:8080
215
+ - **Dashboard Plugin:** http://localhost:3001
216
+ - **Todo Plugin:** http://localhost:3002
217
+
218
+ ### Running Individual Services
219
+
220
+ **Host only:**
221
+ ```bash
222
+ pnpm run dev:host
223
+ ```
224
+
225
+ **Dashboard plugin only:**
226
+ ```bash
227
+ cd packages/plugins/@lego/plugin-dashboard
228
+ pnpm run dev
229
+ ```
230
+
231
+ **Todo plugin only:**
232
+ ```bash
233
+ cd packages/plugins/@lego/plugin-todo
234
+ pnpm run dev
235
+ ```
236
+
237
+ ### Running Tests
238
+
239
+ ```bash
240
+ # All tests
241
+ pnpm test
242
+
243
+ # Unit and component tests only
244
+ pnpm test:run
245
+
246
+ # E2E tests
247
+ pnpm test:e2e
248
+
249
+ # With coverage report
250
+ pnpm test:coverage
251
+ ```
252
+
253
+ ### Linting and Formatting
254
+
255
+ ```bash
256
+ # Lint all code
257
+ pnpm run lint
258
+
259
+ # Format code
260
+ pnpm run format
261
+ ```
262
+
263
+ ---
264
+
265
+ ## Plugins
266
+
267
+ See [`07-plugin-development.md`](./07-plugin-development.md) for creating custom plugins.
268
+
269
+ ### Included Plugins
270
+
271
+ **Dashboard Plugin** (`@lego/plugin-dashboard`)
272
+ - Organization statistics
273
+ - Recent activity feed
274
+ - Quick actions
275
+ - Location: `/dashboard`
276
+
277
+ **Todo Plugin** (`@lego/plugin-todo`)
278
+ - Full CRUD for tasks
279
+ - Priority levels
280
+ - Due dates
281
+ - Filtering and search
282
+ - Location: `/todos`
283
+
284
+ ### Enabling/Disabling Plugins
285
+
286
+ **Via Config File:**
287
+
288
+ Edit `host/src/saas.config.ts` and set `enabled: false`
289
+
290
+ **Via Admin UI:**
291
+
292
+ Navigate to Settings → Plugins and toggle the plugin.
293
+
294
+ ---
295
+
296
+ ## Production Deployment
297
+
298
+ ### Building for Production
299
+
300
+ ```bash
301
+ # Build all (recommended)
302
+ pnpm run build
303
+
304
+ # Build host only
305
+ pnpm run build:host
306
+ ```
307
+
308
+ Output directory: `host/dist/`
309
+
310
+ ### Docker Deployment
311
+
312
+ ```bash
313
+ # Build and start with Docker Compose
314
+ docker-compose -f docker-compose.prod.yml up -d --build
315
+ ```
316
+
317
+ See [`13-deployment-guide.md`](./13-deployment-guide.md) for detailed deployment instructions.
318
+
319
+ ---
320
+
321
+ ## Troubleshooting
322
+
323
+ ### Common Issues
324
+
325
+ **"Cannot connect to PocketBase"**
326
+ - Ensure PocketBase is running: `./pocketbase serve`
327
+ - Check `VITE_POCKETBASE_URL` in .env file
328
+ - Verify no firewall blocking port 8090
329
+
330
+ **"Module not found" errors**
331
+ - Clear cache: `pnpm run clean`
332
+ - Reinstall: `rm -rf node_modules && pnpm install`
333
+
334
+ **"Port already in use"**
335
+ ```bash
336
+ # Find and kill process on port 8080
337
+ lsof -ti:8080 | xargs kill -9 # macOS/Linux
338
+ netstat -ano | findstr :8080 # Windows
339
+ ```
340
+
341
+ **Plugin not loading**
342
+ - Check browser console for errors
343
+ - Verify plugin is enabled in `saas.config.ts`
344
+ - Ensure plugin dev server is running (dev mode)
345
+ - Check `modern.runtime.ts` has plugin registered
346
+
347
+ **Hot reload not working**
348
+ - Clear browser cache
349
+ - Restart dev server
350
+ - Check for syntax errors in your code
351
+
352
+ ### Getting Help
353
+
354
+ If you're still stuck:
355
+
356
+ 1. Read [`02-development-workflow.md`](./02-development-workflow.md) troubleshooting section
357
+ 2. Review [Implementation Plans](../plans/)
358
+ 3. Examine [Existing Plugins](../../packages/plugins/)
359
+ 4. Open an issue on GitHub
360
+
361
+ ---
362
+
363
+ ## For AI Agents
364
+
365
+ ### Critical Information for Task Execution
366
+
367
+ When working with Lego-One, AI agents should understand these core concepts:
368
+
369
+ **Architecture Pattern:**
370
+ - **Host/Kernel** (`host/`) - Core application with auth, RBAC, state management
371
+ - **Plugins** (`packages/plugins/@lego/`) - Feature modules loaded by host
372
+ - **Communication** - Window bridge pattern: `window.__LEGO_KERNEL_STATE__` and `window.__LEGO_CHANNEL_BUS__`
373
+
374
+ **File Location Conventions:**
375
+ ```
376
+ host/src/
377
+ ├── kernel/ # Core systems (auth, RBAC, state, channels)
378
+ ├── layout/ # Layout components (Sidebar, Topbar, Shell)
379
+ ├── routes/ # Page routes
380
+ ├── providers/ # Context providers
381
+ └── test/ # Test setup
382
+
383
+ packages/plugins/@lego/plugin-<name>/
384
+ ├── src/
385
+ │ ├── components/ # Plugin components
386
+ │ ├── hooks/ # Data fetching hooks
387
+ │ ├── pages/ # Plugin pages
388
+ │ ├── plugin.config.ts # Plugin configuration
389
+ │ └── plugin.ts # Entry point
390
+ ```
391
+
392
+ **Plugin Development Checklist:**
393
+ 1. Read `00-index.md` first
394
+ 2. Read `07-plugin-development.md` for complete guide
395
+ 3. Review existing plugins (Dashboard, Todo) for patterns
396
+ 4. Create all required files in correct structure
397
+ 5. Register plugin in `host/src/modern.runtime.ts`
398
+ 6. Enable in `host/src/saas.config.ts`
399
+ 7. Test thoroughly
400
+ 8. Write checkpoint in `/docs/checkpoints/`
401
+
402
+ **Key Hooks and APIs:**
403
+ - `usePocketBase()` - Access PocketBase client
404
+ - `useCurrentOrganization()` - Get current organization context
405
+ - `useUserPermissions()` - Get user permissions
406
+ - `useGlobalKernelState()` - Access kernel state
407
+ - `useToastChannel()` - Show toast notifications
408
+ - `window.__LEGO_KERNEL_STATE__` - Read-only kernel state access
409
+ - `window.__LEGO_CHANNEL_BUS__` - Event publishing/subscribing
410
+
411
+ **Import Path Conventions:**
412
+ ```typescript
413
+ // From host kernel
414
+ import { usePocketBase } from '@/kernel/providers/PocketBaseProvider';
415
+ import { useCurrentOrganization } from '@/kernel/hooks/useCurrentOrganization';
416
+ import { Button } from '@/kernel/components/ui/Button';
417
+
418
+ // Window bridge (in plugins)
419
+ const kernelState = window.__LEGO_KERNEL_STATE__;
420
+ const channelBus = window.__LEGO_CHANNEL_BUS__;
421
+ ```
422
+
423
+ **Testing Commands:**
424
+ ```bash
425
+ # Run all tests
426
+ pnpm test
427
+
428
+ # Unit and component tests
429
+ pnpm --filter './host' test
430
+
431
+ # E2E tests (requires dev server running)
432
+ pnpm test:e2e
433
+
434
+ # Coverage report
435
+ pnpm test:coverage
436
+ ```
437
+
438
+ **Build Commands:**
439
+ ```bash
440
+ # Build all
441
+ pnpm run build
442
+
443
+ # Build host only
444
+ pnpm --filter './host' build
445
+
446
+ # Build specific plugin
447
+ pnpm --filter './packages/plugins/@lego/plugin-dashboard' build
448
+ ```
449
+
450
+ **Version Management (Framework Maintainers):**
451
+ ```bash
452
+ # Patch release (bug fixes)
453
+ pnpm run version:patch
454
+
455
+ # Minor release (new features)
456
+ pnpm run version:minor
457
+
458
+ # Major release (breaking changes)
459
+ pnpm run version:major
460
+
461
+ # Full release workflow
462
+ pnpm run release
463
+ ```
464
+
465
+ ### Common AI Task Patterns
466
+
467
+ **Creating a Plugin:**
468
+ 1. Use the CLI: `pnpm run create-plugin <plugin-name>` or create manually
469
+ 2. Follow the exact structure of existing plugins
470
+ 3. Copy patterns from Todo Plugin for CRUD features
471
+ 4. Copy patterns from Dashboard Plugin for display features
472
+ 5. Always create: types.ts, schemas.ts, hooks/, components/, pages/
473
+ 6. Register in `modern.runtime.ts` and `saas.config.ts`
474
+
475
+ **Adding UI Components:**
476
+ 1. Check if component exists in `host/src/kernel/components/ui/`
477
+ 2. Use existing components: Button, Input, Badge, Dialog, etc.
478
+ 3. Follow Tailwind CSS naming conventions
479
+ 4. Ensure responsive design (mobile-first)
480
+
481
+ **Data Operations:**
482
+ 1. Use `usePocketBase()` hook for API access
483
+ 2. Use TanStack Query for data fetching (via custom hooks)
484
+ 3. Always scope queries to current organization
485
+ 4. Handle loading and error states
486
+ 5. Show toast notifications for actions
487
+
488
+ **Multi-Tenancy:**
489
+ 1. All data must be scoped to organization
490
+ 2. Use `useCurrentOrganization()` to get org context
491
+ 3. Filter PocketBase queries: `filter: 'organizationId = "${orgId}"'`
492
+ 4. Set API rules in PocketBase for data isolation
493
+
494
+ **Testing:**
495
+ 1. Write unit tests for hooks and utilities
496
+ 2. Write component tests for UI components
497
+ 3. Mock PocketBase and window bridge in tests
498
+ 4. Use test setup in `host/src/test/setup.ts`
499
+
500
+ ### Important Constraints
501
+
502
+ **DO NOT:**
503
+ - Skip reading documentation before coding
504
+ - Create circular dependencies between host and plugins
505
+ - Import directly from host kernel in plugins (use window bridge)
506
+ - Skip TypeScript strict mode compliance
507
+ - Forget to handle loading and error states
508
+ - Create components without responsive design
509
+ - Skip testing before completion
510
+ - Forget to write checkpoints for your work
511
+
512
+ **ALWAYS:**
513
+ - Read relevant documentation first
514
+ - Follow existing file structures and naming conventions
515
+ - Use window bridge for host-plugin communication
516
+ - Implement proper error handling
517
+ - Test in both dev and production modes
518
+ - Document complex logic
519
+ - Use established UI components
520
+ - Write checkpoints in `/docs/checkpoints/`
521
+
522
+ ### Quick Decision Tree
523
+
524
+ ```
525
+ Task: Create a new feature
526
+ ├─ Is it a CRUD feature? → Follow Todo Plugin pattern (file 07)
527
+ ├─ Is it display only? → Follow Dashboard Plugin pattern (file 07)
528
+ ├─ Does it need backend storage? → Create PocketBase collection
529
+ ├─ Does it need authentication? → Add protected route
530
+ └─ Is it a calculation? → Create hook with pure functions
531
+
532
+ Task: Fix a bug
533
+ ├─ In host kernel? → Edit files in host/src/kernel/
534
+ ├─ In plugin? → Edit files in packages/plugins/@lego/plugin-<name>/
535
+ ├─ UI related? → Check components and layout
536
+ └─ Data related? → Check hooks and PocketBase queries
537
+ ```
538
+
539
+ ---
540
+
541
+ ## Next Steps
542
+
543
+ - Start with [`00-index.md`](./00-index.md) for complete documentation overview
544
+ - Explore the [Dashboard Plugin](../../packages/plugins/@lego/plugin-dashboard)
545
+ - Explore the [Todo Plugin](../../packages/plugins/@lego/plugin-todo)
546
+ - Read [`07-plugin-development.md`](./07-plugin-development.md) for plugin creation
547
+ - Check [`11-hooks-api.md`](./11-hooks-api.md) for kernel hooks reference
548
+ - Review [`13-deployment-guide.md`](./13-deployment-guide.md) for deployment
@@ -0,0 +1,38 @@
1
+ import { test, expect } from '@playwright/test';
2
+
3
+ test.describe('Authentication', () => {
4
+ test.beforeEach(async ({ page }) => {
5
+ await page.goto('/');
6
+ });
7
+
8
+ test('should show sign in page when not authenticated', async ({ page }) => {
9
+ await expect(page.locator('h1')).toContainText('Sign In');
10
+ });
11
+
12
+ test('should show sign in form', async ({ page }) => {
13
+ await expect(page.locator('input[type="email"]')).toBeVisible();
14
+ await expect(page.locator('input[type="password"]')).toBeVisible();
15
+ await expect(page.locator('button[type="submit"]')).toBeVisible();
16
+ });
17
+
18
+ test('should show validation errors for empty form', async ({ page }) => {
19
+ await page.click('button[type="submit"]');
20
+
21
+ // Should show validation errors
22
+ const emailInput = page.locator('input[type="email"]');
23
+ await expect(emailInput).toBeFocused();
24
+ });
25
+
26
+ test('should toggle password visibility', async ({ page }) => {
27
+ const passwordInput = page.locator('input[type="password"]');
28
+ const toggleButton = page.locator('button').filter({ hasText: /show/i }).first();
29
+
30
+ await passwordInput.fill('testpassword');
31
+
32
+ // Click show password button
33
+ if (await toggleButton.isVisible()) {
34
+ await toggleButton.click();
35
+ await expect(passwordInput).toHaveAttribute('type', 'text');
36
+ }
37
+ });
38
+ });
@@ -0,0 +1,38 @@
1
+ import { test, expect } from '@playwright/test';
2
+
3
+ test.describe('Layout & Navigation', () => {
4
+ test.beforeEach(async ({ page }) => {
5
+ // Mock authentication state
6
+ await page.goto('/');
7
+ });
8
+
9
+ test('should render sidebar', async ({ page }) => {
10
+ const sidebar = page.locator('aside').first();
11
+ await expect(sidebar).toBeVisible();
12
+ });
13
+
14
+ test('should render top bar', async ({ page }) => {
15
+ const topbar = page.locator('header').first();
16
+ await expect(topbar).toBeVisible();
17
+ });
18
+
19
+ test('should show navigation links', async ({ page }) => {
20
+ // Check for common navigation items
21
+ const dashboardLink = page.locator('a, button').filter({ hasText: /dashboard/i });
22
+ if (await dashboardLink.count() > 0) {
23
+ await expect(dashboardLink.first()).toBeVisible();
24
+ }
25
+ });
26
+
27
+ test('should be responsive on mobile', async ({ page }) => {
28
+ // Set mobile viewport
29
+ await page.setViewportSize({ width: 375, height: 667 });
30
+
31
+ // Check if mobile menu is available
32
+ const mobileMenuButton = page.locator('button').filter({ hasText: /menu/i });
33
+ if (await mobileMenuButton.isVisible()) {
34
+ await mobileMenuButton.click();
35
+ // Mobile menu should be open
36
+ }
37
+ });
38
+ });
@@ -0,0 +1,19 @@
1
+ import { appTools, defineConfig } from '@modern-js/app-tools';
2
+ import { garfishPlugin } from '@modern-js/plugin-garfish';
3
+
4
+ export default defineConfig({
5
+ // Enable Rspack for high-performance builds
6
+ tools: {
7
+ rspack: (config) => {
8
+ return config;
9
+ },
10
+ },
11
+
12
+ // Enable file-based routing for the host kernel
13
+ runtime: {
14
+ router: true,
15
+ },
16
+
17
+ // Register Garfish plugin for micro-frontend capabilities
18
+ plugins: [appTools(), garfishPlugin()],
19
+ });