Feat/export zip bundles and data contract
Summary of Changes
This PR optimizes and standardizes the export pipeline across all supported formats (Markdown, CSV, XLSX, JSON, and ZIP) according to Data Contract v1. It eliminates stranded server-side export files by bundling individual exports into comprehensive .zip archives, unifies data schemas with cross-referencing keys (Page ID), and aligns architectural documentation.
Key Improvements
1. Individual Export ZIP Bundling
Previously, individual export endpoints only returned a single file while leaving secondary data files stranded on the server:
-
exportType: "MARKDOWN": Bundles all files intomarkdown.zipcontaining:-
clean/*.md: Sanitized Markdown without nav/footer boilerplate (ideal for AI prompt contexts). -
raw/*.md: Original Markdown for debugging and audit. - Removed duplicate root-level
.mdfiles that cluttered the export directory.
-
-
exportType: "CSV": Bundles intocsv.zipcontainingpages.csv,links.csv, andimages.csv. -
exportType: "XLSX": Bundles intoxlsx.zipcontaining:-
pages.xlsx: Standardized page inventory. -
tables.xlsx: Dedicated workbook for all extracted HTML tables.
-
-
exportType: "JSON": Bundles intojson.zipcontaining:-
pages.json: Master envelope with full crawl page records. -
clean/pages.clean.json: Token-optimized dataset for AI/LLM/RAG pipelines. -
raw/pages.raw.json: Raw Markdown audit dataset. -
structured.json: Schema.org / JSON-LD structured data (omitted if empty).
-
2. Schema Standardization & Quality Metrics
-
pages.csv:- Added
pageIdas primary identifier to link withlinks.csvandimages.csv. - Added quality metrics:
wordCount,dataQualityScore,errorMessage. - Replaced multiple long text columns with clean
mainContent.
- Added
-
pages.xlsx:- Added
Page ID,Word Count,Quality Score (0-100). - Replaced truncated 500-char content columns with a single clean
Content Preview. - Removed redundant table sheet embedding to keep the workbook lightweight.
- Added
-
tables.xlsx:- Added
Page IDcolumn to theSummarysheet for cross-sheet and cross-file JOIN operations withpages.xlsx.
- Added
-
structured.json:- Avoids generating empty
{ jobId, records: [] }files when no structured data is detected.
- Avoids generating empty
3. Overall ZIP Hierarchy & Contract Alignment (Option 2B)
- Preserved executive summary and metadata files at the ZIP root (
metadata.json,summary.json,data_quality.json,diff_report.json) for quick inspection upon unzipping. - Organized crawled data under
data/, logs underlogs/, and markdown files undermarkdown/. - Updated
DATA_CONTRACT_V1.mdandREADME.mdto accurately document all export bundles and file structures.