create-lego-one 2.0.12 → 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 (78) hide show
  1. package/dist/index.cjs +34 -0
  2. package/dist/index.cjs.map +1 -1
  3. package/package.json +1 -1
  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/package.json +1 -1
  70. package/template/nginx.conf +72 -0
  71. package/template/package.json +1 -1
  72. package/template/packages/plugins/@lego/plugin-dashboard/package.json +1 -1
  73. package/template/packages/plugins/@lego/plugin-todo/package.json +1 -1
  74. package/template/pocketbase/CHANGELOG.md +911 -0
  75. package/template/pocketbase/LICENSE.md +17 -0
  76. package/template/scripts/create-plugin.js +221 -0
  77. package/template/scripts/deploy.sh +56 -0
  78. package/template/tsconfig.base.json +26 -0
@@ -0,0 +1,312 @@
1
+ # Phase 13: Documentation - Complete
2
+
3
+ ## Overview
4
+
5
+ Comprehensive documentation suite created for the Lego-One SaaS boilerplate, covering API reference, component library, plugin development, deployment, and troubleshooting.
6
+
7
+ ## Documentation Structure
8
+
9
+ ```
10
+ docs/
11
+ ├── api/
12
+ │ └── kernel-api.md # Kernel API reference
13
+ ├── components/
14
+ │ └── ui-components.md # UI component library reference
15
+ ├── guides/
16
+ │ ├── plugin-development.md # Plugin development guide
17
+ │ ├── deployment.md # Deployment guide
18
+ │ └── troubleshooting.md # Troubleshooting guide
19
+ └── checkpoints/
20
+ ├── phase-08-plugin-system.md
21
+ ├── phase-09-dashboard-plugin.md
22
+ ├── phase-10-todo-plugin.md
23
+ ├── phase-11-testing.md
24
+ └── phase-12-deployment.md
25
+ ```
26
+
27
+ ## Documentation Files
28
+
29
+ ### 1. API Reference (`docs/api/kernel-api.md`)
30
+
31
+ **Sections:**
32
+ - Authentication hooks (`useAuth`, `useRequireAuth`)
33
+ - Authorization (RBAC) hooks and types
34
+ - Channel system for plugin-host communication
35
+ - Plugin system APIs
36
+ - Shared state management (Zustand)
37
+ - PocketBase integration utilities
38
+ - Utility functions
39
+
40
+ **Key APIs Documented:**
41
+ - `useAuth()` - Authentication state and methods
42
+ - `useCurrentOrganization()` - Organization context
43
+ - `useRequirePermission()` - Permission checking
44
+ - `useUserPermissions()` - User permissions query
45
+ - `useOrganizations()` - Organizations query
46
+ - `useHasPermission()` - Permission verification
47
+ - Channel hooks (`useAuthChannel`, `useOrganizationChannel`, `useToastChannel`)
48
+ - `useGlobalKernelState` - Global state management
49
+ - `usePocketBase()` - PocketBase client
50
+
51
+ ### 2. Component Reference (`docs/components/ui-components.md`)
52
+
53
+ **Component Categories:**
54
+ - **Form Components:** Button, Input, Label, Select, Switch
55
+ - **Layout Components:** Card, Separator, ScrollArea
56
+ - **Feedback Components:** Alert, Badge, Progress, Skeleton, Toast
57
+ - **Navigation Components:** Tabs, Dropdown Menu
58
+ - **Display Components:** Avatar, Table
59
+ - **Overlay Components:** Dialog, Popover, Tooltip
60
+
61
+ **Each Component Includes:**
62
+ - Import statement
63
+ - Props interface
64
+ - Variant/size options
65
+ - Usage examples
66
+ - Accessibility notes
67
+
68
+ ### 3. Plugin Development Guide (`docs/guides/plugin-development.md`)
69
+
70
+ **Sections:**
71
+ - Quick start with CLI
72
+ - Manual setup instructions
73
+ - Project structure
74
+ - Plugin configuration
75
+ - Slot injection patterns
76
+ - Routing setup
77
+ - Host communication via window bridge
78
+ - PocketBase integration
79
+ - Styling with Tailwind CSS
80
+ - Best practices
81
+ - Testing guidelines
82
+ - Common patterns
83
+ - Troubleshooting
84
+
85
+ **Key Topics:**
86
+ - Creating a plugin from scratch
87
+ - Using slots for UI injection
88
+ - Defining routes
89
+ - Communicating with the host
90
+ - Data fetching with PocketBase
91
+ - Form validation
92
+ - Error handling
93
+
94
+ ### 4. Deployment Guide (`docs/guides/deployment.md`)
95
+
96
+ **Sections:**
97
+ - Prerequisites
98
+ - Environment setup
99
+ - Docker deployment
100
+ - Cloud platforms (Vercel, Railway, Render, DigitalOcean)
101
+ - Production checklist
102
+ - Monitoring & maintenance
103
+ - Scaling strategies
104
+ - CI/CD pipeline
105
+ - Rollback procedures
106
+ - Cost optimization
107
+ - Security best practices
108
+
109
+ **Key Topics:**
110
+ - Environment variable configuration
111
+ - Docker containerization
112
+ - Multi-platform deployment
113
+ - Production build optimization
114
+ - Health checks and monitoring
115
+ - Backup procedures
116
+ - Scaling (horizontal, database)
117
+ - Cost reduction strategies
118
+
119
+ ### 5. Troubleshooting Guide (`docs/guides/troubleshooting.md`)
120
+
121
+ **Categories:**
122
+ - Development Issues
123
+ - Build Issues
124
+ - Deployment Issues
125
+ - Plugin Issues
126
+ - PocketBase Issues
127
+ - Performance Issues
128
+
129
+ **Common Issues Covered:**
130
+ - Port conflicts
131
+ - Hot reload failures
132
+ - TypeScript errors
133
+ - Import path issues
134
+ - Build failures
135
+ - Docker container errors
136
+ - Environment variable problems
137
+ - Plugin loading issues
138
+ - Route 404 errors
139
+ - PocketBase connection issues
140
+ - Authentication problems
141
+ - Performance bottlenecks
142
+
143
+ **Each Issue Includes:**
144
+ - Symptom description
145
+ - Root cause analysis
146
+ - Step-by-step solution
147
+ - Diagnostic commands
148
+
149
+ ## Checkpoint Files
150
+
151
+ ### Phase 8: Plugin System
152
+ - Kernel plugin infrastructure
153
+ - Slot injection system
154
+ - Plugin loader and store
155
+ - Plugin configuration types
156
+
157
+ ### Phase 9: Dashboard Plugin
158
+ - Complete plugin implementation
159
+ - Statistics tracking
160
+ - Activity feed
161
+ - Quick actions widget
162
+
163
+ ### Phase 10: Todo Plugin
164
+ - Full CRUD functionality
165
+ - Form validation
166
+ - Filtering and search
167
+ - Permission-based access
168
+
169
+ ### Phase 11: Testing
170
+ - Vitest configuration
171
+ - Test utilities
172
+ - 32 unit/component tests
173
+ - Playwright E2E setup
174
+
175
+ ### Phase 12: Deployment
176
+ - Docker multi-stage build
177
+ - Nginx configuration
178
+ - Docker Compose setup
179
+ - Production build verification
180
+
181
+ ## Documentation Features
182
+
183
+ ### Code Examples
184
+ All documentation includes:
185
+ - Working TypeScript/React code
186
+ - Import statements
187
+ - Complete examples
188
+ - Error handling patterns
189
+
190
+ ### Cross-References
191
+ - Links between related documents
192
+ - API references in guides
193
+ - Component usage in examples
194
+ - Troubleshooting in all guides
195
+
196
+ ### Best Practices
197
+ - Security considerations
198
+ - Performance optimization
199
+ - Accessibility guidelines
200
+ - Code organization tips
201
+
202
+ ## Documentation Statistics
203
+
204
+ - **Total Documentation Files:** 10+
205
+ - **API References:** 40+ hooks/functions
206
+ - **Component Documentation:** 20+ components
207
+ - **Guides:** 4 comprehensive guides
208
+ - **Troubleshooting Topics:** 30+ issues
209
+
210
+ ## Usage
211
+
212
+ ### For Developers
213
+
214
+ 1. **Getting Started:**
215
+ - Read README.md for project overview
216
+ - Follow setup guide in README.md
217
+
218
+ 2. **Building Features:**
219
+ - Consult API Reference for available hooks
220
+ - Use Component Reference for UI elements
221
+ - Follow Plugin Development Guide for extensibility
222
+
223
+ 3. **Deploying:**
224
+ - Follow Deployment Guide
225
+ - Use Troubleshooting Guide for issues
226
+
227
+ ### For Plugin Developers
228
+
229
+ 1. **Creating Plugins:**
230
+ - Read Plugin Development Guide
231
+ - Reference API documentation
232
+ - Check existing plugins (Dashboard, Todo)
233
+
234
+ 2. **Integration:**
235
+ - Slot system documentation
236
+ - Window bridge API
237
+ - Channel communication
238
+
239
+ ## Maintenance
240
+
241
+ ### Keeping Docs Updated
242
+
243
+ When making changes:
244
+ 1. Update API references for new hooks/functions
245
+ 2. Document new components
246
+ 3. Add troubleshooting entries for new issues
247
+ 4. Update examples to reflect best practices
248
+ 5. Cross-reference related sections
249
+
250
+ ### Documentation Review
251
+
252
+ Before releasing:
253
+ - [ ] All new APIs are documented
254
+ - [ ] Code examples are tested
255
+ - [ ] Cross-references are correct
256
+ - [ ] Troubleshooting covers common issues
257
+ - [ ] Deployment guide works for all platforms
258
+
259
+ ## Tools Used
260
+
261
+ - **Markdown:** Primary documentation format
262
+ - **TypeScript:** Code examples
263
+ - **Mermaid (optional):** Diagrams and flows
264
+ - **Code highlighting:** Syntax highlighting for all examples
265
+
266
+ ## Future Improvements
267
+
268
+ 1. **Interactive Examples:**
269
+ - Live code playgrounds
270
+ - Embedded demos
271
+
272
+ 2. **Video Tutorials:**
273
+ - Getting started walkthrough
274
+ - Plugin development tutorial
275
+ - Deployment guide
276
+
277
+ 3. **API Auto-Generation:**
278
+ - Generate from TypeScript types
279
+ - Automatic doc comments
280
+
281
+ 4. **Search Integration:**
282
+ - Full-text search
283
+ - Tag-based navigation
284
+
285
+ 5. **Translations:**
286
+ - Multi-language support
287
+ - Localized examples
288
+
289
+ ## Documentation Quality
290
+
291
+ ### Standards
292
+ - Clear, concise language
293
+ - Working code examples
294
+ - Consistent formatting
295
+ - Comprehensive coverage
296
+ - Regular updates
297
+
298
+ ### Accessibility
299
+ - High contrast text
300
+ - Screen reader friendly
301
+ - Semantic HTML structure
302
+ - Keyboard navigation support
303
+
304
+ ## Notes
305
+
306
+ Documentation is a living resource. As the project evolves, documentation should be updated to reflect:
307
+ - New features and APIs
308
+ - Breaking changes
309
+ - Best practices learned
310
+ - Common issues and solutions
311
+
312
+ All documentation files are in Markdown format for easy editing and version control.
@@ -0,0 +1,164 @@
1
+ # Lego-One Implementation Plan Index
2
+
3
+ > **For AI Implementing This Plan:** Start with `01-infrastructure-setup.md` and proceed sequentially through all documents. Each document contains complete implementation details with exact file paths, code, and commands.
4
+
5
+ **Goal:** Build a complete, production-ready SaaS boilerplate with microkernel architecture using Modern.js + Garfish + PocketBase
6
+
7
+ **Architecture:** Host (Kernel) provides auth, multitenancy, RBAC, and shared services. Plugins (Dashboard, Todo) are feature modules that can be enabled/disabled. Development uses separate plugin servers; production bundles everything into single host deployment.
8
+
9
+ **Tech Stack:** Modern.js, Rspack, Garfish, React 18, TypeScript, Zustand, TanStack Query v5, Tailwind CSS, Shadcn UI, PocketBase, Vitest, Playwright, Zod
10
+
11
+ ---
12
+
13
+ ## Implementation Plan Documents
14
+
15
+ ### Phase 1: Foundation (Start Here)
16
+
17
+ | Document | Description | Prerequisites |
18
+ |----------|-------------|---------------|
19
+ | [`01-infrastructure-setup.md`](./01-infrastructure-setup.md) | Project structure, monorepo, dependencies, tooling | None |
20
+ | [`02-pocketbase-setup.md`](./02-pocketbase-setup.md) | PocketBase installation, collections, API rules, seed data | 01 |
21
+ | [`03-host-kernel.md`](./03-host-kernel.md) | Host app initialization, shared state, layout, routing | 01 |
22
+ | [`04-auth-system.md`](./04-auth-system.md) | Authentication, login/logout, session management | 02, 03 |
23
+ | [`05-multitenancy-rbac.md`](./05-multitenancy-rbac.md) | Organizations, users, roles, permissions system | 02, 03, 04 |
24
+
25
+ ### Phase 2: User Interface
26
+
27
+ | Document | Description | Prerequisites |
28
+ |----------|-------------|---------------|
29
+ | [`06-ui-components.md`](./06-ui-components.md) | Shadcn components, shared UI library, theming | 03 |
30
+ | [`07-communication-system.md`](./07-communication-system.md) | Garfish channel bus, toast system, state bridge | 03 |
31
+
32
+ ### Phase 3: Plugin System
33
+
34
+ | Document | Description | Prerequisites |
35
+ |----------|-------------|---------------|
36
+ | [`08-plugin-system.md`](./08-plugin-system.md) | Plugin architecture, slot injection, loader, config | 03, 07 |
37
+ | [`09-dashboard-plugin.md`](./09-dashboard-plugin.md) | Dashboard plugin implementation | 03, 06, 08 |
38
+ | [`10-todo-plugin.md`](./10-todo-plugin.md) | Todo plugin with CRUD | 03, 06, 08 |
39
+
40
+ ### Phase 4: Quality & Deployment
41
+
42
+ | Document | Description | Prerequisites |
43
+ |----------|-------------|---------------|
44
+ | [`11-testing.md`](./11-testing.md) | Unit, component, and E2E tests | All above |
45
+ | [`12-deployment.md`](./12-deployment.md) | Build configuration, dev/prod environments, CI/CD | All above |
46
+
47
+ ### Phase 5: Documentation
48
+
49
+ | Document | Description | Prerequisites |
50
+ |----------|-------------|---------------|
51
+ | [`13-setup-guide.md`](./13-setup-guide.md) | User guide: setup, creating plugins, configuration | All above |
52
+
53
+ ---
54
+
55
+ ## Implementation Order
56
+
57
+ Follow this sequence for smooth implementation:
58
+
59
+ ```
60
+ 1. Infrastructure Setup (01)
61
+
62
+ 2. PocketBase Setup (02)
63
+
64
+ 3. Host Kernel (03)
65
+
66
+ 4. Auth System (04)
67
+
68
+ 5. Multitenancy & RBAC (05)
69
+
70
+ 6. UI Components (06)
71
+
72
+ 7. Communication System (07)
73
+
74
+ 8. Plugin System (08)
75
+
76
+ 9. Dashboard Plugin (09)
77
+
78
+ 10. Todo Plugin (10)
79
+
80
+ 11. Testing (11)
81
+
82
+ 12. Deployment (12)
83
+
84
+ 13. Setup Guide (13)
85
+ ```
86
+
87
+ ---
88
+
89
+ ## What Gets Built
90
+
91
+ After implementing this plan, you will have:
92
+
93
+ ### Core Features
94
+ - ✅ Multi-tenant SaaS with organization/user management
95
+ - ✅ Role-based access control (full RBAC)
96
+ - ✅ Authentication (admin-seeded, no public signup)
97
+ - ✅ Plugin system with slot injection
98
+ - ✅ Enable/disable plugins via config or admin UI
99
+ - ✅ Custom toast system (Garfish channel example)
100
+
101
+ ### Included Plugins
102
+ - ✅ **Dashboard Plugin** - Stats, recent activity, quick actions
103
+ - ✅ **Todo Plugin** - Basic CRUD (enable/disable via config)
104
+
105
+ ### Technical Features
106
+ - ✅ Tailwind + Shadcn UI components
107
+ - ✅ Responsive (Desktop/Tablet/Mobile)
108
+ - ✅ TypeScript strict mode
109
+ - ✅ TanStack Query for server state
110
+ - ✅ Zustand for global state
111
+ - ✅ Zod validation
112
+ - ✅ Full testing (Vitest + Playwright)
113
+ - ✅ ESLint + Prettier
114
+ - ✅ Dev: Separate plugin servers
115
+ - ✅ Prod: Single bundled deployment
116
+
117
+ ### Developer Experience
118
+ - ✅ CLI script to scaffold new plugins
119
+ - ✅ Complete setup guide in `/docs/setup/`
120
+ - ✅ Seed data for immediate testing
121
+ - ✅ Configurable admin credentials
122
+
123
+ ---
124
+
125
+ ## Quick Start for AI Implementation
126
+
127
+ **Step 1:** Read `01-infrastructure-setup.md` completely
128
+ **Step 2:** Follow tasks sequentially (each task is 2-5 minutes)
129
+ **Step 3:** Run `pnpm run dev:all` after each phase to verify
130
+ **Step 4:** Continue through all documents in order
131
+
132
+ ---
133
+
134
+ ## File Structure After Implementation
135
+
136
+ ```
137
+ lego-one/
138
+ ├── host/ # Kernel application
139
+ │ ├── src/
140
+ │ │ ├── kernel/ # Shared systems
141
+ │ │ ├── components/
142
+ │ │ ├── layout/
143
+ │ │ ├── routes/
144
+ │ │ └── ...
145
+ │ ├── modern.config.ts
146
+ │ └── package.json
147
+ ├── packages/
148
+ │ └── plugins/
149
+ │ └── @lego/
150
+ │ ├── plugin-dashboard/ # Dashboard plugin
151
+ │ └── plugin-todo/ # Todo plugin
152
+ ├── pocketbase/
153
+ │ └── pb_data/ # PocketBase data
154
+ ├── docs/
155
+ │ ├── research/ # Research docs (done)
156
+ │ ├── plans/ # Implementation docs (this folder)
157
+ │ └── setup/ # User setup guides
158
+ ├── pnpm-workspace.yaml
159
+ └── package.json
160
+ ```
161
+
162
+ ---
163
+
164
+ **Ready to begin implementation?** Start with → [`01-infrastructure-setup.md`](./01-infrastructure-setup.md)