Skip to content

Commit 645d404

Browse files
authored
Merge pull request #330 from objectstack-ai/copilot/update-related-documentation-again
2 parents f354804 + 60651fa commit 645d404

File tree

5 files changed

+104
-3
lines changed

5 files changed

+104
-3
lines changed

ARCHITECTURE.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,86 @@ Each plugin:
219219

220220
---
221221

222+
## 📦 Package Types & Microkernel Architecture
223+
224+
ObjectStack follows a **microkernel architecture** where different package types serve distinct roles in the system lifecycle. The `type` field in the manifest (`objectstack.config.ts`) determines a package's role and initialization order.
225+
226+
### Package Type Hierarchy
227+
228+
```
229+
External Request (Browser/Mobile)
230+
231+
232+
[ adapter ] ←─ HTTP Server Container (Express, Hono, Fastify, Serverless)
233+
│ • Role: Runtime host/container
234+
│ • Cardinality: Singleton (one per runtime)
235+
│ • Examples: @objectstack/adapter-express, @objectstack/adapter-hono
236+
237+
[ gateway ] ←─ API Protocol Layer (GraphQL, REST, RPC, OData)
238+
│ • Role: Protocol translation
239+
│ • Cardinality: Multiple (can coexist)
240+
│ • Examples: @objectstack/gateway-graphql, @objectstack/gateway-rest
241+
242+
[ Kernel ] ←─ Core orchestration (ObjectOS Runtime)
243+
244+
245+
[ objectql] ←─ Core Data Engine
246+
│ • Role: Query engine and business logic layer
247+
│ • Examples: @objectstack/objectql
248+
249+
[ driver ] ←─ Southbound: Database/External Service Adapters
250+
│ • Role: Data persistence and external integrations
251+
│ • Examples: @objectstack/driver-postgres, @objectstack/driver-mongodb
252+
253+
Database
254+
```
255+
256+
### Package Type Definitions
257+
258+
| Type | Description | Cardinality | Layer | Examples |
259+
|:-----|:------------|:------------|:------|:---------|
260+
| **adapter** | Runtime container - HTTP server adapter | Singleton | Outermost | Express, Hono, Fastify, Lambda |
261+
| **gateway** | API protocol entry point | Multiple | North | GraphQL, REST, RPC, OData |
262+
| **objectql** | Core data engine implementation | Singleton | Core | Query engine, business logic |
263+
| **driver** | Database/external service adapter | Multiple | South | Postgres, MongoDB, S3, Salesforce |
264+
| **plugin** | General-purpose functionality extension | Multiple | App | CRM, BI, Analytics |
265+
| **app** | Business application package | Multiple | App | Sales App, Service App |
266+
| **module** | Reusable code library/shared module | Multiple | Lib | Utilities, helpers |
267+
268+
### Lifecycle Ordering
269+
270+
The kernel initializes packages in a specific order to ensure proper dependency resolution:
271+
272+
1. **Adapter** preparation (HTTP server setup)
273+
2. **ObjectQL** engine initialization (core data layer)
274+
3. **Driver** connections (database, external services)
275+
4. **Gateway** registration (API protocol handlers)
276+
5. **App/Plugin** loading (business logic)
277+
278+
This ordering ensures that:
279+
- The HTTP server is ready before routes are registered
280+
- The data engine is initialized before drivers connect
281+
- Drivers are connected before gateways need to query data
282+
- Gateways are ready before apps register business endpoints
283+
284+
### Adapter vs Gateway Distinction
285+
286+
**Key Architectural Difference:**
287+
288+
- **Adapter** = The "what" and "where" (which HTTP framework, which runtime environment)
289+
- Handles raw HTTP Request/Response objects
290+
- Manages server lifecycle (listen, close)
291+
- One adapter per runtime instance
292+
- Cannot coexist (can't run Express + Hono on same port)
293+
294+
- **Gateway** = The "how" (which API protocol)
295+
- Translates protocol to internal `Call` format
296+
- Multiple gateways can coexist
297+
- Registers routes on the adapter
298+
- Example: Same server can expose both GraphQL and REST APIs
299+
300+
---
301+
222302
## 🔐 Security & Permission Model
223303

224304
```

PROTOCOL_REFERENCE.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ Defines the "Runtime Environment" and platform capabilities.
8484

8585
| File | Schema | Purpose |
8686
| :--- | :--- | :--- |
87-
| `manifest.zod.ts` | `ManifestSchema` | Application/plugin manifest (`objectstack.config.ts`) |
87+
| `manifest.zod.ts` | `ManifestSchema` | Application/plugin manifest (`objectstack.config.ts`) with 7 package types: app, plugin, driver, module, objectql, gateway, adapter |
8888
| `datasource.zod.ts` | `DatasourceSchema` | Data source connection configurations |
8989
| `driver.zod.ts` | `DriverSchema` | Database driver definitions and options |
9090
| `driver/postgres.zod.ts` | `PostgresConfigSchema` | PostgreSQL-specific driver configuration |
@@ -100,6 +100,14 @@ Defines the "Runtime Environment" and platform capabilities.
100100
| `scoped-storage.zod.ts` | `ScopedStorageSchema` | Scoped key-value storage |
101101

102102
**Key Features:**
103+
- Microkernel architecture with 7 distinct package types for proper separation of concerns
104+
- **adapter**: Runtime containers (Express, Hono, Fastify, Serverless)
105+
- **gateway**: API protocols (GraphQL, REST, RPC, OData)
106+
- **objectql**: Core data engine implementation
107+
- **driver**: Database/external service adapters (Postgres, MongoDB, S3)
108+
- **plugin**: General-purpose functionality extensions
109+
- **app**: Business application packages
110+
- **module**: Reusable code libraries
103111
- Pluggable architecture with manifest-based configuration
104112
- Multi-driver support (PostgreSQL, MongoDB, and extensible)
105113
- Event-driven architecture with pub/sub

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ Defines the "Shape of Interaction" for rendering interfaces.
9292

9393
### 3. System Protocol (ObjectOS) - 14 Protocols
9494
Defines the "Runtime Environment" and platform capabilities.
95-
- **Manifest:** Application packaging (`objectstack.config.ts`)
95+
- **Manifest:** Application packaging (`objectstack.config.ts`) with support for 7 package types: `app`, `plugin`, `driver`, `module`, `objectql`, `gateway`, `adapter`
9696
- **Identity:** Authentication, Roles, Territories, Licenses, Organizations
9797
- **Integration:** Webhooks, API contracts, ETL Mappings
9898
- **Datasource:** Driver definitions for PostgreSQL, MongoDB, and extensible drivers

content/docs/developers/writing-plugins.mdx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,19 @@ npm run build
704704
}
705705
```
706706

707+
**Package Type Options:**
708+
709+
The `type` field in the `objectstack` configuration can be one of:
710+
- `plugin` - General-purpose functionality extension (default for most plugins)
711+
- `app` - Business application package
712+
- `driver` - Database/external service adapter (Postgres, MongoDB, S3)
713+
- `module` - Reusable code library/shared module
714+
- `objectql` - Core data engine implementation
715+
- `gateway` - API protocol entry point (GraphQL, REST, RPC)
716+
- `adapter` - Runtime container (Express, Hono, Fastify, Serverless)
717+
718+
For most use cases, use `plugin` for business logic extensions and `driver` for data source integrations.
719+
707720
---
708721

709722
## 🚀 Publishing

content/docs/references/kernel/manifest/Manifest.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ description: Manifest Schema Reference
99
| :--- | :--- | :--- | :--- |
1010
| **id** | `string` || Unique package identifier (reverse domain style) |
1111
| **version** | `string` || Package version (semantic versioning) |
12-
| **type** | `Enum<'app' \| 'plugin' \| 'driver' \| 'module'>` || Type of package |
12+
| **type** | `Enum<'app' \| 'plugin' \| 'driver' \| 'module' \| 'objectql' \| 'gateway' \| 'adapter'>` || Type of package |
1313
| **name** | `string` || Human-readable package name |
1414
| **description** | `string` | optional | Package description |
1515
| **permissions** | `string[]` | optional | Array of required permission strings |

0 commit comments

Comments
 (0)