Papers: Document-to-Database (VLDB 2026) Β· DataMosaic Demo (VLDB 2026)
DataMosaic bridges the gap between unstructured enterprise knowledge and structured analytics. While Large Language Models (LLMs) excel at processing local text, they often struggle with global database semanticsβfailing to respect schemas, foreign keys, and integrity constraints.
DataMosaic solves this by mediating between LLM extraction and strict database logic. Instead of a one-shot prompt, it uses an orchestrator-managed closed loop to ensure the final database is not just filled with text, but is structurally sound and analytically useful.
This repository contains the full open-source release, including the
algorithm core (modules/), a Flask + WebSocket backend (backend/),
a React + TypeScript frontend (frontend/), and an evaluation harness.
This work is associated with two publications:
[1] Zhengxuan Zhang, Zhuowen Liang, Jiazhuo Chen, Haixun Wang, and Nan Tang. Document-to-Database: Extraction Meets Relational Semantics. VLDB, 2026. [PDF]
[2] Zhengxuan Zhang, Zhuowen Liang, Haixun Wang, and Nan Tang. DataMosaic: An Interactive Demonstration of Constraint-Driven Document-to-Database Construction. VLDB Demo, 2026. [PDF]
- ποΈ Schema-Driven Extraction. DataMosaic takes an ER schema (with integrity and business constraints) as input and ensures the extracted data actually fits your database structure.
- π Closed-Loop Refinement. Implements an Extraction β Verification β Repair loop. It detects constraint violations (e.g., broken foreign keys) and performs targeted re-extraction to fix them.
- π‘οΈ Semantic Consistency. Distinguishes between intrinsic document ambiguity and correctable extraction errors.
- π Pluggable Architecture. Supports third-party LLM extractors, domain-specific verifiers, and custom repair operators via the MCP (Multi-Constraint-Plugin) registry.
- π₯οΈ Full-stack UI. A React frontend lets you upload documents, define schemas (form-based or natural language), watch the agent loop run in real-time, and inspect / export the resulting database.
DataMosaic/
βββ backend/ # Flask API + WebSocket service
β βββ app.py # Service entry point
β βββ config.py # Paths, CORS, ports
β βββ routes/ # REST endpoints
β β βββ file_routes.py # Upload / file listing
β β βββ doc2db_routes.py # Extraction jobs & SSE stream
β β βββ memory_routes.py # Snapshots / violations / fixes
β β βββ database_routes.py # SQLite DB management
β β βββ settings_routes.py # Model & API key settings
β βββ utils/ # File / history / websocket helpers
β βββ websocket_signals.py # Realtime signal broadcaster
β
βββ frontend/ # React + TypeScript SPA
β βββ public/ # Static assets
β βββ src/
β β βββ App.tsx # Root component
β β βββ components/ # Layout, panels, dialogs
β β β βββ Doc2DBProcessor/ # Main extraction UI (config, steps, results)
β β β βββ Doc2DBHistoryPanel.tsx
β β β βββ DatabaseManager.tsx
β β β βββ FileLibraryWithUpload.tsx
β β βββ hooks/ # useFiles, usePanel, useDoc2DB
β β βββ services/ # WebSocket client
β β βββ constants/ # Theme & config (models, project)
β β βββ styles/
β βββ package.json
β βββ tsconfig.json
β
βββ modules/ # Core algorithm (the "DataMosaic" engine)
β βββ agents/
β β βββ extractor/ # Entity & relation extractors (base + utils)
β β βββ verifier/ # MCP router + MCP-based verifier
β β βββ fixer/ # MCP-based repair operators
β β βββ orchestrator/ # Unified/parallel orchestrators, signal coordinator
β β βββ mcp/ # Pluggable constraint servers
β β βββ config/ # MCP plugin configuration
β β βββ ... # structure / value / logic / type /
β β # temporal / aggregation / reference /
β β # format / data quality
β βββ core/ # IO + ID generation (io.py, ids.py)
β βββ memory/ # Memory manager, snapshots, tables,
β β # violations, fixes
β βββ services/ # Doc2DBService (used by the Flask backend)
β βββ signals/ # Internal signal bus (core + handlers)
β βββ utils/ # Orchestrator logging, task helpers
β
βββ llm/ # LLM client routers (GPT / DeepSeek / Qwen)
β βββ main.py # Unified get_answer() entry
β βββ global_config.py # Current model selector
β βββ gpt.py / qwen.py / deepseek.py / utils.py
β βββ .env.example # Copy to .env and fill in your keys
β
βββ dataset/ # Open-source evaluation datasets
β βββ FinanceDB/ LegalDB/ PaperDB/ StudentDB/
β β βββ <case>/docs/ # Per-case documents + schema
β
βββ tests/ # Unit tests (service, memory manager)
β
βββ scripts/ # Convenience launchers
β βββ start_backend.sh
β βββ start_frontend.sh
β
βββ test_dataset_evaluate.py # Full system evaluation script
βββ llm_evaluate.py # LLM-only baseline evaluator
βββ update_experiment/ # Schema-update robustness experiments
β βββ C01_... C12_... # Add / delete / update scenarios
βββ results.md # Published evaluation comparison
βββ requirements.txt
βββ README.md
- Python 3.8+
- Node.js 18+ and npm
- One LLM API key (OpenAI-compatible, DeepSeek, or Qwen/DashScope)
cd DataMosaic
python3 -m venv .venv && source .venv/bin/activate
pip install -r requirements.txtcp llm/.env.example llm/.env
# Edit llm/.env with your real keys, then:llm/.env example:
API_KEY=sk-...
API_URL=https://api.openai.com/v1
DEEPSEEK_KEY=...
DEEPSEEK_URL=https://api.deepseek.com
QWEN_KEY=...
QWEN_URL=https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions./scripts/start_backend.sh
# or manually:
# cd backend && python app.pyThe backend exposes:
http://localhost:5000β REST APIws://localhost:8765β realtime signal stream
./scripts/start_frontend.sh
# or manually:
# cd frontend && npm install && npm startOpen http://localhost:3000 in your browser.
python test_dataset_evaluate.py --dataset FinanceDB --case case1 --model gpt-4oParameters:
| Flag | Description |
|---|---|
--dataset |
FinanceDB, PaperDB, StudentDB, or LegalDB |
--case |
Test case within the dataset (e.g. case1) |
--model |
LLM model identifier (e.g. gpt-4o, claude-3-5-sonnet, qwen2.5-72b-instruct) |
--run_name |
Custom output run identifier |
python llm_evaluate.py --dataset FinanceDB --case case1 --model gpt-4oMetrics produced: Precision / Recall / F1 / LLM-Score (0β100).
See results.md for a published comparison.
| Endpoint | Purpose |
|---|---|
GET /api/health |
Health check |
POST /api/upload/batch |
Upload one or more documents |
GET /api/files |
List uploaded documents |
POST /api/doc2db/process |
Start an extraction job |
GET /api/doc2db/stream/<task_id> |
Server-Sent Events progress stream |
GET /api/doc2db/status/<task_id> |
Poll task status |
GET /api/doc2db/history |
List historical runs |
GET /api/memory/snapshots/<run_id> |
Inspect table snapshots |
GET /api/memory/violations/<run_id> |
Inspect detected violations |
GET /api/memory/fixes/<run_id> |
Inspect repair operations |
GET /api/databases / POST .../tables |
SQLite database management |
GET /api/settings / POST /api/settings |
Read / update active model and keys |
ββββββββββββββββββββββββββββββββββββββββββββββββ
Documents βββΆβ Extractor (entities + relations) β
β ββ LLM calls via llm.main.get_answer() β
βββββββββββββ¬βββββββββββββββββββββββββββββββββββ
βΌ
ββββββββββββββββββββββββββββββββββββββββββββββββ
β Verifier (MCP plugins) β
β structure / type / value / logic / format / β
β temporal / reference / aggregation / DQ β
βββββββββββββ¬βββββββββββββββββββββββββββββββββββ
βΌ violations
ββββββββββββββββββββββββββββββββββββββββββββββββ
β Fixer (targeted re-extraction / repair) β
βββββββββββββ¬βββββββββββββββββββββββββββββββββββ
βΌ
ββββββββββββββββββββββββββββββββββββββββββββββββ
β Orchestrator (signal-driven closed loop) β
β β memory snapshots β final DB instance β
ββββββββββββββββββββββββββββββββββββββββββββββββ
The full pipeline is exposed both as a service (modules.services.Doc2DBService,
used by the Flask backend) and as an importable Python library (use the
modules directly without the HTTP layer).
To keep this repository clean and reproducible we exclude:
backend/history/,backend/output/,backend/uploads/,backend/logs/β runtime artifactsfrontend/node_modules/,frontend/build/β install / build outputsllm/.envβ your private credentials (only.env.exampleis shipped)
These paths are pre-listed in .gitignore.
Released under the project's open-source license. See LICENSE (if present)
for full terms.
DataMosaic uses Material-UI for the frontend.
If you find this work helpful, please consider citing our papers:
@inproceedings{datamosaic,
title={Document-to-Database: Extraction Meets Relational Semantics},
author={Zhang, Zhengxuan and Liang, Zhuowen and Chen, Jiazhuo and Wang, Haixun and Tang, Nan},
year={2026},
journal={Proceedings of the VLDB Endowment},
volume={19},
number={9},
pages={2522--2535},
year={2026},
publisher={VLDB Endowment}
}
@inproceedings{datamosaic_demo,
title={DataMosaic: An Interactive Demonstration of Constraint-Driven Document-to-Database Construction},
author={Zhang, Zhengxuan and Liang, Zhuowen and Wang, Haixun and Tang, Nan},
journal={Proceedings of the VLDB Endowment},
volume={19},
number={12},
pages={4570--4573},
year={2026},
publisher={VLDB Endowment},
}