How capypara20/sqldev works
Project Type and Purpose
• No standalone backend or microservices—everything runs in the user’s browser.
High-Level File Structure Analysis
• public/
• Static assets, sample SQL files for examples and tests
• src/
• constants/, types/ – Shared TS constants and types
• App.tsx & main.tsx – Entry point and root React component
• Config files (tsconfig, vite.config.ts, tailwind.config.js) – Build and styling setup
Core Architecture Components
a. User Interface Layer
• FileUploadButton (uses useFileUpload hook)
• ColumnEditPanel & EdgeEditPanel (fine-tune schema elements)
• ERDiagram component (wraps React Flow canvas)
b. Parsing & Schema Extraction
• sqlParser.ts: tokenizes and parses SQL to AST
• exportTableSchema.ts: transforms AST into JSON table/column/relationship model
• App state holds parsed schema model
d. Export Engine
• useDiagramExport hook + exportDiagram.ts
• html-to-image produces PNG/SVG from the React Flow DOM
e. Styling & Theming
• Tailwind CSS classes throughout components
• Dynamic style props driven by StylePanel
Component Interactions and Data Flow
• User clicks “Open SQL” → FileUploadButton → useFileUpload reads file
• SQL content passed to sqlParser → AST → exportTableSchema → schema JSON
• App state updated → ERDiagram re-renders via React Flow
• User interacts (drag/drop, zoom, panels adjust style props)
• On “Export” → useDiagramExport captures React Flow container → html-to-image → downloads file
Architectural Patterns and Principles
• Component-based UI: each panel/node/edge is a self-contained React component
• Separation of concerns: parsing logic in utils, UI in components, state via hooks
• Declarative rendering: React Flow’s nodes/edges configuration reflects schema model