|
1 | | -# ObjectQL Examples Gallery |
| 1 | +# ObjectQL Examples |
2 | 2 |
|
3 | | -Welcome to the ObjectQL examples collection. This directory is organized to help you find the right starting point for your needs, from simple scripts to complex real-world applications. |
| 3 | +Welcome to the ObjectQL Examples repository. This collection demonstrates everything from "Hello World" scripts to complex, module-driven enterprise architectures. |
4 | 4 |
|
5 | | -## 📚 Quick References |
| 5 | +## 📂 Directory Structure |
6 | 6 |
|
7 | | -| Resource | Description | |
8 | | -| :--- | :--- | |
9 | | -| **[Attachment Upload Demo](./attachment-upload-demo.md)** | Complete guide to uploading files, handling images, creating records with attachments, and implementing file upload components | |
10 | | - |
11 | | -## 🌐 Browser Demos |
12 | | -*ObjectQL running directly in web browsers - no backend required!* |
| 7 | +### 1. 🚀 Starters (Quick Start) |
| 8 | +*Standard templates found in `examples/starters/`* |
13 | 9 |
|
14 | 10 | | Example | Description | Proficiency | |
15 | 11 | | :--- | :--- | :--- | |
16 | | -| **[Memory Driver Demo](./browser-demo/)** | Interactive task manager running entirely in the browser with in-memory storage. Perfect for prototyping and understanding ObjectQL's client-side capabilities. | 🌱 Beginner | |
17 | | -| **[LocalStorage Demo](./browser-localstorage-demo/)** | Persistent browser storage that survives page refreshes. Ideal for offline apps, PWAs, and user preferences. | ⚡️ Intermediate | |
| 12 | +| **[Hello World](./starters/hello-world)** | **Absolute minimum.** A single TypeScript file using `ObjectQL` programmatically with an in-memory database. No config, no CLI. | 🟢 Basic | |
| 13 | +| **[Express API](./starters/express-api)** | **The Standard Server.** Shows how to mount ObjectQL onto an existing Express.js application as a middleware. | 🟢 Basic | |
| 14 | +| **[Basic Script](./starters/basic-script)** | A simple TypeScript script initializing ObjectQL with SQLite. Perfect for testing logic without a web server. | 🟢 Basic | |
| 15 | + |
| 16 | +### 2. 🧩 Module Architecture |
| 17 | +*Demonstrating the power of the new `modules` system in `objectql.config.ts`. See `examples/scenarios/`.* |
18 | 18 |
|
19 | | -**Features:** |
20 | | -- 🎨 Beautiful interactive UI with live CRUD operations |
21 | | -- 📊 Real-time statistics dashboard |
22 | | -- 🖥️ Browser console debugging (`window.app`, `window.taskRepo`) |
23 | | -- ✨ Sample data generation |
24 | | -- 🔄 Filter and manage data visually |
| 19 | +| Example | Description | Proficiency | |
| 20 | +| :--- | :--- | :--- | |
| 21 | +| **[Module Composition](./scenarios/module-composition)** | **[Code](./scenarios/module-composition)** <br> Shows how to mix **Local Modules** (`./src/modules/billing`) with **External NPM Modules** (`@objectql/module-auth`) in a single application. | 💡 Intermediate | |
| 22 | +| **[Enterprise Monorepo](./scenarios/enterprise-monorepo)** | **[Code](./scenarios/enterprise-monorepo)** <br> Organizing a large-scale application into domain-specific modules (CRM, HR, Finance). | 🏢 Advanced | |
25 | 23 |
|
26 | | -## 🚀 Starters |
27 | | -*Boilerplates and minimal setups to get you coding in seconds.* |
| 24 | +### 3. 📚 Tutorials (Step-by-Step) |
| 25 | +*Found in `examples/tutorials/`* |
28 | 26 |
|
29 | 27 | | Example | Description | Proficiency | |
30 | 28 | | :--- | :--- | :--- | |
31 | | -| **[Basic Script](./starters/basic-script)** | A simple TypeScript script initializing ObjectQL with SQLite. Perfect for testing logic. | 🌱 Beginner | |
32 | | -| **[Express API](./starters/express-api)** | A REST API server using Express.js + ObjectQL. Shows how to mount the server adapter. | ⚡️ Intermediate | |
| 29 | +| **[Task Manager](./tutorials/tutorial-task-manager)** | A simple Todo list app to learn objects, fields, and basic validation. | 🟢 Basic | |
| 30 | +| **[CRM System](./tutorials/tutorial-crm-system)** | A relational database example with Customers, Contacts, and Deals. Demonstrates `lookup` fields. | 💡 Intermediate | |
| 31 | +| **[AI Agent](./tutorials/tutorial-ai-agent)** | Integrating LLMs to query your data using natural language. | 🧠 AI-Native | |
| 32 | +| **[Formulas & Rules](./tutorials/tutorial-formulas)** | Using Excel-like formula syntax for computed fields and validation. | 💡 Intermediate | |
| 33 | +| **[Federation](./tutorials/tutorial-federation)** | Connecting multiple ObjectQL services together. | 🏢 Advanced | |
33 | 34 |
|
34 | | -## 🧩 Plugins & Extensions |
35 | | -*Learn how to extend the core capabilities of ObjectQL.* |
| 35 | +### 4. 🌐 Browser Demos |
| 36 | +*Run ObjectQL in the browser with no backend.* |
36 | 37 |
|
37 | 38 | | Example | Description | Proficiency | |
38 | 39 | | :--- | :--- | :--- | |
39 | | -| **[Audit Log](./plugins/audit-log)** | A fully functional plugin that tracks changes (`afterCreate`, `afterUpdate`) and stores them. | 🔧 Advanced | |
| 40 | +| **[Memory Driver Demo](./browser-demo/)** | Interactive task manager running entirely in the browser. | 🟢 Basic | |
| 41 | +| **[LocalStorage Demo](./browser-localstorage-demo/)** | Persistent browser storage. Ideal for offline apps. | 💡 Intermediate | |
40 | 42 |
|
41 | | -## 🏗 Scenarios & Patterns |
42 | | -*Demonstrations of specific architectural patterns.* |
| 43 | +### 5. 🔌 Plugins & Extensions |
| 44 | +*Found in `examples/plugins/`* |
43 | 45 |
|
44 | 46 | | Example | Description | Proficiency | |
45 | 47 | | :--- | :--- | :--- | |
46 | | -| **[Enterprise Structure](./scenarios/enterprise-structure)** | **[NEW]** Best practices for organizing metadata in large-scale applications. Shows domain-driven module structure with 20+ objects across CRM, HR, Finance, and Project modules. | 🏢 Advanced | |
47 | | -| **[Module Usage](./scenarios/module-usage)** | Shows how to consume pre-packaged business logic (modules) in an application. | 💡 Intermediate | |
| 48 | +| **[Audit Log](./plugins/audit-log)** | How to write a generic plugin that intercepts `beforeCreate` and `afterUpdate` hooks to log changes. | 💡 Intermediate | |
48 | 49 |
|
49 | | -## 🚧 Coming Soon |
50 | | -We are working on high-fidelity examples: |
51 | | -- **CRM System**: A Salesforce-like CRM with rich permission rules. |
52 | | -- **E-Commerce**: High-performance catalog and order management. |
53 | | -- **Next.js Integration**: Using Server Actions with ObjectQL. |
54 | | -- **AI RAG Demo**: Semantic search connecting to OpenAI. |
| 50 | +### 6. 🛠 Integration Snippets |
| 51 | +*Standalone files in root `examples/`* |
| 52 | + |
| 53 | +| Example | Description | |
| 54 | +| :--- | :--- | |
| 55 | +| **[Existing Database](./connect-existing-database.ts)** | How to use Introspection to generate ObjectQL schema from an existing SQL database. | |
| 56 | +| **[Custom API Routes](./custom-api-routes.ts)** | Adding custom REST endpoints alongside the auto-generated ObjectQL API. | |
| 57 | +| **[Schema Migration](./schema-migration-example.ts)** | Programmatic usage of the migration system. | |
55 | 58 |
|
56 | 59 | --- |
57 | | -## How to Run |
58 | 60 |
|
59 | | -Each example is a self-contained NPM package. |
| 61 | +## 🏃♀️ How to Run |
| 62 | + |
| 63 | +Most examples can be decoupled and run independently. |
60 | 64 |
|
| 65 | +**For Starters:** |
61 | 66 | ```bash |
62 | | -cd examples/starters/express-api |
| 67 | +cd examples/starters/hello-world |
63 | 68 | pnpm install |
64 | 69 | pnpm start |
65 | 70 | ``` |
66 | 71 |
|
67 | | -- [ObjectQL Documentation](../docs/) |
68 | | -- [Metadata Specification](../docs/spec/metadata-format.md) |
69 | | -- [Metadata Protection Guide](../docs/spec/metadata-format.md#9-metadata-protection) |
| 72 | +**For Modules/Scenarios:** |
| 73 | +```bash |
| 74 | +# From root |
| 75 | +pnpm objectql dev --dir examples/tutorials/tutorial-task-manager |
| 76 | +``` |
| 77 | + |
0 commit comments