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,714 @@
1
+ # Host Setup: Modern.js with Tailwind + Shadcn
2
+
3
+ **Project:** Lego-One (Modern.js SaaS OS)
4
+ **Document:** 03 - Host Setup Guide
5
+ **Status:** Research Phase
6
+
7
+ ## Executive Summary
8
+
9
+ Step-by-step guide to initialize the Modern.js Host (Kernel) application with Tailwind CSS and Shadcn UI. Since Shadcn is optimized for Next.js, we need specific configuration for Modern.js compatibility.
10
+
11
+ ---
12
+
13
+ ## 1. Project Initialization
14
+
15
+ ### 1.1 Create Host Project
16
+
17
+ ```bash
18
+ # Create the host directory
19
+ mkdir lego-one
20
+ cd lego-one
21
+
22
+ # Initialize Modern.js project
23
+ npx @modern-js/create@latest host
24
+
25
+ # Select options:
26
+ # - Language: TypeScript
27
+ # - Package manager: pnpm
28
+ # - Git: Yes
29
+ ```
30
+
31
+ ```bash
32
+ cd host
33
+
34
+ # Enable Micro Frontend feature
35
+ pnpm run new
36
+ # Select: Enable features -> Micro Front-end Feature
37
+ ```
38
+
39
+ ### 1.2 Install Core Dependencies
40
+
41
+ ```bash
42
+ cd host
43
+
44
+ # UI System
45
+ pnpm add tailwindcss postcss autoprefixer
46
+ pnpm add @radix-ui/react-slot
47
+ pnpm add class-variance-authority clsx tailwind-merge
48
+
49
+ # State Management
50
+ pnpm add zustand
51
+
52
+ # Server State
53
+ pnpm add @tanstack/react-query
54
+
55
+ # Notifications
56
+ pnpm add sonner
57
+
58
+ # Backend
59
+ pnpm add pocketbase
60
+
61
+ # Icons
62
+ pnpm add lucide-react
63
+
64
+ # Additional Radix Primitives (for Shadcn)
65
+ pnpm add @radix-ui/react-dialog
66
+ pnpm add @radix-ui/react-dropdown-menu
67
+ pnpm add @radix-ui/react-label
68
+ pnpm add @radix-ui/react-select
69
+ pnpm add @radix-ui/react-separator
70
+ pnpm add @radix-ui/react-switch
71
+ pnpm add @radix-ui/react-tabs
72
+ pnpm add @radix-ui/react-toast
73
+ ```
74
+
75
+ ### 1.3 Install Dev Dependencies
76
+
77
+ ```bash
78
+ # Type safety
79
+ pnpm add -D @types/node
80
+
81
+ # Shadcn CLI
82
+ pnpm add -D shadcn-ui
83
+ ```
84
+
85
+ ---
86
+
87
+ ## 2. Tailwind CSS Configuration
88
+
89
+ ### 2.1 Initialize Tailwind
90
+
91
+ ```bash
92
+ # This will create tailwind.config.js and postcss.config.js
93
+ npx tailwindcss init -p
94
+ ```
95
+
96
+ ### 2.2 Configure Tailwind for Modern.js
97
+
98
+ **File:** `host/tailwind.config.js`
99
+
100
+ ```javascript
101
+ /** @type {import('tailwindcss').Config} */
102
+ module.exports = {
103
+ darkMode: ['class'],
104
+ content: [
105
+ './src/**/*.{ts,tsx}',
106
+ // Include Shadcn components when we add them
107
+ './src/components/**/*.{ts,tsx}',
108
+ ],
109
+ theme: {
110
+ container: {
111
+ center: true,
112
+ padding: '2rem',
113
+ screens: {
114
+ '2xl': '1400px',
115
+ },
116
+ },
117
+ extend: {
118
+ colors: {
119
+ border: 'hsl(var(--border))',
120
+ input: 'hsl(var(--input))',
121
+ ring: 'hsl(var(--ring))',
122
+ background: 'hsl(var(--background))',
123
+ foreground: 'hsl(var(--foreground))',
124
+ primary: {
125
+ DEFAULT: 'hsl(var(--primary))',
126
+ foreground: 'hsl(var(--primary-foreground))',
127
+ },
128
+ secondary: {
129
+ DEFAULT: 'hsl(var(--secondary))',
130
+ foreground: 'hsl(var(--secondary-foreground))',
131
+ },
132
+ destructive: {
133
+ DEFAULT: 'hsl(var(--destructive))',
134
+ foreground: 'hsl(var(--destructive-foreground))',
135
+ },
136
+ muted: {
137
+ DEFAULT: 'hsl(var(--muted))',
138
+ foreground: 'hsl(var(--muted-foreground))',
139
+ },
140
+ accent: {
141
+ DEFAULT: 'hsl(var(--accent))',
142
+ foreground: 'hsl(var(--accent-foreground))',
143
+ },
144
+ popover: {
145
+ DEFAULT: 'hsl(var(--popover))',
146
+ foreground: 'hsl(var(--popover-foreground))',
147
+ },
148
+ card: {
149
+ DEFAULT: 'hsl(var(--card))',
150
+ foreground: 'hsl(var(--card-foreground))',
151
+ },
152
+ },
153
+ borderRadius: {
154
+ lg: 'var(--radius)',
155
+ md: 'calc(var(--radius) - 2px)',
156
+ sm: 'calc(var(--radius) - 4px)',
157
+ },
158
+ keyframes: {
159
+ 'accordion-down': {
160
+ from: { height: '0' },
161
+ to: { height: 'var(--radix-accordion-content-height)' },
162
+ },
163
+ 'accordion-up': {
164
+ from: { height: 'var(--radix-accordion-content-height)' },
165
+ to: { height: '0' },
166
+ },
167
+ },
168
+ animation: {
169
+ 'accordion-down': 'accordion-down 0.2s ease-out',
170
+ 'accordion-up': 'accordion-up 0.2s ease-out',
171
+ },
172
+ },
173
+ },
174
+ plugins: [require('tailwindcss-animate')],
175
+ };
176
+ ```
177
+
178
+ ### 2.3 Install Tailwind Animate Plugin
179
+
180
+ ```bash
181
+ pnpm add -D tailwindcss-animate
182
+ ```
183
+
184
+ ### 2.4 Configure PostCSS
185
+
186
+ **File:** `host/postcss.config.js`
187
+
188
+ ```javascript
189
+ module.exports = {
190
+ plugins: {
191
+ tailwindcss: {},
192
+ autoprefixer: {},
193
+ },
194
+ };
195
+ ```
196
+
197
+ **NOTE:** Modern.js has built-in PostCSS support. The above config works alongside Modern.js's default PostCSS configuration.
198
+
199
+ ### 2.5 Verify Modern.js PostCSS Integration
200
+
201
+ **File:** `host/modern.config.ts`
202
+
203
+ ```typescript
204
+ import { appTools, defineConfig } from '@modern-js/app-tools';
205
+ import { garfishPlugin } from '@modern-js/plugin-garfish';
206
+
207
+ export default defineConfig({
208
+ // Modern.js handles PostCSS automatically
209
+ // No extra config needed for Tailwind to work
210
+ tools: {
211
+ postcss: (config, { addPlugins }) => {
212
+ // Optionally add custom PostCSS plugins
213
+ // addPlugins([...]);
214
+ return config;
215
+ },
216
+ },
217
+
218
+ runtime: {
219
+ router: true,
220
+ },
221
+
222
+ plugins: [appTools(), garfishPlugin()],
223
+ });
224
+ ```
225
+
226
+ ---
227
+
228
+ ## 3. Global Styles
229
+
230
+ ### 3.1 Create CSS Variables
231
+
232
+ **File:** `host/src/styles/globals.css`
233
+
234
+ ```css
235
+ @tailwind base;
236
+ @tailwind components;
237
+ @tailwind utilities;
238
+
239
+ @layer base {
240
+ :root {
241
+ --background: 0 0% 100%;
242
+ --foreground: 222.2 84% 4.9%;
243
+ --card: 0 0% 100%;
244
+ --card-foreground: 222.2 84% 4.9%;
245
+ --popover: 0 0% 100%;
246
+ --popover-foreground: 222.2 84% 4.9%;
247
+ --primary: 222.2 47.4% 11.2%;
248
+ --primary-foreground: 210 40% 98%;
249
+ --secondary: 210 40% 96.1%;
250
+ --secondary-foreground: 222.2 47.4% 11.2%;
251
+ --muted: 210 40% 96.1%;
252
+ --muted-foreground: 215.4 16.3% 46.9%;
253
+ --accent: 210 40% 96.1%;
254
+ --accent-foreground: 222.2 47.4% 11.2%;
255
+ --destructive: 0 84.2% 60.2%;
256
+ --destructive-foreground: 210 40% 98%;
257
+ --border: 214.3 31.8% 91.4%;
258
+ --input: 214.3 31.8% 91.4%;
259
+ --ring: 222.2 84% 4.9%;
260
+ --radius: 0.5rem;
261
+ }
262
+
263
+ .dark {
264
+ --background: 222.2 84% 4.9%;
265
+ --foreground: 210 40% 98%;
266
+ --card: 222.2 84% 4.9%;
267
+ --card-foreground: 210 40% 98%;
268
+ --popover: 222.2 84% 4.9%;
269
+ --popover-foreground: 210 40% 98%;
270
+ --primary: 210 40% 98%;
271
+ --primary-foreground: 222.2 47.4% 11.2%;
272
+ --secondary: 217.2 32.6% 17.5%;
273
+ --secondary-foreground: 210 40% 98%;
274
+ --muted: 217.2 32.6% 17.5%;
275
+ --muted-foreground: 215 20.2% 65.1%;
276
+ --accent: 217.2 32.6% 17.5%;
277
+ --accent-foreground: 210 40% 98%;
278
+ --destructive: 0 62.8% 30.6%;
279
+ --destructive-foreground: 210 40% 98%;
280
+ --border: 217.2 32.6% 17.5%;
281
+ --input: 217.2 32.6% 17.5%;
282
+ --ring: 212.7 26.8% 83.9%;
283
+ }
284
+ }
285
+
286
+ @layer base {
287
+ * {
288
+ @apply border-border;
289
+ }
290
+ body {
291
+ @apply bg-background text-foreground;
292
+ }
293
+ }
294
+ ```
295
+
296
+ ### 3.2 Import Global Styles
297
+
298
+ **File:** `host/src/main.tsx` (or update existing entry point)
299
+
300
+ ```typescript
301
+ import React from 'react';
302
+ import ReactDOM from 'react-dom/client';
303
+ import App from './App';
304
+ import './styles/globals.css';
305
+
306
+ ReactDOM.createRoot(document.getElementById('root')!).render(
307
+ <React.StrictMode>
308
+ <App />
309
+ </React.StrictMode>,
310
+ );
311
+ ```
312
+
313
+ ---
314
+
315
+ ## 4. Shadcn UI Setup for Modern.js
316
+
317
+ ### 4.1 Initialize Shadcn
318
+
319
+ Since Shadcn uses Next.js-specific features, we need to configure it manually for Modern.js.
320
+
321
+ **File:** `host/components.json`
322
+
323
+ ```json
324
+ {
325
+ "$schema": "https://ui.shadcn.com/schema.json",
326
+ "style": "default",
327
+ "rsc": false,
328
+ "tsx": true,
329
+ "tailwind": {
330
+ "config": "tailwind.config.js",
331
+ "css": "src/styles/globals.css",
332
+ "baseColor": "slate",
333
+ "cssVariables": true,
334
+ "prefix": ""
335
+ },
336
+ "aliases": {
337
+ "components": "@/components",
338
+ "utils": "@/lib/utils",
339
+ "ui": "@/components/ui",
340
+ "lib": "@/lib",
341
+ "hooks": "@/hooks"
342
+ }
343
+ }
344
+ ```
345
+
346
+ ### 4.2 Create Path Aliases
347
+
348
+ **File:** `host/tsconfig.json`
349
+
350
+ ```json
351
+ {
352
+ "extends": "@modern-js/tsconfig/base",
353
+ "compilerOptions": {
354
+ "baseUrl": ".",
355
+ "paths": {
356
+ "@/*": ["./src/*"]
357
+ }
358
+ },
359
+ "include": ["src"]
360
+ }
361
+ ```
362
+
363
+ ### 4.3 Update Modern.js Config for Path Aliases
364
+
365
+ **File:** `host/modern.config.ts`
366
+
367
+ ```typescript
368
+ import { appTools, defineConfig } from '@modern-js/app-tools';
369
+ import { garfishPlugin } from '@modern-js/plugin-garfish';
370
+
371
+ export default defineConfig({
372
+ source: {
373
+ alias: {
374
+ '@': './src',
375
+ },
376
+ },
377
+
378
+ runtime: {
379
+ router: true,
380
+ },
381
+
382
+ plugins: [appTools(), garfishPlugin()],
383
+ });
384
+ ```
385
+
386
+ ### 4.4 Create Utility Functions
387
+
388
+ **File:** `host/src/lib/utils.ts`
389
+
390
+ ```typescript
391
+ import { type ClassValue, clsx } from 'clsx';
392
+ import { twMerge } from 'tailwind-merge';
393
+
394
+ export function cn(...inputs: ClassValue[]) {
395
+ return twMerge(clsx(inputs));
396
+ }
397
+ ```
398
+
399
+ ### 4.5 Add Shadcn Components
400
+
401
+ Use Shadcn CLI to add components:
402
+
403
+ ```bash
404
+ # Example: Add button component
405
+ npx shadcn-ui@latest add button
406
+ ```
407
+
408
+ **NOTE:** You may need to manually move components to the correct location after CLI adds them, as Shadcn expects Next.js structure.
409
+
410
+ **Manual Alternative:** Copy component code from [shadcn/ui](https://ui.shadcn.com/) to `host/src/components/ui/`
411
+
412
+ **Example:** `host/src/components/ui/button.tsx`
413
+
414
+ ```typescript
415
+ import * as React from 'react';
416
+ import { Slot } from '@radix-ui/react-slot';
417
+ import { cva, type VariantProps } from 'class-variance-authority';
418
+ import { cn } from '@/lib/utils';
419
+
420
+ const buttonVariants = cva(
421
+ 'inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50',
422
+ {
423
+ variants: {
424
+ variant: {
425
+ default: 'bg-primary text-primary-foreground hover:bg-primary/90',
426
+ destructive:
427
+ 'bg-destructive text-destructive-foreground hover:bg-destructive/90',
428
+ outline:
429
+ 'border border-input bg-background hover:bg-accent hover:text-accent-foreground',
430
+ secondary:
431
+ 'bg-secondary text-secondary-foreground hover:bg-secondary/80',
432
+ ghost: 'hover:bg-accent hover:text-accent-foreground',
433
+ link: 'text-primary underline-offset-4 hover:underline',
434
+ },
435
+ size: {
436
+ default: 'h-10 px-4 py-2',
437
+ sm: 'h-9 rounded-md px-3',
438
+ lg: 'h-11 rounded-md px-8',
439
+ icon: 'h-10 w-10',
440
+ },
441
+ },
442
+ defaultVariants: {
443
+ variant: 'default',
444
+ size: 'default',
445
+ },
446
+ }
447
+ );
448
+
449
+ export interface ButtonProps
450
+ extends React.ButtonHTMLAttributes<HTMLButtonElement>,
451
+ VariantProps<typeof buttonVariants> {
452
+ asChild?: boolean;
453
+ }
454
+
455
+ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
456
+ ({ className, variant, size, asChild = false, ...props }, ref) => {
457
+ const Comp = asChild ? Slot : 'button';
458
+ return (
459
+ <Comp
460
+ className={cn(buttonVariants({ variant, size, className }))}
461
+ ref={ref}
462
+ {...props}
463
+ />
464
+ );
465
+ }
466
+ );
467
+ Button.displayName = 'Button';
468
+
469
+ export { Button, buttonVariants };
470
+ ```
471
+
472
+ ---
473
+
474
+ ## 5. Garfish Micro-Frontend Configuration
475
+
476
+ ### 5.1 Configure Garfish Plugin
477
+
478
+ **File:** `host/modern.config.ts`
479
+
480
+ ```typescript
481
+ import { appTools, defineConfig } from '@modern-js/app-tools';
482
+ import { garfishPlugin } from '@modern-js/plugin-garfish';
483
+
484
+ export default defineConfig({
485
+ runtime: {
486
+ router: true,
487
+ },
488
+
489
+ plugins: [appTools(), garfishPlugin()],
490
+
491
+ // Rspack configuration for optimal performance
492
+ tools: {
493
+ rspack: (config, { addRules }) => {
494
+ return config;
495
+ },
496
+ },
497
+ });
498
+ ```
499
+
500
+ ### 5.2 Configure Sub-Apps
501
+
502
+ **File:** `host/src/modern.runtime.ts`
503
+
504
+ ```typescript
505
+ import { defineRuntimeConfig } from '@modern-js/runtime';
506
+
507
+ export default defineRuntimeConfig({
508
+ masterApp: {
509
+ apps: [
510
+ {
511
+ name: '@lego/plugin-dashboard',
512
+ entry: 'http://localhost:3001',
513
+ activeWhen: '/dashboard',
514
+ },
515
+ {
516
+ name: '@lego/plugin-loan-calculator',
517
+ entry: 'http://localhost:3002',
518
+ activeWhen: '/apps/loan',
519
+ },
520
+ ],
521
+ },
522
+ });
523
+ ```
524
+
525
+ ---
526
+
527
+ ## 6. Shared State Bridge Setup
528
+
529
+ ### 6.1 Create Zustand Store
530
+
531
+ **File:** `host/src/kernel/shared-state-bridge.ts`
532
+
533
+ ```typescript
534
+ import { create } from 'zustand';
535
+ import { devtools, persist } from 'zustand/middleware';
536
+
537
+ interface GlobalKernelState {
538
+ // User
539
+ currentUser: {
540
+ id: string;
541
+ email: string;
542
+ role: string;
543
+ } | null;
544
+
545
+ // UI State
546
+ theme: 'light' | 'dark';
547
+ sidebarOpen: boolean;
548
+
549
+ // Actions
550
+ setCurrentUser: (user: GlobalKernelState['currentUser']) => void;
551
+ setTheme: (theme: 'light' | 'dark') => void;
552
+ toggleSidebar: () => void;
553
+ }
554
+
555
+ export const useGlobalKernelState = create<GlobalKernelState>()(
556
+ devtools(
557
+ persist(
558
+ (set) => ({
559
+ currentUser: null,
560
+ theme: 'light',
561
+ sidebarOpen: true,
562
+
563
+ setCurrentUser: (user) => set({ currentUser: user }),
564
+ setTheme: (theme) => set({ theme }),
565
+ toggleSidebar: () => set((state) => ({ sidebarOpen: !state.sidebarOpen })),
566
+ }),
567
+ {
568
+ name: 'lego-kernel-state',
569
+ partialize: (state) => ({ theme: state.theme, sidebarOpen: state.sidebarOpen }),
570
+ }
571
+ ),
572
+ { name: 'LegoKernelState' }
573
+ )
574
+ );
575
+
576
+ // Register to window for plugin access
577
+ export function registerSharedState() {
578
+ (window as any).__LEGO_KERNEL_STATE__ = {
579
+ useGlobalKernelState,
580
+ };
581
+ }
582
+ ```
583
+
584
+ ### 6.2 Initialize in Bootstrap
585
+
586
+ **File:** `host/src/bootstrap.tsx`
587
+
588
+ ```typescript
589
+ import { registerSharedState } from './kernel/shared-state-bridge';
590
+ import './styles/globals.css';
591
+
592
+ // Initialize shared state bridge before app starts
593
+ registerSharedState();
594
+
595
+ export {};
596
+ ```
597
+
598
+ ---
599
+
600
+ ## 7. Basic Layout Structure
601
+
602
+ ### 7.1 Create Main Layout
603
+
604
+ **File:** `host/src/layout/AppLayout.tsx`
605
+
606
+ ```typescript
607
+ import { Outlet } from '@modern-js/runtime/router';
608
+ import { Sidebar } from './Sidebar';
609
+ import { Topbar } from './Topbar';
610
+ import { Toaster } from '@/components/ui/sonner';
611
+
612
+ export function AppLayout() {
613
+ return (
614
+ <div className="flex h-screen bg-background">
615
+ <Sidebar />
616
+ <div className="flex flex-col flex-1 overflow-hidden">
617
+ <Topbar />
618
+ <main className="flex-1 overflow-auto p-6">
619
+ <Outlet />
620
+ </main>
621
+ </div>
622
+ <Toaster />
623
+ </div>
624
+ );
625
+ }
626
+ ```
627
+
628
+ ### 7.2 Create Root Layout
629
+
630
+ **File:** `host/src/routes/layout.tsx`
631
+
632
+ ```typescript
633
+ import { Outlet } from '@modern-js/runtime/router';
634
+ import { AppLayout } from '@/layout/AppLayout';
635
+
636
+ export default function Layout() {
637
+ return (
638
+ <AppLayout>
639
+ <Outlet />
640
+ </AppLayout>
641
+ );
642
+ }
643
+ ```
644
+
645
+ ---
646
+
647
+ ## 8. Verification Steps
648
+
649
+ ### 8.1 Test Tailwind
650
+
651
+ **File:** `host/src/routes/page.tsx`
652
+
653
+ ```typescript
654
+ export default function Home() {
655
+ return (
656
+ <div className="p-8">
657
+ <h1 className="text-4xl font-bold text-primary">Lego-One Host</h1>
658
+ <p className="text-muted-foreground mt-4">
659
+ Modern.js + Tailwind + Shadcn
660
+ </p>
661
+ </div>
662
+ );
663
+ }
664
+ ```
665
+
666
+ ### 8.2 Test Shadcn Component
667
+
668
+ ```typescript
669
+ import { Button } from '@/components/ui/button';
670
+
671
+ export default function Home() {
672
+ return (
673
+ <div className="p-8">
674
+ <Button>Click Me</Button>
675
+ </div>
676
+ );
677
+ }
678
+ ```
679
+
680
+ ### 8.3 Run Development Server
681
+
682
+ ```bash
683
+ pnpm run dev
684
+ # Navigate to http://localhost:8080
685
+ ```
686
+
687
+ ---
688
+
689
+ ## 9. Key Differences from Next.js
690
+
691
+ | Feature | Next.js | Modern.js | Solution |
692
+ |---------|---------|-----------|----------|
693
+ | Routing | App Router | File-based (routes/) | Use `routes/` directory |
694
+ | Imports | `@/` alias | Needs config | Set `source.alias` in modern.config.ts |
695
+ | CSS | Global CSS auto-imported | Manual import | Import in `main.tsx` |
696
+ | PostCSS | Built-in config | Built-in config | Works the same |
697
+ | RSC | Supported | Not supported | Use client components |
698
+
699
+ ---
700
+
701
+ ## 10. Next Steps
702
+
703
+ 1. **`04-plugin-architecture.md`**: Create a "Hello World" plugin
704
+ 2. **`05-slot-injection-pattern.md`**: Implement UI slot system
705
+ 3. **`06-cli-strategy.md`**: CLI tool for project scaffolding
706
+
707
+ ---
708
+
709
+ ## References
710
+
711
+ - [Modern.js Tailwind CSS Guide](https://modernjs.dev/guides/basic-features/css/tailwindcss)
712
+ - [Shadcn UI Documentation](https://ui.shadcn.com/)
713
+ - [Rsbuild Tailwind CSS v3 Guide](https://rsbuild.rs/guide/styling/tailwindcss-v3)
714
+ - [Modern.js Micro Frontend Guide](https://modernjs.dev/guides/topic-detail/micro-frontend/c02-development)