Skip to content

Commit aca952e

Browse files
committed
Refactor examples and introduce modular templates
Reorganized example projects to use a new modular structure, moving and renaming starter, plugin, and showcase examples under 'examples/'. Added new quickstart and integration templates, removed legacy tutorials and scripts, and updated documentation to reflect the new module-based architecture. Introduced a pnpm-lock.yaml merge driver, improved .gitignore, and updated CLI commands and docs for the new workflow. Added new CLI commands and created a separate 'create' package for project scaffolding.
2 parents aea12cd + aa38245 commit aca952e

File tree

212 files changed

+2022
-5603
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

212 files changed

+2022
-5603
lines changed

.changeset/config.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,7 @@
1212
"@objectql/sdk",
1313
"@objectql/server",
1414
"@objectql/types",
15-
"@objectql/platform-node",
16-
"@objectql/starter-basic",
17-
"@objectql/starter-express-api",
18-
"@objectql/starter-enterprise"
15+
"@objectql/platform-node"
1916
]
2017
],
2118
"linked": [],

.gitattributes

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# pnpm-lock.yaml merge driver
2+
# This custom merge driver automatically resolves conflicts in pnpm-lock.yaml
3+
# by regenerating the lock file using 'pnpm install'
4+
pnpm-lock.yaml merge=pnpm-merge

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,6 @@ docs/.vitepress/dist
1515
*.db
1616

1717
# Example tutorials CHANGELOG (auto-generated, not tracked)
18-
examples/tutorials/*/CHANGELOG.md
18+
examples/tutorials/*/CHANGELOG.md
19+
# Generated Types
20+
generated/

.vscode/launch.json

Lines changed: 0 additions & 53 deletions
This file was deleted.

.vscode/tasks.json

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,12 @@
22
"version": "2.0.0",
33
"tasks": [
44
{
5-
"label": "Run Studio: Basic Script",
5+
"label": "Run Dev Server",
66
"type": "shell",
7-
"command": "node",
7+
"command": "pnpm",
88
"args": [
9-
"packages/cli/dist/index.js",
10-
"studio",
11-
"--dir",
12-
"examples/starters/basic-script"
9+
"objectql",
10+
"dev"
1311
],
1412
"group": "test",
1513
"presentation": {

README.md

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,20 @@ ObjectQL is organized as a Monorepo to ensure modularity and universal compatibi
4545

4646
## ⚡ Quick Start
4747

48-
### 1. Installation
48+
### 0. Use the Generator (Recommended)
49+
50+
The fastest way to start is using the CLI to scaffold a new project.
51+
52+
```bash
53+
# Create a new project
54+
npm create @objectql@latest my-app
55+
56+
# Choose a template when prompted (hello-world or starter)
57+
```
58+
59+
### 1. Manual Installation
60+
61+
If you prefer to install manually:
4962

5063
```bash
5164
# Install core and a driver (e.g., Postgres or SQLite)
@@ -274,6 +287,44 @@ For a complete status report on ObjectQL's implementation against the documented
274287

275288
---
276289

290+
## 🛠️ Development & Contributing
291+
292+
If you fork or clone the repository to contribute or run examples from source:
293+
294+
1. **Setup Workspace**
295+
```bash
296+
git clone https://github.com/objectql/objectql.git
297+
cd objectql
298+
npm install -g pnpm
299+
pnpm install
300+
```
301+
302+
2. **Build Packages**
303+
You must build the core libraries before running examples, as they rely on local workspace builds.
304+
```bash
305+
pnpm build
306+
```
307+
308+
3. **Run Examples**
309+
310+
These examples run as **scripts** to demonstrate the ObjectQL Core Engine capabilities (Validation, CRUD, Logic Hooks). They use an in-memory SQLite database.
311+
312+
**Starter (Project Tracker):**
313+
```bash
314+
# Starts the API Server (http://localhost:3000)
315+
pnpm --filter @objectql/example-project-tracker start
316+
317+
# Note: Sample data (projects.data.yml) is automatically loaded on startup
318+
```
319+
320+
**Enterprise ERP:**
321+
```bash
322+
pnpm --filter @objectql/example-enterprise-erp start
323+
# Output: Plugin initialization, Employee creation logs, Audit trails
324+
```
325+
326+
---
327+
277328
## ⚖️ License
278329

279330
ObjectQL is open-source software licensed under the [MIT License](https://www.google.com/search?q=LICENSE).

docs/api/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,5 +86,5 @@ curl -X POST http://localhost:3000/api/objectql \
8686
### Auto-Generated Specs
8787

8888
For automated tool ingestion, use the following endpoints:
89-
- **OpenAPI / Swagger**: `/api/docs/swagger.json`
89+
- **OpenAPI / Swagger**: `/openapi.json` (Used by `/docs` UI)
9090
- **GraphQL Schema**: `/api/graphql/schema`

docs/guide/cli.md

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,30 @@ You can then run it via `npx objectql` or add scripts to your `package.json`.
1616

1717
### 2.1 `init` (Create Project)
1818

19-
Create a new ObjectQL project from a starter template.
19+
The recommended way to create a new ObjectQL project is using the initialization package.
2020

2121
```bash
22-
npx objectql init [options]
22+
npm create @objectql@latest [name] [options]
2323
```
2424

2525
**Options:**
2626

2727
| Option | Alias | Default | Description |
2828
| :--- | :--- | :--- | :--- |
29-
| `--template <template>` | `-t` | `basic` | Template to use (`basic`, `express-api`, `enterprise`). |
30-
| `--name <name>` | `-n` | - | Project name. |
31-
| `--dir <path>` | `-d` | - | Target directory. |
29+
| `--template <template>` | `-t` | `starter` | Template to use (`starter`, `hello-world`). |
3230
| `--skip-install` | | `false` | Skip dependency installation. |
3331
| `--skip-git` | | `false` | Skip git initialization. |
3432

3533
**Example:**
3634

3735
```bash
38-
npx objectql init -t express-api -n my-app
36+
npm create @objectql@latest my-app -- --template showcase
37+
```
38+
39+
Alternatively, if you already have the CLI installed globally or in a project, you can use the legacy `init` command:
40+
41+
```bash
42+
npx objectql init [options]
3943
```
4044

4145
### 2.2 `generate` (Type Generation)
@@ -86,23 +90,43 @@ npx objectql new object customer
8690

8791
## 3. Development Tools
8892

89-
### 3.1 `serve` (Dev Server)
93+
### 3.1 `dev` (Development Server)
9094

91-
Start a standalone development server.
92-
**Alias**: `s`
95+
Start the development server with hot-reload support.
96+
**Alias**: `d`
9397

9498
```bash
95-
npx objectql serve [options]
99+
npx objectql dev [options]
96100
```
97101

98102
**Options:**
99103

100104
| Option | Alias | Default | Description |
101105
| :--- | :--- | :--- | :--- |
102106
| `--port <number>` | `-p` | `3000` | Port to listen on. |
103-
| `--dir <path>` | `-d` | `.` | Directory containing schema. |
107+
| `--dir <path>` | `-d` | `.` | Root module directory (context). |
108+
| `--config <path>` | `-c` | - | Path to `objectql.config.ts`. |
109+
| `--modules <items>` | | - | Comma-separated list of modules to load (overrides config). Supports NPM packages (`@org/pkg`) or local paths (`./src/mod`). |
110+
| `--no-watch` | | `false` | Disable file watching. |
111+
112+
### 3.2 `start` (Production Server)
113+
114+
good Start the server in production mode.
115+
116+
```bash
117+
npx objectql start [options]
118+
```
119+
120+
**Options:**
121+
122+
| Option | Alias | Default | Description |
123+
| :--- | :--- | :--- | :--- |
124+
| `--port <number>` | `-p` | `3000` | Port to listen on. |
125+
| `--dir <path>` | `-d` | `.` | Root module directory (context). |
126+
| `--config <path>` | `-c` | - | Path to `objectql.config.ts`. |
127+
| `--modules <items>` | | - | Comma-separated list of modules to load (overrides config). |
104128

105-
### 3.2 `studio` (Admin UI)
129+
### 3.3 `studio` (Admin UI)
106130

107131
Starts the web-based admin studio to browse data and view schema.
108132
**Alias**: `ui`

docs/guide/configuration.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,11 @@ import { ObjectQL } from '@objectql/core';
1010

1111
export const db = new ObjectQL({
1212
connection: 'sqlite://data.db', // 1. Infrastructure
13-
presets: ['@objectql/preset-auth'], // 2. Base Capabilities
14-
source: ['src'], // 3. Application Logic
13+
modules: [
14+
'@my-org/module-crm', // 2. External Module (NPM)
15+
'./src/modules/billing' // 3. Local Module
16+
],
17+
// source: ... (Deprecated, use modules)
1518
plugins: [] // 4. Extensions
1619
});
1720
```
@@ -26,14 +29,12 @@ The Connection String URI defining the database connection.
2629

2730
The engine will automatically load the appropriate driver (`@objectql/driver-sql` or `@objectql/driver-mongo`).
2831

29-
### `source` (string | string[])
30-
One or more directory paths (relative or absolute) containing your schema files (`*.object.yml`).
31-
The loader scans these directories recursively.
32+
### `modules` (string[])
33+
A list of modules to load. A module can be:
34+
1. **An NPM Package**: (e.g., `@objectql/starter-crm`). The loader resolves the package and looks for `src` or root directory files.
35+
2. **A Local Directory**: (e.g., `./src/my-module`). The loader scans the directory for schema files (`*.object.yml`).
3236

33-
### `presets` (string[])
34-
A list of NPM packages to load as presets.
35-
ObjectQL will try to resolve the package and load schema files from its directory.
36-
Useful for sharing common business objects (User, Role, File, etc.).
37+
This unifies the previous concepts of `source`, `dir` and `presets`.
3738

3839
### `plugins` ((ObjectQLPlugin | string)[])
3940
A list of plugin instances OR package names to extend the core functionality.

docs/guide/getting-started.md

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,40 @@
88
2. **Universal Protocol**: The query language is a JSON AST, making it easy for frontends or AI agents to generate queries.
99
3. **Action & Hook System**: Built-in support for "Button Actions" (RPC) and "Triggers" (Hooks), allowing you to model **Behavior** alongside **Data**.
1010

11-
## Quick Start: The "Hello World"
11+
## Quick Start
1212

13-
You can experience ObjectQL with a single file. No YAML, no complex config.
13+
The fastest way to get started is using the CLI to scaffold a project.
1414

15-
### 1. Minimal Setup
15+
### 1. Create a New Project
1616

17-
Install the core and SQLite driver (for zero-config database).
17+
The easiest way to start is using the generator.
1818

1919
```bash
20-
npm install @objectql/core @objectql/driver-sql sqlite3
21-
# or
22-
pnpm add @objectql/core @objectql/driver-sql sqlite3
20+
# Standard Setup (Recommended) - Full Project Tracker Demo
21+
npm create @objectql@latest my-app -- --template starter
22+
23+
# Minimal Setup - Single File
24+
npm create @objectql@latest my-app -- --template hello-world
2325
```
2426

25-
### 2. The Universal Script
27+
This will create a new project with all necessary dependencies.
28+
29+
### 2. Standard Setup (Project Tracker)
30+
31+
For building real applications, use the `showcase` template. This sets up a proper folder structure with YAML metadata, TypeScript logic hooks, and relationship management.
2632

27-
Create `index.ts`. This script defines the schema, boots the engine, and runs queries in one go.
33+
```bash
34+
npm create @objectql@latest project-tracker -- --template showcase
35+
```
36+
37+
This structure follows our **Best Practices**:
38+
* **`src/objects/*.object.yml`**: Data definitions.
39+
* **`src/hooks/*.hook.ts`**: Business logic.
40+
* **`src/index.ts`**: Application entry point.
41+
42+
## Manual Setup (The Hard Way)
43+
44+
If you prefer to set up manually or add ObjectQL to an existing project:
2845

2946
```typescript
3047
import { ObjectQL } from '@objectql/core';
@@ -82,13 +99,12 @@ async function main() {
8299
// Detects 'sqlite', 'postgres', 'mongodb' automatically
83100
connection: 'sqlite://data.db',
84101

85-
// 2. Schema Source
86-
// Where your *.object.yml files are located
87-
source: ['src/objects'],
88-
89-
// 3. Load Presets (Optional)
90-
// Load standard objects from npm packages
91-
presets: ['@objectql/preset-auth']
102+
// 2. Load Modules
103+
// Load schema from local directories OR npm packages
104+
modules: [
105+
'src/objects', // Local Module
106+
'@objectql/module-auth' // External Module (NPM)
107+
]
92108
});
93109

94110
await db.init();

0 commit comments

Comments
 (0)