Generated Schema Artifacts
Auto-generated files from the Neo4j AuraDB database.
Source of Truth
Neo4j AuraDB - The live database is the single source of truth for schema.
Schema is exported using APOC procedures and used to generate TypeScript types and Zod schemas.
Directory Structure
generated/
├── cypher/
│ ├── schema-export.cypher # Full schema export from APOC
│ └── constraints.cypher # Extracted constraints only
├── types/
│ └── neo4j-types.ts # TypeScript node/relationship types
└── schemas/
└── neo4j-schemas.ts # Zod validation schemas
Generated Files
| File | Purpose | Generated By |
|---|---|---|
cypher/schema-export.cypher | Complete Cypher export (constraints + data) | export_schema_from_neo4j task |
cypher/constraints.cypher | Just the CREATE CONSTRAINT statements | export_schema_from_neo4j task |
types/neo4j-types.ts | TypeScript interface definitions | generate_typescript_types task |
schemas/neo4j-schemas.ts | Zod validation schemas | generate_zod_schemas task |
Regenerate
Use Prefect tasks to regenerate all artifacts from Neo4j:
from tasks.schema import export_schema_from_neo4j, get_schema_metadata
# Export schema from Neo4j
result = export_schema_from_neo4j()
print(f"Exported to: {result['schema_export']}")
# Get metadata for type generation
metadata = get_schema_metadata()
print(f"Found {len(metadata['nodes'])} node types")
Or run the tasks directly:
python tasks/schema/export_from_neo4j.py
Workflow
When schema changes in Neo4j:
- Update Neo4j database (apply migrations, add constraints, etc.).
- Export schema from Neo4j:
uv run python -m tasks.schema.export_from_neo4j
- Generate TypeScript types:
uv run python -m tasks.schema.generate_typescript
- Generate Zod schemas:
uv run python -m tasks.schema.generate_zod
- Resulting artifacts (committed to this repo):
generated/types/neo4j-types.tsgenerated/schemas/neo4j-schemas.ts
- Schema package source (kept in sync by the same generators):
schema-package/src/neo4j-types.tsschema-package/src/neo4j-schemas.ts
These source files are bundled and published as the npm package
@rlhatcher/rocketry-graph-schema to GitHub Packages.
Schema npm package & CI publish flow
Package location & contents
- Package directory:
schema-package/ - Package name:
@rlhatcher/rocketry-graph-schema - Public entrypoint:
schema-package/src/index.tsre-exports:./neo4j-types./neo4j-schemas
The Python generators write to both generated/... and schema-package/src/..., so
the npm package always reflects the latest Neo4j schema.
Publishing to GitHub Packages (manual steps)
- Ensure schema has been regenerated (steps above).
- Bump the npm version inside
schema-package:cd schema-packagenpm version patch# or minor/major as appropriate
- Commit the version bump in
blog_data:git add schema-package/package.jsongit commit -m "Bump schema package to <version>"
- Tag the commit to trigger CircleCI publish:
git tag schema-v<version>(e.g.schema-v0.1.1)git push origin maingit push origin schema-v<version>
CircleCI workflow publish-schema-package-wf will:
- Use the
aws-blog-infra-prodcontext. - Assume
OrganizationAccountAccessRolevia STS. - Fetch the GitHub PAT from AWS Secrets Manager secret
prod/github/pat/blog_data_ci. - Configure npm auth for
https://npm.pkg.github.com. - Run
npm publishinsideschema-package.
Consuming the package (other repos, e.g. blog_code)
-
Configure npm scope for GitHub Packages (repo-local
.npmrc):@rlhatcher:registry=https://npm.pkg.github.com -
Add dependency (example
package.jsonexcerpt):{ "dependencies": { "@rlhatcher/rocketry-graph-schema": "^0.1.0" } } -
Use in TypeScript:
import { Neo4jNode, Neo4jRelationship, Neo4jNodeSchema, Neo4jRelationshipSchema } from '@rlhatcher/rocketry-graph-schema'
Notes
- Yes Neo4j AuraDB is the source of truth
- No DO NOT manually edit generated files
- Yes DO use Prefect tasks to regenerate after schema changes
- Yes DO commit generated files to version control
Migration from graph-schema.json
The old graph-schema.json approach has been deprecated in favor of using Neo4j directly:
- Old approach: Manually maintain
graph-schema.json→ Generate artifacts - New approach: Neo4j AuraDB → Export via APOC → Generate artifacts
Benefits:
- No drift between JSON and database
- Always up-to-date with current schema
- Captures all constraints and indexes automatically