How gwendalbroudin/dbml-flow works
Project type and purpose
• This is a client-only, single-page web application (an open-source DBML viewer/editor tool) built with React, TypeScript and Vite.
File structure
• Top level:
• index.html, package.json, Vite config → SPA bootstrapping & build
• src/main.tsx → React entry point
• src/routes → route definitions for edit vs view modes
• src/state/store.ts → centralized state (likely Zustand/Redux)
• src/lib → core logic libraries:
– dbml/parser.ts → parse DBML → AST
– layout (dagre.utils.ts, useElk.ts) → compute node/edge positions
– editor.helper.ts, math.helper.ts, utils.ts, url.helpers.ts
– monaco (init DBML support in Monaco Editor)
• src/components → UI layers:
– editor (Monaco editor + controls)
– viewer (canvas/SVG renderer for nodes & edges)
– controls (minimap, rearrange button)
– base-node, base-handle, labeled-handle, hidden-handle → building blocks for graph nodes
– database-schema-node, table-node → specialized node components
– nav (generate-image button)
– ui/table.tsx → helper UI
• config files: tsconfig, .github/workflows, .codesandbox, .gitignore.
README for additional insights
• Mentions inspirations and reference implementations.
Diagramming recommendations
• Use clear labels: e.g., “Parser Module (dbml/parser.ts)”, “ELK Layout Engine (useElk)”
• Blue for UI components
• Green for core libraries (parser, layout)
• Yellow for external dependencies (Monaco, Dagre, ELK)