Skip to content

Commit 72cfc25

Browse files
committed
2 parents 64bd5d9 + 66d49d7 commit 72cfc25

6 files changed

Lines changed: 548 additions & 113 deletions

File tree

content/docs/developer/index.mdx

Lines changed: 105 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,94 @@
11
---
22
title: Developer Guide
3-
description: Learn to build enterprise applications with the ObjectStack Protocol — from data modeling to AI agents
3+
description: Learn to build enterprise applications with the ObjectStack Protocol
44
---
55

66
# Developer Guide
77

88
This guide teaches you how to **build real applications** using the ObjectStack Protocol. Each section is hands-on, with code examples derived from the [CRM example app](https://github.com/objectstack-ai/spec/tree/main/examples/app-crm).
99

1010
<Callout type="tip">
11-
**New to ObjectStack?** Read the [Introduction](/docs/introduction) first to understand the protocol-driven architecture.
11+
**New to ObjectStack?** Start with the [Example Apps](/docs/framework/examples) to see working code, or read the [Introduction](/docs/introduction) for the architecture overview.
1212
</Callout>
1313

14+
## Quick Start
15+
16+
<Steps>
17+
18+
### Create a project
19+
20+
```bash
21+
npx @objectstack/cli init my-app
22+
cd my-app
23+
```
24+
25+
### Define your first object
26+
27+
The scaffolded project includes a sample object. Open `src/objects/my_app.ts`:
28+
29+
```typescript
30+
import { Data } from '@objectstack/spec';
31+
32+
const myApp: Data.Object = {
33+
name: 'my_app',
34+
label: 'My App',
35+
ownership: 'own',
36+
fields: {
37+
name: {
38+
type: 'text',
39+
label: 'Name',
40+
required: true,
41+
},
42+
description: {
43+
type: 'textarea',
44+
label: 'Description',
45+
},
46+
status: {
47+
type: 'select',
48+
label: 'Status',
49+
options: [
50+
{ label: 'Draft', value: 'draft' },
51+
{ label: 'Active', value: 'active' },
52+
{ label: 'Archived', value: 'archived' },
53+
],
54+
defaultValue: 'draft',
55+
},
56+
},
57+
};
58+
59+
export default myApp;
60+
```
61+
62+
### Launch the Studio
63+
64+
```bash
65+
os studio
66+
```
67+
68+
Open [http://localhost:3000/_studio/](http://localhost:3000/_studio/) to browse your objects, test the REST API, and inspect metadata. The server automatically provides:
69+
70+
- **ObjectQL Engine** &mdash; Query layer with CRUD operations
71+
- **InMemory Driver** &mdash; Zero-config data storage for development
72+
- **Hono HTTP Server** &mdash; REST API at `/api/v1/{object}`
73+
- **Console UI** &mdash; Admin interface at `/_studio/`
74+
75+
### Add more metadata
76+
77+
```bash
78+
os g object customer # Generate a new object
79+
os g action approve # Generate an action
80+
os g flow onboarding # Generate an automation flow
81+
```
82+
83+
### Validate and build
84+
85+
```bash
86+
os validate # Check schema correctness
87+
os compile # Generate production artifact
88+
```
89+
90+
</Steps>
91+
1492
## Learning Path
1593

1694
Follow these guides in order for the best experience:
@@ -43,99 +121,47 @@ Follow these guides in order for the best experience:
43121
/>
44122
</Cards>
45123

46-
## Quick Start
47-
48-
### 1. Scaffold a new project
49-
50-
```bash
51-
npx @objectstack/cli init my-app
52-
cd my-app && pnpm install
53-
```
54-
55-
### 2. Define your first object
56-
57-
```typescript
58-
// src/objects/customer.object.ts
59-
import { ObjectSchema, Field } from '@objectstack/spec/data';
60-
61-
export const Customer = ObjectSchema.create({
62-
name: 'customer',
63-
label: 'Customer',
64-
fields: {
65-
name: Field.text({ label: 'Name', required: true }),
66-
industry: Field.select({
67-
label: 'Industry',
68-
options: [
69-
{ label: 'Technology', value: 'technology' },
70-
{ label: 'Finance', value: 'finance' },
71-
],
72-
}),
73-
revenue: Field.currency({ label: 'Revenue' }),
74-
},
75-
});
76-
```
77-
78-
### 3. Validate and build
79-
80-
```bash
81-
npx objectstack validate # Check schema correctness
82-
npx objectstack compile # Generate TypeScript types
83-
npx objectstack dev # Start dev server
84-
```
85-
86-
### 4. Add a view
87-
88-
```typescript
89-
// src/views/customer_list.view.ts
90-
import { ListView } from '@objectstack/spec/ui';
91-
92-
export const CustomerList = ListView({
93-
object: 'customer',
94-
type: 'grid',
95-
columns: [
96-
{ field: 'name', width: 200 },
97-
{ field: 'industry' },
98-
{ field: 'revenue' },
99-
],
100-
});
101-
```
102-
103124
## Project Structure
104125

105-
A typical ObjectStack application:
126+
A typical ObjectStack application (generated by `os init`):
106127

107128
```
108129
my-app/
109-
├── objectstack.config.ts # App manifest
130+
├── objectstack.config.ts # App manifest + metadata wiring
131+
├── package.json
132+
├── tsconfig.json
110133
├── src/
111-
│ ├── objects/ # Data models (ObjectQL)
112-
│ │ ├── customer.object.ts
113-
│ │ └── opportunity.object.ts
114-
│ ├── views/ # UI definitions (ObjectUI)
115-
│ │ ├── customer_list.view.ts
116-
│ │ └── customer_form.view.ts
117-
│ ├── flows/ # Automation (Flows, Workflows)
118-
│ │ └── welcome_email.flow.ts
119-
│ ├── security/ # Permissions & Sharing
120-
│ │ └── profiles.ts
121-
│ └── ai/ # AI agents & RAG
122-
│ └── sales_assistant.agent.ts
134+
│ ├── objects/ # Data models (required)
135+
│ │ ├── index.ts # Barrel export
136+
│ │ └── my_app.ts # Object definition
137+
│ ├── actions/ # Buttons, batch operations
138+
│ ├── flows/ # Automation logic
139+
│ ├── apps/ # Navigation definitions
140+
│ ├── dashboards/ # Analytics dashboards
141+
│ ├── agents/ # AI agents
142+
│ └── rag/ # RAG pipelines
123143
└── test/ # Tests
124144
```
125145

146+
**File naming conventions:**
147+
- **Object files:** `{name}.object.ts` or `{name}.ts` (one object per file)
148+
- **Action files:** `{name}.actions.ts`
149+
- **Flow files:** `{name}.flow.ts`
150+
- **Barrel exports:** Each directory has an `index.ts` that re-exports everything
151+
126152
## Key Concepts
127153

128-
| Concept | Protocol | You Define | ObjectStack Generates |
154+
| Concept | Protocol | You Define | ObjectStack Provides |
129155
| :--- | :--- | :--- | :--- |
130156
| Data Model | ObjectQL | Objects, Fields, Validation | CRUD APIs, database schema, type safety |
131-
| User Interface | ObjectUI | Views, Pages, Dashboards | React components, navigation, responsive layout |
157+
| User Interface | ObjectUI | Views, Apps, Dashboards | React components, navigation, responsive layout |
132158
| Business Logic | Automation | Flows, Workflows, Triggers | Event handlers, approval chains, scheduled jobs |
133159
| Access Control | Security | Profiles, Permissions, Sharing | Middleware, RLS policies, field masking |
134160
| Intelligence | AI | Agents, RAG, Models | Chat interfaces, search indexes, predictions |
135161

136162
## Next Steps
137163

138-
- [Data Modeling Guide →](./data-modeling) — Start building your data layer
139-
- [CLI Reference](/docs/framework/cli) — All available commands
140-
- [Protocol Reference](/docs/references) — Complete schema documentation
141-
- [Example: CRM App](https://github.com/objectstack-ai/spec/tree/main/examples/app-crm) — Full working example
164+
- [Example Apps](/docs/framework/examples) &mdash; Run the Todo, CRM, and BI examples
165+
- [Data Modeling Guide](/docs/developer/data-modeling) &mdash; Deep dive into objects and fields
166+
- [CLI Reference](/docs/framework/cli) &mdash; All available commands
167+
- [Protocol Reference](/docs/references) &mdash; Complete schema documentation

content/docs/framework/cli.mdx

Lines changed: 46 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,48 @@ pnpm add -D @objectstack/cli
1515

1616
The CLI is available as `objectstack` or the shorter alias `os`.
1717

18-
## Quick Start
18+
## Your First App in 2 Minutes
19+
20+
<Steps>
21+
22+
### Create a project
1923

2024
```bash
21-
# Initialize a new project
22-
os init my-app
25+
npx @objectstack/cli init my-app
26+
cd my-app
27+
```
2328

24-
# Generate metadata
25-
os generate object task
26-
os generate view task
27-
os generate flow task
29+
This scaffolds a working project with `objectstack.config.ts`, a sample object, and all dependencies installed.
2830

29-
# Validate configuration
30-
os validate
31+
### Add more metadata
32+
33+
```bash
34+
os generate object customer # Add a Customer object
35+
os generate action approve # Add an action
36+
os generate flow onboarding # Add an automation flow
37+
```
3138

32-
# Start development server
33-
os dev
39+
### Launch the Studio
3440

35-
# Compile for production
36-
os compile
41+
```bash
42+
os studio
3743
```
3844

45+
Open [http://localhost:3000/_studio/](http://localhost:3000/_studio/) — you'll see the Console UI with a data browser, metadata explorer, and API documentation.
46+
47+
### Validate & Build
48+
49+
```bash
50+
os validate # Check schema correctness
51+
os compile # Build production artifact → dist/objectstack.json
52+
```
53+
54+
</Steps>
55+
56+
<Callout type="tip">
57+
`os studio` = `os serve --dev --ui`. It starts a dev server with the Console UI, auto-loads ObjectQL, InMemory driver, and Hono HTTP server — zero config needed.
58+
</Callout>
59+
3960
## Commands
4061

4162
### Development
@@ -358,32 +379,33 @@ os compile path/to/my-config.ts
358379

359380
```bash
360381
# 1. Create project
361-
os init my-crm
382+
os init my-crm && cd my-crm
362383

363384
# 2. Define your data model
364385
os g object account
365386
os g object contact
366387
os g object opportunity
367388

368-
# 3. Add UI definitions
369-
os g view account
370-
os g view contact
371-
os g dashboard sales
372-
373-
# 4. Add business logic
389+
# 3. Add business logic
374390
os g flow lead-qualification
375391
os g agent sales-assistant
376392

377-
# 5. Validate everything
393+
# 4. Validate everything
378394
os validate
379395

380-
# 6. Start development
381-
os dev
396+
# 5. Start development with Console UI
397+
os studio
382398

383-
# 7. Build for production
399+
# 6. Build for production
384400
os compile
385401
```
386402

403+
## Next Steps
404+
405+
- [Examples Guide](/docs/framework/examples) — Run the built-in example apps (Todo, CRM, BI)
406+
- [Developer Guide](/docs/developer) — Learn data modeling, security, and automation
407+
- [Protocol Reference](/docs/references) — Complete schema documentation
408+
387409
## CI/CD Integration
388410

389411
All commands that produce output support `--json` for machine-readable output:

0 commit comments

Comments
 (0)