Skip to content

Commit 60b2c3e

Browse files
authored
Merge pull request #364 from objectstack-ai/copilot/update-examples-and-cleanup
2 parents 3ce563c + dda5213 commit 60b2c3e

23 files changed

Lines changed: 2033 additions & 1323 deletions

examples/basic/README.md

Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
# Basic Protocol Examples
2+
3+
A standalone package containing comprehensive examples demonstrating core ObjectStack protocols and features.
4+
5+
## 📦 Package Information
6+
7+
- **Package**: `@objectstack/example-basic`
8+
- **Type**: Demonstration/Reference
9+
- **Status**: Standalone examples with type checking
10+
11+
## 🚀 Usage
12+
13+
### Build and Type Check
14+
15+
```bash
16+
# From monorepo root
17+
pnpm install
18+
19+
# Build the spec package first
20+
pnpm --filter @objectstack/spec build
21+
22+
# Type check the examples
23+
pnpm --filter @objectstack/example-basic typecheck
24+
25+
# Or run directly with tsx
26+
npx tsx examples/basic/stack-definition-example.ts
27+
```
28+
29+
### Running Examples
30+
31+
Each example file can be run independently with `tsx`:
32+
33+
```bash
34+
# Run a specific example
35+
npx tsx examples/basic/ai-rag-example.ts
36+
37+
# Or uncomment the demonstration function calls at the end of each file
38+
```
39+
40+
## 📚 Examples
41+
42+
### Stack Definition
43+
**File:** [`stack-definition-example.ts`](./stack-definition-example.ts)
44+
45+
Demonstrates the `defineStack()` helper for creating comprehensive ObjectStack configurations:
46+
- Minimal stack setup
47+
- Task management application with Objects, UI, and Workflows
48+
- CRM with AI agent integration
49+
- Type-safe configuration patterns
50+
51+
**Key Concepts:**
52+
- Manifest configuration
53+
- Object and Field definitions
54+
- UI components (Apps, Views, Dashboards)
55+
- Automation (Workflows)
56+
- Security (Roles, Permissions)
57+
- AI Agents
58+
59+
### Capabilities Configuration
60+
**File:** [`capabilities-example.ts`](./capabilities-example.ts)
61+
62+
Shows how to define runtime capabilities for ObjectStack instances:
63+
- Production environment with full features
64+
- Development environment with minimal features
65+
- AI-focused environment optimized for RAG
66+
- Capability checking helpers
67+
68+
**Key Concepts:**
69+
- ObjectQL (Data) capabilities
70+
- ObjectUI (UI) capabilities
71+
- ObjectOS (System) capabilities
72+
- Environment-specific configurations
73+
74+
### API Discovery
75+
**File:** [`api-discovery-example.ts`](./api-discovery-example.ts)
76+
77+
Demonstrates the API Discovery protocol for runtime introspection:
78+
- Complete discovery response
79+
- Development mode discovery
80+
- Adaptive client behavior
81+
- AI agent system prompt generation
82+
83+
**Key Concepts:**
84+
- System identity and versioning
85+
- Available API endpoints (REST, GraphQL, OData, WebSocket)
86+
- Runtime capabilities
87+
- Authentication configuration
88+
- Feature flags
89+
90+
### AI & RAG Pipeline
91+
**File:** [`ai-rag-example.ts`](./ai-rag-example.ts)
92+
93+
Shows Retrieval-Augmented Generation (RAG) pipeline configuration:
94+
- Document ingestion and chunking
95+
- Vector embeddings and storage
96+
- Semantic search and retrieval
97+
- Context assembly for LLMs
98+
- AI agent with RAG integration
99+
100+
**Key Concepts:**
101+
- RAG pipeline configuration
102+
- Document processing
103+
- Vector database integration
104+
- Hybrid search (vector + keyword)
105+
- Reranking for better results
106+
- Context template formatting
107+
108+
### Auth & Permissions
109+
**File:** [`auth-permission-example.ts`](./auth-permission-example.ts)
110+
111+
Demonstrates authentication and authorization systems:
112+
- User identity and sessions
113+
- Role-based access control (RBAC) with hierarchy
114+
- Object and field-level permissions
115+
- Row-level security (RLS)
116+
- Sharing rules for data access
117+
- Territory management
118+
119+
**Key Concepts:**
120+
- User authentication and profiles
121+
- Role hierarchy and inheritance
122+
- Permission sets
123+
- Granular access control
124+
- Dynamic data filtering
125+
- Territory-based assignments
126+
127+
### Automation & Workflows
128+
**File:** [`automation-example.ts`](./automation-example.ts)
129+
130+
Shows automation capabilities in ObjectStack:
131+
- Workflow rules for field updates
132+
- Email alerts and notifications
133+
- Automatic record creation
134+
- Multi-step approval processes
135+
- Screen flows with user interaction
136+
- ETL processes for data integration
137+
138+
**Key Concepts:**
139+
- Event-driven automation
140+
- Scheduled workflows (cron)
141+
- Approval hierarchies
142+
- Visual process automation
143+
- Data transformation pipelines
144+
- Error handling and notifications
145+
146+
## 🎯 Usage
147+
148+
These examples are TypeScript files in a proper package that can be:
149+
150+
1. **Type checked:**
151+
```bash
152+
pnpm --filter @objectstack/example-basic typecheck
153+
```
154+
155+
2. **Run directly:**
156+
```bash
157+
npx tsx examples/basic/stack-definition-example.ts
158+
```
159+
160+
3. **Used as references:**
161+
Import types and patterns in your own projects
162+
163+
## 🔗 Related Resources
164+
165+
- **[CRM Example](../crm/)** - Full application using these patterns
166+
- **[Todo Example](../todo/)** - Simple application example
167+
- **[Protocol Reference](../../packages/spec/)** - Complete schema documentation
168+
169+
## 📝 Notes
170+
171+
- All examples use TypeScript for type safety
172+
- Examples import types from `@objectstack/spec`
173+
- Each example is self-contained and documented
174+
- Examples demonstrate real-world patterns, not toy scenarios

0 commit comments

Comments
 (0)