|
| 1 | +--- |
| 2 | +title: Architecture |
| 3 | +description: Understanding the ObjectStack Protocol Architecture - How 11 protocol namespaces collaborate to build the Enterprise Kernel |
| 4 | +--- |
| 5 | + |
| 6 | +import { Layers, Database, Layout, ShieldCheck, Lock, Cog, Brain, Cloud, Zap } from 'lucide-react'; |
| 7 | + |
| 8 | +# Architecture Overview |
| 9 | + |
| 10 | +ObjectStack is not a monolithic framework. It is a composable ecosystem designed around a **Protocol-Driven Architecture**. The system is organized into **11 protocol namespaces**, each responsible for a specific domain. |
| 11 | + |
| 12 | +Each protocol is decoupled and communicates via standard JSON schemas defined with Zod. This allows you to swap out implementations (e.g., swapping the Postgres driver for MongoDB, or the React renderer for Flutter) without breaking the rest of the stack. |
| 13 | + |
| 14 | +## The 11 Protocol Namespaces |
| 15 | + |
| 16 | +ObjectStack is organized into 11 protocol namespaces: |
| 17 | + |
| 18 | +<Cards> |
| 19 | + <Card |
| 20 | + icon={<Database />} |
| 21 | + title="Data Protocol" |
| 22 | + description="Object schema, fields, validation, and queries." |
| 23 | + /> |
| 24 | + <Card |
| 25 | + icon={<Cog />} |
| 26 | + title="Driver Protocol" |
| 27 | + description="Database adapters (Postgres, MongoDB, SQLite, etc.)." |
| 28 | + /> |
| 29 | + <Card |
| 30 | + icon={<ShieldCheck />} |
| 31 | + title="Permission Protocol" |
| 32 | + description="Object-level, field-level, sharing, and territory rules." |
| 33 | + /> |
| 34 | + <Card |
| 35 | + icon={<Layout />} |
| 36 | + title="UI Protocol" |
| 37 | + description="Apps, views, dashboards, reports, and themes." |
| 38 | + /> |
| 39 | + <Card |
| 40 | + icon={<Layers />} |
| 41 | + title="System Protocol" |
| 42 | + description="Events, jobs, translations, and audit logging." |
| 43 | + /> |
| 44 | + <Card |
| 45 | + icon={<Lock />} |
| 46 | + title="Auth Protocol" |
| 47 | + description="Identity, roles, sessions, and authentication strategies." |
| 48 | + /> |
| 49 | + <Card |
| 50 | + icon={<Cog />} |
| 51 | + title="Kernel Protocol" |
| 52 | + description="Plugin lifecycle, manifest, logging, and context." |
| 53 | + /> |
| 54 | + <Card |
| 55 | + icon={<Cloud />} |
| 56 | + title="Hub Protocol" |
| 57 | + description="Marketplace, licensing, tenancy, and deployment." |
| 58 | + /> |
| 59 | + <Card |
| 60 | + icon={<Brain />} |
| 61 | + title="AI Protocol" |
| 62 | + description="Agents, RAG, NLQ, predictive models, and orchestration." |
| 63 | + /> |
| 64 | + <Card |
| 65 | + icon={<Zap />} |
| 66 | + title="API Protocol" |
| 67 | + description="REST contracts, discovery, realtime, and routing." |
| 68 | + /> |
| 69 | + <Card |
| 70 | + icon={<Zap />} |
| 71 | + title="Automation Protocol" |
| 72 | + description="Workflows, flows, and webhooks." |
| 73 | + /> |
| 74 | +</Cards> |
| 75 | + |
| 76 | +## The Three-Layer Architecture |
| 77 | + |
| 78 | +While ObjectStack has 11 protocol namespaces, they are logically grouped into three architectural layers: |
| 79 | + |
| 80 | +### 1. Data Layer (ObjectQL) |
| 81 | +**"The Universal Data Protocol"** |
| 82 | + |
| 83 | +The foundation layer responsible for **Data Definition** and **Data Access**. |
| 84 | + |
| 85 | +**Protocols:** |
| 86 | +- **Data Protocol:** Object schema, fields, validation, queries, filters |
| 87 | +- **Driver Protocol:** Database adapters for Postgres, MongoDB, SQLite, etc. |
| 88 | +- **Permission Protocol:** Object-level CRUD, field-level security, sharing rules |
| 89 | +- **AI Protocol:** AI agents, RAG pipelines, NLQ, predictive models |
| 90 | + |
| 91 | +**Role:** Defines *Structure* (Schema) and *Intent* (Query AST). |
| 92 | + |
| 93 | +**Responsibility:** It knows *what* a "Customer" object looks like, but it doesn't know *who* is accessing it or *how* it is displayed. |
| 94 | + |
| 95 | +**Key Component:** The **Compiler**. It takes an abstract query (`find customers where active = true`) and translates it into optimized SQL/NoSQL queries for the specific underlying database. |
| 96 | + |
| 97 | +### 2. Presentation Layer (ObjectUI) |
| 98 | +**"Server-Driven UI"** |
| 99 | + |
| 100 | +The interface layer responsible for **Visual Representation** and **User Interaction**. |
| 101 | + |
| 102 | +**Protocols:** |
| 103 | +- **UI Protocol:** Apps, views, dashboards, reports, actions, themes |
| 104 | + |
| 105 | +**Role:** Projects the Data Protocol into visual components. |
| 106 | + |
| 107 | +**Responsibility:** It knows *how* to display a "Customer" form, but it doesn't know the business rules or who can access it. |
| 108 | + |
| 109 | +**Key Component:** The **Renderer**. It takes UI metadata (JSON) and renders it as native components (React, Flutter, etc.). |
| 110 | + |
| 111 | +### 3. Control Layer (ObjectOS) |
| 112 | +**"The Business Kernel"** |
| 113 | + |
| 114 | +The orchestration layer responsible for **Runtime** and **Governance**. |
| 115 | + |
| 116 | +**Protocols:** |
| 117 | +- **System Protocol:** Events, jobs, translations, audit logging |
| 118 | +- **Auth Protocol:** Identity, roles, sessions, authentication |
| 119 | +- **Kernel Protocol:** Plugin lifecycle, manifest, context |
| 120 | +- **Hub Protocol:** Marketplace, licensing, tenancy |
| 121 | +- **API Protocol:** REST contracts, discovery, realtime |
| 122 | +- **Automation Protocol:** Workflows, flows, webhooks |
| 123 | + |
| 124 | +**Role:** Orchestrates the entire system and enforces policies. |
| 125 | + |
| 126 | +**Responsibility:** It knows *who* is accessing *what* and *when* actions should happen. |
| 127 | + |
| 128 | +**Key Component:** The **Kernel**. It manages plugins, handles events, enforces security, and coordinates between layers. |
| 129 | + |
| 130 | +## How They Work Together |
| 131 | + |
| 132 | +``` |
| 133 | +┌─────────────────────────────────────────┐ |
| 134 | +│ Control Layer (ObjectOS) │ |
| 135 | +│ ┌──────────┐ ┌────────┐ ┌──────────┐│ |
| 136 | +│ │ Kernel │ │ Auth │ │ System ││ |
| 137 | +│ │ Protocol │ │Protocol│ │ Protocol ││ |
| 138 | +│ └──────────┘ └────────┘ └──────────┘│ |
| 139 | +└─────────────────────────────────────────┘ |
| 140 | + ↕ ↕ |
| 141 | +┌──────────────────┐ ┌──────────────────┐ |
| 142 | +│ Data Layer (QL) │ │ UI Layer (UI) │ |
| 143 | +│ ┌────────────┐ │ │ ┌────────────┐ │ |
| 144 | +│ │ Data │ │ │ │ UI │ │ |
| 145 | +│ │ Protocol │ │ │ │ Protocol │ │ |
| 146 | +│ └────────────┘ │ │ └────────────┘ │ |
| 147 | +│ ┌────────────┐ │ │ │ |
| 148 | +│ │ Driver │ │ │ │ |
| 149 | +│ │ Protocol │ │ │ │ |
| 150 | +│ └────────────┘ │ │ │ |
| 151 | +└──────────────────┘ └──────────────────┘ |
| 152 | + ↕ |
| 153 | + ┌──────────┐ |
| 154 | + │ Database │ |
| 155 | + └──────────┘ |
| 156 | +``` |
| 157 | + |
| 158 | +### Example: Creating a Record |
| 159 | + |
| 160 | +1. **UI Layer:** User clicks "Save" on a Customer form |
| 161 | +2. **Control Layer:** Kernel receives the request, validates authentication |
| 162 | +3. **Data Layer:** ObjectQL compiler generates SQL INSERT statement |
| 163 | +4. **Driver:** PostgreSQL driver executes the query |
| 164 | +5. **Control Layer:** Event system triggers "after_create" workflow |
| 165 | +6. **UI Layer:** Renderer updates the interface with the new record |
| 166 | + |
| 167 | +## Protocol vs Implementation |
| 168 | + |
| 169 | +**Critical Distinction:** |
| 170 | + |
| 171 | +- **Protocol Layer:** Defined in `packages/spec` (This Repository) |
| 172 | + - Pure Zod schemas |
| 173 | + - TypeScript types |
| 174 | + - No runtime logic |
| 175 | + |
| 176 | +- **Runtime Layer:** Implemented in separate packages |
| 177 | + - Node.js Kernel (`@objectstack/kernel`) |
| 178 | + - React Renderer (`@objectstack/react`) |
| 179 | + - PostgreSQL Driver (`@objectstack/driver-postgres`) |
| 180 | + |
| 181 | +The protocol defines the "what" and "how." The runtime implements it. |
| 182 | + |
| 183 | +## Design Benefits |
| 184 | + |
| 185 | +### 1. Composability |
| 186 | +Each protocol can be used independently or combined with others. |
| 187 | + |
| 188 | +### 2. Replaceability |
| 189 | +Don't like the React renderer? Build a Vue or Flutter one. The protocol stays the same. |
| 190 | + |
| 191 | +### 3. Testability |
| 192 | +Test against the protocol specification, not a specific implementation. |
| 193 | + |
| 194 | +### 4. Future-Proof |
| 195 | +New features are additive, not breaking. Implementations can evolve independently. |
| 196 | + |
| 197 | +## Next Steps |
| 198 | + |
| 199 | +- [Glossary](/docs/00-introduction/glossary) - Key terminology explained |
| 200 | +- [Core Concepts](/docs/01-core-concepts) - Understand metadata-driven development |
| 201 | +- [Protocols](/docs/02-protocols) - Dive into each protocol specification |
0 commit comments