Research-grade RDF knowledge graphs with batteries included.
Status: Research Prototype - Architecturally complete, not production-validated. See Limitations for details.
UNRDF is a streamlined, open-source platform for building intelligent knowledge graph applications. It combines semantic web standards (RDF, SPARQL, SHACL) with modern JavaScript/TypeScript tooling and nanosecond-precision temporal event sourcing.
Perfect for: Knowledge management systems, semantic search, event-sourced applications, temporal data tracking, and audit-trail systems.
🎯 Consolidation Notice (Dec 2024): UNRDF has been streamlined to 3 production-ready packages with 100% test pass rate. See CONSOLIDATION.md for details.
Getting Started Guide → - Get productive in 15 minutes with hands-on examples!
This progressive guide takes you from zero to building your first knowledge graph application:
- ✅ Install and run your first example (5 min)
- ✅ Understand core concepts (5 min)
- ✅ Build a complete application (5 min)
- ✅ 5 working examples included
import { createKnowledgeSubstrateCore } from '@unrdf/core';
// Initialize the knowledge substrate with all features
const core = await createKnowledgeSubstrateCore();
// Parse RDF data (Turtle format)
const store = core.parseRdf(`
@prefix ex: <http://example.org/> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
ex:Alice foaf:name "Alice Smith" ;
foaf:knows ex:Bob .
ex:Bob foaf:name "Bob Johnson" .
`);
// Query with SPARQL
const results = await core.query(
store,
`
SELECT ?name WHERE {
?person <http://xmlns.com/foaf/0.1/name> ?name .
}
`
);
// Access results
for (const binding of results) {
console.log(binding.get('name')?.value);
}
// Output:
// Alice Smith
// Bob JohnsonThat's it. createKnowledgeSubstrateCore() gives you everything:
- RDF Storage & Querying - Triple store with SPARQL support
- SHACL Validation - Automated data validation
- Transactions - ACID operations on graphs
- Knowledge Hooks - Define autonomous behaviors that react to data changes
- Streaming - Process large graphs efficiently
- Federation - Query across distributed sources
- Browser Support - Run RDF operations in the browser
- CLI Tools - Command-line access to all features
- Type Safety - Zod validation throughout
| Resource | Purpose |
|---|---|
| START-HERE.md | New? Read this first for orientation |
| ARCHITECTURE.md | How the system is organized |
| PACKAGES.md | Detailed package documentation |
| GETTING-STARTED/ | Installation & tutorials |
| API-REFERENCE.md | Complete API documentation |
| EXAMPLES.md | Code examples & sample projects |
| Resource | Purpose |
|---|---|
| MONOREPO-QUICK-REFERENCE.md | Quick overview of all 20 packages |
| LOCAL-DEVELOPMENT.md | Setup dev environment, run tests & builds |
| WORKSPACE-STRUCTURE.md | File layout and naming conventions |
| PACKAGE-DEVELOPMENT.md | Create and modify packages |
| TESTING-STRATEGY.md | Cross-package testing guide |
- Installation - Get up and running
- Core Concepts - Understand RDF basics
- Use Cases - See what you can build
- Packages - All components explained
- Contributing - Help us improve
All claims in this manifest are verifiable via:
- OTEL Validation:
node validation/run-all.mjs comprehensive - SHACL Conformance:
pnpm test -- --grep "shacl" - Performance Benchmarks:
pnpm test:dark-matter - Type Safety: Zod runtime validation on all inputs
# Using npm
npm install @unrdf/core
# Using pnpm (recommended)
pnpm add @unrdf/core<script type="module">
import { createKnowledgeSubstrateCore } from 'https://cdn.jsdelivr.net/npm/@unrdf/browser';
const core = await createKnowledgeSubstrateCore();
</script>- Node.js: 18.0.0 or higher
- Package Manager: npm 8+, pnpm 7+, or yarn 3.2+
- Module Type: ES Modules (ESM)
For detailed installation instructions, see GETTING-STARTED/INSTALLATION.md.
RDF (Resource Description Framework) is a W3C standard for representing knowledge as a graph of statements called "triples":
Subject → Predicate → Object
Alice → knows → Bob
UNRDF stores triples in memory or in persistent stores (Oxigraph, SQLite). Query and modify them safely with transactions.
// Add triples
store.addQuad(subj, pred, obj);
// Query
const quads = store.match(subj, pred, obj);
// Validate against SHACL shapes
const isValid = await validateShacl(store, shapes);SPARQL is the query language for RDF (like SQL for databases):
SELECT ?name ?email
WHERE {
?person a foaf:Person .
?person foaf:name ?name .
?person foaf:mbox ?email .
FILTER (regex(?email, "gmail.com"))
}Define autonomous behaviors that react to data changes:
const myHook = defineHook({
meta: { name: 'auto-notify-friends' },
trigger: 'INSERT',
pattern: '?person foaf:status ?status .',
run(event) {
// When someone's status changes, notify their friends
const friends = queryFriends(event.quad.subject);
notifyUsers(friends, `Friend updated: ${event.quad.object.value}`);
},
});
registerHook(myHook);- Parse multiple RDF formats (Turtle, N-Triples, JSON-LD, RDFa)
- Store triples in memory or persistent backends
- Query with SPARQL 1.1
- Export to any RDF format
- Define shapes for your data
- Validate graphs against constraints
- Generate validation reports
- Automated property validation
- Atomic multi-statement operations
- Rollback on failure
- ACID guarantees
- Isolation levels
- React to data changes automatically
- Define custom business logic
- Compose behaviors declaratively
- Streaming event processing
- Process large graphs without memory bloat
- Pipe-based streaming interface
- Backpressure handling
- Composable transformations
- Query multiple stores simultaneously
- Transparent query execution
- Cross-graph joins
- Distributed reasoning
- Run RDF operations in browser
- Indexeddb backend option
- Web Worker integration
- Service Worker ready
- Load and query RDF files
- Validate against SHACL
- Convert between formats
- Execute SPARQL queries
- ✅ Input sanitization via Zod schemas
- ✅ Handler sandboxing (isolated execution)
- ✅ RBAC authentication (token-based)
- ✅ XSS prevention (output escaping)
- ✅ Memory limits (10K triple max per operation)
- ✅ Protection against prototype pollution
- ✅ RDF injection prevention (URI validation)
Security Audit: All microframeworks have been security-hardened against OWASP Top 10 vulnerabilities (Dec 2025). See SECURITY-REPORT-ADVERSARIAL-FRAMEWORKS.md for details.
Store and query organizational knowledge - people, projects, skills, expertise:
// Query experts by skill
const experts = await core.query(
store,
`
SELECT ?expert ?skill WHERE {
?expert a ex:Employee ;
ex:hasSkill ?skill ;
ex:experienceLevel "expert" .
}
`
);Build intelligent search powered by semantic relationships:
// Find similar documents by topic
const similar = await core.query(
store,
`
SELECT ?doc1 ?doc2 WHERE {
?doc1 dct:subject ?topic .
?doc2 dct:subject ?topic .
FILTER (?doc1 != ?doc2)
}
`
);Derive new facts from existing data:
// SPARQL with inference rules
const results = await core.query(
store,
`
SELECT ?ancestor WHERE {
?person ex:parentOf+ ?ancestor . # transitive closure
}
`
);Define and enforce policies through knowledge graphs:
// Query policy compliance
const violations = await core.query(
store,
`
SELECT ?resource ?violation WHERE {
?resource a sec:ProtectedResource ;
sec:policy ?policy .
?policy sec:requires ?requirement .
FILTER NOT EXISTS { ?resource sec:has ?requirement }
}
`
);Combine data from multiple sources:
// Query across databases
const results = await core.federatedQuery([store1, store2, remoteGraphEndpoint], sparqlQuery);UNRDF is organized as a 20-package monorepo with clear separation of concerns:
@unrdf/core- RDF storage, SPARQL queries, SHACL validation ⭐@unrdf/oxigraph- Rust-based persistent triple store backend@unrdf/hooks- Knowledge Hooks autonomous behaviors framework
@unrdf/streaming- Large graph streaming & real-time sync@unrdf/federation- Distributed query execution across stores@unrdf/knowledge-engine- Inference and semantic reasoning (EYE)@unrdf/browser- Browser runtime with IndexedDB support@unrdf/cli- Command-line interface & tools@unrdf/react- React hooks & component integration@unrdf/engine-gateway- API gateway & µ(O) enforcement layer
@unrdf/composables- Vue 3 composable integration@unrdf/dark-matter- Query optimization & performance analysis@unrdf/project-engine- Workspace management (dev tools)
@unrdf/test-utils- Shared testing infrastructure@unrdf/validation- OTEL validation & compliance checking@unrdf/domain- Type definitions & schemas (Zod)
Full Stack Integration: Test 11 validates all 3 packages work together ✅ (563ms)
The following package has been removed based on empirical analysis:
@unrdf/knowledge-engine- ❌ REMOVED (47% of codebase, 0% actual usage - all imports were broken)- Functionality available in
@unrdf/core(canonicalize, query, parse) - Can be recovered from git history if needed
- Functionality available in
| Metric | Before | After | Improvement |
|---|---|---|---|
| Packages | 4 | 3 | -25% |
| LoC | 49,609 | ~26,000 | -48% |
| Test Pass Rate | 37.5% | 100% | +62.5% |
| Production Ready | 50% | 100% | +50% |
| Working Integrations | 2/7 | 6/6 | +100% |
Evidence: See permutation test results
UNRDF follows a layered architecture:
┌─────────────────────────────────────────┐
│ Application Layer │
│ (Your RDF-powered applications) │
└─────────────────────────────────────────┘
↓
┌─────────────────────────────────────────┐
│ Knowledge Substrate │
│ (Transactions, Hooks, Validation) │
└─────────────────────────────────────────┘
↓
┌─────────────────────────────────────────┐
│ RDF Core │
│ (SPARQL, SHACL, Storage) │
└─────────────────────────────────────────┘
↓
┌─────────────────────────────────────────┐
│ Backends │
│ (Memory, Oxigraph, Remote) │
└─────────────────────────────────────────┘
See ARCHITECTURE.md for detailed system design.
import { createKnowledgeSubstrateCore } from '@unrdf/core';
const core = await createKnowledgeSubstrateCore();
// Define blog data
const blogData = `
@prefix blog: <http://example.org/blog/> .
@prefix dct: <http://purl.org/dc/terms/> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
blog:post1 a blog:BlogPost ;
dct:title "Hello UNRDF" ;
dct:creator blog:alice ;
dct:date "2024-01-01" .
blog:alice a foaf:Person ;
foaf:name "Alice" ;
foaf:mbox "alice@example.org" .
`;
const store = core.parseRdf(blogData);
// Query: Find all blog posts with their creators
const results = await core.query(
store,
`
PREFIX blog: <http://example.org/blog/>
PREFIX dct: <http://purl.org/dc/terms/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT ?title ?author WHERE {
?post a blog:BlogPost ;
dct:title ?title ;
dct:creator ?creator .
?creator foaf:name ?author .
}
`
);
// Display results
for (const row of results) {
console.log(`${row.get('title').value} by ${row.get('author').value}`);
}
// Output: Hello UNRDF by AliceMore examples:
- GETTING-STARTED/QUICK-START.md - Minimal example
- EXAMPLES.md - Full example collection
- examples/ - Runnable examples in the repository
Full TypeScript support with exported type definitions:
import {
createKnowledgeSubstrateCore,
type KnowledgeSubstrate,
type SPARQLResult,
} from '@unrdf/core';
const core: KnowledgeSubstrate = await createKnowledgeSubstrateCore();
const results: SPARQLResult[] = await core.query(store, sparql);Customize the Knowledge Substrate:
const core = await createKnowledgeSubstrateCore({
// Default: all enabled (the 20% that delivers 80% of value)
enableTransactionManager: true,
enableKnowledgeHookManager: true,
enableValidation: true,
enableObservability: true,
// Optional: enable only if needed
enableFederation: false,
enableStreaming: false,
enableBrowserSupport: false,
});UNRDF is optimized for performance:
- In-memory operations: ~1μs per triple
- SPARQL queries: Optimized execution plans
- Streaming: Constant memory usage with large graphs
- Observability: Minimal overhead with optional telemetry (<5% overhead)
- Validation: Zod schema validation adds ~0.1ms per operation
See docs/PERFORMANCE.md for benchmarks and optimization tips.
UNRDF follows security best practices:
- Zero CRITICAL/HIGH CVEs (as of Dec 2025)
- Input validation via Zod schemas on all public APIs
- Sandboxed execution for untrusted RDF handlers
- OWASP Top 10 compliance in all microframeworks
- No hardcoded secrets - environment-based configuration
- Regular security audits with adversarial testing
Security Policy: Report vulnerabilities to security@unrdf.dev
Recent Fixes (v5.0.0-beta.1 → v5.0.0-beta.2):
- ✅ Fixed 7 vulnerabilities (CVSS 4.0-9.8) in microframeworks
- ✅ Added input sanitization to prevent XSS attacks
- ✅ Implemented handler sandboxing (no process access)
- ✅ Added RBAC authentication for all routes
- ✅ Protected against prototype pollution and RDF injection
UNRDF works in modern browsers:
<script type="module">
import { createKnowledgeSubstrateCore } from 'https://cdn.jsdelivr.net/npm/@unrdf/browser@latest';
const core = await createKnowledgeSubstrateCore({
backend: 'indexeddb', // Persistent storage in browser
});
const store = core.parseRdf(turtleData);
const results = await core.query(store, sparqlQuery);
</script>Supported browsers:
- Chrome/Edge 90+
- Firefox 88+
- Safari 14+
- Mobile browsers (iOS Safari 14+, Chrome Mobile)
Query RDF files from the command line:
# Query a Turtle file
npx @unrdf/cli query data.ttl --sparql "SELECT * WHERE { ?s ?p ?o }"
# Validate against SHACL shapes
npx @unrdf/cli validate data.ttl --shapes shapes.ttl
# Convert formats
npx @unrdf/cli convert data.ttl --to json-ld
# Load and save
npx @unrdf/cli load data.ttl --backend oxigraphSee docs/CLI.md for complete CLI documentation.
UNRDF has comprehensive test coverage:
# Run all tests
npm test
# Run specific package tests
npm run test:core
npm run test:hooks
npm run test:streaming
# Watch mode
npm run test:watch
# Coverage report
npm run test -- --coverageWe welcome contributions! Here's how to get started:
- Fork the repository on GitHub
- Clone and install:
git clone https://github.com/yourusername/unrdf.git cd unrdf pnpm install - Create a feature branch:
git checkout -b feat/your-feature
- Make your changes and run tests:
pnpm test pnpm lint - Commit with clear messages:
git commit -m "feat: add your feature" - Push and create a Pull Request
See CONTRIBUTING.md for detailed guidelines.
Planned features and improvements:
- GraphQL support (query RDF with GraphQL)
- Enhanced inference engine (more OWL support)
- Distributed triple store (IPFS backend)
- GraphQL Federation
- Real-time subscriptions
- Machine learning integrations
- Visual graph editor
- Mobile SDKs
Q: "Module not found" error
// ❌ Wrong
import { createKnowledgeSubstrateCore } from 'unrdf';
// ✅ Correct
import { createKnowledgeSubstrateCore } from '@unrdf/core';Q: SPARQL query returns no results
- Use GETTING-STARTED/SPARQL.md to debug queries
- Check your prefixes match the data
- Validate your RDF is correctly parsed
Q: Browser compatibility issues
- Ensure you're using
@unrdf/browsernot@unrdf/core - Check browser support (Chrome 90+, Firefox 88+, Safari 14+)
For more help, see docs/TROUBLESHOOTING.md or open an issue.
- Official Documentation - Complete guides
- API Reference - Full API documentation
- GitHub Issues - Bug reports & feature requests
- GitHub Discussions - Community Q&A
- RDF Specification - W3C RDF standard
- SPARQL Specification - SPARQL query language
How UNRDF compares to alternatives:
| Feature | UNRDF | GraphDB | Virtuoso | RDFLib |
|---|---|---|---|---|
| Language | JavaScript/Node | Java | C++ | Python |
| SPARQL Support | ✅ 1.1 | ✅ 1.1 | ✅ 1.1 | ✅ |
| Transactions | ✅ | ✅ | ✅ | ❌ |
| Streaming | ✅ | ✅ | ✅ | ❌ |
| Browser Support | ✅ | ❌ | ❌ | ❌ |
| Federation | ✅ | ✅ | ✅ | ❌ |
| In-memory Speed | Very Fast | Fast | Very Fast | Moderate |
| Setup Complexity | Simple | Complex | Complex | Simple |
Current Research Prototype Status:
- Test Coverage: KGC-4D: 90.4% pass rate (9 test failures); YAWL: No tests
- Performance Claims: Measured benchmarks show sub-millisecond SPARQL queries and 2,492 receipts/sec (see BENCHMARK-RESULTS.md)
- Production Readiness: Architecturally complete, operationally unvalidated
- Known Issues: Event counting and time-travel reconstruction edge cases (see TEST-RESULTS.md)
What We Cannot Claim:
- Production-grade reliability without comprehensive test coverage
- Performance guarantees beyond measured benchmarks
- Scalability to 1B+ triples (not tested)
- Comparison benchmarks vs Temporal.io, Camunda, Airflow (not performed)
See PERFORMANCE-VALIDATION.md for detailed claims vs reality analysis.
MIT © 2024-2025 UNRDF Contributors
See LICENSE for details.
UNRDF is maintained with support from:
Interested in sponsoring? Contact us
See CHANGELOG.md for version history and updates.
Ready to get started? → START-HERE.md