|
1 | 1 | --- |
2 | 2 | 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 |
4 | 4 | --- |
5 | 5 |
|
6 | 6 | # Developer Guide |
7 | 7 |
|
8 | 8 | 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). |
9 | 9 |
|
10 | 10 | <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. |
12 | 12 | </Callout> |
13 | 13 |
|
| 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** — Query layer with CRUD operations |
| 71 | +- **InMemory Driver** — Zero-config data storage for development |
| 72 | +- **Hono HTTP Server** — REST API at `/api/v1/{object}` |
| 73 | +- **Console UI** — 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 | + |
14 | 92 | ## Learning Path |
15 | 93 |
|
16 | 94 | Follow these guides in order for the best experience: |
@@ -43,99 +121,47 @@ Follow these guides in order for the best experience: |
43 | 121 | /> |
44 | 122 | </Cards> |
45 | 123 |
|
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 | | - |
103 | 124 | ## Project Structure |
104 | 125 |
|
105 | | -A typical ObjectStack application: |
| 126 | +A typical ObjectStack application (generated by `os init`): |
106 | 127 |
|
107 | 128 | ``` |
108 | 129 | my-app/ |
109 | | -├── objectstack.config.ts # App manifest |
| 130 | +├── objectstack.config.ts # App manifest + metadata wiring |
| 131 | +├── package.json |
| 132 | +├── tsconfig.json |
110 | 133 | ├── 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 |
123 | 143 | └── test/ # Tests |
124 | 144 | ``` |
125 | 145 |
|
| 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 | + |
126 | 152 | ## Key Concepts |
127 | 153 |
|
128 | | -| Concept | Protocol | You Define | ObjectStack Generates | |
| 154 | +| Concept | Protocol | You Define | ObjectStack Provides | |
129 | 155 | | :--- | :--- | :--- | :--- | |
130 | 156 | | 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 | |
132 | 158 | | Business Logic | Automation | Flows, Workflows, Triggers | Event handlers, approval chains, scheduled jobs | |
133 | 159 | | Access Control | Security | Profiles, Permissions, Sharing | Middleware, RLS policies, field masking | |
134 | 160 | | Intelligence | AI | Agents, RAG, Models | Chat interfaces, search indexes, predictions | |
135 | 161 |
|
136 | 162 | ## Next Steps |
137 | 163 |
|
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) — Run the Todo, CRM, and BI examples |
| 165 | +- [Data Modeling Guide](/docs/developer/data-modeling) — Deep dive into objects and fields |
| 166 | +- [CLI Reference](/docs/framework/cli) — All available commands |
| 167 | +- [Protocol Reference](/docs/references) — Complete schema documentation |
0 commit comments