Online code editor and database browser powered by HoloDB and Next.js.
npm run devBy default, saved configurations are written below .dbpen-data/ in the
current working directory. Override it with:
DBPEN_DATA_DIR=/absolute/path/to/dbpen-data npm run devThe landing page prerenders the configured initial YAML together with a static, syntax-highlighted editor preview. CodeMirror hydrates over that preview on the client.
Default mode:
npm run buildPrerender the sample YAML explicitly:
npm run build --dbpen-initial-yaml=samplePrerender an empty editor:
npm run build --dbpen-initial-yaml=emptyEquivalent explicit empty override:
npm run build --dbpen-initial-yaml-emptyRead initial YAML from a file:
npm run build --dbpen-initial-yaml-file=./sample.yamlThe same options can be supplied as environment variables:
DBPEN_INITIAL_YAML_MODE=sample|emptyDBPEN_INITIAL_YAML=sample|emptyDBPEN_INITIAL_YAML_EMPTY=trueDBPEN_INITIAL_YAML_FILE=./sample.yaml
/starts with demo content./editstarts with an empty editor./d/<id>starts with backend-provided saved content when it exists, otherwise with an empty editor so local recovery can run in the browser.
Client-side URL changes use history.replaceState() so editor and layout state
are not remounted. Unsaved editor content is canonicalized to /edit; a
successful save is canonicalized to /d/<id>.
Saved YAML records are cached in local storage under dbpen.saved-yaml.v1.
Remote saves update this cache with localOnly: false and a real expiration.
When offline, Save asks for confirmation and writes a localOnly: true record
with expiresAtEpochSeconds: -1. Expired online-backed local records are
reported during writes, but not deleted yet.
If /d/<id> loads empty content, the client treats that as a backend not-found
signal. It checks for a local record with the same ID, offers local recovery if
one exists, or reports that the configuration was not found. Hash-loaded YAML is
integrity-checked against the route ID before it is accepted as saved.
The service worker is served from /sw.js. It is registered automatically in
production builds, and in development only when explicitly enabled:
NEXT_PUBLIC_DBPEN_ENABLE_SW=true npm run devThe worker caches the app shell and static assets, falls back to the cached
shell for offline navigations, and accepts messages from the app to cache saved
/d/<id> route shells after successful saves.
Client components under EditorStateProvider can call
replaceEditorContent(value) from useEditorState(). The editor applies the
replacement safely whether CodeMirror has already mounted or is still loading,
then evaluates the same YAML state used by the rest of the UI.
The frontend saves by posting raw YAML to /api/d.
POST /api/d- request body: YAML
- request content type:
application/yaml; charset=utf-8 - success status:
201 Created - response body: empty
GET /api/d/<hash-id>- success status:
200 OK - response body: YAML
- response content type:
application/yaml; charset=utf-8
- success status:
Both endpoints return metadata in headers:
X-DBPen-IdX-DBPen-Created-AtX-DBPen-Expires-At
Saved records are content-addressed with SHA-256 over the UTF-8 YAML bytes. Storage layout:
<data-dir>/
<hash-id>/
config.yaml
metadata.yaml
preview.html
preview.html is derived from config.yaml at save time and is used for the
initial editor preview on saved pages. The page still works if it is missing,
but the editor can briefly fall back to the client-side activation path. The
default TTL is one day. Override it with DBPEN_SAVE_TTL_SECONDS.
Use this when generic Node/Next hosting is available:
pnpm build
DBPEN_DATA_DIR=/absolute/path/to/dbpen-data pnpm startThe Next backend serves:
- the application pages,
POST /api/d,GET /api/d/<hash-id>,- SSR initial content for
/d/<hash-id>.
For a container-ready standalone artifact, use:
pnpm dist:nextThis creates:
build/next/build/dbpen-next.tar.gz
Run the standalone build with:
cd build/next/app
DBPEN_DATA_DIR=../data node server.jsThe standalone artifact uses a private-root layout:
build/next/
app/
data/
Use this for restricted classical PHP hosting.
Build the PHP/static deployable artifact:
pnpm dist:phpThis creates:
build/php/build/dbpen-php.tar.gz
Deploy by copying build/php/ to the host and configuring build/php/public/
as the document root.
The PHP artifact uses a private-root layout:
build/php/
public/
app/
data/
Make data/ writable:
chmod 775 build/php/dataBy default the PHP backend uses ../data relative to public/. If the hosting
panel supports environment variables, set DBPEN_DATA_DIR to an absolute
writable directory instead.
The PHP backend serves:
/,/edit,/d/<hash-id>throughindex.php,POST /api/dthroughapi/d.php,GET /api/d/<hash-id>throughapi/d.php.
For /d/<hash-id>, PHP serves the exported empty editor page and injects the
saved YAML into window.__DBPEN_RUNTIME_INITIAL_CONFIG__ before hydration. If
the saved record has preview.html, PHP also injects that preview into the
editor preview slot before the response is sent.
Next.js still writes its own framework-native outputs:
.next/for normal Node/Next builds,out/for static export builds.
Those are intermediate framework outputs. The stable deployable artifacts are
assembled under build/:
pnpm dist:next
pnpm dist:php
pnpm dist