Generative AI & LLM Applications

Structured Data Copilot

Grounded LLM application for generating and validating structured data from live webpages.

Built a retrieval-augmented application that analyzes webpage content, retrieves relevant Schema.org and Google structured-data requirements, generates JSON-LD with GPT-4o, and validates the result before returning it to the user.

PythonFastAPIGPT-4oAzure OpenAIRAGChromaDBNext.js

Business Problem

Generating structured data is easy. Generating reliable structured data is not.

Structured data helps search engines understand webpage content, but implementing it correctly requires identifying the appropriate schema type, following detailed requirements, and ensuring every field is supported by information actually present on the page.

Problem

Creating JSON-LD manually requires developers to interpret both webpage content and detailed schema requirements.

Challenge

An LLM can generate markup quickly, but unsupported fields, outdated requirements, and fabricated values can make the output unreliable.

Approach

Ground generation in source-page content and retrieved documentation, then validate the result before returning it.

How It Works

Generation as a pipeline, not a single prompt

The application breaks the task into separate stages so extraction, retrieval, generation, and validation can each be controlled independently.

Structured Data Copilot workflow from webpage URL to validated JSON-LD
01

Analyze the webpage

Crawl the supplied URL and extract visible page content along with any existing JSON-LD.

02

Identify the schema

Use page characteristics to determine relevant structured-data types such as Product, Article, Event, or LocalBusiness.

03

Retrieve documentation

Retrieve relevant Schema.org definitions and Google structured-data requirements from a ChromaDB vector store.

04

Generate grounded JSON-LD

Provide webpage content and retrieved documentation to GPT-4o as context for generation.

05

Validate the output

Apply deterministic checks for required fields, schema properties, and structural requirements.

06

Repair when necessary

Feed validation errors back to the model for correction, with the repair process repeating for up to three iterations.

Grounded Generation

The goal was not just to generate JSON-LD. It was to control what the model was allowed to generate.

Generated values must come from the webpage or existing structured data. If the source does not provide a value, the model is instructed to omit the field rather than infer or fabricate it.

Retrieval also reduces reliance on the model's training memory. Relevant Schema.org and Google documentation is supplied at generation time so the model can work against retrieved requirements instead of relying only on what it already knows.

Grounded generation and validation workflow

Validation & Repair

Treating LLM output as a draft, not the final answer

After generation, the application evaluates the JSON-LD against deterministic validation rules. When errors are detected, the specific failures are passed back to the model so it can revise the markup instead of regenerating blindly.

Generate→Validate→Identify Errors→Repair→Revalidate

Output Quality

From incomplete markup to grounded, validated JSON-LD

The value of the system is not simply that it generates structured data faster. It improves the quality of the output by grounding values in real page content, applying relevant schema requirements, and validating the result before delivery.

Comparison between weak JSON-LD and Structured Data Copilot output

Application Output

Making the result understandable, not just technically correct

Rather than returning only a block of generated JSON, the application is designed to help users understand what was detected, what was generated, and whether the final output passed validation.

Structured Data Copilot application interface

Generated JSON-LD

Structured-data markup produced by the generation pipeline.

Validation Results

Issues detected by the deterministic validation layer.

Before / After Comparison

Changes between existing structured data and the generated result.

Rationale

An explanation of why the recommended structured-data changes were made.

Technical Architecture

Separating retrieval, generation, and control

Backend & API

Python and FastAPI coordinate crawling, retrieval, generation, validation, and repair.

Retrieval

Schema.org and Google documentation are chunked and stored in ChromaDB for schema-specific retrieval.

LLM Layer

Azure OpenAI GPT-4o generates and repairs structured data using retrieved documentation and extracted webpage content.

Frontend

Next.js provides the interface for submitting webpages and reviewing generated markup and validation results.

Takeaway

Building the system around the model

The hardest part of the project was not calling the LLM. It was designing the surrounding system so the model had the right information, operated within clear constraints, and could be checked when it produced an incorrect result.

Retrieval provides context, the LLM handles interpretation and generation, and deterministic code provides control and validation.

View Project on GitHub