|
1 | 1 | --- |
2 | | -title: CRM Application Guide |
3 | | -description: A comprehensive, enterprise-grade Customer Relationship Management system demonstrating the full capabilities of the ObjectStack Protocol |
| 2 | +title: Developer Guide |
| 3 | +description: Learn to build enterprise applications with the ObjectStack Protocol — from data modeling to AI agents |
4 | 4 | --- |
5 | 5 |
|
6 | | -# ObjectStack CRM Application - Complete Guide |
7 | | - |
8 | | -Welcome to the **ObjectStack CRM Application**, a comprehensive, enterprise-grade Customer Relationship Management system demonstrating the full capabilities of the ObjectStack Protocol. |
9 | | - |
10 | | -## 🎯 Overview |
11 | | - |
12 | | -This CRM application showcases: |
13 | | - |
14 | | -- **128+ Protocol Modules** across 15 categories |
15 | | -- **Enterprise-grade architecture** following Salesforce and ServiceNow best practices |
16 | | -- **AI-powered automation** with agents and RAG pipelines |
17 | | -- **Comprehensive security** with profiles, roles, and sharing rules |
18 | | -- **Complete business process automation** with flows and workflows |
19 | | - |
20 | | -## 📚 Documentation Structure |
21 | | - |
22 | | -This guide is organized into specialized sections: |
23 | | - |
24 | | -### 1. [Data Modeling](./data-modeling) |
25 | | -Learn how to design robust data models with objects, fields, relationships, and validations. |
26 | | - |
27 | | -**Topics:** |
28 | | -- Object schema design patterns |
29 | | -- Field types and configurations |
30 | | -- Relationship modeling (lookup, master-detail) |
31 | | -- Validation rules and formulas |
32 | | -- Database indexing strategies |
33 | | - |
34 | | -### 2. [Business Logic](./business-logic) |
35 | | -Implement business rules, validations, and automated processes. |
36 | | - |
37 | | -**Topics:** |
38 | | -- Validation rules (script, unique, required) |
39 | | -- Workflow rules and field updates |
40 | | -- Approval processes |
41 | | -- Record triggers |
42 | | -- Business process automation |
43 | | - |
44 | | -### 3. [Security Model](./security) |
45 | | -Implement enterprise-grade security with fine-grained permissions. |
46 | | - |
47 | | -**Topics:** |
48 | | -- Profiles and permission sets |
49 | | -- Object and field-level security |
50 | | -- Sharing rules and role hierarchy |
51 | | -- Organization-wide defaults |
52 | | -- Territory management |
53 | | - |
54 | | -### 4. [AI Capabilities](./ai-capabilities) |
55 | | -Leverage AI agents and RAG pipelines for intelligent automation. |
56 | | - |
57 | | -**Topics:** |
58 | | -- AI agent types (assistant, worker, analyst) |
59 | | -- RAG pipeline configuration |
60 | | -- Knowledge base integration |
61 | | -- Natural language queries |
62 | | -- Predictive analytics |
63 | | - |
64 | | -### 5. [Development Standards](./standards) |
65 | | -Best practices and coding standards for developing enterprise applications. |
66 | | - |
67 | | -**Topics:** |
68 | | -- Folder structure standards |
69 | | -- Naming conventions |
70 | | -- Code organization patterns |
71 | | -- Testing strategies |
72 | | -- Documentation guidelines |
73 | | - |
74 | | -## 🏗️ Application Architecture |
75 | | - |
76 | | -### Domain-Driven Design |
77 | | - |
78 | | -The CRM application is organized by business domains: |
79 | | - |
80 | | -``` |
81 | | -src/ |
82 | | -├── domains/ |
83 | | -│ ├── sales/ # Sales objects (Account, Opportunity, Lead, Quote, Contract) |
84 | | -│ ├── service/ # Service objects (Case, Task) |
85 | | -│ ├── marketing/ # Marketing objects (Campaign) |
86 | | -│ ├── products/ # Product catalog |
87 | | -│ └── analytics/ # Analytics and reporting |
88 | | -├── ui/ # User interface definitions |
89 | | -│ ├── dashboards.ts # Dashboard configurations |
90 | | -│ ├── reports.ts # Report definitions |
91 | | -│ └── actions.ts # Custom actions |
92 | | -├── security/ # Security configurations |
93 | | -│ ├── profiles.ts # User profiles |
94 | | -│ └── sharing-rules.ts # Sharing and permissions |
95 | | -├── automation/ # Business process automation |
96 | | -│ └── flows.ts # Flow definitions |
97 | | -├── ai/ # AI and ML configurations |
98 | | -│ ├── agents.ts # AI agents |
99 | | -│ └── rag-pipelines.ts # RAG pipelines |
100 | | -└── integration/ # External integrations |
101 | | - └── connectors.ts # API connectors |
102 | | -``` |
103 | | - |
104 | | -## 🚀 Quick Start |
105 | | - |
106 | | -### 1. Install Dependencies |
107 | | - |
108 | | -```bash |
109 | | -pnpm install |
110 | | -``` |
111 | | - |
112 | | -### 2. Build the Application |
| 6 | +# Developer Guide |
| 7 | + |
| 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 | + |
| 10 | +<Callout type="tip"> |
| 11 | +**New to ObjectStack?** Read the [Introduction](/docs/introduction) first to understand the protocol-driven architecture. |
| 12 | +</Callout> |
| 13 | + |
| 14 | +## Learning Path |
| 15 | + |
| 16 | +Follow these guides in order for the best experience: |
| 17 | + |
| 18 | +<Cards> |
| 19 | + <Card |
| 20 | + title="1. Data Modeling" |
| 21 | + href="./data-modeling" |
| 22 | + description="Design objects, fields, relationships, and validation rules. The foundation of every app." |
| 23 | + /> |
| 24 | + <Card |
| 25 | + title="2. Business Logic" |
| 26 | + href="./business-logic" |
| 27 | + description="Implement workflows, approval flows, triggers, and formulas to automate business processes." |
| 28 | + /> |
| 29 | + <Card |
| 30 | + title="3. Security Model" |
| 31 | + href="./security" |
| 32 | + description="Configure profiles, permissions, sharing rules, and row-level security for enterprise-grade access control." |
| 33 | + /> |
| 34 | + <Card |
| 35 | + title="4. AI Capabilities" |
| 36 | + href="./ai-capabilities" |
| 37 | + description="Add AI agents, RAG pipelines, natural language queries, and predictive analytics." |
| 38 | + /> |
| 39 | + <Card |
| 40 | + title="5. Development Standards" |
| 41 | + href="./standards" |
| 42 | + description="Naming conventions, project structure, testing strategies, and best practices." |
| 43 | + /> |
| 44 | +</Cards> |
| 45 | + |
| 46 | +## Quick Start |
| 47 | + |
| 48 | +### 1. Scaffold a new project |
113 | 49 |
|
114 | 50 | ```bash |
115 | | -pnpm --filter @example/app-crm build |
| 51 | +npx @objectstack/cli init my-app |
| 52 | +cd my-app && pnpm install |
116 | 53 | ``` |
117 | 54 |
|
118 | | -### 3. Run the Application |
119 | | - |
120 | | -```bash |
121 | | -pnpm --filter @example/app-crm dev |
122 | | -``` |
123 | | - |
124 | | -### 4. Deploy to Production |
125 | | - |
126 | | -```bash |
127 | | -pnpm --filter @example/app-crm deploy |
128 | | -``` |
129 | | - |
130 | | -## 📦 Core Objects |
131 | | - |
132 | | -### Sales Domain |
133 | | -- **Account** - Companies and organizations |
134 | | -- **Contact** - People at accounts |
135 | | -- **Lead** - Prospective customers |
136 | | -- **Opportunity** - Sales deals in progress |
137 | | -- **Quote** - Price quotes for customers |
138 | | -- **Contract** - Legal agreements |
139 | | - |
140 | | -### Service Domain |
141 | | -- **Case** - Customer support tickets |
142 | | -- **Task** - To-do items and activities |
143 | | - |
144 | | -### Marketing Domain |
145 | | -- **Campaign** - Marketing campaigns and initiatives |
146 | | - |
147 | | -### Product Domain |
148 | | -- **Product** - Product catalog |
149 | | - |
150 | | -## 🔧 Configuration |
151 | | - |
152 | | -The application is configured in `objectstack.config.ts`: |
153 | | - |
154 | | -```typescript |
155 | | -export default defineStack({ |
156 | | - manifest: { |
157 | | - id: 'com.example.crm', |
158 | | - version: '2.0.0', |
159 | | - type: 'app', |
160 | | - name: 'CRM App', |
161 | | - }, |
162 | | - |
163 | | - objects: [...], |
164 | | - apis: [...], |
165 | | - actions: [...], |
166 | | - dashboards: [...], |
167 | | - reports: [...], |
168 | | - apps: [...], |
169 | | -}); |
170 | | -``` |
171 | | - |
172 | | -## 🎓 Best Practices |
173 | | - |
174 | | -### Naming Conventions |
175 | | - |
176 | | -1. **Configuration Keys (TypeScript Props):** Use `camelCase` |
177 | | - - `maxLength`, `referenceFilters`, `defaultValue` |
178 | | - |
179 | | -2. **Machine Names (Data Values):** Use `snake_case` |
180 | | - - `account_number`, `first_name`, `close_date` |
181 | | - |
182 | | -3. **Object Names:** Use `snake_case` |
183 | | - - `account`, `opportunity`, `case` |
184 | | - |
185 | | -4. **Field Names:** Use `snake_case` |
186 | | - - `account_number`, `annual_revenue`, `is_active` |
187 | | - |
188 | | -### Schema Design |
189 | | - |
190 | | -Always start with Zod schemas: |
| 55 | +### 2. Define your first object |
191 | 56 |
|
192 | 57 | ```typescript |
| 58 | +// src/objects/customer.object.ts |
193 | 59 | import { ObjectSchema, Field } from '@objectstack/spec/data'; |
194 | 60 |
|
195 | | -export const MyObject = ObjectSchema.create({ |
196 | | - name: 'my_object', |
197 | | - label: 'My Object', |
198 | | - |
| 61 | +export const Customer = ObjectSchema.create({ |
| 62 | + name: 'customer', |
| 63 | + label: 'Customer', |
199 | 64 | fields: { |
200 | | - my_field: Field.text({ |
201 | | - label: 'My Field', |
202 | | - required: true, |
| 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 | + ], |
203 | 72 | }), |
| 73 | + revenue: Field.currency({ label: 'Revenue' }), |
204 | 74 | }, |
205 | 75 | }); |
206 | 76 | ``` |
207 | 77 |
|
208 | | -### Type Safety |
| 78 | +### 3. Validate and build |
209 | 79 |
|
210 | | -Use type inference from Zod schemas: |
| 80 | +```bash |
| 81 | +npx objectstack validate # Check schema correctness |
| 82 | +npx objectstack compile # Generate TypeScript types |
| 83 | +npx objectstack dev # Start dev server |
| 84 | +``` |
211 | 85 |
|
212 | | -```typescript |
213 | | -import { z } from 'zod'; |
| 86 | +### 4. Add a view |
214 | 87 |
|
215 | | -const MySchema = z.object({ |
216 | | - name: z.string(), |
| 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 | + ], |
217 | 100 | }); |
218 | | - |
219 | | -type MyType = z.infer<typeof MySchema>; |
220 | 101 | ``` |
221 | 102 |
|
222 | | -## 🔒 Security |
223 | | - |
224 | | -The application implements enterprise-grade security: |
225 | | - |
226 | | -- **5 User Profiles** (System Admin, Sales Manager, Sales Rep, Service Agent, Marketing User) |
227 | | -- **Role Hierarchy** with 10 roles |
228 | | -- **Sharing Rules** for account, opportunity, and case objects |
229 | | -- **Territory Management** for geographic sales regions |
230 | | -- **Field-Level Security** for sensitive data |
231 | | - |
232 | | -## 🤖 AI Features |
233 | | - |
234 | | -### AI Agents |
235 | | - |
236 | | -- **Sales Assistant** - Lead qualification and opportunity management |
237 | | -- **Service Agent** - Customer support automation |
238 | | -- **Lead Enrichment** - Automatic data enrichment |
239 | | -- **Revenue Intelligence** - Pipeline analysis and forecasting |
240 | | -- **Email Campaign** - Marketing email generation |
241 | | - |
242 | | -### RAG Pipelines |
243 | | - |
244 | | -- **Sales Knowledge** - Sales playbook and best practices |
245 | | -- **Support Knowledge** - Customer support knowledge base |
246 | | -- **Product Information** - Product catalog and specs |
247 | | -- **Competitive Intelligence** - Market research and competitive analysis |
248 | | - |
249 | | -## 📊 Analytics |
| 103 | +## Project Structure |
250 | 104 |
|
251 | | -### Dashboards |
| 105 | +A typical ObjectStack application: |
252 | 106 |
|
253 | | -- **Sales Dashboard** - Pipeline metrics and trends |
254 | | -- **Service Dashboard** - Support case analytics |
255 | | -- **Executive Dashboard** - High-level business metrics |
256 | | - |
257 | | -### Reports |
258 | | - |
259 | | -- Opportunities by Stage |
260 | | -- Won Opportunities by Owner |
261 | | -- Accounts by Industry |
262 | | -- Cases by Status and Priority |
263 | | -- SLA Performance |
264 | | -- Leads by Source |
265 | | -- Contacts by Account |
266 | | -- Tasks by Owner |
267 | | - |
268 | | -## 🔗 Resources |
269 | | - |
270 | | -- [ObjectStack Documentation](https://docs.objectstack.ai) |
271 | | -- [API Reference](https://api.objectstack.ai) |
272 | | -- [Community Forum](https://community.objectstack.ai) |
273 | | -- [GitHub Repository](https://github.com/objectstack-ai/spec) |
274 | | - |
275 | | -## 📝 License |
276 | | - |
277 | | -This example application is part of the ObjectStack specification repository and is licensed under the MIT License. |
| 107 | +``` |
| 108 | +my-app/ |
| 109 | +├── objectstack.config.ts # App manifest |
| 110 | +├── 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 |
| 123 | +└── test/ # Tests |
| 124 | +``` |
278 | 125 |
|
279 | | -## 🤝 Contributing |
| 126 | +## Key Concepts |
280 | 127 |
|
281 | | -Contributions are welcome! Please read our [Contributing Guide](https://github.com/objectstack-ai/spec/blob/main/CONTRIBUTING.md) for details. |
| 128 | +| Concept | Protocol | You Define | ObjectStack Generates | |
| 129 | +| :--- | :--- | :--- | :--- | |
| 130 | +| Data Model | ObjectQL | Objects, Fields, Validation | CRUD APIs, database schema, type safety | |
| 131 | +| User Interface | ObjectUI | Views, Pages, Dashboards | React components, navigation, responsive layout | |
| 132 | +| Business Logic | Automation | Flows, Workflows, Triggers | Event handlers, approval chains, scheduled jobs | |
| 133 | +| Access Control | Security | Profiles, Permissions, Sharing | Middleware, RLS policies, field masking | |
| 134 | +| Intelligence | AI | Agents, RAG, Models | Chat interfaces, search indexes, predictions | |
282 | 135 |
|
283 | | ---- |
| 136 | +## Next Steps |
284 | 137 |
|
285 | | -**Next:** Start with [Data Modeling →](./data-modeling) |
| 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 |
0 commit comments