Skip to content
james6848Public

About

AI-powered structured data generation

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

DataSynth

Intelligent web application for generating structured "dummy" data using Generative AI. Define data schemas and let AI create realistic, validated data.

DataSynth application screenshot

Tech Stack

  • Frontend: Vue 3 (Composition API) + Vite, PrimeVue, Tailwind CSS, Pinia
  • Backend: Node.js + Express, OpenAI API (currently the only supported provider)
  • Validation: Zod, Ajv
  • Package Manager: pnpm

Project Structure

datasynth/
├── frontend/     # Vue 3 + Vite application
├── backend/      # Node.js + Express API
├── shared/       # Shared types and utilities
└── package.json  # Root workspace configuration

Setup Instructions

You do not need Apache, Laragon, or any local vhost setup for normal development.

Prerequisites

  • Node.js 18+
  • pnpm 8+

Install dependencies

pnpm install

Set up environment variables

The backend uses a project-local backend/.env file via dotenv, so you do not need a global OPENAI_API_KEY.

Copy backend/.env.example to backend/.env, then add your own OPENAI_API_KEY.

If you are on Windows, you can also use the helper script:

.\setup-env.ps1

PowerShell:

Copy-Item backend/.env.example backend/.env

macOS/Linux:

cp backend/.env.example backend/.env

Start the app

For day-to-day development, use the Vite and Node dev servers. Apache or Nginx is not needed for this mode.

pnpm dev

Open the frontend on http://localhost:5173.

If generation fails, check that backend/.env exists and OPENAI_API_KEY is set.

Other dev commands

Frontend only:

pnpm dev:frontend

Backend only:

pnpm dev:backend

Local URLs:

  • Frontend: http://localhost:5173
  • Backend: http://localhost:3000
  • Health check: http://localhost:3000/api/health

Notes:

  • The frontend uses the Vite dev server in local development.
  • /api requests are proxied to the backend automatically.
  • Apache or Nginx is only needed for a production-style deployment setup, not for normal local development.

Building for Production

pnpm build

This produces the frontend build in frontend/dist.

Local Production-Style Setup

This section is optional and is only useful if you want to mimic the production hosting arrangement locally.

The normal deployment shape for this app is:

  • Apache or Nginx serves the static frontend from frontend/dist
  • The backend runs as a separate Node process
  • The web server reverse-proxies /api to the backend

That gives you a single public origin such as http://datasynth.test/ for both the UI and API.

Laragon / Apache example

Build the frontend:

pnpm build

Start the backend:

pnpm --filter backend start

Then point your Apache vhost at C:/laragon/www/datasynth/frontend/dist and proxy /api to http://localhost:3000/api.

Example vhost:

<VirtualHost *:80>
    ServerName datasynth.test
    DocumentRoot "C:/laragon/www/datasynth/frontend/dist"

    <Directory "C:/laragon/www/datasynth/frontend/dist">
        AllowOverride All
        Require all granted
        FallbackResource /index.html
    </Directory>

    ProxyPreserveHost On
    ProxyPass /api http://localhost:3000/api
    ProxyPassReverse /api http://localhost:3000/api
</VirtualHost>

Make sure the Apache proxy modules are enabled if they are not already:

  • proxy_module
  • proxy_http_module

After restarting Apache, open http://datasynth.test/.

Environment Variables

Backend

  • OPENAI_API_KEY - Required for data generation. The backend can still start without it.
  • OPENAI_ORG_ID - Optional: Organization ID
  • PORT - Server port (default: 3000)
  • NODE_ENV - Environment (development | production)
  • FRONTEND_URL - Optional: Allowed frontend origin when not using same-origin proxying
  • RATE_LIMIT_MAX_REQUESTS - Requests allowed per rate-limit window (default: 100)
  • RATE_LIMIT_WINDOW_MS - Rate-limit window in milliseconds (default: 60000)
  • MAX_ITEMS_PER_CHUNK - Max items per chunk (default: 50)
  • MAX_CONCURRENT_CHUNKS - Parallel chunk limit (default: 5)
  • CHUNK_TIMEOUT_MS - Timeout per chunk in milliseconds (default: 30000)
  • MAX_COST_PER_REQUEST - Reserved for future cost controls; currently not enforced
  • ENABLE_COST_TRACKING - Reserved for future cost tracking; currently not enforced

Frontend

  • VITE_API_BASE_URL - Optional override for the API base URL (default: /api)

Development

This is a monorepo using pnpm workspaces. Each package (frontend, backend, shared) is independent but can share dependencies.

The internal schema model includes groundwork for nested object and array fields, but nested schema editing is not currently exposed in the UI.

Intelligent Model Selection

The backend automatically selects the most cost-effective OpenAI model based on your schema content, with automatic fallback chains for reliability.

How It Works

Model selection is determined by analyzing field prompts:

Tier Triggered By Model Chain
premium Creative keywords (biography, story, narrative, paragraph >1) gpt-5.2 → gpt-4o
standard HTML content or string fields gpt-5-nano → gpt-5-mini → gpt-4o-mini → gpt-4o
saver Everything else (numbers, booleans) Same as standard

Fallback Chains

If the preferred model is unavailable or fails, the system automatically tries the next model in the chain. Only models supporting structured outputs (json_schema) are included.

Implementation

  • Selection logic: backend/src/config/openai.js - selectModel()
  • Fallback handling: backend/src/config/openai.js - generateWithFallback()
  • System prompt building: backend/src/services/promptBuilder.js

License

MIT

About

AI-powered structured data generation

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages