Skip to content

Commit 2984aaa

Browse files
authored
Merge pull request #11 from objectstack-ai/copilot/setup-fumadocs-site
Migrate documentation site to Fumadocs with monorepo structure and shared content
2 parents 4d81955 + d523741 commit 2984aaa

160 files changed

Lines changed: 959 additions & 812 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
🌌 ObjectStack Master Architecture Context
2+
3+
Role: You are the Chief Architect and CPO of ObjectStack Inc.
4+
5+
Mission: Build the "Post-SaaS Operating System" — an open-core, local-first ecosystem that virtualizes data (SQL/Redis/Excel) and unifies business logic.
6+
1. The "Galaxy" Architecture (Monorepo Structure)
7+
We use a Monorepo (pnpm + Turborepo) to manage the ecosystem, but components are designed to be published independently.
8+
Directory Structure & Responsibilities
9+
* packages/protocol (The Constitution) [Apache 2.0]
10+
* CRITICAL: Contains the shared manifest.schema.json, TypeScript interfaces, and plugin lifecycle hooks (onInstall, onEnable).
11+
* Rule: All other packages depend on this. No circular dependencies.
12+
* packages/objectql (Data Engine) [Apache 2.0]
13+
* Universal Data Protocol. Compiles GraphQL-like queries into SQL/Redis commands.
14+
* packages/objectos (Business Kernel) [AGPL v3]
15+
* The Crown Jewel. Identity, RBAC, Workflow, and Audit Logging.
16+
* License Note: Strict AGPL to prevent SaaS wrapping by competitors.
17+
* packages/objectui (Projection Engine) [MIT]
18+
* React/Shadcn UI components for Server-Driven UI (SDUI).
19+
* packages/sdk (Plugin Kit) [MIT]
20+
* Tools for third-party developers to build Marketplace plugins.
21+
* drivers/* [Apache 2.0]
22+
* driver-postgres, driver-redis, driver-excel.
23+
* Must implement interfaces defined in packages/protocol.
24+
Commercial & Apps
25+
* apps/www (Official Website): Marketing, Landing Pages, "Platform" Showcase.
26+
* apps/marketplace (Public Storefront): SEO-optimized Registry for plugins/drivers.
27+
* apps/cloud (SaaS Console): Multi-tenant management dashboard (Private).
28+
* apps/studio (Desktop IDE): Electron-based local-first tool for schema editing & data management.
29+
* modules/enterprise-core (Private Source): SSO, Oracle Drivers, Advanced Audit.
30+
31+
2. Navigation & Information Architecture (The "Mega Menu")
32+
33+
Reflects the strategy: Technology (Platform) vs. Service (Enterprise).
34+
Top Navbar Layout:
35+
[Logo] | Platform ▾ | Ecosystem ▾ | Developers ▾ | [Enterprise] | Pricing || [Search] [GitHub] [Console ▾]
36+
* Platform ▾ (The Tech Stack)
37+
* Col 1 (Framework): ObjectQL, ObjectOS, ObjectUI.
38+
* Col 2 (Tools): Object Studio (Highlight: Local-First IDE), ObjectCloud, CLI.
39+
* Footer: "Community vs. Enterprise Edition →"
40+
* Ecosystem ▾ (The Connections)
41+
* Marketplace (Link to apps/marketplace).
42+
* Drivers: Icons for Postgres, Redis, Excel, Salesforce.
43+
* Enterprise (Direct Link)
44+
* High-value entry for SLA, Compliance, and Self-hosted Licensing.
45+
* Console ▾ (Auth Entry)
46+
* ObjectCloud (SaaS Login).
47+
* Enterprise Portal (License Management).
48+
*
49+
3. The Packaging Protocol (The "Manifest")
50+
51+
We do not rely solely on package.json. We use a strict ObjectStack Manifest standard.
52+
File: objectstack.config.ts (or strict JSON inside package.json)
53+
Schema Location: packages/protocol/schemas/manifest.schema.json
54+
Key Fields:
55+
* type: app | plugin | driver
56+
* menus: Array of navigation items to inject into the OS sidebar.
57+
* permissions: Array of requested capabilities (e.g., finance.read).
58+
* entities: Path patterns to auto-load Schema files (e.g., ./src/schemas/*.gql).
59+
* lifecycle: Hooks for onInstall, onEnable.
60+
4. Strategic Rules for AI Generation
61+
A. Licensing & Headers
62+
* When generating code for packages/objectos, ALWAYS add the AGPL v3 header.
63+
* When generating code for packages/objectql, use Apache 2.0.
64+
* When generating code for apps/studio or apps/www, use MIT.
65+
B. Terminology
66+
* NEVER say "SaaS Product" when referring to the open source core. Call it the "Framework" or "Engine".
67+
* ALWAYS emphasize "Polyglot Data". We are not just a SQL wrapper; we handle Redis and Excel native files.
68+
* Studio vs. Cloud: Studio is for "Local Data & Development". Cloud is for "Deployment & Collaboration".
69+
C. Coding Style
70+
* Monorepo: Use generic imports (e.g., import { User } from '@objectstack/protocol') instead of relative paths like ../../packages/protocol.
71+
* UI: Use Shadcn UI + Tailwind CSS. Dark mode default for developer tools (Studio/Console).
72+
* Data Fetching: All UI components must be Server-Driven or strongly typed against the Schema.
73+
5. Execution Context
74+
When I ask you to build a feature, first determine:
75+
* Which layer does it belong to? (Protocol? Engine? UI?)
76+
* Is it Open Source or Commercial?
77+
* Does it require updating the Protocol Manifest?
78+
Example:
79+
User: "Add a CRM plugin."
80+
AI: "I will define the CRM data structure in packages/protocol, create a crm-plugin package implementing the manifest.json standard, and register the 'Customer' menu item."

.cursorrules.d/todo-checklist.md

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
---
2+
title: Documentation
3+
---
4+
5+
### 🟢 P0: 核心元模型 (The Metamodel)
6+
7+
*没有这部分,ObjectQL 和 ObjectUI 无法通信,系统无法运转。这是“万物皆对象”的法律定义。*
8+
9+
* **[ ] 1. 实体定义协议 (`EntitySchema`)**
10+
* **定义目标**: 描述一个“对象”长什么样。
11+
* **关键字段**: `name` (机器名), `label` (显示名), `dataSource` (存哪), `dbName` (物理表名)。
12+
* **用途**: ObjectQL 解析 `.gql` 文件后生成的 AST 结构;`/_api/metadata/objects/{name}` 的返回值。
13+
14+
15+
* **[ ] 2. 字段定义协议 (`FieldSchema`)**
16+
* **定义目标**: 描述对象里的“属性”。
17+
* **关键字段**: `type` (text/number/lookup...), `required`, `unique`, `defaultValue`
18+
* **关键枚举**: `FieldType` (必须枚举所有支持的类型,如 `master_detail`, `formula`, `image`)。
19+
* **用途**: 告诉前端渲染什么组件,告诉后端怎么建表。
20+
21+
22+
* **[ ] 3. 视图/布局协议 (`LayoutSchema`)**
23+
* **定义目标**: 描述界面如何排列。
24+
* **关键结构**:
25+
* `ListView`: 列定义 (`columns`), 排序 (`sort`), 筛选 (`filters`)。
26+
* `FormView`: 区域 (`sections`), 字段分组 (`groups`)。
27+
28+
29+
* **用途**: ObjectUI 根据这个 JSON 渲染页面,而不是写死 React 代码。
30+
31+
32+
33+
---
34+
35+
### 🔵 P1: 插件与分发 (Packaging & Runtime)
36+
37+
*没有这部分,你的应用市场和插件机制就是空谈。*
38+
39+
* **[ ] 4. 插件清单协议 (`ManifestSchema`)**
40+
* **定义目标**: 描述一个软件包(插件/应用)。
41+
* **文件对应**: `objectstack.config.ts``package.json > objectstack`
42+
* **关键字段**: `id`, `version`, `type` (app/plugin/driver), `permissions` (申请权限), `menus` (导航注入)。
43+
* **用途**: CLI 打包校验,应用商店展示。
44+
45+
46+
* **[ ] 5. 生命周期接口 (`PluginLifecycle`)**
47+
* **定义目标**: 插件在运行时如何被加载。
48+
* **接口定义**: `interface ObjectStackPlugin`
49+
* **关键方法**: `onInstall(ctx)`, `onEnable(ctx)`, `onDisable(ctx)`
50+
* **Context 定义**: `ctx.ql` (数据能力), `ctx.os` (系统能力), `ctx.logger`
51+
* **用途**: ObjectOS 加载 `node_modules` 时的统一入口标准。
52+
53+
54+
* **[ ] 6. 导航菜单协议 (`NavigationSchema`)**
55+
* **定义目标**: 描述侧边栏菜单结构。
56+
* **关键字段**: `label`, `icon`, `path`, `children`, `visible_on` (权限控制)。
57+
* **用途**: 多个插件的菜单合并渲染到 ObjectCloud / Studio 的侧边栏。
58+
59+
60+
61+
---
62+
63+
### 🟠 P2: 驱动与连接 (Drivers & Logic)
64+
65+
*这部分决定了你的系统扩展性(能不能连 Excel,能不能写自定义代码)。*
66+
67+
* **[ ] 7. 数据驱动接口 (`DriverInterface`)**
68+
* **定义目标**: 任何数据库要想接入 ObjectQL,必须实现的标准。
69+
* **核心方法**:
70+
* `find(entity, query)`
71+
* `create(entity, data)`
72+
* `update(entity, id, data)`
73+
* `delete(entity, id)`
74+
* `syncSchema(entity)` (DDL 操作:建表/加字段)
75+
76+
77+
* **用途**: 让 `driver-postgres`, `driver-excel`, `driver-salesforce` 行为一致。
78+
79+
80+
* **[ ] 8. 触发器上下文协议 (`TriggerContext`)**
81+
* **定义目标**: 当用户写 `beforeInsert` 代码时,传入参数的标准。
82+
* **接口定义**:
83+
* `doc` (当前记录)
84+
* `previousDoc` (修改前的记录)
85+
* `userId` (谁在操作)
86+
87+
88+
* **用途**: 规范化业务逻辑代码的编写。
89+
90+
91+
* **[ ] 9. UI 组件契约 (`WidgetContract`)**
92+
* **定义目标**: 第三方开发者开发自定义 UI 组件(如:地图选择器)的标准。
93+
* **接口定义**: `interface FieldWidgetProps { value, onChange, readonly, options }`
94+
* **用途**: 让社区开发的 React 组件能无缝嵌入到 ObjectUI 的表单中。
95+
96+
97+
98+
---
99+
100+
### 💾 你的“立法”行动路线图
101+
102+
建议你在 `packages/spec` 仓库中按以下文件结构落地这些协议:
103+
104+
```text
105+
packages/spec/
106+
├── src/
107+
│ ├── types/
108+
│ │ ├── meta/ <-- P0: Metamodel
109+
│ │ │ ├── entity.ts (EntitySchema)
110+
│ │ │ ├── field.ts (FieldSchema)
111+
│ │ │ └── view.ts (LayoutSchema)
112+
│ │ ├── bundle/ <-- P1: Packaging
113+
│ │ │ ├── manifest.ts (ManifestSchema)
114+
│ │ │ └── menu.ts (NavigationSchema)
115+
│ │ ├── runtime/ <-- P2: Logic
116+
│ │ │ ├── plugin.ts (Lifecycle)
117+
│ │ │ └── driver.ts (DriverInterface)
118+
│ │ └── auth/ <-- from plugin-auth
119+
│ │ └── session.ts (User/Session Interface)
120+
│ ├── zods/ <-- 对应的 Zod 实现 (用于运行时校验)
121+
│ └── constants/ <-- 目录约定 (paths)
122+
└── package.json
123+
124+
```
125+

.gitignore

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,13 @@ temp/
4141
packages/*/dist/
4242
packages/*/*.tsbuildinfo
4343

44-
.next
44+
# Next.js
45+
.next
46+
out/
47+
next-env.d.ts
48+
.vercel
49+
50+
# Fumadocs
51+
.source/
52+
apps/*/. source/
53+
apps/*/.next/

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,19 @@ This repository contains the core specifications, schemas, and protocols that po
1010

1111
## 📚 Documentation
1212

13-
The official documentation is co-located in this repository.
13+
The official documentation is built with Fumadocs and Next.js.
1414

15-
* **[Concepts](./content/docs/concepts/):** Architecture, Manifesto, and Core Values.
16-
* **[Specifications](./packages/spec/json-schema/):** Auto-generated JSON Schemas.
17-
* **[API Reference](./content/docs/references/):** Detailed property references generated from code.
15+
* **[Documentation Content](./content/docs/):** MDX documentation files (concepts, specifications, references).
16+
* **[Documentation Site](./apps/docs/):** Fumadocs-powered Next.js app.
17+
* **[Live Site](http://localhost:3000/docs):** Run `pnpm docs:dev` to view locally.
1818

1919
## 📦 Monorepo Structure
2020

2121
| Package | Description | Status |
2222
| :--- | :--- | :--- |
2323
| **[`@objectstack/spec`](packages/spec)** | **THE PROTOCOL**. Contains all Zod definitions, Types, and JSON Schemas. | 🟢 **Active** |
24-
| `content/docs` | The documentation site source. | 🟢 **Active** |
24+
| **[`@objectstack/docs`](apps/docs)** | Documentation site built with Fumadocs and Next.js. | 🟢 **Active** |
25+
| `content/docs/` | Documentation content (MDX files). Shared resource. | 🟢 **Active** |
2526
| *Other packages* | *Legacy/Migration in progress* | 🟡 *Legacy* |
2627

2728
## 🛠️ The Protocol Architecture
@@ -67,11 +68,10 @@ pnpm --filter @objectstack/spec build
6768
# Output:
6869
# - packages/spec/dist/ (Compiled TS)
6970
# - packages/spec/json-schema/ (JSON Schemas)
70-
# - content/docs/references/ (Markdown Docs)
7171

72-
# 3. Start Documentation Site (Optional)
73-
# (Assuming a doc site runner is configured)
74-
pnpm dev
72+
# 3. Start Documentation Site
73+
pnpm docs:dev
74+
# Visit http://localhost:3000/docs
7575
```
7676

7777
## 🤝 Contribution

apps/docs/README.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# ObjectStack Documentation Site
2+
3+
This is the documentation site for the ObjectStack Protocol, built with [Fumadocs](https://fumadocs.dev/) and Next.js.
4+
5+
## Structure
6+
7+
```
8+
Repository Root:
9+
├── content/docs/ # Documentation content (MDX files)
10+
│ ├── concepts/
11+
│ ├── references/
12+
│ └── specifications/
13+
14+
apps/docs/
15+
├── app/ # Next.js app directory
16+
│ ├── docs/ # Documentation pages
17+
│ ├── layout.tsx # Root layout
18+
│ └── source.ts # Fumadocs source loader
19+
├── source.config.ts # Fumadocs collection config (references ../../content/docs)
20+
├── next.config.mjs # Next.js configuration
21+
├── tailwind.config.js
22+
├── postcss.config.mjs
23+
└── package.json
24+
```
25+
26+
## Development
27+
28+
```bash
29+
# From repository root
30+
pnpm docs:dev
31+
32+
# Or from apps/docs
33+
pnpm dev
34+
```
35+
36+
## Building
37+
38+
```bash
39+
# From repository root
40+
pnpm docs:build
41+
42+
# Or from apps/docs
43+
pnpm build
44+
```
45+
46+
## Deployment
47+
48+
```bash
49+
# From repository root
50+
pnpm docs:start
51+
52+
# Or from apps/docs
53+
pnpm start
54+
```
55+
56+
## Features
57+
58+
- 📝 **MDX Support**: Write documentation with React components
59+
- 🎨 **Tailwind CSS v4**: Modern styling with Tailwind
60+
- 🔍 **Search**: Built-in search functionality (⌘K)
61+
- 🌗 **Dark Mode**: Automatic theme switching
62+
- 📱 **Responsive**: Mobile-friendly design
63+
- 🚀 **Static Generation**: All 136 pages pre-rendered for optimal performance
64+
65+
## Content Management
66+
67+
Documentation content is stored in the repository root at `/content/docs/` (shared location) with the following structure:
68+
69+
- `concepts/` - Core concepts and architecture
70+
- `references/` - API and schema references
71+
- `specifications/` - Detailed specifications
72+
73+
Each directory can have a `meta.json` file to configure navigation order and labels.
74+
75+
**Note**: The content is stored at the root level to allow sharing with other tools and workflows. The Next.js app in `apps/docs/` references this content via relative path in `source.config.ts`.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import { source } from '@/app/source';
2+
import type { Metadata } from 'next';
3+
import { DocsPage, DocsBody } from 'fumadocs-ui/page';
4+
import { notFound } from 'next/navigation';
5+
import defaultMdxComponents from 'fumadocs-ui/mdx';
6+
7+
export default async function Page(props: {
8+
params: Promise<{ slug?: string[] }>;
9+
}) {
10+
const params = await props.params;
11+
const page = await source.getPage(params.slug ?? []);
12+
if (!page) notFound();
13+
14+
const data = page.data as any;
15+
const Content = data.body;
16+
17+
return (
18+
<DocsPage toc={data.toc} full={data.full}>
19+
<DocsBody>
20+
<h1 className="mb-2 text-3xl font-bold text-foreground">{page.data.title}</h1>
21+
{page.data.description && (
22+
<p className="mb-8 text-lg text-muted-foreground">
23+
{page.data.description}
24+
</p>
25+
)}
26+
<Content components={defaultMdxComponents} />
27+
</DocsBody>
28+
</DocsPage>
29+
);
30+
}
31+
32+
export async function generateStaticParams() {
33+
return source.generateParams();
34+
}
35+
36+
export async function generateMetadata(props: {
37+
params: Promise<{ slug?: string[] }>;
38+
}): Promise<Metadata> {
39+
const params = await props.params;
40+
const page = await source.getPage(params.slug ?? []);
41+
if (!page) notFound();
42+
43+
return {
44+
title: page.data.title,
45+
description: page.data.description,
46+
};
47+
}

0 commit comments

Comments
 (0)