A single-page Next.js app for turning PostgreSQL DDL into an interactive ER diagram.
Paste CREATE TABLE / foreign-key DDL, click Render Graph, and explore the generated schema graph powered by React Flow and dagre layout.
- Next.js 16.2.9 App Router
- React 19.2.4
- Tailwind CSS 4
node-sql-parserfor PostgreSQL DDL parsing@xyflow/reactfor graph rendering@dagrejs/dagrefor auto-layouthtml-to-imagefor PNG/SVG export
Install dependencies:
bun installRun the development server:
bun run devOpen http://localhost:3000.
bun run dev # Start the Turbopack dev server
bun run build # Create a production build
bun run start # Start the production server after build
bun run typecheck # Type-check the project
bun run test # Run Vitest
bun run check # Run Biome lint + format checksThe parser is focused on PostgreSQL-style DDL and currently handles common cases such as:
CREATE TABLE- Schema-qualified table names like
public.users - Column names and data types
- Primary keys
- Unique columns/table constraints
- Nullable vs.
NOT NULLcolumns - Default values, best-effort
- Identity/serial-like columns, best-effort
- Inline foreign keys
- Table-level foreign keys
ALTER TABLE ... ADD ... FOREIGN KEY, best-effort
See gpt5.5-report.md, fallow.md, and AUDIT.md for detailed findings. Important limitations include:
parseSql.tsdepends on fragilenode-sql-parserAST shapes; keep regression tests green before refactoring parser logic.- Export-to-image behavior should be manually verified for large, zoomed, or panned graphs.
- README/public assets were originally create-next-app boilerplate; this README has been updated, but unused public SVGs may still be removable.
src/app/
layout.tsx # Root layout
page.tsx # Marketing landing page
app/page.tsx # Visualizer app
globals.css # Global styles
src/components/
SchemaGraphCanvas.tsx # Main React Flow canvas
TableNode.tsx # Table node renderer
DefaultEdge.tsx # Relationship edge renderer
Toolbar.tsx # Canvas toolbar
FindTableSelector.tsx # Table finder
SchemaGraphContext.tsx # Canvas context
SchemaGraphLegend.tsx # Legend
useExportSchemaToImage.ts # PNG/SVG export hook
src/lib/
parseSql.ts # SQL DDL parser
graph.ts # React Flow graph/layout generation
types.ts # Shared types
utils.ts # Utility functions/export formatting
sampleSchema.ts # Built-in example schema- Use Bun for package management and scripts.
bun.lockis the lockfile. - This is Next.js 16. Linting and formatting are handled by Biome (
biome.json); usebun run check/bun run check:fix. - Tailwind 4 is configured through
postcss.config.mjsand@tailwindcss/postcss. - The
@/*path alias resolves to./src/*. - Add parser tests before refactoring
src/lib/parseSql.ts.
gpt5.5-report.md— detailed GPT-5.5 codebase review with suggested changes.fallow.md— Fallow dead-code, duplication, and health findings.AUDIT.md— earlier detailed audit.PHASE1_PLAN.md— focused dead-code/tooling cleanup plan.
- Clear current Fallow dead-code findings.
- Start Phase 4 from
ROADMAP.md: parser helper dedupe and graph construction refactors. - Keep
bun run test,bun run typecheck, andbun run buildgreen after each small change.