@@ -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```
0 commit comments