Skip to content

Commit 0d19ae2

Browse files
authored
Merge pull request #427 from objectstack-ai/copilot/deploy-demo-app-to-vercel
2 parents 72c1aea + a99888e commit 0d19ae2

File tree

14 files changed

+940
-3
lines changed

14 files changed

+940
-3
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ apps/site/.next
1616
apps/site/out
1717
apps/site/.source
1818

19+
# Apps — Demo
20+
apps/demo/.vercel
21+
1922
# Database
2023
*.sqlite3
2124
*.db

CHANGELOG.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Changelog
2+
3+
All notable changes to the ObjectQL monorepo are documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [Unreleased]
9+
10+
### Added
11+
12+
- **`apps/demo`** — standalone Vercel-deployable demo application ([#issue](https://github.com/objectstack-ai/objectql/issues)):
13+
- `vercel.json` — Vercel deployment configuration (custom serverless, 1 GiB memory, 60 s timeout).
14+
- `api/[[...route]].ts` — catch-all serverless entry point bootstrapping the ObjectStack kernel with ObjectQL plugins, InMemoryDriver, Auth, Console, and Studio UIs.
15+
- `scripts/build-vercel.sh` — ordered build script for all workspace dependencies.
16+
- `scripts/patch-symlinks.cjs` — pnpm symlink dereference for Vercel bundling.
17+
- `objectstack.config.ts` — local development configuration reusing the project-tracker showcase.
18+
- `README.md` — deployment documentation for both local and Vercel workflows.
19+
- Root `demo:dev` script for quick local start.

ROADMAP.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -793,6 +793,7 @@ Priority tasks following the `@objectstack` v3.2.6 upgrade:
793793
| 7 | Structured logging framework | Low | 🔴 Open | Migrate `sdk` retry `console.log` and `types/logger.ts` fallback `console.error` to hook-based structured logging. |
794794
| 8 | Add tests for `plugin-optimizations` and `plugin-query` | High | ✅ Done | Both packages now have comprehensive test suites — 202 tests across 4 test files. |
795795
| 9 | Reduce `any` in protocol handlers | Medium | 🔴 Open | `protocol-json-rpc` (102), `protocol-graphql` (101), `protocol-odata-v4` (83) — highest `any` density in the monorepo. |
796+
| 10 | Deploy `apps/demo` to Vercel | Medium | ✅ Done | Standalone `apps/demo` sub-project with serverless entry point (`api/[[...route]].ts`), Vercel config, build script, and pnpm symlink patching. Independent from `apps/site`. |
796797

797798
---
798799

apps/demo/README.md

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
# ObjectQL Demo
2+
3+
A standalone, deployable demo application for the ObjectQL platform.
4+
Runs locally with `@objectstack/cli` and deploys to **Vercel** as a serverless function.
5+
6+
## Features
7+
8+
- **In-memory driver** — zero external database required; data persists across warm Vercel invocations.
9+
- **Console UI** — full ObjectStack Console available at `/console/`.
10+
- **Studio UI** — ObjectStack Studio available at `/_studio/`.
11+
- **Project-Tracker showcase** — ships with the `examples/showcase/project-tracker` metadata (objects, views, permissions) so the demo has real data structures out of the box.
12+
- **Auth** — Better-Auth based authentication via `@objectstack/plugin-auth`.
13+
14+
## Local Development
15+
16+
```bash
17+
# From the monorepo root:
18+
pnpm install
19+
20+
# Start the demo in dev mode:
21+
pnpm --filter @objectql/demo dev
22+
23+
# Or from the apps/demo directory:
24+
cd apps/demo
25+
pnpm dev
26+
```
27+
28+
The development server starts on `http://localhost:3000`.
29+
30+
## Vercel Deployment
31+
32+
### Prerequisites
33+
34+
1. A [Vercel account](https://vercel.com).
35+
2. The [Vercel CLI](https://vercel.com/docs/cli) installed (`npm i -g vercel`).
36+
37+
### Setup
38+
39+
1. **Create a new Vercel project** pointing to this repository.
40+
2. In **Project Settings → General**, set the **Root Directory** to `apps/demo`.
41+
3. Configure the following **Environment Variables**:
42+
43+
| Variable | Required | Description |
44+
|---|---|---|
45+
| `AUTH_SECRET` | **Yes** (production) | Secret key for signing auth tokens. Generate with `openssl rand -base64 32`. |
46+
| `AUTH_TRUSTED_ORIGINS` | No | Comma-separated list of additional trusted origins (e.g. `https://myapp.example.com`). |
47+
48+
4. Deploy:
49+
50+
```bash
51+
# From the monorepo root:
52+
vercel --cwd apps/demo
53+
54+
# Or for production:
55+
vercel --cwd apps/demo --prod
56+
```
57+
58+
### How It Works
59+
60+
- **`vercel.json`** — Configures Vercel to use a custom build command, allocate 1 GiB memory to the serverless function, and rewrite all requests to the catch-all `api/[[...route]].ts` handler.
61+
- **`api/[[...route]].ts`** — Bootstraps the full ObjectStack kernel with ObjectQL plugins, the in-memory driver, auth, Console, and Studio. Uses `@hono/node-server`'s `getRequestListener()` to bridge the Vercel serverless runtime with the Hono HTTP framework.
62+
- **`scripts/build-vercel.sh`** — Builds all required workspace packages (foundation, drivers, plugins, protocols, examples) in the correct dependency order.
63+
- **`scripts/patch-symlinks.cjs`** — Replaces pnpm workspace symlinks with real copies so Vercel can bundle the function without symlink errors.
64+
65+
### Monorepo Multi-Project
66+
67+
This repository contains two independent Vercel projects:
68+
69+
| Project | Root Directory | Framework |
70+
|---|---|---|
71+
| **`apps/site`** | `apps/site` | Next.js (fumadocs) |
72+
| **`apps/demo`** | `apps/demo` | `null` (custom serverless) |
73+
74+
Each project is configured independently and deployed separately. Changes to one do not affect the other.
75+
76+
## Project Structure
77+
78+
```
79+
apps/demo/
80+
├── api/
81+
│ └── [[...route]].ts # Vercel serverless entry point
82+
├── scripts/
83+
│ ├── build-vercel.sh # Vercel build script
84+
│ └── patch-symlinks.cjs # pnpm symlink dereference for Vercel
85+
├── objectstack.config.ts # Local dev configuration
86+
├── package.json
87+
├── tsconfig.json
88+
├── vercel.json
89+
└── README.md
90+
```
91+
92+
## Architecture
93+
94+
```
95+
Vercel Edge Network
96+
97+
98+
┌──────────────────┐
99+
│ api/[[...route]] │ ← catch-all serverless function
100+
└────────┬─────────┘
101+
102+
┌───────────┼───────────┐
103+
▼ ▼ ▼
104+
┌──────────┐ ┌────────┐ ┌──────────┐
105+
│ Console │ │ Studio │ │ REST/RPC │
106+
│ SPA (/) │ │/_studio│ │ /api/* │
107+
└──────────┘ └────────┘ └──────────┘
108+
│ │ │
109+
└───────────┴───────────┘
110+
111+
ObjectStack Kernel
112+
(ObjectQL + Auth +
113+
InMemoryDriver)
114+
```

0 commit comments

Comments
 (0)