Skip to content

Commit 38abac2

Browse files
committed
Refactor docs: move and restructure concepts section
Moved and renamed framework documentation files to the concepts section, added new architecture and introduction docs in both English and Chinese, and updated meta files accordingly. Removed obsolete framework and objectql protocol-spec files, and updated references in index and meta files to reflect the new structure. This improves organization and clarity of the documentation, consolidating conceptual materials under a unified path.
1 parent f4d8ee7 commit 38abac2

65 files changed

Lines changed: 1472 additions & 10384 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ npx typedoc --out docs/api src/
305305
### 1. Clear Context
306306
307307
When conversing with AI, clearly specify:
308-
- Using ObjectStack framework
308+
- Using ObjectStack concepts
309309
- Protocol specifications to follow
310310
- Target database type (if special requirements)
311311
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
---
2+
title: Architecture Overview
3+
description: Understanding the ObjectStack Trinity. How ObjectQL, ObjectOS, and ObjectUI collaborate to build the Enterprise Kernel.
4+
---
5+
6+
# Architecture Overview
7+
8+
ObjectStack is not a monolithic framework. It is a composable ecosystem designed around a **Layered Architecture**. We call this the **"ObjectStack Trinity."**
9+
10+
Each layer is decoupled and communicates via standard JSON protocols. This allows you to swap out implementations (e.g., swapping the React renderer for a Flutter renderer) without breaking the rest of the stack.
11+
12+
13+
14+
## The Trinity
15+
16+
### 1. The Data Layer: ObjectQL
17+
**"The Universal Protocol"**
18+
19+
At the foundation lies ObjectQL. It is responsible for **Data Definition** and **Data Access**.
20+
21+
* **Role:** Defines *Structure* (Schema) and *Intent* (Query AST).
22+
* **Responsibility:** It knows *what* a "Customer" object looks like, but it doesn't know *who* is accessing it or *how* it is displayed.
23+
* **Key Component:** The **Compiler**. It takes an abstract query (`find customers where active = true`) and translates it into optimized SQL for the specific underlying database (Postgres, SQLite, MySQL).
24+
25+
### 2. The Control Layer: ObjectOS
26+
**"The Business Kernel"**
27+
28+
Sitting in the middle is ObjectOS. It is responsible for **Orchestration** and **Governance**.
29+
30+
* **Role:** Manages the *Lifecycle* of a request.
31+
* **Responsibility:**
32+
* **Identity:** "Who is this user?" (Authentication).
33+
* **Security:** "Can they see this field?" (RBAC/ACL).
34+
* **Sync:** "How do we merge these offline changes?" (Conflict Resolution).
35+
* **Process:** "What happens after this record is saved?" (Workflows/Triggers).
36+
* **Key Concept:** It acts as the gateway. No direct database access is allowed; everything must pass through the OS Kernel.
37+
38+
### 3. The View Layer: ObjectUI
39+
**"The Projection Engine"**
40+
41+
At the top is ObjectUI. It is responsible for **Interaction** and **Rendering**.
42+
43+
* **Role:** Consumes the Protocol to render the Interface.
44+
* **Responsibility:** It does not contain hardcoded forms. Instead, it asks ObjectQL: *"What is the schema for a Customer?"* and dynamically renders a layout based on that metadata.
45+
* **Key Concept:** **Server-Driven UI (SDUI)**. The backend dictates the layout, validation rules, and available actions. The frontend is merely a highly capable renderer.
46+
47+
---
48+
49+
## The Request Lifecycle
50+
51+
To understand how these pieces fit together, let's trace a typical user interaction—for example, a Sales Rep updating a deal status while offline.
52+
53+
### Step 1: Interaction (ObjectUI)
54+
The user clicks "Mark as Won" in the UI.
55+
* **ObjectUI** validates the input against the JSON Schema (loaded locally).
56+
* It does not send an API request immediately. It writes the change to the **Local Database** (e.g., SQLite/RxDB).
57+
* The UI updates instantly (0ms latency).
58+
59+
### Step 2: Synchronization (ObjectOS Sync)
60+
When the network is available, the Client pushes a "Mutation Packet" to the Server.
61+
* **ObjectOS** receives the packet.
62+
* It authenticates the session (`@objectos/auth`).
63+
* It checks against the **Audit Log** for conflicts (e.g., did someone else edit this deal 5 minutes ago?).
64+
* It runs any server-side **Workflow** logic (e.g., "If Deal > $10k, trigger Manager Approval").
65+
66+
### Step 3: Compilation (ObjectQL)
67+
Once ObjectOS approves the request, it passes the data operation to ObjectQL.
68+
* **ObjectQL** receives the AST: `UPDATE Deals SET Status = 'Won' WHERE ID = '123'`.
69+
* The **Compiler** translates this into the target dialect: `UPDATE "deals" SET "status" = 'Won'...`.
70+
* The **Driver** executes the SQL against the master PostgreSQL database.
71+
72+
---
73+
74+
## Deployment Topologies
75+
76+
Because the architecture is protocol-driven, it supports various deployment models depending on your infrastructure needs.
77+
78+
### A. The Monolith (Default)
79+
Ideal for small-to-medium enterprise apps.
80+
* **Frontend:** React Single Page App (SPA).
81+
* **Backend:** A single Node.js instance running ObjectOS + ObjectQL Core.
82+
* **Database:** Single PostgreSQL instance.
83+
84+
### B. Local-First / Edge
85+
Ideal for field service apps, POS systems, and high-performance SaaS.
86+
* **Frontend:** ObjectUI + Embedded ObjectQL (Wasm) + SQLite.
87+
* **Backend:** ObjectOS running as a Sync Gateway (Stateless).
88+
* **Database:** Distributed SQL or simple object storage for replication logs.
89+
90+
### C. Microservices Federation
91+
Ideal for large-scale enterprise integration.
92+
* Multiple ObjectOS instances (CRM Service, ERP Service, HR Service).
93+
* A centralized **Gateway** aggregates the ObjectQL schemas into a "Super Graph" (similar to GraphQL Federation).
94+
* ObjectUI renders a unified dashboard by consuming the federated schema.

content/docs/concepts/core-values.mdx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
---
22
title: Core Values
33
description: "Deep dive into the three pillars of ObjectStack: Protocol-Driven Architecture, Local-First Data Sovereignty, and Database Agnosticism."
4-
sidebar_position: 2
5-
slug: /concepts/core-values
64
---
75

86
# Core Values

content/docs/concepts/enterprise-patterns.mdx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
---
22
title: Enterprise Patterns
33
description: Handling complex ERP/CRM business logic (State Machines, Calculations, RBAC) using the Protocol-Driven approach.
4-
sidebar_position: 4
5-
slug: /concepts/enterprise-patterns
64
---
75

86
# Enterprise Patterns

content/docs/concepts/index.cn.mdx

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
---
2+
title: 导读:协议驱动范式
3+
description: 为什么世界需要一个通用的企业级全栈协议标准?从代码驱动转向协议驱动的架构变革。
4+
---
5+
6+
# 导读:协议驱动范式 (The Protocol-Driven Paradigm)
7+
8+
> "Code rots. Protocols endure."
9+
> (代码会腐烂,协议永存。)
10+
11+
在过去的一二十年里,企业软件开发陷入了一个西西弗斯式的循环:
12+
13+
我们用 JSP 写了一遍 CRM,五年后用 Angular 重写,再过五年用 React 重写。后端也从 PHP 换到 Node.js,再到 Go。每一次技术栈的迭代,我们都在**重新实现完全相同的业务逻辑**——相同的表单验证、相同的权限判断、相同的审批流程。
14+
15+
这种**“代码驱动(Code-Driven)”**的开发模式带来了巨大的隐性成本:**业务逻辑与技术实现紧密耦合**。当技术框架过时,业务资产也随之贬值,甚至成为技术债。
16+
17+
**ObjectStack 的诞生,旨在终结这一循环。**
18+
19+
## 什么是 ObjectStack?
20+
21+
ObjectStack 不是一个简单的框架或库,它是一套**全栈应用开发协议标准(Standard Protocols)**
22+
23+
它主张将应用的**“意图(Intent)”****“实现(Implementation)”**彻底分离。通过标准化的 JSON 协议来定义数据、界面和流程,从而使业务逻辑独立于具体的编程语言和数据库技术。
24+
25+
ObjectStack 的核心架构由三大支柱构成:
26+
27+
1. **ObjectQL (The Data Protocol):** 数据库无关的通用数据协议。
28+
2. **ObjectUI (The View Protocol):** 声明式的通用界面协议。
29+
3. **ObjectOS (The Runtime Protocol):** 负责编排与治理的业务操作系统。
30+
31+
32+
33+
## 核心哲学
34+
35+
### 1. 协议驱动开发 (Protocol-Driven Development)
36+
37+
在传统开发中,业务逻辑被硬编码在函数中:
38+
39+
```javascript
40+
// The Old Way: Imperative & Coupled
41+
function createOrder(data) {
42+
if (data.amount > 1000 && !user.isManager) {
43+
throw new Error("Need approval");
44+
}
45+
db.query("INSERT INTO orders ...");
46+
}
47+
48+
```
49+
50+
在 ObjectStack 中,业务逻辑被定义为**数据(Metadata/Protocol)**
51+
52+
```yaml
53+
# The ObjectStack Way: Declarative & Decoupled
54+
object: order
55+
fields:
56+
amount: { type: currency }
57+
validation:
58+
- rule: "amount > 1000"
59+
guard: "!user.isManager"
60+
message: "Need approval"
61+
62+
```
63+
64+
* **差异:** 上述 YAML 配置不依赖任何语言。它可以被 Node.js 后端执行,可以被 Python 脚本分析,甚至可以直接传输给前端进行即时校验。
65+
* **价值:** 你的业务逻辑成为了**可移植、可分析、可进化的数字资产**,而不仅仅是一堆即将过时的代码。
66+
67+
### 2. 本地优先 (Local-First & Data Sovereignty)
68+
69+
云原生(Cloud-Native)带来了便捷,但也剥夺了用户的数据主权。SaaS 厂商的数据孤岛让企业失去了对自己数据的物理控制权。
70+
71+
ObjectStack 拥抱 **Local-First** 架构:
72+
73+
* 应用首先在本地数据库(如 SQLite, RxDB)读写数据。
74+
* 操作即时响应,无需等待网络往返。
75+
* **ObjectOS** 负责在后台处理复杂的数据同步和冲突解决(CRDTs/LWW)。
76+
77+
这意味着:**即便断网,你的企业软件依然可用;即便云服务商倒闭,你的数据依然在你手中。**
78+
79+
### 3. 跨数据库 (Database-Agnostic)
80+
81+
企业不应被数据库厂商锁定。
82+
83+
**ObjectQL** 充当了一个**数据库编译器**的角色。你编写标准的 ObjectQL Schema 和 Query AST,引擎负责将其编译为:
84+
85+
* **PostgreSQL** (用于生产环境)
86+
* **SQLite** (用于边缘设备或本地开发)
87+
* **MySQL / Oracle / SQL Server** (用于遗留系统集成)
88+
89+
这种能力让架构师可以在不同的场景下选择最优的存储引擎,而无需重写任何业务代码。
90+
91+
## 为什么是现在?
92+
93+
AI 正在重塑软件工程。
94+
95+
当 AI 辅助编程(Copilot)日益普及,我们发现 AI 生成**结构化的协议(JSON/YAML)**比生成**过程式的代码(JavaScript/Python)**要准确得多、安全得多。
96+
97+
* AI 生成代码容易产生幻觉(Hallucinations)和 Bug。
98+
* AI 生成符合 Schema 的 JSON 配置则是确定性的、可校验的。
99+
100+
ObjectStack 是**为 AI 时代设计的架构**。它提供了一套 AI 能够完美理解和操作的标准语义层,使得“通过对话生成软件”成为可能。
101+
102+
## 概览
103+
104+
在接下来的章节中,我们将深入探讨这套协议的细节:
105+
106+
* 前往 **[架构全景](https://www.google.com/search?q=./03-architecture.md)** 查看各组件如何协作。
107+
* 前往 **[核心价值](https://www.google.com/search?q=./02-core-values.md)** 了解更多关于本地优先的思考。
108+
* 前往 **[企业级模式](https://www.google.com/search?q=./04-enterprise-patterns.md)** 了解如何处理复杂的 ERP 场景。
109+
110+
:::tip 记住
111+
ObjectStack 的目标不是让你写代码写得更快,而是让你写的代码**活得更久**
112+
:::

content/docs/concepts/index.mdx

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
---
2+
title: "Introduction"
3+
description: Why the world needs a universal enterprise full-stack protocol standard. Shifting from Code-Driven to Protocol-Driven architecture.
4+
---
5+
6+
# Introduction: The Protocol-Driven Paradigm
7+
8+
> "Code rots. Protocols endure."
9+
10+
For the past two decades, enterprise software development has been trapped in a Sisyphean cycle:
11+
12+
We built CRMs with JSP, then rewrote them in Angular five years later, and rewrote them again in React five years after that. Backends shifted from PHP to Node.js, and then to Go. With every iteration of the tech stack, we are **re-implementing the exact same business logic**—the same form validations, the same permission checks, the same approval workflows.
13+
14+
This **"Code-Driven"** development model carries a massive hidden cost: **Business logic is tightly coupled with technical implementation.** When the framework becomes obsolete, your business assets depreciate with it, eventually turning into technical debt.
15+
16+
**ObjectStack was born to end this cycle.**
17+
18+
## What is ObjectStack?
19+
20+
ObjectStack is not just a framework or a library; it is a **Universal Full-Stack Application Protocol Standard**.
21+
22+
It advocates for the complete separation of **"Intent"** from **"Implementation"**. By defining data, interfaces, and processes through standardized JSON protocols, business logic becomes independent of specific programming languages and database technologies.
23+
24+
The core architecture of ObjectStack consists of three pillars:
25+
26+
1. **ObjectQL (The Data Protocol):** A database-agnostic universal data protocol.
27+
2. **ObjectUI (The View Protocol):** A declarative universal interface protocol.
28+
3. **ObjectOS (The Runtime Protocol):** A business operating system responsible for orchestration and governance.
29+
30+
31+
32+
## Core Philosophy
33+
34+
### 1. Protocol-Driven Development
35+
36+
In traditional development, business logic is hard-coded into functions:
37+
38+
```javascript
39+
// The Old Way: Imperative & Coupled
40+
function createOrder(data) {
41+
if (data.amount > 1000 && !user.isManager) {
42+
throw new Error("Need approval");
43+
}
44+
db.query("INSERT INTO orders ...");
45+
}
46+
47+
```
48+
49+
In ObjectStack, business logic is defined as **Data (Metadata/Protocol)**:
50+
51+
```yaml
52+
# The ObjectStack Way: Declarative & Decoupled
53+
object: order
54+
fields:
55+
amount: { type: currency }
56+
validation:
57+
- rule: "amount > 1000"
58+
guard: "!user.isManager"
59+
message: "Need approval"
60+
61+
```
62+
63+
* **The Difference:** The YAML configuration above relies on no specific language. It can be executed by a Node.js backend, analyzed by a Python script, or even transmitted to the frontend for immediate client-side validation.
64+
* **The Value:** Your business logic becomes a **portable, analyzable, and evolvable digital asset**, rather than a pile of code destined for obsolescence.
65+
66+
### 2. Local-First & Data Sovereignty
67+
68+
Cloud-Native brings convenience, but it also strips users of data sovereignty. Data silos created by SaaS vendors leave enterprises without physical control over their own data.
69+
70+
ObjectStack embraces a **Local-First** architecture:
71+
72+
* Applications read and write data primarily to a local database (e.g., SQLite, RxDB).
73+
* Interactions are instantaneous, requiring no network round-trips.
74+
* **ObjectOS** handles complex data synchronization and conflict resolution (CRDTs/LWW) in the background.
75+
76+
This means: **Even if the network goes down, your enterprise software remains usable. Even if the cloud provider goes bankrupt, your data remains in your hands.**
77+
78+
### 3. Database-Agnostic
79+
80+
Enterprises should not be locked into a specific database vendor.
81+
82+
**ObjectQL** acts as a **Database Compiler**. You write standard ObjectQL Schema and Query ASTs, and the engine compiles them into:
83+
84+
* **PostgreSQL** (For production environments)
85+
* **SQLite** (For edge devices or local development)
86+
* **MySQL / Oracle / SQL Server** (For legacy system integration)
87+
88+
This capability allows architects to choose the optimal storage engine for different scenarios without rewriting a single line of business code.
89+
90+
## Why Now?
91+
92+
AI is reshaping software engineering.
93+
94+
As AI-assisted programming (Copilot) becomes ubiquitous, we are discovering that AI generates **Structured Protocols (JSON/YAML)** far more accurately and safely than it generates **Imperative Code (JavaScript/Python)**.
95+
96+
* AI-generated code is prone to hallucinations and bugs.
97+
* AI-generated JSON configuration, validated against a Schema, is deterministic and verifiable.
98+
99+
ObjectStack is an **architecture designed for the AI Era**. It provides a standard semantic layer that AI can perfectly understand and manipulate, making "Software Generation via Conversation" a reality.
100+
101+
## Overview
102+
103+
In the following sections, we will explore the details of these protocols:
104+
105+
* Go to **[Architecture Overview](https://www.google.com/search?q=./03-architecture.md)** to see how the components collaborate.
106+
* Go to **[Core Values](https://www.google.com/search?q=./02-core-values.md)** to learn more about Local-First thinking.
107+
* Go to **[Enterprise Patterns](https://www.google.com/search?q=./04-enterprise-patterns.md)** to understand how to handle complex ERP scenarios.
108+
109+
:::tip Remember
110+
The goal of ObjectStack is not just to make you write code faster, but to make the code you write **live longer**.
111+
:::
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ ObjectStack's protocol layer (ObjectQL, ObjectUI) consists purely of specificati
2929

3030
**When designing protocols**:
3131
- Use standard JSON Schema format
32-
- Avoid introducing language or framework-specific concepts
32+
- Avoid introducing language or concepts-specific concepts
3333
- Keep protocols simple and extensible
3434
- Define in Spec layer first, implement in Engine layer second
3535

content/docs/concepts/meta.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"title": "Concepts",
3+
"root": true,
4+
"pages": ["index", "core-values", "architecture", "enterprise-patterns", "terminology"]
5+
}

content/docs/concepts/terminology.mdx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
---
22
title: Terminology
33
description: A glossary of key terms, concepts, and jargon used within the ObjectStack ecosystem.
4-
sidebar_position: 5
5-
slug: /concepts/terminology
64
---
75

86
# Terminology

0 commit comments

Comments
 (0)