trigo

module
v0.1.0-phase2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 28, 2025 License: Apache-2.0

README ΒΆ

Trigo Logo

Trigo

A high-performance RDF triplestore and SPARQL 1.1 query engine written in Go

Go Report Card License Documentation

Documentation | Quick Start | Architecture | HTTP API

Overview

Trigo is a modern RDF triplestore inspired by Oxigraph, implementing efficient storage and querying of RDF data using SPARQL. Built in Go, it provides a simple, maintainable codebase with excellent performance characteristics.

Key Features

  • Full SPARQL 1.1 Support - SELECT, CONSTRUCT, ASK, DESCRIBE queries with advanced patterns (OPTIONAL, UNION, MINUS, GRAPH, BIND)
  • Multiple RDF Formats - Turtle, N-Triples, N-Quads, TriG, RDF/XML, JSON-LD parsers
  • Efficient 11-Index Architecture - BadgerDB backend with optimal index selection
  • HTTP SPARQL Endpoint - W3C SPARQL 1.1 Protocol compliant with interactive web UI
  • Named Graphs Support - Full quad store with graph-level operations
  • High Performance - xxHash3 encoding, query optimization, lazy evaluation

Quick Start

Installation
# Clone the repository
git clone https://github.com/aleksaelezovic/trigo.git
cd trigo

# Build the CLI
go build -o trigo ./cmd/trigo
Start SPARQL Endpoint
# Start the server
./trigo serve

# Visit http://localhost:8080/ for the interactive web UI
Query via HTTP
curl -X POST http://localhost:8080/sparql \
  -H 'Content-Type: application/sparql-query' \
  -H 'Accept: application/sparql-results+json' \
  -d 'SELECT ?s ?p ?o WHERE { ?s ?p ?o } LIMIT 10'
Use as a Library
import (
    "github.com/aleksaelezovic/trigo/pkg/store"
    "github.com/aleksaelezovic/trigo/pkg/rdf"
)

storage, _ := storage.NewBadgerStorage("./data")
ts := store.NewTripleStore(storage)

triple := rdf.NewTriple(
    rdf.NewNamedNode("http://example.org/alice"),
    rdf.NewNamedNode("http://xmlns.com/foaf/0.1/name"),
    rdf.NewLiteral("Alice"),
)
ts.InsertTriple(triple)

Documentation

πŸ“š Full Documentation - Complete guides and API reference

Test Results

Validated against official W3C test suites:

RDF 1.1 Parsers (Perfect Compliance!)
  • RDF N-Triples: 100% (70/70 tests) βœ…
  • RDF N-Quads: 100% (87/87 tests) βœ…
  • RDF Turtle: 100% (296/296 tests) βœ…
  • RDF TriG: 100% (335/335 tests) βœ…
  • RDF/XML: 100% (166/166 tests) βœ…

πŸŽ‰ RDF 1.1 Total: 100% (954/954 tests) β€” Full W3C Compliance Achieved!

RDF 1.2 Parsers (Near-Perfect Compliance)
  • RDF 1.2 N-Triples: 99.3% (139/140 tests) β€” 1 C14N canonicalization test
  • RDF 1.2 N-Quads: 99.4% (154/155 tests) β€” 1 C14N canonicalization test
  • RDF 1.2 Turtle: 100% (388/388 tests) βœ…
  • RDF 1.2 TriG: 99.7% (395/396 tests) β€” 1 test skipped
  • RDF 1.2 RDF/XML: 100% (196/196 tests) βœ…

πŸš€ RDF 1.2 Total: 99.8% (1,272/1,275 tests) β€” 3 tests remaining

Combined RDF Compliance

Overall: 99.9% (2,226/2,229 tests) β€” Excellent W3C Compliance! πŸŽ‰

SPARQL Query Engine
  • Overall SPARQL: 74.4% (574/772 tests) β€” Combining SPARQL 1.0 + 1.1
    • SPARQL 1.0: 99.2% (467/471 tests) β€” 4 tests remaining
    • SPARQL 1.1: 35.5% (107/301 tests) β€” Many features implemented

SPARQL 1.0 (Near-Perfect):

  • Perfect Suites (15): distinct, boolean-effective-value, expr-builtin, expr-ops, bound, cast, reduced, regex, solution-seq, sort, triple-match, type-promotion, bnode-coreference, syntax-sparql5, ask βœ…
  • Remaining: 4 edge case tests (date comparison, GRAPH+OPTIONAL, complex optional semantics)

SPARQL 1.1 (Growing Support):

  • construct: 100% (7/7 tests) βœ… β€” Full CONSTRUCT WHERE support
  • bind: 80.0% (8/10 tests) β€” BIND clause with expressions
  • csv-tsv-res: 83.3% (5/6 tests) β€” CSV and TSV result formats
  • Not yet implemented: Aggregates, GROUP BY, Property Paths, Subqueries, VALUES clause, UPDATE operations

See Testing & Compliance for detailed breakdown.

Project Structure

trigo/
β”œβ”€β”€ cmd/           # CLI applications
β”œβ”€β”€ internal/      # Internal packages (encoding, storage, testing)
β”œβ”€β”€ pkg/           # Public API (rdf, store, sparql, server)
└── docs/          # Documentation site

See the Architecture Guide for details.

Contributing

Contributions are welcome! Please:

  • Check existing issues or create a new one
  • Follow the existing code style
  • Run tests and quality checks before submitting
  • Update documentation as needed

License

Apache License 2.0 - See LICENSE for details

Acknowledgments

Inspired by Oxigraph architecture. Built with BadgerDB and xxHash3.


Directories ΒΆ

Path Synopsis
cmd
test-runner command
trigo command
internal
pkg
rdf

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL