@plures/praxis 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/FRAMEWORK.md +420 -0
- package/LICENSE +21 -0
- package/README.md +1310 -0
- package/dist/adapters/cli.d.ts +43 -0
- package/dist/adapters/cli.d.ts.map +1 -0
- package/dist/adapters/cli.js +126 -0
- package/dist/adapters/cli.js.map +1 -0
- package/dist/cli/commands/auth.d.ts +26 -0
- package/dist/cli/commands/auth.d.ts.map +1 -0
- package/dist/cli/commands/auth.js +233 -0
- package/dist/cli/commands/auth.js.map +1 -0
- package/dist/cli/commands/cloud.d.ts +27 -0
- package/dist/cli/commands/cloud.d.ts.map +1 -0
- package/dist/cli/commands/cloud.js +232 -0
- package/dist/cli/commands/cloud.js.map +1 -0
- package/dist/cli/commands/generate.d.ts +25 -0
- package/dist/cli/commands/generate.d.ts.map +1 -0
- package/dist/cli/commands/generate.js +168 -0
- package/dist/cli/commands/generate.js.map +1 -0
- package/dist/cli/index.d.ts +8 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +179 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cloud/auth.d.ts +51 -0
- package/dist/cloud/auth.d.ts.map +1 -0
- package/dist/cloud/auth.js +194 -0
- package/dist/cloud/auth.js.map +1 -0
- package/dist/cloud/billing.d.ts +184 -0
- package/dist/cloud/billing.d.ts.map +1 -0
- package/dist/cloud/billing.js +179 -0
- package/dist/cloud/billing.js.map +1 -0
- package/dist/cloud/client.d.ts +39 -0
- package/dist/cloud/client.d.ts.map +1 -0
- package/dist/cloud/client.js +176 -0
- package/dist/cloud/client.js.map +1 -0
- package/dist/cloud/index.d.ts +44 -0
- package/dist/cloud/index.d.ts.map +1 -0
- package/dist/cloud/index.js +44 -0
- package/dist/cloud/index.js.map +1 -0
- package/dist/cloud/marketplace.d.ts +166 -0
- package/dist/cloud/marketplace.d.ts.map +1 -0
- package/dist/cloud/marketplace.js +159 -0
- package/dist/cloud/marketplace.js.map +1 -0
- package/dist/cloud/provisioning.d.ts +110 -0
- package/dist/cloud/provisioning.d.ts.map +1 -0
- package/dist/cloud/provisioning.js +148 -0
- package/dist/cloud/provisioning.js.map +1 -0
- package/dist/cloud/relay/endpoints.d.ts +62 -0
- package/dist/cloud/relay/endpoints.d.ts.map +1 -0
- package/dist/cloud/relay/endpoints.js +217 -0
- package/dist/cloud/relay/endpoints.js.map +1 -0
- package/dist/cloud/relay/health/index.d.ts +5 -0
- package/dist/cloud/relay/health/index.d.ts.map +1 -0
- package/dist/cloud/relay/health/index.js +9 -0
- package/dist/cloud/relay/health/index.js.map +1 -0
- package/dist/cloud/relay/stats/index.d.ts +5 -0
- package/dist/cloud/relay/stats/index.d.ts.map +1 -0
- package/dist/cloud/relay/stats/index.js +9 -0
- package/dist/cloud/relay/stats/index.js.map +1 -0
- package/dist/cloud/relay/sync/index.d.ts +5 -0
- package/dist/cloud/relay/sync/index.d.ts.map +1 -0
- package/dist/cloud/relay/sync/index.js +9 -0
- package/dist/cloud/relay/sync/index.js.map +1 -0
- package/dist/cloud/relay/usage/index.d.ts +5 -0
- package/dist/cloud/relay/usage/index.d.ts.map +1 -0
- package/dist/cloud/relay/usage/index.js +9 -0
- package/dist/cloud/relay/usage/index.js.map +1 -0
- package/dist/cloud/sponsors.d.ts +81 -0
- package/dist/cloud/sponsors.d.ts.map +1 -0
- package/dist/cloud/sponsors.js +130 -0
- package/dist/cloud/sponsors.js.map +1 -0
- package/dist/cloud/types.d.ts +169 -0
- package/dist/cloud/types.d.ts.map +1 -0
- package/dist/cloud/types.js +7 -0
- package/dist/cloud/types.js.map +1 -0
- package/dist/components/index.d.ts +43 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +17 -0
- package/dist/components/index.js.map +1 -0
- package/dist/core/actors.d.ts +95 -0
- package/dist/core/actors.d.ts.map +1 -0
- package/dist/core/actors.js +158 -0
- package/dist/core/actors.js.map +1 -0
- package/dist/core/component/generator.d.ts +122 -0
- package/dist/core/component/generator.d.ts.map +1 -0
- package/dist/core/component/generator.js +307 -0
- package/dist/core/component/generator.js.map +1 -0
- package/dist/core/engine.d.ts +92 -0
- package/dist/core/engine.d.ts.map +1 -0
- package/dist/core/engine.js +199 -0
- package/dist/core/engine.js.map +1 -0
- package/dist/core/introspection.d.ts +141 -0
- package/dist/core/introspection.d.ts.map +1 -0
- package/dist/core/introspection.js +208 -0
- package/dist/core/introspection.js.map +1 -0
- package/dist/core/logic/generator.d.ts +76 -0
- package/dist/core/logic/generator.d.ts.map +1 -0
- package/dist/core/logic/generator.js +339 -0
- package/dist/core/logic/generator.js.map +1 -0
- package/dist/core/pluresdb/generator.d.ts +58 -0
- package/dist/core/pluresdb/generator.d.ts.map +1 -0
- package/dist/core/pluresdb/generator.js +162 -0
- package/dist/core/pluresdb/generator.js.map +1 -0
- package/dist/core/protocol.d.ts +121 -0
- package/dist/core/protocol.d.ts.map +1 -0
- package/dist/core/protocol.js +46 -0
- package/dist/core/protocol.js.map +1 -0
- package/dist/core/rules.d.ts +120 -0
- package/dist/core/rules.d.ts.map +1 -0
- package/dist/core/rules.js +81 -0
- package/dist/core/rules.js.map +1 -0
- package/dist/core/schema/loader.d.ts +47 -0
- package/dist/core/schema/loader.d.ts.map +1 -0
- package/dist/core/schema/loader.js +189 -0
- package/dist/core/schema/loader.js.map +1 -0
- package/dist/core/schema/normalize.d.ts +72 -0
- package/dist/core/schema/normalize.d.ts.map +1 -0
- package/dist/core/schema/normalize.js +190 -0
- package/dist/core/schema/normalize.js.map +1 -0
- package/dist/core/schema/types.d.ts +370 -0
- package/dist/core/schema/types.d.ts.map +1 -0
- package/dist/core/schema/types.js +161 -0
- package/dist/core/schema/types.js.map +1 -0
- package/dist/dsl/index.d.ts +152 -0
- package/dist/dsl/index.d.ts.map +1 -0
- package/dist/dsl/index.js +132 -0
- package/dist/dsl/index.js.map +1 -0
- package/dist/dsl.d.ts +124 -0
- package/dist/dsl.d.ts.map +1 -0
- package/dist/dsl.js +130 -0
- package/dist/dsl.js.map +1 -0
- package/dist/examples/advanced-todo/index.d.ts +55 -0
- package/dist/examples/advanced-todo/index.d.ts.map +1 -0
- package/dist/examples/advanced-todo/index.js +222 -0
- package/dist/examples/advanced-todo/index.js.map +1 -0
- package/dist/examples/auth-basic/index.d.ts +17 -0
- package/dist/examples/auth-basic/index.d.ts.map +1 -0
- package/dist/examples/auth-basic/index.js +122 -0
- package/dist/examples/auth-basic/index.js.map +1 -0
- package/dist/examples/cart/index.d.ts +19 -0
- package/dist/examples/cart/index.d.ts.map +1 -0
- package/dist/examples/cart/index.js +202 -0
- package/dist/examples/cart/index.js.map +1 -0
- package/dist/examples/hero-ecommerce/index.d.ts +39 -0
- package/dist/examples/hero-ecommerce/index.d.ts.map +1 -0
- package/dist/examples/hero-ecommerce/index.js +506 -0
- package/dist/examples/hero-ecommerce/index.js.map +1 -0
- package/dist/examples/svelte-counter/index.d.ts +31 -0
- package/dist/examples/svelte-counter/index.d.ts.map +1 -0
- package/dist/examples/svelte-counter/index.js +123 -0
- package/dist/examples/svelte-counter/index.js.map +1 -0
- package/dist/flows.d.ts +125 -0
- package/dist/flows.d.ts.map +1 -0
- package/dist/flows.js +160 -0
- package/dist/flows.js.map +1 -0
- package/dist/index.d.ts +67 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +59 -0
- package/dist/index.js.map +1 -0
- package/dist/integrations/pluresdb.d.ts +56 -0
- package/dist/integrations/pluresdb.d.ts.map +1 -0
- package/dist/integrations/pluresdb.js +46 -0
- package/dist/integrations/pluresdb.js.map +1 -0
- package/dist/integrations/svelte.d.ts +306 -0
- package/dist/integrations/svelte.d.ts.map +1 -0
- package/dist/integrations/svelte.js +447 -0
- package/dist/integrations/svelte.js.map +1 -0
- package/dist/registry.d.ts +94 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +181 -0
- package/dist/registry.js.map +1 -0
- package/dist/runtime/terminal-adapter.d.ts +105 -0
- package/dist/runtime/terminal-adapter.d.ts.map +1 -0
- package/dist/runtime/terminal-adapter.js +113 -0
- package/dist/runtime/terminal-adapter.js.map +1 -0
- package/dist/step.d.ts +34 -0
- package/dist/step.d.ts.map +1 -0
- package/dist/step.js +111 -0
- package/dist/step.js.map +1 -0
- package/dist/types.d.ts +63 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +6 -0
- package/dist/types.js.map +1 -0
- package/docs/MONETIZATION.md +394 -0
- package/docs/TERMINAL_NODE.md +588 -0
- package/docs/guides/canvas.md +389 -0
- package/docs/guides/getting-started.md +347 -0
- package/docs/guides/history-state-pattern.md +618 -0
- package/docs/guides/orchestration.md +617 -0
- package/docs/guides/parallel-state-pattern.md +767 -0
- package/docs/guides/svelte-integration.md +691 -0
- package/package.json +96 -0
- package/src/__tests__/actors.test.ts +270 -0
- package/src/__tests__/billing.test.ts +175 -0
- package/src/__tests__/cloud.test.ts +247 -0
- package/src/__tests__/dsl.test.ts +154 -0
- package/src/__tests__/edge-cases.test.ts +475 -0
- package/src/__tests__/engine.test.ts +137 -0
- package/src/__tests__/generators.test.ts +270 -0
- package/src/__tests__/introspection.test.ts +321 -0
- package/src/__tests__/protocol.test.ts +40 -0
- package/src/__tests__/provisioning.test.ts +162 -0
- package/src/__tests__/schema.test.ts +241 -0
- package/src/__tests__/svelte-integration.test.ts +431 -0
- package/src/__tests__/terminal-node.test.ts +352 -0
- package/src/adapters/cli.ts +175 -0
- package/src/cli/commands/auth.ts +271 -0
- package/src/cli/commands/cloud.ts +281 -0
- package/src/cli/commands/generate.ts +225 -0
- package/src/cli/index.ts +190 -0
- package/src/cloud/README.md +383 -0
- package/src/cloud/auth.ts +245 -0
- package/src/cloud/billing.ts +336 -0
- package/src/cloud/client.ts +221 -0
- package/src/cloud/index.ts +121 -0
- package/src/cloud/marketplace.ts +303 -0
- package/src/cloud/provisioning.ts +254 -0
- package/src/cloud/relay/endpoints.ts +307 -0
- package/src/cloud/relay/health/function.json +17 -0
- package/src/cloud/relay/health/index.ts +10 -0
- package/src/cloud/relay/host.json +15 -0
- package/src/cloud/relay/local.settings.json +8 -0
- package/src/cloud/relay/stats/function.json +17 -0
- package/src/cloud/relay/stats/index.ts +10 -0
- package/src/cloud/relay/sync/function.json +17 -0
- package/src/cloud/relay/sync/index.ts +10 -0
- package/src/cloud/relay/usage/function.json +17 -0
- package/src/cloud/relay/usage/index.ts +10 -0
- package/src/cloud/sponsors.ts +213 -0
- package/src/cloud/types.ts +198 -0
- package/src/components/README.md +125 -0
- package/src/components/TerminalNode.svelte +457 -0
- package/src/components/index.ts +46 -0
- package/src/core/actors.ts +205 -0
- package/src/core/component/generator.ts +432 -0
- package/src/core/engine.ts +243 -0
- package/src/core/introspection.ts +329 -0
- package/src/core/logic/generator.ts +420 -0
- package/src/core/pluresdb/generator.ts +229 -0
- package/src/core/protocol.ts +132 -0
- package/src/core/rules.ts +167 -0
- package/src/core/schema/loader.ts +247 -0
- package/src/core/schema/normalize.ts +322 -0
- package/src/core/schema/types.ts +557 -0
- package/src/dsl/index.ts +218 -0
- package/src/dsl.ts +214 -0
- package/src/examples/advanced-todo/App.svelte +506 -0
- package/src/examples/advanced-todo/README.md +371 -0
- package/src/examples/advanced-todo/index.ts +309 -0
- package/src/examples/auth-basic/index.ts +163 -0
- package/src/examples/cart/index.ts +259 -0
- package/src/examples/hero-ecommerce/index.ts +657 -0
- package/src/examples/svelte-counter/index.ts +168 -0
- package/src/flows.ts +268 -0
- package/src/index.ts +154 -0
- package/src/integrations/pluresdb.ts +93 -0
- package/src/integrations/svelte.ts +617 -0
- package/src/registry.ts +223 -0
- package/src/runtime/terminal-adapter.ts +175 -0
- package/src/step.ts +151 -0
- package/src/types.ts +70 -0
- package/templates/basic-app/README.md +147 -0
- package/templates/fullstack-app/README.md +279 -0
|
@@ -0,0 +1,389 @@
|
|
|
1
|
+
# CodeCanvas Integration Guide
|
|
2
|
+
|
|
3
|
+
CodeCanvas is the visual IDE for the Praxis framework. It provides a graphical interface for designing schemas, logic flows, and components.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
CodeCanvas enables:
|
|
8
|
+
- **Visual Schema Design**: Drag-and-drop model and component design
|
|
9
|
+
- **Logic Flow Editor**: Build rules and state machines visually
|
|
10
|
+
- **Component Preview**: See generated components in real-time
|
|
11
|
+
- **Orchestration Visualization**: Visualize distributed systems
|
|
12
|
+
- **Documentation Navigation**: Interactive documentation browser
|
|
13
|
+
|
|
14
|
+
## Getting Started
|
|
15
|
+
|
|
16
|
+
### Launch Canvas
|
|
17
|
+
|
|
18
|
+
From your Praxis project:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
praxis canvas src/schemas/app.schema.ts
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
This opens Canvas at http://localhost:3000 with your schema loaded.
|
|
25
|
+
|
|
26
|
+
### Create New Schema
|
|
27
|
+
|
|
28
|
+
Start Canvas without a schema:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
praxis canvas --new
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Canvas Features
|
|
35
|
+
|
|
36
|
+
### 1. Schema Editor
|
|
37
|
+
|
|
38
|
+
**Model Designer**:
|
|
39
|
+
- Drag models onto canvas
|
|
40
|
+
- Define fields with visual editor
|
|
41
|
+
- Set relationships between models
|
|
42
|
+
- Configure indexes and constraints
|
|
43
|
+
- Preview generated PluresDB schema
|
|
44
|
+
|
|
45
|
+
**Component Designer**:
|
|
46
|
+
- Create components from templates
|
|
47
|
+
- Bind components to models
|
|
48
|
+
- Configure props and events
|
|
49
|
+
- Design layout visually
|
|
50
|
+
- Preview generated Svelte components
|
|
51
|
+
|
|
52
|
+
### 2. Logic Flow Editor
|
|
53
|
+
|
|
54
|
+
**Flow Canvas**:
|
|
55
|
+
- Visual state machine designer
|
|
56
|
+
- Connect facts, events, and rules
|
|
57
|
+
- Define transitions with conditions
|
|
58
|
+
- Test flows interactively
|
|
59
|
+
- Export to Praxis logic code
|
|
60
|
+
|
|
61
|
+
**Rule Builder**:
|
|
62
|
+
- Visual rule editor
|
|
63
|
+
- Condition builder with drag-and-drop
|
|
64
|
+
- Action designer
|
|
65
|
+
- Priority management
|
|
66
|
+
- Constraint visualization
|
|
67
|
+
|
|
68
|
+
### 3. Component Preview
|
|
69
|
+
|
|
70
|
+
**Live Preview**:
|
|
71
|
+
- Real-time component rendering
|
|
72
|
+
- Interactive component testing
|
|
73
|
+
- Props editor
|
|
74
|
+
- Event logging
|
|
75
|
+
- Responsive preview modes
|
|
76
|
+
|
|
77
|
+
**Code Sync**:
|
|
78
|
+
- Two-way sync with files
|
|
79
|
+
- Live reload on changes
|
|
80
|
+
- Conflict resolution
|
|
81
|
+
- Version history
|
|
82
|
+
|
|
83
|
+
### 4. Orchestration View
|
|
84
|
+
|
|
85
|
+
**System Topology**:
|
|
86
|
+
- Node visualization
|
|
87
|
+
- Connection mapping
|
|
88
|
+
- State distribution view
|
|
89
|
+
- Health monitoring
|
|
90
|
+
- Performance metrics
|
|
91
|
+
|
|
92
|
+
**DSC Designer**:
|
|
93
|
+
- Visual DSC configuration
|
|
94
|
+
- Node role assignment
|
|
95
|
+
- State sync configuration
|
|
96
|
+
- Health check setup
|
|
97
|
+
|
|
98
|
+
### 5. Documentation Browser
|
|
99
|
+
|
|
100
|
+
**Interactive Docs**:
|
|
101
|
+
- Schema documentation
|
|
102
|
+
- API reference
|
|
103
|
+
- Component catalog
|
|
104
|
+
- Logic flow diagrams
|
|
105
|
+
- Generated from State-Docs
|
|
106
|
+
|
|
107
|
+
## Workflows
|
|
108
|
+
|
|
109
|
+
### Visual-First Workflow
|
|
110
|
+
|
|
111
|
+
1. Design schema in Canvas
|
|
112
|
+
2. Generate code with `praxis generate`
|
|
113
|
+
3. Customize generated code
|
|
114
|
+
4. Preview in Canvas
|
|
115
|
+
5. Deploy
|
|
116
|
+
|
|
117
|
+
### Code-First Workflow
|
|
118
|
+
|
|
119
|
+
1. Write schema in TypeScript
|
|
120
|
+
2. Open in Canvas for visualization
|
|
121
|
+
3. Make visual adjustments in Canvas
|
|
122
|
+
4. Sync changes back to code
|
|
123
|
+
5. Continue development
|
|
124
|
+
|
|
125
|
+
### Hybrid Workflow
|
|
126
|
+
|
|
127
|
+
1. Start with visual design
|
|
128
|
+
2. Export to code
|
|
129
|
+
3. Add custom logic in code
|
|
130
|
+
4. Use Canvas for visualization
|
|
131
|
+
5. Iterate between visual and code
|
|
132
|
+
|
|
133
|
+
## Configuration
|
|
134
|
+
|
|
135
|
+
### Canvas Config File
|
|
136
|
+
|
|
137
|
+
Create `canvas.config.ts`:
|
|
138
|
+
|
|
139
|
+
```typescript
|
|
140
|
+
import type { CanvasConfig } from '@plures/praxis/canvas';
|
|
141
|
+
|
|
142
|
+
export const config: CanvasConfig = {
|
|
143
|
+
// Server settings
|
|
144
|
+
port: 3000,
|
|
145
|
+
host: 'localhost',
|
|
146
|
+
|
|
147
|
+
// Editor settings
|
|
148
|
+
mode: 'edit', // 'edit' | 'view' | 'present'
|
|
149
|
+
theme: 'dark', // 'light' | 'dark' | 'auto'
|
|
150
|
+
|
|
151
|
+
// Features
|
|
152
|
+
features: {
|
|
153
|
+
collaboration: true,
|
|
154
|
+
autosave: true,
|
|
155
|
+
versionHistory: true,
|
|
156
|
+
aiAssist: false,
|
|
157
|
+
},
|
|
158
|
+
|
|
159
|
+
// Preview settings
|
|
160
|
+
preview: {
|
|
161
|
+
autoRefresh: true,
|
|
162
|
+
refreshInterval: 1000,
|
|
163
|
+
iframe: true,
|
|
164
|
+
},
|
|
165
|
+
|
|
166
|
+
// Code sync
|
|
167
|
+
sync: {
|
|
168
|
+
enabled: true,
|
|
169
|
+
watchFiles: true,
|
|
170
|
+
conflictResolution: 'ask', // 'ask' | 'canvas' | 'code'
|
|
171
|
+
},
|
|
172
|
+
|
|
173
|
+
// Export settings
|
|
174
|
+
export: {
|
|
175
|
+
format: 'typescript',
|
|
176
|
+
includeComments: true,
|
|
177
|
+
formatting: 'prettier',
|
|
178
|
+
},
|
|
179
|
+
};
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### Launch with Config
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
praxis canvas --config canvas.config.ts
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
## Collaboration
|
|
189
|
+
|
|
190
|
+
### Real-Time Collaboration
|
|
191
|
+
|
|
192
|
+
Enable in config:
|
|
193
|
+
|
|
194
|
+
```typescript
|
|
195
|
+
features: {
|
|
196
|
+
collaboration: true,
|
|
197
|
+
}
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
Share Canvas URL with team members. Changes sync in real-time.
|
|
201
|
+
|
|
202
|
+
### Permissions
|
|
203
|
+
|
|
204
|
+
Configure access:
|
|
205
|
+
|
|
206
|
+
```typescript
|
|
207
|
+
collaboration: {
|
|
208
|
+
enabled: true,
|
|
209
|
+
permissions: {
|
|
210
|
+
view: ['*'],
|
|
211
|
+
edit: ['team@example.com'],
|
|
212
|
+
admin: ['owner@example.com'],
|
|
213
|
+
},
|
|
214
|
+
}
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
## Keyboard Shortcuts
|
|
218
|
+
|
|
219
|
+
- `Ctrl/Cmd + N`: New model
|
|
220
|
+
- `Ctrl/Cmd + C`: Create component
|
|
221
|
+
- `Ctrl/Cmd + R`: Add rule
|
|
222
|
+
- `Ctrl/Cmd + S`: Save
|
|
223
|
+
- `Ctrl/Cmd + G`: Generate code
|
|
224
|
+
- `Ctrl/Cmd + P`: Preview component
|
|
225
|
+
- `Ctrl/Cmd + /`: Command palette
|
|
226
|
+
- `Space`: Pan canvas
|
|
227
|
+
- `+/-`: Zoom in/out
|
|
228
|
+
|
|
229
|
+
## Tips & Tricks
|
|
230
|
+
|
|
231
|
+
### Efficient Model Design
|
|
232
|
+
|
|
233
|
+
1. Start with core models
|
|
234
|
+
2. Add fields incrementally
|
|
235
|
+
3. Use Canvas to visualize relationships
|
|
236
|
+
4. Generate early and often
|
|
237
|
+
5. Iterate based on generated code
|
|
238
|
+
|
|
239
|
+
### Logic Flow Design
|
|
240
|
+
|
|
241
|
+
1. Map business processes first
|
|
242
|
+
2. Identify key events
|
|
243
|
+
3. Define facts that matter
|
|
244
|
+
4. Connect with rules
|
|
245
|
+
5. Test flows in Canvas
|
|
246
|
+
|
|
247
|
+
### Component Design
|
|
248
|
+
|
|
249
|
+
1. Use templates as starting points
|
|
250
|
+
2. Preview frequently
|
|
251
|
+
3. Test with different data
|
|
252
|
+
4. Sync to code for styling
|
|
253
|
+
5. Maintain separation of concerns
|
|
254
|
+
|
|
255
|
+
## Integration with VS Code
|
|
256
|
+
|
|
257
|
+
### Canvas Extension
|
|
258
|
+
|
|
259
|
+
Install the Praxis Canvas extension:
|
|
260
|
+
|
|
261
|
+
```bash
|
|
262
|
+
code --install-extension plures.praxis-canvas
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
Features:
|
|
266
|
+
- Open Canvas from editor
|
|
267
|
+
- Inline previews
|
|
268
|
+
- Quick navigation
|
|
269
|
+
- Code snippets
|
|
270
|
+
|
|
271
|
+
## Troubleshooting
|
|
272
|
+
|
|
273
|
+
### Canvas won't start
|
|
274
|
+
|
|
275
|
+
Check:
|
|
276
|
+
- Port 3000 is available
|
|
277
|
+
- Schema file path is correct
|
|
278
|
+
- Dependencies are installed
|
|
279
|
+
|
|
280
|
+
### Changes not syncing
|
|
281
|
+
|
|
282
|
+
Solutions:
|
|
283
|
+
- Enable sync in config
|
|
284
|
+
- Check file permissions
|
|
285
|
+
- Restart Canvas with `--force-sync`
|
|
286
|
+
|
|
287
|
+
### Preview not updating
|
|
288
|
+
|
|
289
|
+
Try:
|
|
290
|
+
- Clear browser cache
|
|
291
|
+
- Disable ad blockers
|
|
292
|
+
- Check preview refresh settings
|
|
293
|
+
|
|
294
|
+
## Advanced Features
|
|
295
|
+
|
|
296
|
+
### Custom Templates
|
|
297
|
+
|
|
298
|
+
Add custom component templates:
|
|
299
|
+
|
|
300
|
+
```typescript
|
|
301
|
+
canvas: {
|
|
302
|
+
templates: {
|
|
303
|
+
components: [
|
|
304
|
+
{
|
|
305
|
+
name: 'CustomForm',
|
|
306
|
+
template: './templates/custom-form.svelte',
|
|
307
|
+
thumbnail: './templates/custom-form.png',
|
|
308
|
+
},
|
|
309
|
+
],
|
|
310
|
+
},
|
|
311
|
+
}
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
### Plugins
|
|
315
|
+
|
|
316
|
+
Extend Canvas with plugins:
|
|
317
|
+
|
|
318
|
+
```typescript
|
|
319
|
+
canvas: {
|
|
320
|
+
plugins: [
|
|
321
|
+
'@plures/canvas-plugin-figma',
|
|
322
|
+
'@plures/canvas-plugin-storybook',
|
|
323
|
+
'./plugins/custom-plugin.ts',
|
|
324
|
+
],
|
|
325
|
+
}
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
### AI Assistance
|
|
329
|
+
|
|
330
|
+
Enable AI features:
|
|
331
|
+
|
|
332
|
+
```typescript
|
|
333
|
+
features: {
|
|
334
|
+
aiAssist: true,
|
|
335
|
+
}
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
AI can:
|
|
339
|
+
- Suggest models from descriptions
|
|
340
|
+
- Generate rules from natural language
|
|
341
|
+
- Optimize logic flows
|
|
342
|
+
- Recommend component layouts
|
|
343
|
+
|
|
344
|
+
## Export Options
|
|
345
|
+
|
|
346
|
+
### Export to Code
|
|
347
|
+
|
|
348
|
+
```bash
|
|
349
|
+
# From Canvas UI: File > Export > TypeScript
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
Or via CLI:
|
|
353
|
+
|
|
354
|
+
```bash
|
|
355
|
+
praxis export --source canvas --format typescript
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
### Export Diagrams
|
|
359
|
+
|
|
360
|
+
Export visual diagrams:
|
|
361
|
+
- PNG/SVG for documentation
|
|
362
|
+
- Mermaid for markdown
|
|
363
|
+
- DOT for Graphviz
|
|
364
|
+
- PDF for presentations
|
|
365
|
+
|
|
366
|
+
### Export Documentation
|
|
367
|
+
|
|
368
|
+
Generate State-Docs from Canvas:
|
|
369
|
+
|
|
370
|
+
```bash
|
|
371
|
+
praxis docs --source canvas
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
## Next Steps
|
|
375
|
+
|
|
376
|
+
- Explore example Canvas projects
|
|
377
|
+
- Try collaborative editing
|
|
378
|
+
- Customize with plugins
|
|
379
|
+
- Integrate with CI/CD
|
|
380
|
+
- Share your Canvas templates
|
|
381
|
+
|
|
382
|
+
## Resources
|
|
383
|
+
|
|
384
|
+
- [Canvas Examples](../../examples/canvas/)
|
|
385
|
+
- [Plugin Development](../api/canvas-plugins.md)
|
|
386
|
+
- [Canvas API Reference](../api/canvas-api.md)
|
|
387
|
+
- [Video Tutorials](https://youtube.com/plures)
|
|
388
|
+
|
|
389
|
+
Canvas makes Praxis development visual, collaborative, and fun! 🎨
|
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
# Getting Started with Praxis Framework
|
|
2
|
+
|
|
3
|
+
Welcome to Praxis, the full-stack application framework for the Plures ecosystem! This guide will help you get started building modern, local-first, distributed applications.
|
|
4
|
+
|
|
5
|
+
## What is Praxis?
|
|
6
|
+
|
|
7
|
+
Praxis is a **schema-driven framework** that unifies:
|
|
8
|
+
- **Logic Engine**: Facts, events, rules, and constraints for business logic
|
|
9
|
+
- **Component Generation**: Auto-generate UI from schemas
|
|
10
|
+
- **Local-First Data**: PluresDB for reactive, offline-capable storage
|
|
11
|
+
- **Visual Development**: CodeCanvas for schema and logic editing
|
|
12
|
+
- **Orchestration**: Distributed system coordination with DSC/MCP
|
|
13
|
+
- **Documentation**: Automatic State-Docs generation
|
|
14
|
+
|
|
15
|
+
## Prerequisites
|
|
16
|
+
|
|
17
|
+
- Node.js 18+ and npm
|
|
18
|
+
- Basic TypeScript knowledge
|
|
19
|
+
- Familiarity with Svelte (for UI)
|
|
20
|
+
- Git for version control
|
|
21
|
+
|
|
22
|
+
## Installation
|
|
23
|
+
|
|
24
|
+
### Install Praxis CLI
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
npm install -g @plures/praxis
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Verify installation:
|
|
31
|
+
```bash
|
|
32
|
+
praxis --version
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Create Your First App
|
|
36
|
+
|
|
37
|
+
### 1. Create a new project
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
praxis create app my-first-app
|
|
41
|
+
cd my-first-app
|
|
42
|
+
npm install
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
This creates a basic Praxis app with:
|
|
46
|
+
- Schema setup
|
|
47
|
+
- Logic engine configuration
|
|
48
|
+
- Svelte UI scaffolding
|
|
49
|
+
- PluresDB integration
|
|
50
|
+
- Development scripts
|
|
51
|
+
|
|
52
|
+
### 2. Explore the structure
|
|
53
|
+
|
|
54
|
+
```
|
|
55
|
+
my-first-app/
|
|
56
|
+
├── src/
|
|
57
|
+
│ ├── schemas/
|
|
58
|
+
│ │ └── app.schema.ts # Your app schema
|
|
59
|
+
│ ├── logic/
|
|
60
|
+
│ │ └── engine.ts # Logic engine setup
|
|
61
|
+
│ ├── components/ # UI components
|
|
62
|
+
│ ├── store/ # Data store
|
|
63
|
+
│ └── main.ts # Entry point
|
|
64
|
+
├── package.json
|
|
65
|
+
└── README.md
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### 3. Define your schema
|
|
69
|
+
|
|
70
|
+
Open `src/schemas/app.schema.ts`:
|
|
71
|
+
|
|
72
|
+
```typescript
|
|
73
|
+
import type { PraxisSchema } from '@plures/praxis/schema';
|
|
74
|
+
|
|
75
|
+
export const appSchema: PraxisSchema = {
|
|
76
|
+
version: '1.0.0',
|
|
77
|
+
name: 'MyFirstApp',
|
|
78
|
+
description: 'My first Praxis application',
|
|
79
|
+
|
|
80
|
+
// Define data models
|
|
81
|
+
models: [
|
|
82
|
+
{
|
|
83
|
+
name: 'Task',
|
|
84
|
+
description: 'A task item',
|
|
85
|
+
fields: [
|
|
86
|
+
{ name: 'id', type: 'string', description: 'Unique identifier' },
|
|
87
|
+
{ name: 'title', type: 'string', description: 'Task title' },
|
|
88
|
+
{ name: 'completed', type: 'boolean', default: false },
|
|
89
|
+
{ name: 'createdAt', type: 'date' },
|
|
90
|
+
],
|
|
91
|
+
indexes: [
|
|
92
|
+
{ name: 'by_created', fields: ['createdAt'] },
|
|
93
|
+
],
|
|
94
|
+
},
|
|
95
|
+
],
|
|
96
|
+
|
|
97
|
+
// Define UI components
|
|
98
|
+
components: [
|
|
99
|
+
{
|
|
100
|
+
name: 'TaskForm',
|
|
101
|
+
type: 'form',
|
|
102
|
+
model: 'Task',
|
|
103
|
+
description: 'Form for creating/editing tasks',
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
name: 'TaskList',
|
|
107
|
+
type: 'list',
|
|
108
|
+
model: 'Task',
|
|
109
|
+
description: 'List of all tasks',
|
|
110
|
+
},
|
|
111
|
+
],
|
|
112
|
+
|
|
113
|
+
// Define business logic
|
|
114
|
+
logic: [
|
|
115
|
+
{
|
|
116
|
+
id: 'task-logic',
|
|
117
|
+
description: 'Task management logic',
|
|
118
|
+
events: [
|
|
119
|
+
{
|
|
120
|
+
tag: 'TASK_CREATE',
|
|
121
|
+
payload: { title: 'string' },
|
|
122
|
+
description: 'Create a new task',
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
tag: 'TASK_COMPLETE',
|
|
126
|
+
payload: { taskId: 'string' },
|
|
127
|
+
description: 'Mark task as completed',
|
|
128
|
+
},
|
|
129
|
+
],
|
|
130
|
+
facts: [
|
|
131
|
+
{
|
|
132
|
+
tag: 'TaskCreated',
|
|
133
|
+
payload: { taskId: 'string', title: 'string' },
|
|
134
|
+
description: 'A task was created',
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
tag: 'TaskCompleted',
|
|
138
|
+
payload: { taskId: 'string' },
|
|
139
|
+
description: 'A task was completed',
|
|
140
|
+
},
|
|
141
|
+
],
|
|
142
|
+
rules: [
|
|
143
|
+
{
|
|
144
|
+
id: 'create-task',
|
|
145
|
+
description: 'Create a task when TASK_CREATE event occurs',
|
|
146
|
+
on: ['TASK_CREATE'],
|
|
147
|
+
then: 'emit TaskCreated fact',
|
|
148
|
+
priority: 10,
|
|
149
|
+
},
|
|
150
|
+
],
|
|
151
|
+
constraints: [
|
|
152
|
+
{
|
|
153
|
+
id: 'task-title-required',
|
|
154
|
+
description: 'Task title must not be empty',
|
|
155
|
+
check: 'title.length > 0',
|
|
156
|
+
message: 'Task title is required',
|
|
157
|
+
},
|
|
158
|
+
],
|
|
159
|
+
},
|
|
160
|
+
],
|
|
161
|
+
};
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### 4. Generate code from schema
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
praxis generate --schema src/schemas/app.schema.ts
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
This generates:
|
|
171
|
+
- `src/components/TaskForm.svelte` - Form component
|
|
172
|
+
- `src/components/TaskList.svelte` - List component
|
|
173
|
+
- `src/logic/facts.ts` - Fact definitions
|
|
174
|
+
- `src/logic/events.ts` - Event definitions
|
|
175
|
+
- `src/logic/rules.ts` - Rule implementations
|
|
176
|
+
- TypeScript types throughout
|
|
177
|
+
|
|
178
|
+
### 5. Implement custom logic
|
|
179
|
+
|
|
180
|
+
The generator creates stubs that you can customize. Edit `src/logic/rules.ts`:
|
|
181
|
+
|
|
182
|
+
```typescript
|
|
183
|
+
import { defineRule } from '@plures/praxis';
|
|
184
|
+
import { TaskCreated } from './facts';
|
|
185
|
+
import { TASK_CREATE } from './events';
|
|
186
|
+
|
|
187
|
+
export const createTaskRule = defineRule({
|
|
188
|
+
id: 'create-task',
|
|
189
|
+
description: 'Create a task when TASK_CREATE event occurs',
|
|
190
|
+
impl: (state, events) => {
|
|
191
|
+
const createEvent = events.find(TASK_CREATE.is);
|
|
192
|
+
if (createEvent) {
|
|
193
|
+
const taskId = crypto.randomUUID();
|
|
194
|
+
return [
|
|
195
|
+
TaskCreated.create({
|
|
196
|
+
taskId,
|
|
197
|
+
title: createEvent.payload.title,
|
|
198
|
+
}),
|
|
199
|
+
];
|
|
200
|
+
}
|
|
201
|
+
return [];
|
|
202
|
+
},
|
|
203
|
+
});
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
### 6. Wire up the UI
|
|
207
|
+
|
|
208
|
+
Edit `src/App.svelte`:
|
|
209
|
+
|
|
210
|
+
```svelte
|
|
211
|
+
<script lang="ts">
|
|
212
|
+
import { createPraxisStore } from '@plures/praxis/svelte';
|
|
213
|
+
import { engine } from './logic/engine';
|
|
214
|
+
import TaskForm from './components/TaskForm.svelte';
|
|
215
|
+
import TaskList from './components/TaskList.svelte';
|
|
216
|
+
|
|
217
|
+
const store = createPraxisStore(engine);
|
|
218
|
+
</script>
|
|
219
|
+
|
|
220
|
+
<main>
|
|
221
|
+
<h1>My Task App</h1>
|
|
222
|
+
<TaskForm />
|
|
223
|
+
<TaskList />
|
|
224
|
+
</main>
|
|
225
|
+
|
|
226
|
+
<style>
|
|
227
|
+
main {
|
|
228
|
+
max-width: 800px;
|
|
229
|
+
margin: 0 auto;
|
|
230
|
+
padding: 2rem;
|
|
231
|
+
}
|
|
232
|
+
</style>
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
### 7. Run the development server
|
|
236
|
+
|
|
237
|
+
```bash
|
|
238
|
+
npm run dev
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
Open http://localhost:5173 to see your app!
|
|
242
|
+
|
|
243
|
+
## Core Concepts
|
|
244
|
+
|
|
245
|
+
### Schemas
|
|
246
|
+
|
|
247
|
+
Schemas are the single source of truth. They define:
|
|
248
|
+
- **Models**: Data structures and relationships
|
|
249
|
+
- **Components**: UI elements and their behavior
|
|
250
|
+
- **Logic**: Facts, events, rules, and constraints
|
|
251
|
+
- **Orchestration**: Distributed coordination (optional)
|
|
252
|
+
|
|
253
|
+
### Logic Engine
|
|
254
|
+
|
|
255
|
+
The Praxis logic engine processes:
|
|
256
|
+
- **Events**: Things that happen (user actions, external triggers)
|
|
257
|
+
- **Facts**: Derived information about the domain
|
|
258
|
+
- **Rules**: Pure functions that transform events into facts
|
|
259
|
+
- **Constraints**: Invariants that must always hold
|
|
260
|
+
|
|
261
|
+
### Component Generation
|
|
262
|
+
|
|
263
|
+
Components are generated from schemas but can be customized:
|
|
264
|
+
- Generated components provide scaffolding
|
|
265
|
+
- Extend with custom behavior and styling
|
|
266
|
+
- Regenerate safely (customizations preserved in separate files)
|
|
267
|
+
|
|
268
|
+
### Local-First Data
|
|
269
|
+
|
|
270
|
+
PluresDB provides:
|
|
271
|
+
- Reactive data storage
|
|
272
|
+
- Offline operation
|
|
273
|
+
- Automatic sync when connected
|
|
274
|
+
- Conflict resolution
|
|
275
|
+
|
|
276
|
+
## Next Steps
|
|
277
|
+
|
|
278
|
+
### Visual Editing with Canvas
|
|
279
|
+
|
|
280
|
+
```bash
|
|
281
|
+
praxis canvas src/schemas/app.schema.ts
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
Opens CodeCanvas at http://localhost:3000 for visual schema editing.
|
|
285
|
+
|
|
286
|
+
### Add Authentication
|
|
287
|
+
|
|
288
|
+
```bash
|
|
289
|
+
praxis create component Auth --template auth
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
Generates authentication components and logic.
|
|
293
|
+
|
|
294
|
+
### Enable Documentation
|
|
295
|
+
|
|
296
|
+
State-Docs automatically generates documentation from your schemas:
|
|
297
|
+
|
|
298
|
+
```bash
|
|
299
|
+
npm run docs
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
View at http://localhost:3001
|
|
303
|
+
|
|
304
|
+
### Deploy
|
|
305
|
+
|
|
306
|
+
Build for production:
|
|
307
|
+
|
|
308
|
+
```bash
|
|
309
|
+
npm run build
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
Deploy the `dist/` folder to your hosting provider.
|
|
313
|
+
|
|
314
|
+
## Examples
|
|
315
|
+
|
|
316
|
+
Check out the examples in the Praxis repository:
|
|
317
|
+
|
|
318
|
+
- **Offline-First Chat**: Demonstrates local-first architecture
|
|
319
|
+
- **Knowledge Canvas**: Shows Canvas integration
|
|
320
|
+
- **E-Commerce**: Full-featured example with auth and cart
|
|
321
|
+
|
|
322
|
+
## Resources
|
|
323
|
+
|
|
324
|
+
- [Framework Architecture](./FRAMEWORK.md)
|
|
325
|
+
- [Schema Reference](../api/schema.md)
|
|
326
|
+
- [Logic Engine Guide](../api/logic.md)
|
|
327
|
+
- [Component Generation](../api/components.md)
|
|
328
|
+
- [Praxis Repository](https://github.com/plures/praxis)
|
|
329
|
+
|
|
330
|
+
## Getting Help
|
|
331
|
+
|
|
332
|
+
- GitHub Issues: Report bugs and request features
|
|
333
|
+
- Discussions: Ask questions and share your projects
|
|
334
|
+
- Discord: Join the Plures community
|
|
335
|
+
|
|
336
|
+
## What's Next?
|
|
337
|
+
|
|
338
|
+
Now that you have a basic app running:
|
|
339
|
+
|
|
340
|
+
1. Explore the generated code
|
|
341
|
+
2. Add more models and components
|
|
342
|
+
3. Implement complex business logic
|
|
343
|
+
4. Try visual editing with Canvas
|
|
344
|
+
5. Enable orchestration for distributed features
|
|
345
|
+
6. Build something amazing!
|
|
346
|
+
|
|
347
|
+
Welcome to the Praxis framework! 🚀
|