xiaohongshu
xiaohongshu
classdiagram-to-neo4j
Extract entities, properties, and relationships from UML class diagrams (images) and populate Neo4j graph database. Supports TMF-style diagrams, schema diagrams, and other UML class diagrams. Uses vision models for extraction and generates Cypher queries for Neo4j population.
Full skill instructions
This skill extracts structured data from UML class diagrams (images) and populates Neo4j graph databases. It's designed for:
from classdiagram_to_neo4j import extract_and_populate
# Extract from image and populate Neo4j
extract_and_populate(
image_path="diagrams/product_offering.png",
neo4j_uri="bolt://localhost:7687",
neo4j_user="neo4j",
neo4j_password="password"
)
from classdiagram_to_neo4j import extract_diagram, populate_neo4j
# Step 1: Extract to JSON/YAML
data = extract_diagram(
image_path="diagrams/product_offering.png",
output_format="json",
output_path="extracted.json"
)
# Step 2: Review/edit JSON if needed
# ... manual review ...
# Step 3: Populate Neo4j
populate_neo4j(
data=data,
neo4j_uri="bolt://localhost:7687",
neo4j_user="neo4j",
neo4j_password="password"
)
from classdiagram_to_neo4j import extract_diagram, populate_neo4j
# Process multiple diagrams
diagrams = [
"diagrams/product_offering.png",
"diagrams/category.png",
"diagrams/pricing.png"
]
for diagram_path in diagrams:
data = extract_diagram(diagram_path, output_format="json")
populate_neo4j(
data=data,
neo4j_uri="bolt://localhost:7687",
neo4j_user="neo4j",
neo4j_password="password"
)
The vision model analyzes the image and extracts:
Extracted data is normalized into:
meta:
source: "diagrams/product_offering.png"
extracted_at: "2024-01-01T00:00:00Z"
diagram_type: "uml_class"
entities:
ProductOffering:
label: "ProductOffering"
properties:
- name: "id"
type: "string"
required: true
- name: "name"
type: "string"
required: true
- name: "isBundle"
type: "boolean"
required: false
relationships:
- from: "ProductOffering"
to: "ProductSpecification"
type: "has_specification"
cardinality: "0..1"
direction: "out"
properties:
role: null
Generates Cypher queries:
// Create schema block
MERGE (sb:SchemaBlock {id: 'tmf620_productoffering'})
SET sb.title = 'ProductOffering Diagram',
sb.artifact = 'diagrams/productoffering.png';
// Create entities with FQN
MERGE (e:Entity {fqn: 'tmf620_productoffering#ProductOffering'})
SET e.name = 'ProductOffering',
e.specId = 'tmf620_productoffering',
e.kind = 'Entity';
// Create fields
MERGE (f:Field {fqn: 'tmf620_productoffering#ProductOffering.name'})
SET f.name = 'name',
f.type = 'string',
f.required = true;
// Link field to entity
MATCH (e:Entity {fqn: 'tmf620_productoffering#ProductOffering'})
MATCH (f:Field {fqn: 'tmf620_productoffering#ProductOffering.name'})
MERGE (e)-[:HAS_FIELD]->(f);
// Create relationships
MATCH (from:Entity {fqn: 'tmf620_productoffering#ProductOffering'})
MATCH (to:Entity {fqn: 'tmf620_productoffering#ProductSpecification'})
MERGE (from)-[r:RELATES_TO {
type: 'has_specification',
fromCardinality: '0..1',
toCardinality: '1',
direction: 'out'
}]->(to);
:Entity, :RefType, :SchemaBlock) instead of per-class labels<specId>#<entityName>RELATES_TO relationship type with type propertyreferences/SCALABLE_RELATIONSHIP_MODEL.mdSchemaBlock nodesspecId, extracted_at)CONTAINS_ENTITY--no-validate flag:Field nodesHAS_FIELD relationshipsvision:
provider: "openai" # or "anthropic"
model: "gpt-4o" # or "claude-3-5-sonnet-20241022"
max_tokens: 8000
temperature: 0.1
use_structured_output: true # Uses JSON mode when available
neo4j:
uri: "bolt://localhost:7687"
user: "neo4j"
password: "password"
database: "neo4j"
create_constraints: true
create_indexes: true
extraction:
include_properties: true
include_methods: false
normalize_names: true
handle_references: true
extract_cardinality: true
See schema_examples/tmf620/productoffering_hub.core.example.yaml for example.
{
"meta": {
"source": "diagrams/product_offering.png",
"extracted_at": "2024-01-01T00:00:00Z"
},
"entities": {
"ProductOffering": {
"label": "ProductOffering",
"properties": [...]
}
},
"relationships": [...]
}
See schema_examples/neo4j/tmf620_productoffering_scalable_model.cypher for example.
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).parent / "scripts"))
from extract_and_populate import extract_and_populate
from neo4j import GraphDatabase
# Extract and populate
extract_and_populate(
image_path="diagrams/tmf620_productoffering.png",
neo4j_password="password"
)
# Query for relevant subgraph
driver = GraphDatabase.driver("bolt://localhost:7687", auth=("neo4j", "password"))
with driver.session() as session:
result = session.run("""
MATCH (e:Entity {name: 'ProductOffering'})-[r:RELATES_TO*1..2]->(related)
WHERE r.type IN ['has_specification', 'has_price']
RETURN e, r, related
""")
# Process results...
driver.close()
Pre-process Images
Validate Extraction
Incremental Updates
Query Optimization
Error Handling
See examples/ directory for:
references/SCALABLE_RELATIONSHIP_MODEL.md - Relationship modeling approachreferences/VISION_EXTRACTION_PROMPTS.md - Vision model promptsNEO4J_REQUIREMENTS.md - Neo4j server version requirementsschema_examples/neo4j/ - Example Cypher scriptsImportant: Relationship property indexes require Neo4j server version 4.3+.
requirements.txt specifies the Python driver version, not the server versionneo4j version or CALL dbms.components()NEO4J_REQUIREMENTS.md for full compatibility detailsLow Extraction Quality
Missing Relationships
Neo4j Population Errors
Performance Issues
xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience