Skip to content

Commit 3acc2c5

Browse files
Set up multi-root documentation structure with framework, guides, and api roots
Co-authored-by: xuyushun441-sys <255036401+xuyushun441-sys@users.noreply.github.com>
1 parent 1fe5e07 commit 3acc2c5

61 files changed

Lines changed: 8495 additions & 3 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

content/api/index.mdx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
title: "API Reference"
3+
description: Complete API reference for ObjectStack components
4+
---
5+
6+
# API Reference
7+
8+
Complete API documentation for all ObjectStack components and protocols.
9+
10+
## Coming Soon
11+
12+
This section is currently under development. Check back soon for:
13+
14+
- ObjectQL API Reference
15+
- ObjectUI API Reference
16+
- ObjectOS API Reference
17+
- Protocol Specifications
18+
- SDK Documentation

content/api/meta.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"title": "API Reference",
3+
"pages": [
4+
"index"
5+
]
6+
}
Lines changed: 373 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,373 @@
1+
---
2+
title: The AI Codex
3+
description: Best practices for AI-assisted ObjectStack development
4+
---
5+
6+
# The AI Codex
7+
8+
This guide helps developers leverage AI tools to enhance ObjectStack development efficiency.
9+
10+
## Why AI Collaboration
11+
12+
ObjectStack, as a protocol-driven platform, involves a lot of:
13+
- Schema definitions
14+
- UI protocol configurations
15+
- Repetitive CRUD code
16+
- API documentation generation
17+
18+
These are all well-suited for AI assistance, significantly improving development efficiency.
19+
20+
## Core Terminology
21+
22+
Using consistent terminology when collaborating with AI is crucial. Here are ObjectStack's core terms:
23+
24+
### Data Layer Terms
25+
26+
- **Schema**: Data model definition in JSON format describing table structure
27+
- **Object**: Business object, corresponding to database table
28+
- **Field**: Object field, corresponding to database column
29+
- **Reference**: Relationship field, used to establish associations between objects
30+
- **Virtual Field**: Computed field not stored in database
31+
32+
### Query Layer Terms
33+
34+
- **ObjectQL**: Unified cross-database query language
35+
- **Query DSL**: Query Domain-Specific Language
36+
- **Filter**: Query filter conditions
37+
- **Aggregation**: Aggregation queries
38+
- **Driver**: Database driver, e.g., `@objectql/driver-mysql`
39+
40+
### UI Layer Terms
41+
42+
- **ObjectUI**: JSON-driven UI protocol
43+
- **Component**: Components like Form, Table, Card, etc.
44+
- **Action**: Interactive actions like API requests, page navigation, etc.
45+
- **Renderer**: Converts JSON protocol to actual UI
46+
47+
### Platform Layer Terms
48+
49+
- **ObjectOS**: Runtime platform
50+
- **Plugin**: Extension for functionality
51+
- **Hook**: Lifecycle hooks like beforeInsert, afterUpdate
52+
- **RBAC**: Role-Based Access Control
53+
- **FLS**: Field-Level Security
54+
55+
## AI-Assisted Schema Design
56+
57+
### Prompt Template
58+
59+
```
60+
I need to create a Schema for [business scenario] in ObjectStack.
61+
62+
Business requirements:
63+
- [Requirement 1]
64+
- [Requirement 2]
65+
- [Requirement 3]
66+
67+
Please generate a JSON Schema compliant with ObjectStack specifications, including:
68+
1. All necessary field definitions
69+
2. Field types (text, number, date, reference, etc.)
70+
3. Field constraints (required, unique, etc.)
71+
4. Relationship definitions between objects
72+
```
73+
74+
### Example Conversation
75+
76+
**User**:
77+
```
78+
I need to create a Schema for an e-commerce order management system in ObjectStack.
79+
80+
Business requirements:
81+
- Manage customer information (name, phone, email)
82+
- Manage product information (name, price, stock)
83+
- Manage orders (order number, customer, product list, total amount, status)
84+
- Order statuses include: pending, paid, shipped, completed, cancelled
85+
86+
Please generate a JSON Schema compliant with ObjectStack specifications.
87+
```
88+
89+
**AI Response**:
90+
```json
91+
{
92+
"objects": {
93+
"customers": {
94+
"label": "Customer",
95+
"fields": {
96+
"name": { "type": "text", "label": "Name", "required": true },
97+
"phone": { "type": "text", "label": "Phone" },
98+
"email": { "type": "email", "label": "Email", "unique": true }
99+
}
100+
},
101+
"products": {
102+
"label": "Product",
103+
"fields": {
104+
"name": { "type": "text", "label": "Product Name", "required": true },
105+
"price": { "type": "number", "label": "Price", "required": true },
106+
"stock": { "type": "number", "label": "Stock", "default": 0 }
107+
}
108+
},
109+
"orders": {
110+
"label": "Order",
111+
"fields": {
112+
"order_no": { "type": "text", "label": "Order Number", "unique": true },
113+
"customer": { "type": "reference", "ref": "customers", "label": "Customer" },
114+
"items": { "type": "grid", "label": "Order Items", "fields": {
115+
"product": { "type": "reference", "ref": "products" },
116+
"quantity": { "type": "number", "default": 1 },
117+
"price": { "type": "number" }
118+
}},
119+
"total": { "type": "number", "label": "Total Amount" },
120+
"status": {
121+
"type": "select",
122+
"label": "Status",
123+
"options": ["pending", "paid", "shipped", "completed", "cancelled"],
124+
"default": "pending"
125+
}
126+
}
127+
}
128+
}
129+
}
130+
```
131+
132+
## AI-Assisted UI Protocol Generation
133+
134+
### Prompt Template
135+
136+
```
137+
I need to create ObjectUI protocol for [object name].
138+
139+
UI requirements:
140+
- [UI requirement 1]
141+
- [UI requirement 2]
142+
143+
Please generate JSON protocol compliant with ObjectStack ObjectUI specifications.
144+
```
145+
146+
### Example Conversation
147+
148+
**User**:
149+
```
150+
I need to create a list page and detail form for the orders object.
151+
152+
UI requirements:
153+
- List page displays order number, customer name, total amount, status
154+
- Support filtering by status
155+
- Clicking an order shows details
156+
- Detail form can edit order status
157+
```
158+
159+
**AI Response**:
160+
```json
161+
{
162+
"pages": {
163+
"order_list": {
164+
"type": "page",
165+
"title": "Order List",
166+
"components": [
167+
{
168+
"type": "table",
169+
"object": "orders",
170+
"columns": [
171+
{ "field": "order_no", "label": "Order No" },
172+
{ "field": "customer.name", "label": "Customer" },
173+
{ "field": "total", "label": "Total" },
174+
{ "field": "status", "label": "Status" }
175+
],
176+
"filters": [
177+
{ "field": "status", "type": "select", "label": "Status" }
178+
],
179+
"actions": [
180+
{ "type": "navigate", "target": "order_detail", "label": "View" }
181+
]
182+
}
183+
]
184+
},
185+
"order_detail": {
186+
"type": "page",
187+
"title": "Order Detail",
188+
"components": [
189+
{
190+
"type": "form",
191+
"object": "orders",
192+
"fields": [
193+
{ "name": "order_no", "label": "Order No", "readonly": true },
194+
{ "name": "customer", "label": "Customer", "readonly": true },
195+
{ "name": "total", "label": "Total", "readonly": true },
196+
{ "name": "status", "label": "Status", "type": "select" }
197+
],
198+
"actions": [
199+
{ "type": "submit", "label": "Save" }
200+
]
201+
}
202+
]
203+
}
204+
}
205+
}
206+
```
207+
208+
## AI-Assisted Plugin Development
209+
210+
### Prompt Template
211+
212+
```
213+
I need to develop a server-side plugin for ObjectStack.
214+
215+
Functional requirements:
216+
- [Requirement description]
217+
218+
Please generate code compliant with ObjectStack plugin specifications, including:
219+
1. Plugin entry file
220+
2. Necessary lifecycle hooks
221+
3. Error handling
222+
```
223+
224+
### Example Code Generation
225+
226+
**User**:
227+
```
228+
I need to develop a plugin that automatically sends email notifications after order creation.
229+
```
230+
231+
**AI Response**:
232+
```javascript
233+
// plugins/order-notification.js
234+
module.exports = {
235+
name: 'order-notification',
236+
237+
hooks: {
238+
afterInsert: async (context, object, record) => {
239+
if (object === 'orders') {
240+
const { customer, total, order_no } = record;
241+
242+
// Query customer email
243+
const customerData = await context.db.query({
244+
object: 'customers',
245+
filters: { _id: customer },
246+
fields: ['email', 'name']
247+
});
248+
249+
if (customerData && customerData[0]?.email) {
250+
await context.email.send({
251+
to: customerData[0].email,
252+
subject: `Order Confirmation - ${order_no}`,
253+
body: `
254+
Dear ${customerData[0].name},
255+
256+
Your order ${order_no} has been created successfully.
257+
Order amount: $${total}
258+
259+
Thank you for your purchase!
260+
`
261+
});
262+
}
263+
}
264+
}
265+
}
266+
};
267+
```
268+
269+
## AI-Assisted Documentation Generation
270+
271+
### Auto-Generate API Documentation
272+
273+
Use TypeDoc or JSDoc to automatically generate documentation from code comments:
274+
275+
```typescript
276+
/**
277+
* Query object data
278+
* @param {Object} options - Query options
279+
* @param {string} options.object - Object name
280+
* @param {Object} options.filters - Filter conditions
281+
* @param {Object} options.sort - Sort rules
282+
* @param {number} options.limit - Limit count
283+
* @returns {Promise<Array>} Query results
284+
*
285+
* @example
286+
* const users = await db.query({
287+
* object: 'users',
288+
* filters: { age: { $gt: 18 } },
289+
* sort: { created_at: 'desc' },
290+
* limit: 10
291+
* });
292+
*/
293+
async function query(options) {
294+
// Implementation code
295+
}
296+
```
297+
298+
Then run:
299+
```bash
300+
npx typedoc --out docs/api src/
301+
```
302+
303+
## Best Practices
304+
305+
### 1. Clear Context
306+
307+
When conversing with AI, clearly specify:
308+
- Using ObjectStack concepts
309+
- Protocol specifications to follow
310+
- Target database type (if special requirements)
311+
312+
### 2. Provide Complete Information
313+
314+
Including:
315+
- Detailed description of business requirements
316+
- Relationships between data models
317+
- UI interaction flows
318+
- Special business rules
319+
320+
### 3. Validate Generated Code
321+
322+
AI-generated code needs:
323+
- Verification of ObjectStack compliance
324+
- Functional testing
325+
- Security and performance review
326+
327+
### 4. Iterative Optimization
328+
329+
If results are not ideal:
330+
- Provide more specific requirements
331+
- Give examples or references
332+
- Break down requirements step by step
333+
334+
## Recommended Tools
335+
336+
### Code Generation
337+
- **GitHub Copilot**: Code completion and generation
338+
- **ChatGPT / Claude**: Architecture design and problem solving
339+
- **Cursor**: AI-assisted programming IDE
340+
341+
### Documentation Generation
342+
- **TypeDoc**: TypeScript API documentation
343+
- **JSDoc**: JavaScript API documentation
344+
- **Swagger/OpenAPI**: REST API documentation
345+
346+
### Testing Assistance
347+
- **AI-generated test cases**: Cover edge cases
348+
- **AI code review**: Discover potential issues
349+
350+
## Considerations
351+
352+
### ⚠️ AI Limitations
353+
354+
- AI may generate code not compliant with latest specifications
355+
- Manual verification of business logic correctness needed
356+
- Complex architecture design still requires human decision-making
357+
358+
### ✅ AI Advantages
359+
360+
- Quickly generate repetitive code
361+
- Provide multiple implementation options
362+
- Assist documentation writing
363+
- Code refactoring suggestions
364+
365+
## Summary
366+
367+
AI is a powerful assistant for ObjectStack development, but not a replacement. Best practices:
368+
369+
1. **Use AI to accelerate**: Schema definitions, UI protocols, repetitive code
370+
2. **Manual review**: Business logic, security, performance optimization
371+
3. **Continuous learning**: Understand AI capabilities and boundaries, use appropriately
372+
373+
By properly using AI tools, development efficiency can be improved 3-5x, allowing developers to focus more on core business logic.

0 commit comments

Comments
 (0)