@picadeck/core
v1.0.0
Published
Core schema visualizer - Express middleware, HTML renderer, types, and layout
Maintainers
Readme
@picadeck/core
Core package for Picadeck Schema Visualizer. Provides Express middleware, HTML renderer, types, and auto-layout for interactive database schema visualization.
Installation
npm install @picadeck/coreUsage with Express
import express from "express";
import { schemaVisualizer } from "@picadeck/core";
import { parseMongooseModels } from "@picadeck/mongoose-parser";
import { User, Post } from "./models";
const app = express();
app.use(
"/schema",
schemaVisualizer({
parser: parseMongooseModels,
models: [User, Post],
theme: "dark",
title: "My App Schema",
})
);
app.listen(3000, () => {
console.log("Visit http://localhost:3000/schema");
});API
schemaVisualizer(options)
Creates Express middleware that serves an interactive schema visualizer.
Options:
| Option | Type | Required | Description |
| -------- | --------------------------- | -------- | ------------------------------------ |
| parser | ParserFunction | Yes | Parser function from any @picadeck parser package |
| models | any[] | Yes | Array of models/schemas to visualize |
| theme | 'light' \| 'dark' | No | UI theme (default: 'light') |
| title | string | No | Page title |
generateHTML(schema, theme?)
Generates a self-contained HTML string with the embedded visualizer.
schema—UniversalSchemaobjecttheme—'light' | 'dark'(default:'light')
calculateLayout(schema) / applyLayout(schema)
Utility functions for computing and applying automatic node positions.
Types
All parsers produce UniversalSchema, which contains:
Entity— a table or collection withField[],Index[], andConstraint[]Field— column definition withnormalizedType, nullability, keys, defaultsRelationship— one-to-one, one-to-many, or many-to-many link between entitiesNormalizedType— cross-framework type enum (STRING,INTEGER,BOOLEAN,JSON,UUID, etc.)
Features
- Light and dark theme support with CSS variables
- Interactive ReactFlow-based visualization (pan, zoom, drag)
- Automatic hierarchical layout algorithm
- Relationship mapping with cardinality indicators
- Single self-contained HTML response (no external requests)
- Schema injected via
window.__PICADECK_SCHEMA__
License
MIT
