A modern React web application for generating SQL code for Data Vault 2.0 objects (Hub, Satellite, Link, PIT) using customizable templates with variable placeholders.
- Template Selection: Choose from predefined Data Vault 2.0 templates (Hub, Satellite, Link, PIT)
- Dynamic Input Forms: Automatically generated forms based on selected template variables
- Live SQL Preview: Real-time SQL generation with syntax highlighting using Monaco Editor
- Copy to Clipboard: One-click copying of generated SQL code
- Extensible Template System: Easy to add new templates via JSON configuration
- Responsive Design: Works on desktop, tablet, and mobile devices
- Modern UI: Clean, intuitive interface with Material Design principles
- Node.js (version 14 or higher)
- npm or yarn
- Clone the repository:
git clone <repository-url>
cd sql-template-generator- Install dependencies:
npm install- Start the development server:
npm start- Open your browser and navigate to
http://localhost:3000
- Select a Template: Choose from Hub, Satellite, Link, or PIT templates in the dropdown
- Configure Variables: Fill in the required fields that appear dynamically based on your template selection
- View Generated SQL: The SQL code is generated in real-time in the right panel with syntax highlighting
- Copy SQL: Click the "Copy SQL" button to copy the generated code to your clipboard
Creates a Hub table that represents a unique business concept:
- Required Fields: Table name, Business keys, Hash key name, Source table
- Optional Fields: Load date column, Record source
Creates a Satellite table for descriptive attributes:
- Required Fields: Table name, Parent hash key, Descriptive fields, Source table
- Optional Fields: Load date column, Record source
Creates a Link table for relationships between entities:
- Required Fields: Table name, Link hash key, Hub hash keys, Source table
- Optional Fields: Load date column, Record source
Creates a PIT table for snapshot views:
- Required Fields: Table name, Hub hash key, Satellite tables
- Optional Fields: Snapshot date column
Creates a comprehensive staging view with Data Vault calculations:
- Required Fields: View name, Source table, Source columns, Hash keys configuration
- Optional Fields: Schema name, Hash diffs configuration, Load date settings, Record source settings
- Features: Automatic hash key/diff calculation, Ghost records (unknown/error), Flexible load date and record source options
Some fields support multiple values (like business keys or descriptive fields):
- Click the "+" button to add additional fields
- Click the "×" button to remove fields (minimum of one required)
- All non-empty values will be included in the generated SQL
src/
├── components/
│ ├── FormField.jsx # Dynamic form field component
│ ├── SqlPreview.jsx # SQL preview with Monaco Editor
│ ├── HashKeyConfigField.jsx # Hash key configuration component
│ └── HashDiffConfigField.jsx # Hash diff configuration component
├── utils/
│ └── templateEngine.js # Template processing logic
├── templates.json # Template definitions
├── App.jsx # Main application component
├── main.jsx # React entry point
└── index.css # Global styles
public/
└── templates/
└── stage_view.sql # External SQL template file
Templates can be defined inline or as external files for better maintainability.
- Open
src/templates.json - Add a new template object with the following structure:
"template_key": {
"name": "Template Display Name",
"description": "Brief description of what this template does",
"fields": [...],
"template": "SQL template with {{variable}} placeholders"
}- Create a new
.sqlfile inpublic/templates/ - In
src/templates.json, reference the external file:
"template_key": {
"name": "Template Display Name",
"description": "Brief description of what this template does",
"fields": [...],
"template": "file:your_template.sql"
}- text: Single text input field
- multi-text: Multiple text input fields (for arrays)
- checkbox: Boolean checkbox input
- hashkey-config: Complex hash key configuration with business keys
- hashdiff-config: Complex hash diff configuration with columns
Templates support the following variable syntax:
{{variable_name}}- Simple variable substitution{{#array_name}}...{{/array_name}}- Loop over array values{{.}}- Current array item within a loop{{@index}}- Array index within a loop{{current_date}}- Automatically added current date
npm run dev- Start Vite development servernpm run build- Build for productionnpm run preview- Preview production buildnpm run lint- Run ESLint
- React 18: Modern React with hooks
- Vite: Fast build tool and development server
- Monaco Editor: VS Code editor for syntax highlighting
- Lucide React: Modern icon library
- CSS Grid & Flexbox: Responsive layout
- Chrome (recommended)
- Firefox
- Safari
- Edge
- Fork the repository
- Create a feature branch:
git checkout -b feature-name - Make your changes and commit:
git commit -m 'Add feature' - Push to the branch:
git push origin feature-name - Submit a pull request
This project is open source and available under the MIT License.
For questions, issues, or feature requests, please open an issue on the GitHub repository.